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.

Merge branch 'tcp-annotate-data-races-around-icsk_retransmits-and-icsk_probes_out'

Eric Dumazet says:

====================
tcp: annotate data-races around icsk_retransmits and icsk_probes_out

icsk->icsk_retransmits is read locklessly from inet_sk_diag_fill(),
tcp_get_timestamping_opt_stats, get_tcp4_sock() and get_tcp6_sock().

icsk->icsk_probes_out is read locklessly from inet_sk_diag_fill(),
get_tcp4_sock() and get_tcp6_sock().

Add corresponding READ_ONCE()/WRITE_ONCE() annotations.
====================

Link: https://patch.msgid.link/20250822091727.835869-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+22 -20
+3 -3
net/ipv4/inet_diag.c
··· 313 313 icsk_pending == ICSK_TIME_REO_TIMEOUT || 314 314 icsk_pending == ICSK_TIME_LOSS_PROBE) { 315 315 r->idiag_timer = 1; 316 - r->idiag_retrans = icsk->icsk_retransmits; 316 + r->idiag_retrans = READ_ONCE(icsk->icsk_retransmits); 317 317 r->idiag_expires = 318 318 jiffies_delta_to_msecs(icsk_timeout(icsk) - jiffies); 319 319 } else if (icsk_pending == ICSK_TIME_PROBE0) { 320 320 r->idiag_timer = 4; 321 - r->idiag_retrans = icsk->icsk_probes_out; 321 + r->idiag_retrans = READ_ONCE(icsk->icsk_probes_out); 322 322 r->idiag_expires = 323 323 jiffies_delta_to_msecs(icsk_timeout(icsk) - jiffies); 324 324 } else if (timer_pending(&sk->sk_timer)) { 325 325 r->idiag_timer = 2; 326 - r->idiag_retrans = icsk->icsk_probes_out; 326 + r->idiag_retrans = READ_ONCE(icsk->icsk_probes_out); 327 327 r->idiag_expires = 328 328 jiffies_delta_to_msecs(sk->sk_timer.expires - jiffies); 329 329 }
+3 -2
net/ipv4/tcp.c
··· 3376 3376 WRITE_ONCE(tp->write_seq, seq); 3377 3377 3378 3378 icsk->icsk_backoff = 0; 3379 - icsk->icsk_probes_out = 0; 3379 + WRITE_ONCE(icsk->icsk_probes_out, 0); 3380 3380 icsk->icsk_probes_tstamp = 0; 3381 3381 icsk->icsk_rto = TCP_TIMEOUT_INIT; 3382 3382 WRITE_ONCE(icsk->icsk_rto_min, TCP_RTO_MIN); ··· 4346 4346 nla_put_u32(stats, TCP_NLA_REORDERING, tp->reordering); 4347 4347 nla_put_u32(stats, TCP_NLA_MIN_RTT, tcp_min_rtt(tp)); 4348 4348 4349 - nla_put_u8(stats, TCP_NLA_RECUR_RETRANS, inet_csk(sk)->icsk_retransmits); 4349 + nla_put_u8(stats, TCP_NLA_RECUR_RETRANS, 4350 + READ_ONCE(inet_csk(sk)->icsk_retransmits)); 4350 4351 nla_put_u8(stats, TCP_NLA_DELIVERY_RATE_APP_LMT, !!tp->rate_app_limited); 4351 4352 nla_put_u32(stats, TCP_NLA_SND_SSTHRESH, tp->snd_ssthresh); 4352 4353 nla_put_u32(stats, TCP_NLA_DELIVERED, tp->delivered);
+4 -4
net/ipv4/tcp_input.c
··· 2569 2569 if (frto_undo) 2570 2570 NET_INC_STATS(sock_net(sk), 2571 2571 LINUX_MIB_TCPSPURIOUSRTOS); 2572 - inet_csk(sk)->icsk_retransmits = 0; 2572 + WRITE_ONCE(inet_csk(sk)->icsk_retransmits, 0); 2573 2573 if (tcp_is_non_sack_preventing_reopen(sk)) 2574 2574 return true; 2575 2575 if (frto_undo || tcp_is_sack(tp)) { ··· 3851 3851 3852 3852 if (after(ack, prior_snd_una)) { 3853 3853 flag |= FLAG_SND_UNA_ADVANCED; 3854 - icsk->icsk_retransmits = 0; 3854 + WRITE_ONCE(icsk->icsk_retransmits, 0); 3855 3855 3856 3856 #if IS_ENABLED(CONFIG_TLS_DEVICE) 3857 3857 if (static_branch_unlikely(&clean_acked_data_enabled.key)) ··· 3913 3913 * log. Something worked... 3914 3914 */ 3915 3915 WRITE_ONCE(sk->sk_err_soft, 0); 3916 - icsk->icsk_probes_out = 0; 3916 + WRITE_ONCE(icsk->icsk_probes_out, 0); 3917 3917 tp->rcv_tstamp = tcp_jiffies32; 3918 3918 if (!prior_packets) 3919 3919 goto no_queue; ··· 6636 6636 tcp_try_undo_recovery(sk); 6637 6637 6638 6638 tcp_update_rto_time(tp); 6639 - inet_csk(sk)->icsk_retransmits = 0; 6639 + WRITE_ONCE(inet_csk(sk)->icsk_retransmits, 0); 6640 6640 /* In tcp_fastopen_synack_timer() on the first SYNACK RTO we set 6641 6641 * retrans_stamp but don't enter CA_Loss, so in case that happened we 6642 6642 * need to zero retrans_stamp here to prevent spurious
+2 -2
net/ipv4/tcp_ipv4.c
··· 2958 2958 rx_queue, 2959 2959 timer_active, 2960 2960 jiffies_delta_to_clock_t(timer_expires - jiffies), 2961 - icsk->icsk_retransmits, 2961 + READ_ONCE(icsk->icsk_retransmits), 2962 2962 from_kuid_munged(seq_user_ns(f), sk_uid(sk)), 2963 - icsk->icsk_probes_out, 2963 + READ_ONCE(icsk->icsk_probes_out), 2964 2964 sock_i_ino(sk), 2965 2965 refcount_read(&sk->sk_refcnt), sk, 2966 2966 jiffies_to_clock_t(icsk->icsk_rto),
+3 -3
net/ipv4/tcp_output.c
··· 3956 3956 WRITE_ONCE(tp->copied_seq, tp->rcv_nxt); 3957 3957 3958 3958 inet_csk(sk)->icsk_rto = tcp_timeout_init(sk); 3959 - inet_csk(sk)->icsk_retransmits = 0; 3959 + WRITE_ONCE(inet_csk(sk)->icsk_retransmits, 0); 3960 3960 tcp_clear_retrans(tp); 3961 3961 } 3962 3962 ··· 4394 4394 4395 4395 if (tp->packets_out || tcp_write_queue_empty(sk)) { 4396 4396 /* Cancel probe timer, if it is not required. */ 4397 - icsk->icsk_probes_out = 0; 4397 + WRITE_ONCE(icsk->icsk_probes_out, 0); 4398 4398 icsk->icsk_backoff = 0; 4399 4399 icsk->icsk_probes_tstamp = 0; 4400 4400 return; 4401 4401 } 4402 4402 4403 - icsk->icsk_probes_out++; 4403 + WRITE_ONCE(icsk->icsk_probes_out, icsk->icsk_probes_out + 1); 4404 4404 if (err <= 0) { 4405 4405 if (icsk->icsk_backoff < READ_ONCE(net->ipv4.sysctl_tcp_retries2)) 4406 4406 icsk->icsk_backoff++;
+3 -3
net/ipv4/tcp_timer.c
··· 392 392 int max_probes; 393 393 394 394 if (tp->packets_out || !skb) { 395 - icsk->icsk_probes_out = 0; 395 + WRITE_ONCE(icsk->icsk_probes_out, 0); 396 396 icsk->icsk_probes_tstamp = 0; 397 397 return; 398 398 } ··· 444 444 tp->total_rto_recoveries++; 445 445 tp->rto_stamp = tcp_time_stamp_ms(tp); 446 446 } 447 - icsk->icsk_retransmits++; 447 + WRITE_ONCE(icsk->icsk_retransmits, icsk->icsk_retransmits + 1); 448 448 tp->total_rto++; 449 449 } 450 450 ··· 839 839 goto out; 840 840 } 841 841 if (tcp_write_wakeup(sk, LINUX_MIB_TCPKEEPALIVE) <= 0) { 842 - icsk->icsk_probes_out++; 842 + WRITE_ONCE(icsk->icsk_probes_out, icsk->icsk_probes_out + 1); 843 843 elapsed = keepalive_intvl_when(tp); 844 844 } else { 845 845 /* If keepalive was lost due to local congestion,
+2 -2
net/ipv6/tcp_ipv6.c
··· 2230 2230 rx_queue, 2231 2231 timer_active, 2232 2232 jiffies_delta_to_clock_t(timer_expires - jiffies), 2233 - icsk->icsk_retransmits, 2233 + READ_ONCE(icsk->icsk_retransmits), 2234 2234 from_kuid_munged(seq_user_ns(seq), sk_uid(sp)), 2235 - icsk->icsk_probes_out, 2235 + READ_ONCE(icsk->icsk_probes_out), 2236 2236 sock_i_ino(sp), 2237 2237 refcount_read(&sp->sk_refcnt), sp, 2238 2238 jiffies_to_clock_t(icsk->icsk_rto),
+2 -1
net/mptcp/protocol.c
··· 2587 2587 if (mptcp_data_fin_enabled(msk)) { 2588 2588 struct inet_connection_sock *icsk = inet_csk(sk); 2589 2589 2590 - icsk->icsk_retransmits++; 2590 + WRITE_ONCE(icsk->icsk_retransmits, 2591 + icsk->icsk_retransmits + 1); 2591 2592 mptcp_set_datafin_timeout(sk); 2592 2593 mptcp_send_ack(msk); 2593 2594