Commit 7b6f0a85 authored by Eric Dumazet's avatar Eric Dumazet Committed by Jakub Kicinski
Browse files

net: rps: annotate data-races around (struct sd_flow_limit)->count



softnet_seq_show() can read fl->count while another cpu
updates this field from skb_flow_limit().

Make this field an 'unsigned int', as its only consumer
only deals with 32 bit.

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-3-edumazet@google.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent c3025e94
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -5049,7 +5049,8 @@ static bool skb_flow_limit(struct sk_buff *skb, unsigned int qlen)
			fl->buckets[old_flow]--;

		if (++fl->buckets[new_flow] > (FLOW_LIMIT_HISTORY >> 1)) {
			fl->count++;
			/* Pairs with READ_ONCE() in softnet_seq_show() */
			WRITE_ONCE(fl->count, fl->count + 1);
			rcu_read_unlock();
			return true;
		}
+1 −1
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ struct cpumask;
/* Random bits of netdevice that don't need to be exposed */
#define FLOW_LIMIT_HISTORY	(1 << 7)  /* must be ^2 and !overflow buckets */
struct sd_flow_limit {
	u64			count;
	unsigned int		count;
	u8			log_buckets;
	unsigned int		history_head;
	u16			history[FLOW_LIMIT_HISTORY];
+2 −1
Original line number Diff line number Diff line
@@ -132,8 +132,9 @@ static int softnet_seq_show(struct seq_file *seq, void *v)

	rcu_read_lock();
	fl = rcu_dereference(sd->flow_limit);
	/* Pairs with WRITE_ONCE() in skb_flow_limit() */
	if (fl)
		flow_limit_count = fl->count;
		flow_limit_count = READ_ONCE(fl->count);
	rcu_read_unlock();
#endif