pcpu_mem_zalloc(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ pcpu_mem_zalloc(9) ✨

okay bestie, welcome to the Kernel API Manual πŸ’… β€” yes it's a section 9 page, yes it's about memory, no you can't skip it, this one's actually short and slay.


πŸ’– NAME πŸ’–

pcpu_mem_zalloc β€” allocate memory πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

void * pcpu_mem_zalloc (size_t size , gfp_t gfp );

like, that's the whole function signature, no cap. takes two things, gives you back a pointer 🌸


🌈 ARGUMENTS 🌈

  • size β€” how many bytes you want, bestie. that's it. that's the number. πŸ“
  • gfp β€” the allocation flags. the vibe parameters, if you will. ✨

πŸ‘‘ DESCRIPTION πŸ‘‘

so here's the tea πŸ“ β€” you call this and it allocates size bytes for you. iconic.

but here's the lil plot twist: it picks how based on your size πŸ‘€

  • if size is smaller than PAGE_SIZE β†’ it uses kzalloc
  • otherwise β†’ it uses the equivalent of vzalloc

and why, you ask? because this is to facilitate passing through whitelisted flags πŸ’€ like that's the whole reason. it's giving "we thought about it" energy.

the good news tho: the returned memory is always zeroed. every single time. no surprises. we love a consistent queen πŸ‘‘βœ¨


🫢 RETURN 🫢

  • success β†’ a pointer to the allocated area πŸŽ‰
  • failure β†’ NULL 😭 (check it, bestie, please check it)

⭐ SEE ALSO ⭐

Kernel file ./mm/percpu.c β€” and the whole percpu friend group, fr fr, they all show up together:


and that's the page, bestie πŸ’œ this lil baddie lives in ./mm, dated October 2026, and it goes by pcpu_mem_zalloc(9) β€” go forth and allocate responsibly, mwah πŸ§šπŸ’–

πŸ“¦ where this page comes from