Commit 4d0470b9 authored by Jason Xing's avatar Jason Xing Committed by David S. Miller

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: default avatarJason Xing <kernelxing@tencent.com>
Reviewed-by: default avatarAlexander Lobakin <aleksander.lobakin@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 71329c49
...@@ -6965,9 +6965,9 @@ void skb_attempt_defer_free(struct sk_buff *skb) ...@@ -6965,9 +6965,9 @@ void skb_attempt_defer_free(struct sk_buff *skb)
unsigned int defer_max; unsigned int defer_max;
bool kick; bool kick;
if (WARN_ON_ONCE(cpu >= nr_cpu_ids) || if (cpu == raw_smp_processor_id() ||
!cpu_online(cpu) || WARN_ON_ONCE(cpu >= nr_cpu_ids) ||
cpu == raw_smp_processor_id()) { !cpu_online(cpu)) {
nodefer: kfree_skb_napi_cache(skb); nodefer: kfree_skb_napi_cache(skb);
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment