vmap(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– vmap(9) β€” the kernel API manual, but make it cute πŸŽ€

okay bestie so you already know this one, it's vmap(9) from the Kernel API Manual (the vmap page, section 9) and like. it's genuinely such an icon. let's get into it ✨


🌸 NAME 🌸

vmap β€” maps a whole array of pages into virtually contiguous space. that's it. that's the vibe. πŸ’…


⭐ SYNOPSIS ⭐

void * vmap (struct page **pages , unsigned int count , unsigned long
flags , pgprot_t prot );

look at that signature. the way that void * said "i return an address, maybe, we'll see" β€” main character energy fr fr πŸ‘‘


πŸ¦‹ ARGUMENTS πŸ¦‹

  • pages β€” an array of page pointers. like the little clipboard of pages you're handing over bestie 🫢
  • count β€” how many pages you want to map. the headcount, iykyk.
  • flags β€” literally vm_area->flags. that's the field. that's the flag source. no notes πŸ“
  • prot β€” the page protection for the mapping, i.e. what's allowed to happen in there πŸ”₯

🧚 DESCRIPTION 🧚

so what it does: it maps count pages from pages into contiguous kernel virtual space. contiguous. virtually. slay ✨

⚠️ okay this next part is the IMPORTANT PART, don't skip it: if flags contains VM_MAP_PUT_PAGES, then ownership of the pages array itself gets transferred from you to vmap β€” and that array must be kmalloc or vmalloc memory, no exceptions β€” and also one reference per page in it gets transferred too. then when vfree is called on the return value, all that gets freed / dropped.

so like. you hand over the keys πŸ—οΈ and the refs, and vfree is the one who cleans up. don't be out here double-freeing, that's not the vibe, that's a crash πŸ’€


🌈 RETURN 🌈

the address of the area, or NULL on failure. that's it. that's the whole return section. either you get an address or you get NULL and a bad day 😭


πŸ’œ SEE ALSO πŸ’œ

it's in the kernel file ./mm/vmalloc.c β€” and bestie, the friend group is LARGE. every single one of them, here we go:

that's the whole group chat and yes they're all invited πŸ’…πŸŽ€


mwah πŸ’‹ that's the page! it lives in ./mm, it's dated October 2026, and it's page vmap(9) of the Kernel API Manual. go map some pages, bestie, you've got this πŸ¦‹πŸ’–βœ¨

πŸ“¦ where this page comes from