summaryrefslogtreecommitdiff
path: root/net/core
diff options
context:
space:
mode:
authorJason Xing <kernelxing@tencent.com>2024-04-12 06:07:18 +0300
committerDavid S. Miller <davem@davemloft.net>2024-04-15 12:34:59 +0300
commit4d0470b9ad73e965f5a1e52f1deb0edbb6d03c89 (patch)
tree568b10f31df6dc8bba09d9ad235b4e43136bc825 /net/core
parent71329c491888c9309af41fafb5129a48843ffa09 (diff)
downloadlinux-4d0470b9ad73e965f5a1e52f1deb0edbb6d03c89.tar.xz
net: save some cycles when doing skb_attempt_defer_free()
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> Reviewed-by: Alexander Lobakin <aleksander.lobakin@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/skbuff.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index ea052fa710d8..37c858dc11a6 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -6965,9 +6965,9 @@ void skb_attempt_defer_free(struct sk_buff *skb)
unsigned int defer_max;
bool kick;
- if (WARN_ON_ONCE(cpu >= nr_cpu_ids) ||
- !cpu_online(cpu) ||
- cpu == raw_smp_processor_id()) {
+ if (cpu == raw_smp_processor_id() ||
+ WARN_ON_ONCE(cpu >= nr_cpu_ids) ||
+ !cpu_online(cpu)) {
nodefer: kfree_skb_napi_cache(skb);
return;
}