public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 net-next] net: advance skb_defer_disable_key check in napi_consume_skb
@ 2026-04-02  3:41 Jason Xing
  0 siblings, 0 replies; only message in thread
From: Jason Xing @ 2026-04-02  3:41 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, horms; +Cc: netdev, Jason Xing

From: Jason Xing <kernelxing@tencent.com>

When net.core.skb_defer_max is adjusted to zero, napi_consume_skb()
shouldn't go into that deeper in skb_attempt_defer_free() because it adds
an additional pair of local_bh_enable/disable() which is evidently not
needed. Advancing the check of the static key saves more cycles and
benefits non defer case.

Signed-off-by: Jason Xing <kernelxing@tencent.com>
---
v4
Link: https://lore.kernel.org/all/20260401033211.44463-1-kerneljasonxing@gmail.com/
1. add the missing header file.
Since a new sysctl might not be preferrable, I deicded to apply the
current minimum patch to handle it. If in the future we receive some
reports about this point, we will then consider it one more time.

v3
Link: https://lore.kernel.org/all/20260327153347.98647-1-kerneljasonxing@gmail.com/
1. use a simpler approach to avoid adding a new sysctl. This is the
   minimum change to improvement defer_max 0 case.

V2
Link: https://lore.kernel.org/all/20260326144249.97213-1-kerneljasonxing@gmail.com/
1. reuse proc_do_static_key() (Eric)
2. add doc (Stan)
---
 net/core/skbuff.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 3d6978dd0aa8..4045d7c484a1 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -94,6 +94,7 @@
 
 #include "dev.h"
 #include "devmem.h"
+#include "net-sysfs.h"
 #include "netmem_priv.h"
 #include "sock_destructor.h"
 
@@ -1519,7 +1520,8 @@ void napi_consume_skb(struct sk_buff *skb, int budget)
 
 	DEBUG_NET_WARN_ON_ONCE(!in_softirq());
 
-	if (skb->alloc_cpu != smp_processor_id() && !skb_shared(skb)) {
+	if (!static_branch_unlikely(&skb_defer_disable_key) &&
+	    skb->alloc_cpu != smp_processor_id() && !skb_shared(skb)) {
 		skb_release_head_state(skb);
 		return skb_attempt_defer_free(skb);
 	}
-- 
2.41.3


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-04-02  3:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-02  3:41 [PATCH v4 net-next] net: advance skb_defer_disable_key check in napi_consume_skb Jason Xing

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox