pcpu_build_alloc_info(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ pcpu_build_alloc_info(9) ✨

okay bestie, welcome to the Kernel API Manual 🫢 this one's literally about building an alloc_info while being super aware of how far apart your CPUs are from each other. distance-aware king behavior, no cap πŸ‘‘


🌸 NAME 🌸

pcpu_build_alloc_info β€” build alloc_info considering distances between CPUs


πŸŽ€ SYNOPSIS πŸŽ€

struct pcpu_alloc_info * pcpu_build_alloc_info (size_t reserved_size ,
size_t dyn_size , size_t atom_size , pcpu_fc_cpu_distance_fn_t
cpu_distance_fn );

πŸ’… ARGUMENTS πŸ’…

  • reserved_size β€” literally the size of the reserved percpu area, in bytes πŸ’–
  • dyn_size β€” the minimum free size for dynamic allocation, in bytes ✨
  • atom_size β€” the allocation atom size πŸŽ€
  • cpu_distance_fn β€” the callback that figures out the distance between cpus. it's optional, so no pressure bestie πŸ¦‹

🌈 DESCRIPTION 🌈

so the way this works: it determines the grouping of units, their mappings to cpus, and all the other parameters β€” and it does it while considering the needed percpu size, the allocation atom size, and the distances between CPUs. it's giving ✨thoughtful✨

groups are always multiples of atom size, and CPUs that are of LOCAL_DISTANCE both ways get grouped together and share space for units in the same group. cute, right? πŸ₯°

and the returned configuration is guaranteed to have CPUs on different nodes on different groups, plus >=75% usage of the allocated virtual address space. we love an efficient queen πŸ‘‘


⭐ RETURN ⭐

  • on success β€” a pointer to the new allocation_info is returned πŸ’–
  • on failure β€” an ERR_PTR value is returned 😭

πŸ”₯ SEE ALSO πŸ”₯

kernel file ./mm/percpu.c, then the whole friend group:

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_setup_first_chunk(9), pcpu_embed_first_chunk(9), pcpu_page_first_chunk(9)


okay that's the whole page, you ate that fr fr πŸ’…βœ¨ this little gem lives over in ./mm and it's stamped October 2026 β€” until next time bestie, mwah πŸŽ€πŸ’–πŸŒŸ

πŸ“¦ where this page comes from