pcpu_alloc_area(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… pcpu_alloc_area β€” the pcpu_chunk girlie's fave little allocator

okay so real talk, this one lives in the Kernel API Manual section 9, and it's genuinely one of the most "i got you bestie" functions in mm/percpu.c. let's get into it πŸŽ€


✨ NAME ✨

pcpu_alloc_area β€” allocates an area from a pcpu_chunk 🫢


🌸 SYNOPSIS 🌸

int pcpu_alloc_area (struct pcpu_chunk *chunk , int alloc_bits , size_t
align , int start );

like yes, that's the whole signature, and yes she's serving πŸ’…


πŸ¦‹ ARGUMENTS πŸ¦‹

  • chunk β€” the chunk of interest, i.e. the specific pcpu_chunk we're poking at πŸ‘€
  • alloc_bits β€” how big the request is, measured in allocation units (not bytes, bestie, units)
  • align β€” the alignment of the area β€” and heads up, it maxes out at PAGE_SIZE ⭐
  • start β€” the bit_off where the search begins πŸ”Ž

πŸ’– DESCRIPTION πŸ’–

so this function takes in a start offset and begins searching from there, trying to fit an allocation of alloc_bits with alignment align. periodt. ✨

but here's the thing β€” it has to scan the allocation map, because if the request fits inside the block's contig hint, then start will be block->first_free. it's basically an attempt to fill the allocation before breaking the contig hint 🧚 the vibe is: use the nice contiguous space first, don't go shattering it for no reason.

and if it does confirm a valid free area? the allocation map and the boundary map both get updated accordingly. both of them. no cap πŸ’€


πŸ”₯ RETURN πŸ”₯

  • the allocated addr offset in chunk on success πŸ‘‘
  • -1 if no matching area is found 😭
ngl, that -1 is the "she's not here, girl" of return values. check for it.

🌈 SEE ALSO 🌈

okay this list is long and it ate, honestly. all of these live in the kernel file ./mm/percpu.c:


and that's the whole page, bestie πŸ“ this one's from the ./mm corner of the kernel, dated October 2026 β€” so mark your calendar, she's a whole era πŸ’œ bye ily 🫢

πŸ“¦ where this page comes from