summaryrefslogtreecommitdiff
path: root/include/linux/netdevice.h
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2023-06-06 10:41:15 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-06-14 12:15:21 +0300
commit8a74ea37e1ab8162018a364c8cb419d945609e47 (patch)
tree5f6c7148c692fcf21760fd3c1c17920d1da40b5f /include/linux/netdevice.h
parent3d9eface2eee50ec683d4b9523cd913f1d5ac4aa (diff)
downloadlinux-8a74ea37e1ab8162018a364c8cb419d945609e47.tar.xz
rfs: annotate lockless accesses to RFS sock flow table
[ Upstream commit 5c3b74a92aa285a3df722bf6329ba7ccf70346d6 ] Add READ_ONCE()/WRITE_ONCE() on accesses to the sock flow table. This also prevents a (smart ?) compiler to remove the condition in: if (table->ents[index] != newval) table->ents[index] = newval; We need the condition to avoid dirtying a shared cache line. Fixes: fec5e652e58f ("rfs: Receive Flow Steering") Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Simon Horman <simon.horman@corigine.com> Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'include/linux/netdevice.h')
-rw-r--r--include/linux/netdevice.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index eac51e22a52a..74e05b82f1bf 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -757,8 +757,11 @@ static inline void rps_record_sock_flow(struct rps_sock_flow_table *table,
/* We only give a hint, preemption can change CPU under us */
val |= raw_smp_processor_id();
- if (table->ents[index] != val)
- table->ents[index] = val;
+ /* The following WRITE_ONCE() is paired with the READ_ONCE()
+ * here, and another one in get_rps_cpu().
+ */
+ if (READ_ONCE(table->ents[index]) != val)
+ WRITE_ONCE(table->ents[index], val);
}
}