krealloc_node_align(9)
π krealloc_node_align(9) β the kernel API glow-up π¦
okay so bestie, welcome to krealloc_node_align, from the Kernel API Manual β¨ this is the realloc-adjacent girly who pops up in section 9 of the man pages, and she's here to reallocate memory for you. The contents will remain unchanged. no cap π
β¨ SYNOPSIS β¨
void * krealloc_node_align (const void *p , size_t new_size , unsigned
long align , gfp_t flags , int nid );
literally one function, five arguments, main character energy π
π ARGUMENTS π
pβ the object you wanna reallocate memory for π«Άnew_sizeβ how many bytes of memory are required, tell her exactly what you needalignβ the desired alignment, she wants it aligned, periodtflagsβ the type of memory to allocatenidβ the NUMA node, orNUMA_NO_NODEif you're not being picky πΈ
π DESCRIPTION π
So here's the tea β if p is NULL, krealloc behaves exactly like kmalloc. iconic behavior honestly.
If new_size is 0 and p is not a NULL pointer, the object pointed to is freed. bye bestie π
β οΈ Only alignments up to those guaranteed bykmallocwill be honored. Don't come for her with your fancy alignment dreams, she said what she said. Please seeDocumentation/core-api/memory-allocation.rstfor more details π
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. fr fr, don't skip a call, she's keeping receipts π
When slub_debug_orig_size is off, krealloc only knows about the bucket size of an allocation (but not the exact size it was allocated with) and hence implements the following semantics for shrinking and growing buffers with __GFP_ZERO:
new bucket
0 size size
|--------|----------------|
| keep | zero |
Otherwise, the original allocation size 'orig_size' could be used to precisely clear the requested size, and the new size will also be stored as the new 'orig_size'. she upgraded and now she remembers everything π
In any case, the contents of the object pointed to are preserved up to the lesser of the new and old sizes. the vibe check passes π₯
β RETURN β
Pointer to the allocated memory π or NULL in case of error π (we don't talk about the error timeline)
π¦ SEE ALSO π¦
Kernel file ./include/linux/slab.h β go read her whole friend group:
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)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)kvrealloc_node_align(9)kmalloc_size_roundup(9)
and that's the whole page bestie, every flag and every reference accounted for, iykyk π
this absolute baddie lives in ./include/linux, and the version she's serving is October 2026 β that's the date on the tin, mwah π πβ¨πΈ
π¦ 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