Skip to content

Commit fac3073

Browse files
edumazetkuba-moo
authored andcommitted
tcp: adopt try_cmpxchg() in tcp_release_cb()
try_cmpxchg() is slighly more efficient (at least on x86), and smp_load_acquire(&sk->sk_tsq_flags) could avoid a KCSAN report. Signed-off-by: Eric Dumazet <edumazet@google.com> Link: https://lore.kernel.org/r/20221110174829.3403442-1-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 3e35f26 commit fac3073

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

net/ipv4/tcp_output.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,15 +1077,15 @@ static void tcp_tasklet_func(struct tasklet_struct *t)
10771077
*/
10781078
void tcp_release_cb(struct sock *sk)
10791079
{
1080-
unsigned long flags, nflags;
1080+
unsigned long flags = smp_load_acquire(&sk->sk_tsq_flags);
1081+
unsigned long nflags;
10811082

10821083
/* perform an atomic operation only if at least one flag is set */
10831084
do {
1084-
flags = sk->sk_tsq_flags;
10851085
if (!(flags & TCP_DEFERRED_ALL))
10861086
return;
10871087
nflags = flags & ~TCP_DEFERRED_ALL;
1088-
} while (cmpxchg(&sk->sk_tsq_flags, flags, nflags) != flags);
1088+
} while (!try_cmpxchg(&sk->sk_tsq_flags, &flags, nflags));
10891089

10901090
if (flags & TCPF_TSQ_DEFERRED) {
10911091
tcp_tsq_write(sk);

0 commit comments

Comments
 (0)