pcpu_mem_zalloc(9)
β¨ 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
sizeis smaller thanPAGE_SIZEβ it useskzalloc - 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:
pcpu_addr_in_chunk(9)pcpu_check_block_hint(9)pcpu_next_md_free_region(9)pcpu_next_fit_region(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_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 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
- 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