kmem_cache_alloc_node(9)
π¦ kmem_cache_alloc_node(9) π¦
okay bestie, welcome to the Kernel API Manual β this one's a little function with main character energy in the slab allocator world, and honestly? it slays. let's get into it β¨
πΈ NAME πΈ
kmem_cache_alloc_node β literally allocates an object on the node you specify. that's it, that's the vibe π
π SYNOPSIS π
void * kmem_cache_alloc_node (struct kmem_cache *s , gfp_t gfpflags ,
int node );
like, look at that signature. gorgeous. no notes π«Ά
β¨ ARGUMENTS β¨
sβ the cache you're allocating from. your home base, your safe space πgfpflagsβ the flags. seekmallocfor the deets, i'm not gonna retype the whole thing, iykyknodeβ the node number of the target node. this is the whole point of the function, bestie π―
π DESCRIPTION π
so this is identical to kmem_cache_alloc β same energy, same job β but it's gonna allocate memory on the given node, which lowkey can improve performance for cpu bound structures. the way that locality just hits different ππ₯
and here's the tea: fallback to another node is possible if __GFP_THISNODE is not set. so if you really want it pinned to that one node, you gotta set that flag β otherwise it'll wander off to a neighbour and honestly, fair π
no cap, if node-locality matters to you, check your flags before you ship. this is a real one π
π RETURN π
you get back a pointer to the new object, or NULL in case of error. that's it. NULL means something went wrong, so handle it, bestie π
π§ SEE ALSO π§
- Kernel file
./mm/slub.c enum slab_flags(9)kmem_cache_free(9)ksize(9)kfree(9)kvfree(9)kvfree_atomic(9)kvfree_sensitive(9)kmem_cache_alloc_bulk(9)
go read some of these, they're iconic in their own right β
aaaand that's the page! this lil masterpiece lives in the ./mm source, dated October 2026, and it's one of the kmem_cache_alloc_node(9) girlies fr fr. mwah, go allocate something 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