aboutsummaryrefslogtreecommitdiff
path: root/net/core
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2026-03-10 12:44:51 +0000
committerPaolo Abeni <pabeni@redhat.com>2026-03-12 13:22:03 +0100
commit6f459eda8b60382efa0da2ca025c26a2018adc87 (patch)
tree7b41e552f198f061413c3a28fe33b4d80bdac215 /net/core
parent4320f1f111c587b8c6c9abc06f43e25bc10b670c (diff)
tcp: add tcp_release_cb_cond() helper
Majority of tcp_release_cb() calls do nothing at all. Provide tcp_release_cb_cond() helper so that release_sock() can avoid these calls. Also hint the compiler that __release_sock() and wake_up() are rarely called. $ scripts/bloat-o-meter -t vmlinux.old vmlinux.new add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-77 (-77) Function old new delta release_sock 258 181 -77 Total: Before=25235790, After=25235713, chg -0.00% Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com> Link: https://patch.msgid.link/20260310124451.2280968-1-edumazet@google.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/sock.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/net/core/sock.c b/net/core/sock.c
index f4e2ff23d60e..fdaf66e6dc18 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -3807,16 +3807,18 @@ EXPORT_SYMBOL(lock_sock_nested);
void release_sock(struct sock *sk)
{
spin_lock_bh(&sk->sk_lock.slock);
- if (sk->sk_backlog.tail)
- __release_sock(sk);
- if (sk->sk_prot->release_cb)
- INDIRECT_CALL_INET_1(sk->sk_prot->release_cb,
- tcp_release_cb, sk);
+ if (unlikely(sk->sk_backlog.tail))
+ __release_sock(sk);
+ if (sk->sk_prot->release_cb) {
+ if (!tcp_release_cb_cond(sk))
+ sk->sk_prot->release_cb(sk);
+ }
sock_release_ownership(sk);
- if (waitqueue_active(&sk->sk_lock.wq))
+ if (unlikely(waitqueue_active(&sk->sk_lock.wq)))
wake_up(&sk->sk_lock.wq);
+
spin_unlock_bh(&sk->sk_lock.slock);
}
EXPORT_SYMBOL(release_sock);