kmem_cache_create(9)
π kmem_cache_create(9) β a Kernel API Manual moment π
okay bestie, listen up, because this is the kernel API manual page for kmem_cache_create, and honestly she's a little bit of a legend. grab your strawberry drink π and let's get into it β¨
πΈ NAME πΈ
kmem_cache_create β Create a kmem cache.
like, literally that's the whole job. she makes caches. no cap. π
π¦ SYNOPSIS π¦
kmem_cache_create (__name , __object_size , __args , ... );
that's the shape of it, exactly as written, don't come for me about the spaces π
π ARGUMENTS π
__nameβ a string, and it's the string that gets used in/proc/slabinfoto identify this cache. so like, it's her name tag at the slab party π«Ά__object_sizeβ the size of the objects that are gonna be created in this cache. size matters, and this is the size.__argsβ optional arguments, seestruct kmem_cache_args. and here's the vibe check: passingNULLmeans defaults will be used for all the arguments. slay, no config needed π...β variable arguments. yes girl, the dots are real π
β¨ DESCRIPTION β¨
so here's the tea π₯ β right now this is implemented as a macro using _Generic to call either the new variant of the function or a legacy one. two girlies, one macro, iykyk.
the new variant has 4 parameters:
kmem_cache_create(name, object_size, args, flags)
see __kmem_cache_create_args which implements this. she's the main character doing the actual work behind the scenes π
the legacy variant has 5 parameters:
kmem_cache_create(name, object_size, align, flags, ctor)
and the align and ctor parameters map to the respective fields of struct kmem_cache_args. cute little mapping moment π
π§ CONTEXT π§
cannot be called within a interrupt, but can be interrupted. okay so: not inside an interrupt, but yes she can get interrupted herself. it's giving "don't text me while i'm asleep but yes you can tap me on the shoulder" π
π₯ RETURN π₯
a pointer to the cache on success, NULL on failure. that's it, that's the whole mood. success = pointer π«Ά, failure = NULL π
π SEE ALSO π
kernel file ./include/linux/slab.h β go read the source bestie, it's all there π¦
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)krealloc_node_align(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)
that's the whole friend group, go say hi to all of them π
and finally, the lil sign-off π β this page lives over in ./include/linux, it's dated October 2026, and it's kmem_cache_create(9) all the way down. mwah, go build something iconic bestie π
β¨
π¦ 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