kmem_buckets_create(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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/slabinfo because 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 (peep kmem_cache_create for the deets, bestie).
  • useroffset β€” the starting offset within an allocation that may be copied to/from userspace.
  • usersize β€” how many bytes, starting right at useroffset, 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 πŸ”₯


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