napi_skb_cache_get_bulk(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– napi_skb_cache_get_bulk(9) πŸ’–

okay so bestie, this is a page straight out of the Kernel API Manual (yes, that Kernel API Manual, the one we all live in) and it's all about grabbing a whole little squad of zeroed skb heads out of the cache. literally so iconic of her. πŸŽ€


✨ NAME ✨

napi_skb_cache_get_bulk β€” obtain a number of zeroed skb heads from the cache πŸ¦‹


🌸 SYNOPSIS 🌸

u32 napi_skb_cache_get_bulk (void **skbs , u32 n );

πŸ’… ARGUMENTS πŸ’…

  • skbs β€” pointer to an array that's at least n-sized, and you're gonna fill it up with skb pointers. like, she needs room to work, give her the room. πŸ‘‘
  • n β€” the number of entries to provide, i.e. how many you're asking for. no cap, this is just the count.

🌈 DESCRIPTION 🌈

So what she does is: she tries to obtain n sk_buff entries from the NAPI percpu cache and writes those pointers into the array you handed her, skbs. ✨

If there are less entries available than you asked for, she tries to replenish the cache and bulk-allocates the diff from the MM layer if needed. the way she just handles it. πŸ”₯

Now this next part is the main character detail: the heads are being zeroed with either memset or __GFP_ZERO, so they're ready for {,__}build_skb_around and they don't have any data buffers attached. clean slate, fresh vibe, zero baggage. 🫢

⚠️ big warning, bestie β€” this must be called only from the BH context. like, only. don't get cute about it. πŸ’€

⭐ RETURN ⭐

Returns the number of successfully allocated skbs β€” that's n if no actual allocation was needed, or if kmem_cache_alloc_bulk didn't fail. slay. πŸ’œ


🧚 SEE ALSO 🧚

Kernel file ./net/core/skbuff.c, plus this whole extended friend group:


and that's the whole page, bestie πŸ“ β€” brought to you by ./net/core, dated October 2026, and filed under the manual name napi_skb_cache_get_bulk(9). go forth and allocate responsibly πŸ’–βœ¨

πŸ“¦ where this page comes from