net: shrink napi_skb_cache_put()
Subsystems (2)
PATCH 1/1 net: shrink napi_skb_cache_put()
Following loop in napi_skb_cache_put() is unrolled by the compiler even if CONFIG_KASAN is not enabled:
for (i = NAPI_SKB_CACHE_HALF; i < NAPI_SKB_CACHE_SIZE; i++)
kasan_mempool_unpoison_object(nc->skb_cache[i], kmem_cache_size(net_hotdata.skbuff_cache));
We have 32 times this sequence, for a total of 384 bytes.
48 8b 3d 00 00 00 00 net_hotdata.skbuff_cache,%rdi e8 00 00 00 00 call kmem_cache_size
This is because kmem_cache_size() is an extern function, and kasan_unpoison_object_data() is an inline function.
Cache kmem_cache_size() result in a temporary variable, and make the loop conditional to CONFIG_KASAN.
After this patch, napi_skb_cache_put() is inlined in its callers.
--- net/core/skbuff.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
net/core/skbuff.c +6 -3
@@ -1426,10 +1426,13 @@ static void napi_skb_cache_put(struct sk_buff *skb) nc->skb_cache[nc->skb_count++] = skb;if (unlikely (nc->skb_count ==NAPI_SKB_CACHE_SIZE )) { -for (i =NAPI_SKB_CACHE_HALF ; i <NAPI_SKB_CACHE_SIZE ; i++) -kasan_mempool_unpoison_object (nc->skb_cache[i], -kmem_cache_size (net_hotdata.skbuff_cache)); +if (IS_ENABLED (CONFIG_KASAN )) { +u32 size =kmem_cache_size (net_hotdata.skbuff_cache); +for (i =NAPI_SKB_CACHE_HALF ; i <NAPI_SKB_CACHE_SIZE ; i++) +kasan_mempool_unpoison_object (nc->skb_cache[i], + size); + }kmem_cache_free_bulk (net_hotdata.skbuff_cache,NAPI_SKB_CACHE_HALF , nc->skb_cache +NAPI_SKB_CACHE_HALF ); nc->skb_count =NAPI_SKB_CACHE_HALF ;
Signature · 1 line
2.51.0.869.ge66316f041-goog
Quoted 16 lines · Eric Dumazet
Following loop in
napi_skb_cache_put()is unrolled by the compiler even ifCONFIG_KASANis not enabled:for (i =
NAPI_SKB_CACHE_HALF; i <NAPI_SKB_CACHE_SIZE; i++)kasan_mempool_unpoison_object(nc->skb_cache[i], kmem_cache_size(net_hotdata.skbuff_cache));We have 32 times this sequence, for a total of 384 bytes.
48 8b 3d 00 00 00 00 net_hotdata.skbuff_cache,%rdi
e8 00 00 00 00 callkmem_cache_sizeThis is because
kmem_cache_size()is an extern function, andkasan_unpoison_object_data()is an inline function.
Quoted 6 lines
Cache
kmem_cache_size()result in a temporary variable, and make the loop conditional toCONFIG_KASAN.After this patch,
napi_skb_cache_put()is inlined in its callers.Signed-off-by Eric Dumazet <[email protected]>
Oh exactly, it's interesting that the compiler cannot optimise out unused retval even though kmem_cache_size() is a single load :o
$ grep KASAN .config CONFIG_HAVE_ARCH_KASAN=y CONFIG_HAVE_ARCH_KASAN_VMALLOC=y CONFIG_CC_HAS_KASAN_GENERIC=y CONFIG_CC_HAS_KASAN_SW_TAGS=y # CONFIG_KASAN is not set
$ objdump --disassemble=napi_skb_cache_put vmlinux ... ffffffff81e9fe10 <napi_skb_cache_put>: ... ffffffff81e9fe40: 48 8b 3d 89 bd d6 00 mov 0xd6bd89(%rip),%rdi # ffffffff82c0bbd0 <net_hotdata+0x150> ffffffff81e9fe47: e8 a4 79 60 ff call ffffffff814a77f0 <kmem_cache_size> ffffffff81e9fe4c: 83 eb 01 sub $0x1,%ebx ffffffff81e9fe4f: 75 ef jne ffffffff81e9fe40 <napi_skb_cache_put+0x30>
From: Eric Dumazet <[email protected]>
Date: Wed, 15 Oct 2025 23:38:01 +0000
Quoted 34 lines
Following loop in
napi_skb_cache_put()is unrolled by the compiler even ifCONFIG_KASANis not enabled:for (i =
NAPI_SKB_CACHE_HALF; i <NAPI_SKB_CACHE_SIZE; i++)kasan_mempool_unpoison_object(nc->skb_cache[i], kmem_cache_size(net_hotdata.skbuff_cache));We have 32 times this sequence, for a total of 384 bytes.
48 8b 3d 00 00 00 00 net_hotdata.skbuff_cache,%rdi e8 00 00 00 00 call kmem_cache_sizeThis is because
kmem_cache_size()is an extern function, andkasan_unpoison_object_data()is an inline function.Cache
kmem_cache_size()result in a temporary variable, and make the loop conditional toCONFIG_KASAN.After this patch,
napi_skb_cache_put()is inlined in its callers.Signed-off-by Eric Dumazet <[email protected]>Cc Alexander Lobakin <[email protected]>--- net/core/skbuff.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)net/core/skbuff.c +0
-0@@ -1426,10 +1426,13 @@ static void napi_skb_cache_put(struct sk_buff *skb) nc->skb_cache[nc->skb_count++] = skb;if (unlikely (nc->skb_count ==NAPI_SKB_CACHE_SIZE )) {
net/core/skbuff.c static void napi_skb_cache_put(struct sk_buff *skb) · line 1435
Quoted 10 lines
net/core/skbuff.c +6
-3-for (i =NAPI_SKB_CACHE_HALF ; i <NAPI_SKB_CACHE_SIZE ; i++) -kasan_mempool_unpoison_object (nc->skb_cache[i], -kmem_cache_size (net_hotdata.skbuff_cache)); +if (IS_ENABLED (CONFIG_KASAN )) { +u32 size =kmem_cache_size (net_hotdata.skbuff_cache); +for (i =NAPI_SKB_CACHE_HALF ; i <NAPI_SKB_CACHE_SIZE ; i++) +kasan_mempool_unpoison_object (nc->skb_cache[i], + size); + }
Very interesting; back when implementing napi_skb_cache*() family and someone (most likely Jakub) asked me to add KASAN-related checks here, I was comparing the object code and stopped on the current variant, as without KASAN, the entire loop got optimized away (but only when kmem_cache_size() is *not* a temporary variable).
Or does this patch addresses KASAN-enabled kernels? Either way, if this patch really optimizes things:
net/core/skbuff.c static void napi_skb_cache_put(struct sk_buff *skb) · line 1438
Quoted 3 lines
net/core/skbuff.c +0
-0kmem_cache_free_bulk (net_hotdata.skbuff_cache,NAPI_SKB_CACHE_HALF , nc->skb_cache +NAPI_SKB_CACHE_HALF ); nc->skb_count =NAPI_SKB_CACHE_HALF ;
Thanks,
Olek
Quoted 55 lines · Alexander Lobakin
From: Eric Dumazet <[email protected]>
Date: Wed, 15 Oct 2025 23:38:01 +0000Quoted 34 lines
Following loop in
napi_skb_cache_put()is unrolled by the compiler even ifCONFIG_KASANis not enabled:for (i =
NAPI_SKB_CACHE_HALF; i <NAPI_SKB_CACHE_SIZE; i++)kasan_mempool_unpoison_object(nc->skb_cache[i], kmem_cache_size(net_hotdata.skbuff_cache));We have 32 times this sequence, for a total of 384 bytes.
48 8b 3d 00 00 00 00 net_hotdata.skbuff_cache,%rdi
e8 00 00 00 00 callkmem_cache_sizeThis is because
kmem_cache_size()is an extern function, andkasan_unpoison_object_data()is an inline function.Cache
kmem_cache_size()result in a temporary variable, and make the loop conditional toCONFIG_KASAN.After this patch,
napi_skb_cache_put()is inlined in its callers.Signed-off-by Eric Dumazet <[email protected]>Cc Alexander Lobakin <[email protected]>--- net/core/skbuff.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)net/core/skbuff.c +0
-0@@ -1426,10 +1426,13 @@ static void napi_skb_cache_put(struct sk_buff *skb) nc->skb_cache[nc->skb_count++] = skb;if (unlikely (nc->skb_count ==NAPI_SKB_CACHE_SIZE )) {net/core/skbuff.c static void napi_skb_cache_put(struct sk_buff *skb) · line 1435
Quoted 10 lines
net/core/skbuff.c +6
-3-for (i =NAPI_SKB_CACHE_HALF ; i <NAPI_SKB_CACHE_SIZE ; i++) -kasan_mempool_unpoison_object (nc->skb_cache[i], -kmem_cache_size (net_hotdata.skbuff_cache)); +if (IS_ENABLED (CONFIG_KASAN )) { +u32 size =kmem_cache_size (net_hotdata.skbuff_cache); +for (i =NAPI_SKB_CACHE_HALF ; i <NAPI_SKB_CACHE_SIZE ; i++) +kasan_mempool_unpoison_object (nc->skb_cache[i], + size); + }Very interesting; back when implementing napi_skb_cache*() family and someone (most likely Jakub) asked me to add KASAN-related checks here, I was comparing the object code and stopped on the current variant, as without KASAN, the entire loop got optimized away (but only when
kmem_cache_size()is *not* a temporary variable).
Quoted 2 lines
Or does this patch addresses KASAN-enabled kernels? Either way, if this patch really optimizes things:
No, this is when CONFIG_KASAN is _not_ enabled.
(I have not checked when it is enabled, I do not care about the cost of KASAN as long as it is not too expensive)
Compiler does not know anything about kmem_cache_size()
It could contain some memory cloberring, memory freeing, some kind of destructive action.
So it has to call it 32 times.
And reload net_hotdata.skbuff_cache 32 times, because the value could have been changed
by kmem_cache_size() (if kmem_cache_size() wanted to)
Not sure if kmem_cache_size() could be inlined.
Its use has been discouraged so I guess nobody cared.
Quoted 9 lines
net/core/skbuff.c static void napi_skb_cache_put(struct sk_buff *skb) · line 1438
Quoted 3 lines
net/core/skbuff.c +0
-0kmem_cache_free_bulk (net_hotdata.skbuff_cache,NAPI_SKB_CACHE_HALF , nc->skb_cache +NAPI_SKB_CACHE_HALF ); nc->skb_count =NAPI_SKB_CACHE_HALF ;Thanks,
Olek
From: Eric Dumazet <[email protected]>
Date: Thu, 16 Oct 2025 03:31:37 -0700
Quoted 69 lines
Quoted 55 lines · Alexander Lobakin
From: Eric Dumazet <[email protected]>
Date: Wed, 15 Oct 2025 23:38:01 +0000Quoted 34 lines
Following loop in
napi_skb_cache_put()is unrolled by the compiler even ifCONFIG_KASANis not enabled:for (i =
NAPI_SKB_CACHE_HALF; i <NAPI_SKB_CACHE_SIZE; i++)kasan_mempool_unpoison_object(nc->skb_cache[i], kmem_cache_size(net_hotdata.skbuff_cache));We have 32 times this sequence, for a total of 384 bytes.
48 8b 3d 00 00 00 00 net_hotdata.skbuff_cache,%rdi
e8 00 00 00 00 callkmem_cache_sizeThis is because
kmem_cache_size()is an extern function, andkasan_unpoison_object_data()is an inline function.Cache
kmem_cache_size()result in a temporary variable, and make the loop conditional toCONFIG_KASAN.After this patch,
napi_skb_cache_put()is inlined in its callers.Signed-off-by Eric Dumazet <[email protected]>Cc Alexander Lobakin <[email protected]>--- net/core/skbuff.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)net/core/skbuff.c +0
-0@@ -1426,10 +1426,13 @@ static void napi_skb_cache_put(struct sk_buff *skb) nc->skb_cache[nc->skb_count++] = skb;if (unlikely (nc->skb_count ==NAPI_SKB_CACHE_SIZE )) {net/core/skbuff.c static void napi_skb_cache_put(struct sk_buff *skb) · line 1435
Quoted 10 lines
net/core/skbuff.c +6
-3-for (i =NAPI_SKB_CACHE_HALF ; i <NAPI_SKB_CACHE_SIZE ; i++) -kasan_mempool_unpoison_object (nc->skb_cache[i], -kmem_cache_size (net_hotdata.skbuff_cache)); +if (IS_ENABLED (CONFIG_KASAN )) { +u32 size =kmem_cache_size (net_hotdata.skbuff_cache); +for (i =NAPI_SKB_CACHE_HALF ; i <NAPI_SKB_CACHE_SIZE ; i++) +kasan_mempool_unpoison_object (nc->skb_cache[i], + size); + }Very interesting; back when implementing napi_skb_cache*() family and someone (most likely Jakub) asked me to add KASAN-related checks here, I was comparing the object code and stopped on the current variant, as without KASAN, the entire loop got optimized away (but only when
kmem_cache_size()is *not* a temporary variable).Quoted 2 lines
Or does this patch addresses KASAN-enabled kernels? Either way, if this patch really optimizes things:
No, this is when
CONFIG_KASANis _not_ enabled.(I have not checked when it is enabled, I do not care about the cost of KASAN as long as it is not too expensive)
Compiler does not know anything about
kmem_cache_size()
It could contain some memory cloberring, memory freeing, some kind of destructive action.
Quoted 7 lines
So it has to call it 32 times.
And reload net_hotdata.skbuff_cache 32 times, because the value could have been changed
bykmem_cache_size()(ifkmem_cache_size()wanted to)Not sure if
kmem_cache_size()could be inlined.
BTW doesn't napi_skb_cache_get() (inc. get_bulk()) suffer the same way?
Quoted 9 lines
Its use has been discouraged so I guess nobody cared.
Quoted 6 lines
Quoted 3 lines
net/core/skbuff.c +0
-0kmem_cache_free_bulk (net_hotdata.skbuff_cache,NAPI_SKB_CACHE_HALF , nc->skb_cache +NAPI_SKB_CACHE_HALF ); nc->skb_count =NAPI_SKB_CACHE_HALF ;
Thanks,
Olek
Quoted 4 lines · Alexander Lobakin
From: Eric Dumazet <[email protected]>
BTW doesn't
napi_skb_cache_get()(inc.get_bulk()) suffer the same way?
Probably, like other calls to napi_skb_cache_put(()
No loop there, so I guess there is no big deal.
I was looking at napi_skb_cache_put() because there is a lack of NUMA awareness, and was curious to experiment with some strategies there.
Quoted 6 lines · Eric Dumazet
Quoted 3 lines · Alexander Lobakin
From: Eric Dumazet <[email protected]>
Quoted 8 lines
Quoted 1 line
BTW doesn't
napi_skb_cache_get()(inc.get_bulk()) suffer the same way?Probably, like other calls to napi_skb_cache_put(()
No loop there, so I guess there is no big deal.
I was looking at
napi_skb_cache_put()because there is a lack of NUMA awareness, and was curious to experiment with some strategies there.
If we cache kmem_cache_size() in net_hotdata, the compiler is able to eliminate dead code
for CONFIG_KASAN=n
Maybe this looks better ?
include/net/hotdata.h +0 -0
100644
include/net/hotdata.h +2 -1
@@ -33,9 +33,10 @@ struct net_hotdata {struct kmem_cache *skbuff_cache;struct kmem_cache *skbuff_fclone_cache;struct kmem_cache *skb_small_head_cache; +u32 skbuff_cache_size;#ifdef CONFIG_RPS -struct rps_sock_flow_table __rcu *rps_sock_flow_table;u32 rps_cpu_mask; +struct rps_sock_flow_table __rcu *rps_sock_flow_table;#endif struct skb_defer_node __percpu *skb_defer_nodes;int gro_normal_batch;
net/core/skbuff.c +0 -0
100644
net/core/skbuff.c +0 -1
@@ -365,7 +365,7 @@ static struct sk_buff *napi_skb_cache_get(void) skb = nc->skb_cache[--nc->skb_count];local_unlock_nested_bh (&napi_alloc_cache.bh_lock); - kasan_mempool_unpoison_object(skb,
kmem_cache_size(net_hotdata.skbuff_cache));
+ kasan_mempool_unpoison_object(skb, net_hotdata.skbuff_cache_size);
return skb;
}
@@ -1504,7 +1504,7 @@ static void napi_skb_cache_put(struct sk_buff *skb)
if (unlikely(nc->skb_count == NAPI_SKB_CACHE_SIZE)) {
for (i = NAPI_SKB_CACHE_HALF; i < NAPI_SKB_CACHE_SIZE; i++)
kasan_mempool_unpoison_object(nc->skb_cache[i],-kmem_cache_size(net_hotdata.skbuff_cache));
+ net_hotdata.skbuff_cache_size);
kmem_cache_free_bulk(net_hotdata.skbuff_cache,NAPI_SKB_CACHE_HALF,
nc->skb_cache + NAPI_SKB_CACHE_HALF);
@@ -5164,6 +5164,7 @@ void __init skb_init(void)
offsetof(struct sk_buff, cb), sizeof_field(struct sk_buff, cb), NULL);
+ net_hotdata.skbuff_cache_size =kmem_cache_size(net_hotdata.skbuff_cache);
net_hotdata.skbuff_fclone_cache =
kmem_cache_create("skbuff_fclone_cache",
sizeof(struct sk_buff_fclones),
0,Quoted 14 lines · Eric Dumazet
Quoted 12 lines · Eric Dumazet
Quoted 4 lines · Alexander Lobakin
From: Eric Dumazet <[email protected]>
BTW doesn't
napi_skb_cache_get()(inc.get_bulk()) suffer the same way?Probably, like other calls to napi_skb_cache_put(()
No loop there, so I guess there is no big deal.
Quoted 8 lines
Quoted 2 lines
I was looking at
napi_skb_cache_put()because there is a lack of NUMA awareness, and was curious to experiment with some strategies there.If we cache
kmem_cache_size()innet_hotdata, the compiler is able to eliminate dead code
forCONFIG_KASAN=nMaybe this looks better ?
No need to put this in net_hotdata, I was distracted by a 4byte hole there, we can keep this hole for something hot later.
net/core/skbuff.c +0 -0
100644
net/core/skbuff.c +0 -0
@@ -274,6 +274,8 @@ void *__netdev_alloc_frag_align(unsigned int
fragsz, unsigned int align_mask)
}
EXPORT_SYMBOL(__netdev_alloc_frag_align);
+u32 skbuff_cache_size __read_mostly;
+
static struct sk_buff *napi_skb_cache_get(void)
{
struct napi_alloc_cache *nc = this_cpu_ptr(&napi_alloc_cache);@@ -293,7 +295,7 @@ static struct sk_buff *napi_skb_cache_get(void)
skb = nc->skb_cache[--nc->skb_count];
local_unlock_nested_bh(&napi_alloc_cache.bh_lock);- kasan_mempool_unpoison_object(skb,kmem_cache_size(net_hotdata.skbuff_cache));
+ kasan_mempool_unpoison_object(skb, skbuff_cache_size);
return skb;
}
@@ -1428,7 +1430,7 @@ static void napi_skb_cache_put(struct sk_buff *skb)
if (unlikely(nc->skb_count == NAPI_SKB_CACHE_SIZE)) {
for (i = NAPI_SKB_CACHE_HALF; i < NAPI_SKB_CACHE_SIZE; i++)
kasan_mempool_unpoison_object(nc->skb_cache[i],-kmem_cache_size(net_hotdata.skbuff_cache));
+ skbuff_cache_size);
kmem_cache_free_bulk(net_hotdata.skbuff_cache,NAPI_SKB_CACHE_HALF,
nc->skb_cache + NAPI_SKB_CACHE_HALF);
@@ -5116,6 +5118,8 @@ void __init skb_init(void)
offsetof(struct sk_buff, cb), sizeof_field(struct sk_buff, cb), NULL);
+ skbuff_cache_size = kmem_cache_size(net_hotdata.skbuff_cache);
+
net_hotdata.skbuff_fclone_cache =
kmem_cache_create("skbuff_fclone_cache",
sizeof(struct sk_buff_fclones),
0,From: Eric Dumazet <[email protected]>
Date: Thu, 16 Oct 2025 06:36:55 -0700
Quoted 18 lines · Eric Dumazet
Quoted 17 lines · Eric Dumazet
Quoted 14 lines
Quoted 4 lines · Alexander Lobakin
From: Eric Dumazet <[email protected]>
BTW doesn't
napi_skb_cache_get()(inc.get_bulk()) suffer the same way?Probably, like other calls to napi_skb_cache_put(()
No loop there, so I guess there is no big deal.
I was looking at
napi_skb_cache_put()because there is a lack of NUMA awareness, and was curious to experiment with some strategies there.
Quoted 8 lines
Quoted 5 lines
If we cache
kmem_cache_size()innet_hotdata, the compiler is able to eliminate dead code
forCONFIG_KASAN=nMaybe this looks better ?
No need to put this in
net_hotdata, I was distracted by a 4byte hole there, we can keep this hole for something hot later.
Yeah this looks good! It's not "hot" anyway, so let it lay freestanding.
net/core/skbuff.c void *__netdev_alloc_frag_align(unsigned int · line 278
Quoted 12 lines
net/core/skbuff.c +0
-0100644
net/core/skbuff.c +1
-0@@ -274,6 +274,8 @@ void *__netdev_alloc_frag_align(unsigned int fragsz, unsigned int align_mask) }EXPORT_SYMBOL (__netdev_alloc_frag_align); +u32 skbuff_cache_size__read_mostly ;
...but probably static?
Quoted 34 lines
net/core/skbuff.c +1
-0+static struct sk_buff *napi_skb_cache_get (void ) {struct napi_alloc_cache *nc = this_cpu_ptr(&napi_alloc_cache);net/core/skbuff.c +1
-1@@ -293,7 +295,7 @@ static struct sk_buff *napi_skb_cache_get(void) skb = nc->skb_cache[--nc->skb_count];local_unlock_nested_bh (&napi_alloc_cache.bh_lock); -kasan_mempool_unpoison_object (skb, kmem_cache_size(net_hotdata.skbuff_cache)); +kasan_mempool_unpoison_object (skb, skbuff_cache_size);return skb;}
net/core/skbuff.c +1
-1@@ -1428,7 +1430,7 @@ static void napi_skb_cache_put(struct sk_buff *skb)if (unlikely (nc->skb_count ==NAPI_SKB_CACHE_SIZE )) {for (i =NAPI_SKB_CACHE_HALF ; i <NAPI_SKB_CACHE_SIZE ; i++)kasan_mempool_unpoison_object (nc->skb_cache[i], -kmem_cache_size (net_hotdata.skbuff_cache)); + skbuff_cache_size); kmem_cache_free_bulk(net_hotdata.skbuff_cache,
NAPI_SKB_CACHE_HALF,nc->skb_cache + NAPI_SKB_CACHE_HALF);net/core/skbuff.c +2
-0@@ -5116,6 +5118,8 @@ void __init skb_init(void) offsetof(struct sk_buff , cb), sizeof_field(struct sk_buff, cb), NULL); + skbuff_cache_size =kmem_cache_size (net_hotdata.skbuff_cache); + net_hotdata.skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache", sizeof(struct sk_buff_fclones),
Quoted 1 line
0,
Thanks,
Olek
Quoted 44 lines · Alexander Lobakin
From: Eric Dumazet <[email protected]>
Date: Thu, 16 Oct 2025 06:36:55 -0700Quoted 18 lines · Eric Dumazet
Quoted 17 lines · Eric Dumazet
Quoted 14 lines
Quoted 4 lines · Alexander Lobakin
From: Eric Dumazet <[email protected]>
BTW doesn't
napi_skb_cache_get()(inc.get_bulk()) suffer the same way?Probably, like other calls to napi_skb_cache_put(()
No loop there, so I guess there is no big deal.
I was looking at
napi_skb_cache_put()because there is a lack of NUMA awareness, and was curious to experiment with some strategies there.Quoted 8 lines
Quoted 5 lines
If we cache
kmem_cache_size()innet_hotdata, the compiler is able to eliminate dead code
forCONFIG_KASAN=nMaybe this looks better ?
No need to put this in
net_hotdata, I was distracted by a 4byte hole there, we can keep this hole for something hot later.Yeah this looks good! It's not "hot" anyway, so let it lay freestanding.
Quoted 11 lines
net/core/skbuff.c +0
-0100644
net/core/skbuff.c +0
-0@@ -274,6 +274,8 @@ void *__netdev_alloc_frag_align(unsigned int fragsz, unsigned int align_mask) }EXPORT_SYMBOL (__netdev_alloc_frag_align);
Quoted 3 lines
net/core/skbuff.c void *__netdev_alloc_frag_align(unsigned int · line 278
Quoted 1 line
net/core/skbuff.c +1
-0+u32 skbuff_cache_size__read_mostly ;...but probably
static?
Sure, I will add the static.
Quoted 39 lines
Quoted 35 lines
net/core/skbuff.c +1
-0+static struct sk_buff *napi_skb_cache_get (void ) {struct napi_alloc_cache *nc = this_cpu_ptr(&napi_alloc_cache);net/core/skbuff.c +1
-1@@ -293,7 +295,7 @@ static struct sk_buff *napi_skb_cache_get(void) skb = nc->skb_cache[--nc->skb_count];local_unlock_nested_bh (&napi_alloc_cache.bh_lock); -kasan_mempool_unpoison_object (skb, kmem_cache_size(net_hotdata.skbuff_cache)); +kasan_mempool_unpoison_object (skb, skbuff_cache_size);return skb;}
net/core/skbuff.c +1
-1@@ -1428,7 +1430,7 @@ static void napi_skb_cache_put(struct sk_buff *skb)if (unlikely (nc->skb_count ==NAPI_SKB_CACHE_SIZE )) {for (i =NAPI_SKB_CACHE_HALF ; i <NAPI_SKB_CACHE_SIZE ; i++)kasan_mempool_unpoison_object (nc->skb_cache[i], -kmem_cache_size (net_hotdata.skbuff_cache)); + skbuff_cache_size); kmem_cache_free_bulk(net_hotdata.skbuff_cache,
NAPI_SKB_CACHE_HALF,nc->skb_cache + NAPI_SKB_CACHE_HALF);net/core/skbuff.c +2
-0@@ -5116,6 +5118,8 @@ void __init skb_init(void) offsetof(struct sk_buff , cb), sizeof_field(struct sk_buff, cb), NULL); + skbuff_cache_size =kmem_cache_size (net_hotdata.skbuff_cache); + net_hotdata.skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache", sizeof(struct sk_buff_fclones),Quoted 1 line
0,Thanks,
Olek