kmem_cache_alloc(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… kmem_cache_alloc(9) β€” like, the slab allocator's main character moment

okay bestie, welcome to the Kernel API Manual entry for kmem_cache_alloc. this is the one that hands you a shiny new object straight out of your very own cache. no cap, it's iconic.


✨ NAME ✨

kmem_cache_alloc β€” allocate an object πŸŽ€


🌸 SYNOPSIS 🌸

void * kmem_cache_alloc (struct kmem_cache *cachep , gfp_t flags );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • cachep β€” the cache you're pulling from. like, the one you made earlier. your cache, your rules πŸ’…
  • flags β€” see kmalloc. that's the whole note, bestie, go read kmalloc for the tea πŸ“

πŸ’– DESCRIPTION πŸ’–

so basically: allocate an object from this cache. that's it, that's the vibe. one object, from cachep, with your flags doing their thing.

and lowkey the shortcut you want if you were about to manually OR in __GFP_ZERO: peep kmem_cache_zalloc instead β€” it's literally that, pre-packaged, zeroed, slay ✨


🌈 RETURN 🌈

a pointer to the new object. or NULL in case of error β€” so like, check it, bestie, always check it 😭


πŸ‘‘ SEE ALSO πŸ‘‘

kernel file ./include/linux/slab.h plus this whole friend group:


fr fr, every single one of those is a real manual page, go read them, they're all in the ./include/linux directory family 🫢

and that's the whole page, bestie πŸ’œ this one comes straight out of ./include/linux, dated October 2026 β€” mwah, no notes, periodt πŸ§šβ€β™€οΈβ­

πŸ“¦ where this page comes from