]> git.dujemihanovic.xyz Git - linux.git/commitdiff
net: dst_cache: annotate data-races around dst_cache->reset_ts
authorEric Dumazet <edumazet@google.com>
Tue, 7 May 2024 13:20:00 +0000 (13:20 +0000)
committerJakub Kicinski <kuba@kernel.org>
Thu, 9 May 2024 01:49:51 +0000 (18:49 -0700)
dst_cache->reset_ts is read or written locklessly,
add READ_ONCE() and WRITE_ONCE() annotations.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Paolo Abeni <pabeni@redhat.com>
Link: https://lore.kernel.org/r/20240507132000.614591-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/net/dst_cache.h
net/core/dst_cache.c

index df6622a5fe98f0a9732617bb2a757ef9c9611797..b4a55d2d5e71b974b0012bc7ec9a5970a6c0dffe 100644 (file)
@@ -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);
 }
 
 /**
index 0c0bdb058c5b1ab81e14aa48d8612a6253a7c852..f9df84a6c4b2dbe63c6f61fb431e179f92e072e0 100644 (file)
@@ -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;