Re: [PATCH] mm/slab: improve kmem_cache_alloc_bulk
From: Christoph Hellwig
Date: Wed May 27 2026 - 10:17:52 EST
On Wed, May 27, 2026 at 03:56:38PM +0200, Alexander Lobakin wrote:
> >> - n -= kmem_cache_alloc_bulk(net_hotdata.skbuff_cache,
> >> - GFP_ATOMIC | __GFP_ZERO | __GFP_NOWARN,
> >> - n - nc->skb_count, &skbs[nc->skb_count]);
> >> + if (kmem_cache_alloc_bulk(net_hotdata.skbuff_cache,
> >> + GFP_ATOMIC | __GFP_ZERO | __GFP_NOWARN,
> >> + n - nc->skb_count, &skbs[nc->skb_count]))
> >> + n = nc->skb_count;
>
> kmem_cache_alloc_bulk() allocates `n - nc->skb_count`, but here you
> assign `nc->skb_count` to n.
> Ah wait,
>
> n -= n - nc->skb_count
> n = n - (n - nc->skb_count)
> n = n - n + nc->skb_count
> n = nc->skb_count
>
> Correct :D
Exactly the steps I went through when writing this patch :)