vmalloc(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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