__kmem_cache_create_args(9)
β¨ __KMEM_CACHE_CREATE_ARGS (9) β¨
okay so real talk, this is from the Kernel API Manual bestie, and it's about making a kmem cache. which, yes, sounds like a snooze but it's literally the thing that hands out memory objects to half the kernel, so π
πΈ NAME πΈ
__kmem_cache_create_args β the function that creates a kmem cache. that's it, that's the vibe. β¨
π¦ SYNOPSIS π¦
struct kmem_cache * __kmem_cache_create_args (const char *name ,
unsigned int object_size , struct kmem_cache_args *args , slab_flags_t
flags );
it returns a struct kmem_cache *, periodt. π₯
π ARGUMENTS π
nameβ a string, and it's the one that shows up in/proc/slabinfoto identify this cache. so like, name it something you'd be proud of, iykyk. πobject_sizeβ the size of the objects being created in this cache. how big is each lil guy? this tells you. πargsβ extra arguments for the cache creation. peepstruct kmem_cache_argsfor the full tea. π«flagsβ okay so these are the flags. the descriptions of each individual flag live in their own spots, and the common ones are listed down in DESCRIPTION. no cap. π©
π DESCRIPTION π
not to be called directly, bestie!! π use the kmem_cache_create wrapper with the same parameters. it's giving "the real one is behind the curtain". β¨
the commonly used flags, aka the main characters:
SLAB_ACCOUNTβ account allocations to memcg. π§ΎSLAB_HWCACHE_ALIGNβ align objects on cache line boundaries. so clean, so aligned. π―SLAB_RECLAIM_ACCOUNTβ objects are reclaimable. β»οΈSLAB_TYPESAFE_BY_RCUβ slab page (and, important, not individual objects) freeing is delayed by a grace period. and like, for real, read the full description before using this one β the manpage literally says "see the full description before using" so we're saying it too. π
π§ CONTEXT π§
cannot be called within a interrupt. but it can be interrupted. that's the whole rule, slay. π
okay but the grammar there is not mine, that's straight from the source. interrupt: forbidden. interruption: allowed. π«Ά
β RETURN β
a pointer to the cache on success, and NULL on failure. so likeβ¦ check it, bestie. π
π SEE ALSO π
kernel file ./mm/slab_common.c, plus these iconic siblings:
kmem_buckets_create(9)kmem_cache_shrink(9)kmem_dump_obj(9)kfree_sensitive(9)struct kvfree_rcu_bulk_data(9)struct kfree_rcu_cpu_work(9)struct kfree_rcu_cpu(9)kvfree_rcu_barrier(9)kvfree_rcu_barrier_on_cache(9)
<div align="center">πΈ π¦ π</div>
and that's the whole page!! this one's served up from ./mm in the Kernel API Manual, dated October 2026, and it's __kmem_cache_create_args(9) all the way down. go create a cache, you absolute icon. πβ¨
π¦ 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