__kmem_cache_create_args(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ __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/slabinfo to 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. peep struct kmem_cache_args for 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:


<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