public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: add skb_defer_disable_key static key
@ 2026-03-11 19:13 Eric Dumazet
  2026-03-13  2:50 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2026-03-11 19:13 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: Simon Horman, netdev, eric.dumazet, Eric Dumazet

Add a static key to bypass skb_attempt_defer_free() steps
if net.core.skb_defer_max is set to zero.

Main benefit is the atomic_long_inc_return() avoidance.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/core/net-sysfs.h       |  1 +
 net/core/skbuff.c          |  5 +++++
 net/core/sysctl_net_core.c | 25 ++++++++++++++++++++++++-
 3 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/net/core/net-sysfs.h b/net/core/net-sysfs.h
index e938f25e8e86f9dfd8f710a08922c4cabf662c2e..38e2e3ffd0bdc4ccea2f6c7636c1bbc7d0f46af5 100644
--- a/net/core/net-sysfs.h
+++ b/net/core/net-sysfs.h
@@ -13,4 +13,5 @@ int netdev_change_owner(struct net_device *, const struct net *net_old,
 
 extern struct mutex rps_default_mask_mutex;
 
+DECLARE_STATIC_KEY_FALSE(skb_defer_disable_key);
 #endif
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 513cbfed19bc34bbb6767cdd7a50dad68be430fb..3d6978dd0aa83f63984b994359d0c914c6427a00 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -7256,6 +7256,8 @@ static void kfree_skb_napi_cache(struct sk_buff *skb)
 	local_bh_enable();
 }
 
+DEFINE_STATIC_KEY_FALSE(skb_defer_disable_key);
+
 /**
  * skb_attempt_defer_free - queue skb for remote freeing
  * @skb: buffer
@@ -7272,6 +7274,9 @@ void skb_attempt_defer_free(struct sk_buff *skb)
 	bool kick;
 	int cpu;
 
+	if (static_branch_unlikely(&skb_defer_disable_key))
+		goto nodefer;
+
 	/* zero copy notifications should not be delayed. */
 	if (skb_zcopy(skb))
 		goto nodefer;
diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index 502705e0464981ecfc32233d22c747e14b3febf7..b508618bfc12393ba926ebf5a2dd4ea73ef03ee8 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -349,6 +349,29 @@ static int proc_do_rss_key(const struct ctl_table *table, int write,
 	return proc_dostring(&fake_table, write, buffer, lenp, ppos);
 }
 
+static int proc_do_skb_defer_max(const struct ctl_table *table, int write,
+		 void *buffer, size_t *lenp, loff_t *ppos)
+{
+	static DEFINE_MUTEX(skb_defer_max_mutex);
+	int ret, oval, nval;
+
+	mutex_lock(&skb_defer_max_mutex);
+
+	oval = !net_hotdata.sysctl_skb_defer_max;
+	ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
+	nval = !net_hotdata.sysctl_skb_defer_max;
+
+	if (nval != oval) {
+		if (nval)
+			static_branch_enable(&skb_defer_disable_key);
+		else
+			static_branch_disable(&skb_defer_disable_key);
+	}
+
+	mutex_unlock(&skb_defer_max_mutex);
+	return ret;
+}
+
 #ifdef CONFIG_BPF_JIT
 static int proc_dointvec_minmax_bpf_enable(const struct ctl_table *table, int write,
 					   void *buffer, size_t *lenp,
@@ -650,7 +673,7 @@ static struct ctl_table net_core_table[] = {
 		.data		= &net_hotdata.sysctl_skb_defer_max,
 		.maxlen		= sizeof(unsigned int),
 		.mode		= 0644,
-		.proc_handler	= proc_dointvec_minmax,
+		.proc_handler	= proc_do_skb_defer_max,
 		.extra1		= SYSCTL_ZERO,
 	},
 };
-- 
2.53.0.473.g4a7958ca14-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] net: add skb_defer_disable_key static key
  2026-03-11 19:13 [PATCH net-next] net: add skb_defer_disable_key static key Eric Dumazet
@ 2026-03-13  2:50 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-03-13  2:50 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: davem, kuba, pabeni, horms, netdev, eric.dumazet

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 11 Mar 2026 19:13:40 +0000 you wrote:
> Add a static key to bypass skb_attempt_defer_free() steps
> if net.core.skb_defer_max is set to zero.
> 
> Main benefit is the atomic_long_inc_return() avoidance.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> 
> [...]

Here is the summary with links:
  - [net-next] net: add skb_defer_disable_key static key
    https://git.kernel.org/netdev/net-next/c/08dc30de1a40

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-13  2:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-11 19:13 [PATCH net-next] net: add skb_defer_disable_key static key Eric Dumazet
2026-03-13  2:50 ` patchwork-bot+netdevbpf

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