kvrealloc_node_align(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– NAME πŸ’–

This is kvrealloc_node_align(9), straight out of the Kernel API Manual, section 9 β€” reallocate memory; contents remain unchanged. Slay, but specifically: it’s the realloc bestie that keeps your bytes intact. ✨

🌸 SYNOPSIS 🌸

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

πŸŽ€ ARGUMENTS πŸŽ€

  • p β€” object to reallocate memory for. The main character pointer, bestie.
  • size β€” the size to reallocate.
  • align β€” desired alignment.
  • flags β€” the flags for the page level allocator.
  • nid β€” NUMA node id.

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so here’s the tea, literally. If p is NULL, kvrealloc behaves exactly like kvmalloc. If size is 0 and p is not a NULL pointer, the object pointed to is freed. πŸ’…

Only alignments up to those guaranteed by kmalloc will be honored. Please see Documentation/core-api/memory-allocation.rst for more details. No cap.

⚠️ 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 is possible that __GFP_ZERO is not fully honored by this API. That’s the important part, bestie β€” don’t skip the flag. 😭

In any case, the contents of the object pointed to are preserved up to the lesser of the new and old sizes. So your data stays cute up to whichever size is smaller. 🫢

πŸ’€ This function must not be called concurrently with itself or kvfree for the same memory allocation. Like, do not run up on it at the same time. Periodt.

πŸ‘‘ RETURN πŸ‘‘

Pointer to the allocated memory or NULL in case of error. That’s it, that’s the return. πŸ’–

🌈 SEE ALSO 🌈

Kernel file ./include/linux/slab.h: SLAB_HWCACHE_ALIGN(9), SLAB_TYPESAFE_BY_RCU(9), SLAB_ACCOUNT(9), SLAB_RECLAIM_ACCOUNT(9), struct kmem_cache_args(9), kmem_cache_create_usercopy(9), kmem_cache_create(9), krealloc_node_align(9), kmem_cache_alloc(9), kmem_cache_charge(9), kmalloc(9), kmalloc_nolock(9), __alloc_objs(9), __alloc_flex(9), kmalloc_obj(9), kmalloc_objs(9), kmalloc_flex(9), kmalloc_array(9), krealloc_array(9), kcalloc(9), kzalloc(9), kvmalloc_node(9), kmalloc_size_roundup(9)


Cute little sign-off from the source/version stamp: this page lives under ./include/linux, dated October 2026, and it’s kvrealloc_node_align(9). Bye bestie, go preserve those bytes πŸ’…βœ¨

πŸ“¦ where this page comes from