]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: prefetch the next skb in napi_skb_cache_get()
authorJason Xing <kernelxing@tencent.com>
Tue, 18 Nov 2025 07:06:46 +0000 (15:06 +0800)
committerJakub Kicinski <kuba@kernel.org>
Thu, 20 Nov 2025 04:29:25 +0000 (20:29 -0800)
After getting the current skb in napi_skb_cache_get(), the next skb in
cache is highly likely to be used soon, so prefetch would be helpful.

Suggested-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Jason Xing <kernelxing@tencent.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Alexander Lobakin <aleksander.lobakin@intel.com>
Link: https://patch.msgid.link/20251118070646.61344-5-kerneljasonxing@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/skbuff.c

index d81ac78c32ffcfc167ea6184205bbbeccd1e2b4c..5a1d123e7ef748220cfe9b54f317d05e75027ce8 100644 (file)
@@ -299,6 +299,8 @@ static struct sk_buff *napi_skb_cache_get(bool alloc)
        }
 
        skb = nc->skb_cache[--nc->skb_count];
+       if (nc->skb_count)
+               prefetch(nc->skb_cache[nc->skb_count - 1]);
        local_unlock_nested_bh(&napi_alloc_cache.bh_lock);
        kasan_mempool_unpoison_object(skb, skbuff_cache_size);