net: save some cycles when doing skb_attempt_defer_free()
Subsystems (2)
PATCH v2 1/1 net: save some cycles when doing skb_attempt_defer_free()
From: Jason Xing <[email protected]>
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.
---
v2
1. Fix the wrong order of testing cpu (Eric)
--- net/core/skbuff.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/core/skbuff.c +3 -3
@@ -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) || - !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 ; }
Signature · 1 line
2.37.3
This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Quoted 6 lines · On Fri, 12 Apr 2024 11:07:18 +0800 you wrote:
From: Jason Xing <[email protected]>
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.
Quoted 6 lines
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 captureskb_attempt_defer_free()[...]
Here is the summary with links:
- [net-next,v2] net: save some cycles when doing skb_attempt_defer_free()
https://git.kernel.org/netdev/net-next/c/4d0470b9ad73
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html