kmem_cache_alloc_bulk(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– kmem_cache_alloc_bulk πŸ’–

okay so bestie, welcome to the Kernel API Manual β€” this one is kmem_cache_alloc_bulk(9), and it's literally the "grab a whole squad of objects at once" function. no cap. πŸŽ€


✨ SYNOPSIS ✨

bool kmem_cache_alloc_bulk (struct kmem_cache *s , gfp_t flags , size_t
size , void **p );

that's the whole vibe. it hands you back a bool, so you already know this is a yes-or-no situation πŸ¦‹


🌸 ARGUMENTS 🌸

  • s β€” the cache you're allocating from. your source, your supply, your main character cache πŸ‘‘
  • flags β€” the GFP_* flags. see kmalloc. that's where they live, go look 🫢
  • size β€” how many objects you want. the number of besties you're inviting πŸ’…
  • p β€” the array where the allocated objects land. your little parking lot for pointers πŸš—

πŸ’œ DESCRIPTION πŸ’œ

so basically: this allocates size objects out of s and drops them into p. super straightforward, we love a function that does what it says.

⚠️ important: size must be larger than 0. like, zero is not a vibe here, it's invalid. periodt.

also interrupts must be enabled when you call this function. yes, that's a real requirement, don't come for me 😭

and here's the fun part β€” unlike alloc_pages_bulk, this function does not check for already allocated objects in p. so the caller does not need to zero it out first. convenient? yes. also lowkey means you'd better know what you're doing with p πŸ™ˆ


πŸ”₯ RETURN πŸ”₯

  • true β€” the allocation succeeded, slay ✨
  • false β€” it failed, and we don't talk about it πŸ’€

🧚 SEE ALSO 🧚

kernel file ./mm/slub.c, plus the whole extended friend group:

go read them, iykyk πŸŒˆβ­πŸ“


kisses, this page came to you from ./mm, dated October 2026, and it's kmem_cache_alloc_bulk(9) signing off β€” bye bestie, go allocate responsibly πŸ’–πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from