kmem_cache_alloc_node(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ¦‹ 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. see kmalloc for the deets, i'm not gonna retype the whole thing, iykyk
  • node β€” 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 🧚

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