vrealloc_node_align(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’œ vrealloc_node_align(9) β€” like, the Kernel API Manual page, but make it make sense

okay bestie, gather round 🫢 this one lives in the Kernel API Manual and it's all about reallocating virtually contiguous memory while keeping your contents exactly where they were. no cap, the vibes are immaculate but the rules are strict. let's go πŸ’…


✨ NAME ✨

vrealloc_node_align β€” reallocate virtually contiguous memory; and the contents? they remain unchanged, periodt πŸ’–


🌸 SYNOPSIS 🌸

void * vrealloc_node_align (const void *p , size_t size , unsigned long
align , gfp_t flags , int nid );

that's the whole signature, copy it exactly, don't be cute with it πŸŽ€


πŸ¦‹ ARGUMENTS πŸ¦‹

  • p β€” the object you're reallocating memory for πŸ₯Ί
  • size β€” the size you wanna reallocate to
  • align β€” the alignment you're requesting, bestie, be reasonable
  • flags β€” the flags for the page level allocator πŸ‘‘
  • nid β€” the node number of the target node ⭐

πŸ”₯ DESCRIPTION πŸ”₯

so here's the tea β˜•

if p is NULL, vrealloc_XXX behaves exactly like vmalloc_XXX. literally identical energy, no notes. and if size is 0 and p is not a NULL pointer, the object pointed to gets freed. bye bye πŸ‘‹

if the caller wants the new memory to be on a specific node only, the __GFP_THISNODE flag should be set. otherwise? the function will try to avoid reallocation and possibly disregard the specified nid 😭 iykyk β€” set the flag or don't come crying to me.

now the __GFP_ZERO part, listen up πŸ™ˆ if __GFP_ZERO logic is requested, callers must ensure that, starting with the initial memory allocation, every subsequent call to this API for the same memory allocation is flagged with __GFP_ZERO. otherwise it's possible that __GFP_ZERO is not fully honored by this API. that's a big deal, fr fr πŸ’€

🚨 and requesting an alignment that is bigger than the alignment of the existing allocation will fail. not "might", not "maybe" β€” it fails. respect the existing alignment or perish.

in any case, the contents of the object pointed to are preserved up to the lesser of the new and old sizes πŸ’– (so like, the overlap, basically β€” the smaller of the two).

and the safety warning, because we care about you bestie:

⚠️ this function must not be called concurrently with itself or vfree for the same memory allocation. no race conditions, no chaotic main character energy. one at a time, please 🫢

πŸ‘‘ RETURN πŸ‘‘

  • a pointer to the allocated memory πŸŽ€
  • NULL if size is zero, or in case of failure 😭

🌈 SEE ALSO 🌈

kernel file ./mm/vmalloc.c and the whole extended fam β€” every single one, no skipping:

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(9),
vmalloc_huge_node(9), vzalloc(9), vmalloc_user(9), vmalloc_node(9),
vzalloc_node(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)

like, that's the whole group chat πŸ’…


and that's the page!! πŸ¦‹ this little gem comes to you from ./mm and it's dated October 2026 β€” mwah, slay, go forth and reallocate responsibly bestie πŸ’œβœ¨

πŸ“¦ where this page comes from