From: Jason Xing <kerneljasonxing@gmail.com>
To: edumazet@google.com, pablo@netfilter.org, kuba@kernel.org,
pabeni@redhat.com, davem@davemloft.net, horms@kernel.org,
aleksander.lobakin@intel.com
Cc: netdev@vger.kernel.org, kerneljasonxing@gmail.com,
Jason Xing <kernelxing@tencent.com>
Subject: [PATCH net-next] net: save some cycles when doing skb_attempt_defer_free()
Date: Thu, 11 Apr 2024 11:24:50 +0800 [thread overview]
Message-ID: <20240411032450.51649-1-kerneljasonxing@gmail.com> (raw)
From: Jason Xing <kernelxing@tencent.com>
Normally, we don't face these two exceptions very often meanwhile
we have some chance to meet the condition where the current cpu id
is the same as skb->alloc_cpu.
One simple test that can help us see the frequency of this statement
'cpu == raw_smp_processor_id()':
1. running iperf -s and iperf -c [ip] -P [MAX CPU]
2. using BPF to capture skb_attempt_defer_free()
I can see around 4% chance that happens to satisfy the statement.
So moving this statement at the beginning can save some cycles in
most cases.
Signed-off-by: Jason Xing <kernelxing@tencent.com>
---
net/core/skbuff.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index ab970ded8a7b..b4f252dc91fb 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -7002,9 +7002,9 @@ void skb_attempt_defer_free(struct sk_buff *skb)
unsigned int defer_max;
bool kick;
- if (WARN_ON_ONCE(cpu >= nr_cpu_ids) ||
+ if (cpu == raw_smp_processor_id() ||
!cpu_online(cpu) ||
- cpu == raw_smp_processor_id()) {
+ WARN_ON_ONCE(cpu >= nr_cpu_ids)) {
nodefer: kfree_skb_napi_cache(skb);
return;
}
--
2.37.3
next reply other threads:[~2024-04-11 3:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-11 3:24 Jason Xing [this message]
2024-04-11 5:27 ` [PATCH net-next] net: save some cycles when doing skb_attempt_defer_free() Eric Dumazet
2024-04-11 6:32 ` Jason Xing
2024-04-11 7:11 ` Eric Dumazet
2024-04-11 7:31 ` Jason Xing
2024-04-11 9:11 ` Alexander Lobakin
2024-04-11 10:00 ` Jason Xing
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240411032450.51649-1-kerneljasonxing@gmail.com \
--to=kerneljasonxing@gmail.com \
--cc=aleksander.lobakin@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kernelxing@tencent.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.