pcpu_get_vm_areas(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

okay bestie, welcome to pcpu_get_vm_areas(9) from the Kernel API Manual ✨ this is the one about allocating vmalloc areas for the percpu allocator, and it is lowkey giving main character energy πŸ’…

🌸 NAME 🌸

pcpu_get_vm_areas β€” allocate vmalloc areas for percpu allocator

πŸŽ€ SYNOPSIS πŸŽ€

       struct vm_struct ** pcpu_get_vm_areas (const unsigned long *offsets ,
       const size_t *sizes , int nr_vms , size_t align , gfp_t gfp );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • offsets β€” array containing offset of each area
  • sizes β€” array containing size of each area
  • nr_vms β€” the number of areas to allocate
  • align β€” alignment, all entries in offsets and sizes must be aligned to this
  • gfp β€” allocation flags passed to the underlying memory allocator

✨ RETURN ✨

On success you get a kmalloc'd vm_struct pointer array pointing to allocated vm_structs. On failure you get NULL. That's the whole vibe 😭

πŸ’– DESCRIPTION πŸ’–

So the percpu allocator wants to use congruent vm areas so that it can maintain the offsets among percpu areas. This function allocates congruent vmalloc areas for it. These areas tend to be scattered pretty far β€” the distance between two areas easily going up to gigabytes, no cap. To avoid interacting with regular vmallocs, these areas are allocated from top 🫢

Despite its complicated look, this allocator is rather simple. It does everything top-down and scans free blocks from the end looking for matching base. While scanning, if any of the areas do not fit, the base address is pulled down to fit the area. Scanning is repeated till all the areas fit and then all necessary data structures are inserted and the result is returned. periodt πŸ”₯

🌈 SEE ALSO 🌈

Kernel file ./mm/vmalloc.c is right here, bestie, and these are the related pages:


mwah πŸ’‹ this page came from source/version ./mm, dated October 2026, for pcpu_get_vm_areas(9). stay slaying, kernel bestie 🫢✨

πŸ“¦ where this page comes from