pcpu_alloc(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– pcpu_alloc β€” the percpu allocator, bestie edition πŸ’–

okay so this is a page from the Kernel API Manual (yes, that Kernel API Manual, the one that lives in section 9), and today's main character is pcpu_alloc β€” literally the percpu allocator itself. no cap, this one's kind of a big deal. let's get into it 🫢


🌸 SYNOPSIS 🌸

like, the whole vibe in one line:

void __percpu * pcpu_alloc (size_t size , size_t align , bool reserved ,
gfp_t gfp );

that's it. that's the fit. she returns a void __percpu * and takes four args. slay.


✨ ARGUMENTS ✨

  • size β€” the size of the area you wanna allocate, in bytes. yes, bytes. keep up πŸ’…
  • align β€” the alignment of the area. heads up though: max is PAGE_SIZE, so don't go feral with it.
  • reserved β€” if there's a reserved chunk available, allocate from it. like a VIP section for allocations πŸŽ€
  • gfp β€” the allocation flags. the whole personality of the call lives here, ngl.

πŸ¦‹ DESCRIPTION πŸ¦‹

so what does she actually do? she allocates a percpu area of size bytes, aligned at align. that's the whole errand. 🌈

now for the fine print, and this part is important, so listen up:

if gfp doesn't allow blocking, the allocation is atomic. like, no sleeping on the job, periodt.
and if gfp has __GFP_NOWARN, then no warning will be triggered on invalid or failed allocation requests. she's just gonna silently not warn you. that's the deal. πŸ™ˆ

πŸ‘‘ RETURN πŸ‘‘

  • on success you get a percpu pointer to the allocated area πŸ’–
  • on failure you get NULL πŸ’€

that's the entire return contract, no notes.


⭐ SEE ALSO ⭐

okay this is the part where the page just flexes its whole friend group. every single one of these, no skips:

like, the whole percpu extended universe is here. iykyk 🧚


and that's the page!! this lil drop came from ./mm and it's dated October 2026, filed under pcpu_alloc(9) β€” go read the neighbors, they ate too πŸ”₯πŸ’œ

πŸ“¦ where this page comes from