net: dst_cache: annotate data-races around dst_cache->reset_ts
Subsystems (2)
PATCH 1/1 net: dst_cache: annotate data-races around dst_cache->reset_ts
dst_cache->reset_ts is read or written locklessly, add READ_ONCE() and WRITE_ONCE() annotations.
--- include/net/dst_cache.h | 2 +- net/core/dst_cache.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-)
include/net/dst_cache.h +1 -1
@@ -76,7 +76,7 @@ struct dst_entry *dst_cache_get_ip6(struct dst_cache *dst_cache,*/ static inline void dst_cache_reset (struct dst_cache *dst_cache) { - dst_cache->reset_ts = jiffies; +WRITE_ONCE (dst_cache->reset_ts, jiffies); }/**
net/core/dst_cache.c +3 -2
@@ -47,7 +47,8 @@ static struct dst_entry *dst_cache_per_cpu_get(struct dst_cache *dst_cache,/* the cache already hold a dst reference; it can't go away */ dst_hold (dst); -if (unlikely (!time_after (idst->refresh_ts, dst_cache->reset_ts) || +if (unlikely (!time_after (idst->refresh_ts, +READ_ONCE (dst_cache->reset_ts)) || (dst->obsolete && !dst->ops->check (dst, idst->cookie)))) {dst_cache_per_cpu_dst_set (idst,NULL ,0 );dst_release (dst);
@@ -170,7 +171,7 @@ void dst_cache_reset_now(struct dst_cache *dst_cache)if (!dst_cache->cache)return ; - dst_cache->reset_ts = jiffies; +dst_cache_reset (dst_cache);for_each_possible_cpu (i) {struct dst_cache_pcpu *idst =per_cpu_ptr (dst_cache->cache, i);struct dst_entry *dst = idst->dst;
Signature · 1 line
2.45.0.rc1.225.g2a3ae87e7f-goog
Quoted 4 lines · Eric Dumazet
dst_cache->reset_tsis read or written locklessly, addREAD_ONCE()andWRITE_ONCE()annotations.Signed-off-by Eric Dumazet <[email protected]>
I was wondering if we need the annotation when the RD/WR ops all happen on the same CPU, but dst_cache_reset() can happen on a different core, so LGTM, thanks!
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Tue, 7 May 2024 13:20:00 +0000 you wrote:
dst_cache->reset_tsis read or written locklessly, addREAD_ONCE()andWRITE_ONCE()annotations.Signed-off-by Eric Dumazet <[email protected]>--- include/net/dst_cache.h | 2 +- net/core/dst_cache.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-)
Here is the summary with links:
- [net-next] net: dst_cache: annotate data-races around dst_cache->reset_ts
https://git.kernel.org/netdev/net-next/c/3b09b2bd0d62
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html