Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: add skb_defer_disable_key static key

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>
Link: https://patch.msgid.link/20260311191340.1996888-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
08dc30de 15abbe7c

+30 -1
+1
net/core/net-sysfs.h
··· 13 13 14 14 extern struct mutex rps_default_mask_mutex; 15 15 16 + DECLARE_STATIC_KEY_FALSE(skb_defer_disable_key); 16 17 #endif
+5
net/core/skbuff.c
··· 7256 7256 local_bh_enable(); 7257 7257 } 7258 7258 7259 + DEFINE_STATIC_KEY_FALSE(skb_defer_disable_key); 7260 + 7259 7261 /** 7260 7262 * skb_attempt_defer_free - queue skb for remote freeing 7261 7263 * @skb: buffer ··· 7273 7271 unsigned int defer_max; 7274 7272 bool kick; 7275 7273 int cpu; 7274 + 7275 + if (static_branch_unlikely(&skb_defer_disable_key)) 7276 + goto nodefer; 7276 7277 7277 7278 /* zero copy notifications should not be delayed. */ 7278 7279 if (skb_zcopy(skb))
+24 -1
net/core/sysctl_net_core.c
··· 349 349 return proc_dostring(&fake_table, write, buffer, lenp, ppos); 350 350 } 351 351 352 + static int proc_do_skb_defer_max(const struct ctl_table *table, int write, 353 + void *buffer, size_t *lenp, loff_t *ppos) 354 + { 355 + static DEFINE_MUTEX(skb_defer_max_mutex); 356 + int ret, oval, nval; 357 + 358 + mutex_lock(&skb_defer_max_mutex); 359 + 360 + oval = !net_hotdata.sysctl_skb_defer_max; 361 + ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); 362 + nval = !net_hotdata.sysctl_skb_defer_max; 363 + 364 + if (nval != oval) { 365 + if (nval) 366 + static_branch_enable(&skb_defer_disable_key); 367 + else 368 + static_branch_disable(&skb_defer_disable_key); 369 + } 370 + 371 + mutex_unlock(&skb_defer_max_mutex); 372 + return ret; 373 + } 374 + 352 375 #ifdef CONFIG_BPF_JIT 353 376 static int proc_dointvec_minmax_bpf_enable(const struct ctl_table *table, int write, 354 377 void *buffer, size_t *lenp, ··· 673 650 .data = &net_hotdata.sysctl_skb_defer_max, 674 651 .maxlen = sizeof(unsigned int), 675 652 .mode = 0644, 676 - .proc_handler = proc_dointvec_minmax, 653 + .proc_handler = proc_do_skb_defer_max, 677 654 .extra1 = SYSCTL_ZERO, 678 655 }, 679 656 };