summaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorLi RongQing <lirongqing@baidu.com>2021-09-22 14:17:19 +0800
committerDavid S. Miller <davem@davemloft.net>2021-09-22 14:20:01 +0100
commita5df6333f1a08380c3b94a02105482263711ed3a (patch)
treef8a15e88ea1d210d500d307f9a8fb9f743ec579e /net/core
parentdb4278c55fa53760893266538e86e638330b03bb (diff)
downloadlinux-a5df6333f1a08380c3b94a02105482263711ed3a.tar.gz
linux-a5df6333f1a08380c3b94a02105482263711ed3a.tar.bz2
linux-a5df6333f1a08380c3b94a02105482263711ed3a.zip
skbuff: pass the result of data ksize to __build_skb_around
Avoid to call ksize again in __build_skb_around by passing the result of data ksize to __build_skb_around nginx stress test shows this change can reduce ksize cpu usage, and give a little performance boost Signed-off-by: Li RongQing <lirongqing@baidu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/skbuff.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 7c2ab27fcbf9..74601bbc56ac 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -394,8 +394,9 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
{
struct kmem_cache *cache;
struct sk_buff *skb;
- u8 *data;
+ unsigned int osize;
bool pfmemalloc;
+ u8 *data;
cache = (flags & SKB_ALLOC_FCLONE)
? skbuff_fclone_cache : skbuff_head_cache;
@@ -427,7 +428,8 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
* Put skb_shared_info exactly at the end of allocated zone,
* to allow max possible filling before reallocation.
*/
- size = SKB_WITH_OVERHEAD(ksize(data));
+ osize = ksize(data);
+ size = SKB_WITH_OVERHEAD(osize);
prefetchw(data + size);
/*
@@ -436,7 +438,7 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
* the tail pointer in struct sk_buff!
*/
memset(skb, 0, offsetof(struct sk_buff, tail));
- __build_skb_around(skb, data, 0);
+ __build_skb_around(skb, data, osize);
skb->pfmemalloc = pfmemalloc;
if (flags & SKB_ALLOC_FCLONE) {