vmap(9)
π 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β literallyvm_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: ifflagscontainsVM_MAP_PUT_PAGES, then ownership of thepagesarray itself gets transferred from you tovmapβ and that array must bekmallocorvmallocmemory, no exceptions β and also one reference per page in it gets transferred too. then whenvfreeis 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:
vunmap_range(9)vmap_pages_range(9)vm_area_map_pages(9)vm_area_unmap_pages(9)new_vmap_block(9)vm_unmap_aliases(9)vm_unmap_ram(9)vm_map_ram(9)vm_area_add_early(9)vm_area_register_early(9)get_vm_area(9)find_vm_area(9)remove_vm_area(9)vfree_atomic(9)vfree(9)vunmap(9)vmap_pfn(9)__vmalloc_node_range(9)__vmalloc_node(9)vmalloc(9)vmalloc_huge_node(9)vzalloc(9)vmalloc_user(9)vmalloc_node(9)vzalloc_node(9)vrealloc_node_align(9)vmalloc_32(9)vmalloc_32_user(9)vread_iter(9)remap_vmalloc_range_partial(9)remap_vmalloc_range(9)pvm_find_va_enclose_addr(9)pvm_determine_end_from_reverse(9)pcpu_get_vm_areas(9)pcpu_free_vm_areas(9)
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
- 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