Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'net-adjust-conservative-values-around-napi'

Jason Xing says:

====================
net: adjust conservative values around napi

This series keeps at least 96 skbs per cpu and frees 32 skbs at one
time in conclusion. More initial discussions with Eric can be seen at
the link [1].

[1]: https://lore.kernel.org/all/CAL+tcoBEEjO=-yvE7ZJ4sB2smVBzUht1gJN85CenJhOKV====================

Link: https://patch.msgid.link/20251118070646.61344-1-kerneljasonxing@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+12 -8
+12 -8
net/core/skbuff.c
··· 223 223 skb_panic(skb, sz, addr, __func__); 224 224 } 225 225 226 - #define NAPI_SKB_CACHE_SIZE 64 227 - #define NAPI_SKB_CACHE_BULK 16 228 - #define NAPI_SKB_CACHE_HALF (NAPI_SKB_CACHE_SIZE / 2) 226 + #define NAPI_SKB_CACHE_SIZE 128 227 + #define NAPI_SKB_CACHE_BULK 32 228 + #define NAPI_SKB_CACHE_FREE 32 229 229 230 230 struct napi_alloc_cache { 231 231 local_lock_t bh_lock; ··· 299 299 } 300 300 301 301 skb = nc->skb_cache[--nc->skb_count]; 302 + if (nc->skb_count) 303 + prefetch(nc->skb_cache[nc->skb_count - 1]); 302 304 local_unlock_nested_bh(&napi_alloc_cache.bh_lock); 303 305 kasan_mempool_unpoison_object(skb, skbuff_cache_size); 304 306 ··· 1447 1445 static void napi_skb_cache_put(struct sk_buff *skb) 1448 1446 { 1449 1447 struct napi_alloc_cache *nc = this_cpu_ptr(&napi_alloc_cache); 1450 - u32 i; 1451 1448 1452 1449 if (!kasan_mempool_poison_object(skb)) 1453 1450 return; ··· 1455 1454 nc->skb_cache[nc->skb_count++] = skb; 1456 1455 1457 1456 if (unlikely(nc->skb_count == NAPI_SKB_CACHE_SIZE)) { 1458 - for (i = NAPI_SKB_CACHE_HALF; i < NAPI_SKB_CACHE_SIZE; i++) 1457 + u32 i, remaining = NAPI_SKB_CACHE_SIZE - NAPI_SKB_CACHE_FREE; 1458 + 1459 + for (i = remaining; i < NAPI_SKB_CACHE_SIZE; i++) 1459 1460 kasan_mempool_unpoison_object(nc->skb_cache[i], 1460 1461 skbuff_cache_size); 1461 1462 1462 - kmem_cache_free_bulk(net_hotdata.skbuff_cache, NAPI_SKB_CACHE_HALF, 1463 - nc->skb_cache + NAPI_SKB_CACHE_HALF); 1464 - nc->skb_count = NAPI_SKB_CACHE_HALF; 1463 + kmem_cache_free_bulk(net_hotdata.skbuff_cache, 1464 + NAPI_SKB_CACHE_FREE, 1465 + nc->skb_cache + remaining); 1466 + nc->skb_count = remaining; 1465 1467 } 1466 1468 local_unlock_nested_bh(&napi_alloc_cache.bh_lock); 1467 1469 }