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: make softnet_data.defer_count an atomic

This is preparation work to remove the softnet_data.defer_lock,
as it is contended on hosts with large number of cores.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Jason Xing <kerneljasonxing@gmail.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20250928084934.3266948-2-edumazet@google.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Eric Dumazet and committed by
Paolo Abeni
9c94ae6b 2c0592bd

+4 -6
+1 -1
include/linux/netdevice.h
··· 3538 3538 3539 3539 /* Another possibly contended cache line */ 3540 3540 spinlock_t defer_lock ____cacheline_aligned_in_smp; 3541 - int defer_count; 3541 + atomic_t defer_count; 3542 3542 int defer_ipi_scheduled; 3543 3543 struct sk_buff *defer_list; 3544 3544 call_single_data_t defer_csd;
+1 -1
net/core/dev.c
··· 6726 6726 spin_lock(&sd->defer_lock); 6727 6727 skb = sd->defer_list; 6728 6728 sd->defer_list = NULL; 6729 - sd->defer_count = 0; 6729 + atomic_set(&sd->defer_count, 0); 6730 6730 spin_unlock(&sd->defer_lock); 6731 6731 6732 6732 while (skb != NULL) {
+2 -4
net/core/skbuff.c
··· 7202 7202 7203 7203 sd = &per_cpu(softnet_data, cpu); 7204 7204 defer_max = READ_ONCE(net_hotdata.sysctl_skb_defer_max); 7205 - if (READ_ONCE(sd->defer_count) >= defer_max) 7205 + if (atomic_read(&sd->defer_count) >= defer_max) 7206 7206 goto nodefer; 7207 7207 7208 7208 spin_lock_bh(&sd->defer_lock); 7209 7209 /* Send an IPI every time queue reaches half capacity. */ 7210 - kick = sd->defer_count == (defer_max >> 1); 7211 - /* Paired with the READ_ONCE() few lines above */ 7212 - WRITE_ONCE(sd->defer_count, sd->defer_count + 1); 7210 + kick = (atomic_inc_return(&sd->defer_count) - 1) == (defer_max >> 1); 7213 7211 7214 7212 skb->next = sd->defer_list; 7215 7213 /* Paired with READ_ONCE() in skb_defer_free_flush() */