pcpu_alloc(9)
π 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 isPAGE_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 ifgfphas__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:
- 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_alloc_area(9)pcpu_free_area(9)pcpu_alloc_first_chunk(9)pcpu_chunk_populated(9)pcpu_chunk_depopulated(9)pcpu_chunk_addr_search(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)
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
- 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