pcpu_alloc_area(9)
π
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 specificpcpu_chunkwe'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 atPAGE_SIZEβstartβ thebit_offwhere 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
chunkon success π -1if 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:
pcpu_addr_in_chunk(9)pcpu_check_block_hint(9)pcpu_next_md_free_region(9)pcpu_next_fit_region(9)pcpu_mem_zalloc(9)pcpu_mem_free(9)pcpu_chunk_relocate(9)pcpu_block_update(9)pcpu_chunk_refresh_hint(9)pcpu_block_refresh_hint(9)pcpu_block_update_hint_alloc(9)pcpu_block_update_hint_free(9)pcpu_is_populated(9)pcpu_find_block_fit(9)pcpu_free_area(9)pcpu_alloc_first_chunk(9)pcpu_chunk_populated(9)pcpu_chunk_depopulated(9)pcpu_chunk_addr_search(9)pcpu_alloc(9)pcpu_balance_free(9)pcpu_balance_populated(9)pcpu_reclaim_populated(9)pcpu_balance_workfn(9)free_percpu(9)is_kernel_percpu_address(9)per_cpu_ptr_to_phys(9)pcpu_alloc_alloc_info(9)pcpu_free_alloc_info(9)pcpu_dump_alloc_info(9)pcpu_setup_first_chunk(9)pcpu_build_alloc_info(9)pcpu_embed_first_chunk(9)pcpu_page_first_chunk(9)
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms