vmalloc(9)
π vmalloc(9) β the Kernel API Manual, bestie edition π
okay so this is a page straight out of the Kernel API Manual, and it's about one of those functions that sounds scary but is actually kind of iconic once you get it. sit down, grab a strawberry drink π, and let's get into it.
β¨ NAME β¨
vmalloc β allocate virtually contiguous memory
like, it gives you memory that looks all nice and continuous from where you're standing. the vibe is seamless. the reality is more of a behind-the-scenes situation. iykyk π«Ά
β¨ SYNOPSIS β¨
void * vmalloc (unsigned long size );
that's the whole thing. one argument. no drama. slay.
β¨ ARGUMENTS β¨
sizeβ the allocation size. literally just how much you want. that's it. that's the argument. π
β¨ DESCRIPTION β¨
so what it does: it allocates enough pages to cover size from the page level allocator, and then maps them into contiguous kernel virtual space. the pages themselves? not necessarily next to each other in physical memory. but in virtual space? besties, they're holding hands in a perfect little row. π
it's giving "found family" honestly.
and listen β if you need tight control over the page level allocator and the protection flags, then vmalloc is not your girl. you want __vmalloc instead. different function, different energy. don't mix them up, ngl. π
β¨ RETURN β¨
a pointer to the allocated memory πΈ β or NULL on error π.
please, please check for the NULL. i'm begging. main character energy includes error handling.
β¨ SEE ALSO β¨
okay this is the part where the manpage just dumps the entire friend group on you π but honestly every single one of them deserves their moment, so here's the full roster, no cap:
kernel file ./mm/vmalloc.c β that's where the magic lives π
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(9), vmap_pfn(9), __vmalloc_node_range(9), __vmalloc_node(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 35 whole besties and they all live in ./mm. go say hi. π¦
little sign-off moment: this page is from the source dir ./mm, and it's dated October 2026 β yes, the future is now, and vmalloc(9) is thriving in it πβ¨ love that for us. bye bestie, go allocate responsibly! ππ
π¦ 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