kmem_cache_alloc(9)
π 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β seekmalloc. that's the whole note, bestie, go readkmallocfor 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:
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_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)
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
- 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