]> git.ipfire.org Git - thirdparty/linux.git/commit
net: avoid extra access to sk->sk_wmem_alloc in sock_wfree()
authorEric Dumazet <edumazet@google.com>
Fri, 17 Oct 2025 13:37:12 +0000 (13:37 +0000)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 21 Oct 2025 13:56:21 +0000 (15:56 +0200)
commit3ff9bcecce83f12169ab3e42671bd76554ca521a
treedb362844461ecef320cd31a69cd3121b533c8618
parentd1d7998df9d7d3ee20bcfc876065fa897b11506d
net: avoid extra access to sk->sk_wmem_alloc in sock_wfree()

UDP TX packets destructor is sock_wfree().

It suffers from a cache line bouncing in sock_def_write_space_wfree().

Instead of reading sk->sk_wmem_alloc after we just did an atomic RMW
on it, use __refcount_sub_and_test() to get the old value for free,
and pass the new value to sock_def_write_space_wfree().

Add __sock_writeable() helper.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20251017133712.2842665-1-edumazet@google.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
include/net/sock.h
net/core/sock.c