]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
udp: add drop_counters to udp socket
authorEric Dumazet <edumazet@google.com>
Tue, 26 Aug 2025 12:50:30 +0000 (12:50 +0000)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 28 Aug 2025 11:14:50 +0000 (13:14 +0200)
commit51132b99f01ce05f8008f0fb189d83eed484bd53
tree2ddab074a2cd83582c5e95e1007e11a98d6e7322
parentc51613fa276f038bdd18656a57a90ccc5d4e5200
udp: add drop_counters to udp socket

When a packet flood hits one or more UDP sockets, many cpus
have to update sk->sk_drops.

This slows down other cpus, because currently
sk_drops is in sock_write_rx group.

Add a socket_drop_counters structure to udp sockets.

Using dedicated cache lines to hold drop counters
makes sure that consumers no longer suffer from
false sharing if/when producers only change sk->sk_drops.

This adds 128 bytes per UDP socket.

Tested with the following stress test, sending about 11 Mpps
to a dual socket AMD EPYC 7B13 64-Core.

super_netperf 20 -t UDP_STREAM -H DUT -l10 -- -n -P,1000 -m 120
Note: due to socket lookup, only one UDP socket is receiving
packets on DUT.

Then measure receiver (DUT) behavior. We can see both
consumer and BH handlers can process more packets per second.

Before:

nstat -n ; sleep 1 ; nstat | grep Udp
Udp6InDatagrams                 615091             0.0
Udp6InErrors                    3904277            0.0
Udp6RcvbufErrors                3904277            0.0

After:

nstat -n ; sleep 1 ; nstat | grep Udp
Udp6InDatagrams                 816281             0.0
Udp6InErrors                    7497093            0.0
Udp6RcvbufErrors                7497093            0.0

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20250826125031.1578842-5-edumazet@google.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
include/linux/udp.h
include/net/udp.h
tools/testing/selftests/bpf/progs/bpf_iter_udp4.c
tools/testing/selftests/bpf/progs/bpf_iter_udp6.c