pcpu_setup_first_chunk(9)
π NAME π
okay so pcpu_setup_first_chunk β bestie, it initializes the first percpu chunk and it's kind of a big deal π
(this whole thing lives in the Kernel API Manual, iykyk π«Ά)
β¨ SYNOPSIS β¨
void pcpu_setup_first_chunk (const struct pcpu_alloc_info *ai , void
*base_addr );
π ARGUMENTS π
aiβ thepcpu_alloc_infothat describes how the percpu area is shaped. it's literally the blueprint, no cap πbase_addrβ the mapped address. that's where it lives π
π¦ DESCRIPTION π¦
So like. This function initializes the first percpu chunk, which contains the kernel static percpu area. The way it works: you call it from the arch percpu area setup path. that's the vibe check β
ai contains all the information necessary to initialize the first chunk and prime the dynamic percpu allocator. she's carrying everything, main character energy fr fr π
ai->static_size is the size of the static percpu area. simple as that π
ai->reserved_size, if it's non-zero, specifies the amount of bytes to reserve after the static area in the first chunk. This reserves the first chunk such that it's available only through reserved percpu allocation. This is primarily used to serve module percpu static areas on architectures where the addressing model has limited offset range for symbol relocations, to guarantee module percpu symbols fall inside the relocatable range. like, she's doing it for the safety of the symbols, iconic π
ai->dyn_size determines the number of bytes available for dynamic allocation in the first chunk. The area between ai->static_size + ai->reserved_size + ai->dyn_size and ai->unit_size is unused. give it a little alone time, she's not part of the party π
ai->unit_size specifies unit size and must be aligned to PAGE_SIZE and equal to or larger than ai->static_size + ai->reserved_size + ai->dyn_size. no wiggle room bestie, this is the rule π«Ά
ai->atom_size is the allocation atom size and it's used as alignment for vm areas. little atom, big responsibility β¨
ai->alloc_size is the allocation size and it's always a multiple of ai->atom_size. This is larger than ai->atom_size if ai->unit_size is larger than ai->atom_size. math is mathing π₯
ai->nr_groups and ai->groups describe the virtual memory layout of percpu areas. Units which should be colocated are put into the same group. Dynamic VM areas will be allocated according to these groupings. And if ai->nr_groups is zero, a single group containing all units is assumed. default era π¦
The caller should have mapped the first chunk at base_addr and copied static data to each unit. don't skip this step, it's giving prerequisites π
The first chunk will always contain a static and a dynamic region. However β and this is the part that lowkey trips people up β the static region is not managed by any chunk. If the first chunk also contains a reserved region, it is served by two chunks: one for the reserved region and one for the dynamic region. They share the same vm, but use offset regions in the area allocation map. The chunk serving the dynamic region is circulated in the chunk slots and available for dynamic allocation like any other chunk. periodt π β¨
πΈ SEE ALSO πΈ
Kernel file ./mm/percpu.c β and honestly the whole percpu friend group showed up, so:
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_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_build_alloc_info(9)pcpu_embed_first_chunk(9)pcpu_page_first_chunk(9)
k that's the whole page bestie, go set up that first chunk π
sign-off szn π this one ships from ./mm, October 2026, and it's filed under pcpu_setup_first_chunk(9) β slay, bye! π
β¨
π¦ 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