kmem_buckets_create(9)
π kmem_buckets_create(9) β from the Kernel API Manual, bestie π
okay so picture this: kmem_buckets_create(9) is literally the glow-up page from the Kernel API Manual, and it's giving "let me set up a whole squad of caches for you" energy. she's the one who builds the dynamic-sized-allocation friend group that kmem_buckets_alloc() hangs out with later. no cap, she's a team player. π«Ά
β¨ NAME β¨
kmem_buckets_create β creates a set of caches that handle dynamic sized allocations via kmem_buckets_alloc() π
β¨ SYNOPSIS β¨
kmem_buckets * kmem_buckets_create (const char *name , slab_flags_t
flags , unsigned int useroffset , unsigned int usersize , void
(*ctor)(void *) );
πΈ ARGUMENTS πΈ
nameβ a prefix string, and it's the main character in/proc/slabinfobecause that's where it's used to identify this cache. the individual caches get their sizes tacked on as the suffix, so yeah, they all match but stay unique. iykyk πflagsβ the SLAB flags (peepkmem_cache_createfor the deets, bestie).useroffsetβ the starting offset within an allocation that may be copied to/from userspace.usersizeβ how many bytes, starting right atuseroffset, may be copied to/from userspace. so like, the budget for user-facing copying. πctorβ a constructor for the objects, run whenever new allocations are made. she gets called in to prep the vibes β¨
π¦ DESCRIPTION π¦
cannot be called within an interrupt β big no-no β but it can be interrupted. so like, she needs her space, but she's not gonna block the whole function over it. π
π RETURN π
on success, you get a pointer to the cache. on failure? NULL. that's the whole vibe check.
and here's the iconic part: when CONFIG_SLAB_BUCKETS is not enabled, ZERO_SIZE_PTR is returned, and subsequent calls to kmem_buckets_alloc will fall back to kmalloc. which is lowkey great news β i.e. callers only need to check for NULL on failure. so go ahead, just check for NULL, she's got you. π
π₯ SEE ALSO π₯
- Kernel file
./mm/slab_common.c __kmem_cache_create_args(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)
and that's the whole page, bestie β¨ this one lives under ./mm in the Kernel API Manual, dated October 2026 β section 9 energy all the way through. go forth and create your buckets, 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