Skip to content

Commit 22d046a

Browse files
edumazetkuba-moo
authored andcommitted
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 <[email protected]> Reviewed-by: Willem de Bruijn <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 7b6f0a8 commit 22d046a

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

net/core/dev.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4953,7 +4953,8 @@ static void rps_trigger_softirq(void *data)
49534953
struct softnet_data *sd = data;
49544954

49554955
____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);
49574958
}
49584959

49594960
#endif /* CONFIG_RPS */
@@ -7523,7 +7524,8 @@ static __latent_entropy void net_rx_action(void)
75237524
*/
75247525
if (unlikely(budget <= 0 ||
75257526
time_after_eq(jiffies, time_limit))) {
7526-
sd->time_squeeze++;
7527+
/* Pairs with READ_ONCE() in softnet_seq_show() */
7528+
WRITE_ONCE(sd->time_squeeze, sd->time_squeeze + 1);
75277529
break;
75287530
}
75297531
}

net/core/net-procfs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ static int softnet_seq_show(struct seq_file *seq, void *v)
145145
seq_printf(seq,
146146
"%08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x "
147147
"%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,
150150
0, 0, 0, 0, /* was fastroute */
151151
0, /* was cpu_collision */
152-
sd->received_rps, flow_limit_count,
152+
READ_ONCE(sd->received_rps), flow_limit_count,
153153
input_qlen + process_qlen, (int)seq->index,
154154
input_qlen, process_qlen);
155155
return 0;

0 commit comments

Comments
 (0)