Commit 22d046a7 authored by Eric Dumazet's avatar Eric Dumazet Committed by Jakub Kicinski
Browse files

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: default avatarEric Dumazet <edumazet@google.com>
Reviewed-by: default avatarWillem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20250407163602.170356-4-edumazet@google.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 7b6f0a85
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -4953,7 +4953,8 @@ static void rps_trigger_softirq(void *data)
	struct softnet_data *sd = data;

	____napi_schedule(sd, &sd->backlog);
	sd->received_rps++;
	/* Pairs with READ_ONCE() in softnet_seq_show() */
	WRITE_ONCE(sd->received_rps, sd->received_rps + 1);
}

#endif /* CONFIG_RPS */
@@ -7523,7 +7524,8 @@ static __latent_entropy void net_rx_action(void)
		 */
		if (unlikely(budget <= 0 ||
			     time_after_eq(jiffies, time_limit))) {
			sd->time_squeeze++;
			/* Pairs with READ_ONCE() in softnet_seq_show() */
			WRITE_ONCE(sd->time_squeeze, sd->time_squeeze + 1);
			break;
		}
	}
+3 −3
Original line number Diff line number Diff line
@@ -145,11 +145,11 @@ static int softnet_seq_show(struct seq_file *seq, void *v)
	seq_printf(seq,
		   "%08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x "
		   "%08x %08x\n",
		   sd->processed, atomic_read(&sd->dropped),
		   sd->time_squeeze, 0,
		   READ_ONCE(sd->processed), atomic_read(&sd->dropped),
		   READ_ONCE(sd->time_squeeze), 0,
		   0, 0, 0, 0, /* was fastroute */
		   0,	/* was cpu_collision */
		   sd->received_rps, flow_limit_count,
		   READ_ONCE(sd->received_rps), flow_limit_count,
		   input_qlen + process_qlen, (int)seq->index,
		   input_qlen, process_qlen);
	return 0;