Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: add data-race annotations in softnet_seq_show()

softnet_seq_show() reads several fields that might be updated
concurrently. Add READ_ONCE() and WRITE_ONCE() annotations.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20250407163602.170356-4-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
22d046a7 7b6f0a85

+7 -5
+4 -2
net/core/dev.c
··· 4953 4953 struct softnet_data *sd = data; 4954 4954 4955 4955 ____napi_schedule(sd, &sd->backlog); 4956 - sd->received_rps++; 4956 + /* Pairs with READ_ONCE() in softnet_seq_show() */ 4957 + WRITE_ONCE(sd->received_rps, sd->received_rps + 1); 4957 4958 } 4958 4959 4959 4960 #endif /* CONFIG_RPS */ ··· 7524 7523 */ 7525 7524 if (unlikely(budget <= 0 || 7526 7525 time_after_eq(jiffies, time_limit))) { 7527 - sd->time_squeeze++; 7526 + /* Pairs with READ_ONCE() in softnet_seq_show() */ 7527 + WRITE_ONCE(sd->time_squeeze, sd->time_squeeze + 1); 7528 7528 break; 7529 7529 } 7530 7530 }
+3 -3
net/core/net-procfs.c
··· 145 145 seq_printf(seq, 146 146 "%08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x " 147 147 "%08x %08x\n", 148 - sd->processed, atomic_read(&sd->dropped), 149 - sd->time_squeeze, 0, 148 + READ_ONCE(sd->processed), atomic_read(&sd->dropped), 149 + READ_ONCE(sd->time_squeeze), 0, 150 150 0, 0, 0, 0, /* was fastroute */ 151 151 0, /* was cpu_collision */ 152 - sd->received_rps, flow_limit_count, 152 + READ_ONCE(sd->received_rps), flow_limit_count, 153 153 input_qlen + process_qlen, (int)seq->index, 154 154 input_qlen, process_qlen); 155 155 return 0;