net: avoid potential false sharing in neighbor related code
[linux-2.6-block.git] / include / net / sock.h
index ac6042d0af328a7f6e18f8882d2ee0679a0e59c5..f2f853439b6576925e39f6db010964762e39ccf2 100644 (file)
@@ -1939,8 +1939,8 @@ struct dst_entry *sk_dst_check(struct sock *sk, u32 cookie);
 
 static inline void sk_dst_confirm(struct sock *sk)
 {
-       if (!sk->sk_dst_pending_confirm)
-               sk->sk_dst_pending_confirm = 1;
+       if (!READ_ONCE(sk->sk_dst_pending_confirm))
+               WRITE_ONCE(sk->sk_dst_pending_confirm, 1);
 }
 
 static inline void sock_confirm_neigh(struct sk_buff *skb, struct neighbour *n)
@@ -1950,10 +1950,10 @@ static inline void sock_confirm_neigh(struct sk_buff *skb, struct neighbour *n)
                unsigned long now = jiffies;
 
                /* avoid dirtying neighbour */
-               if (n->confirmed != now)
-                       n->confirmed = now;
-               if (sk && sk->sk_dst_pending_confirm)
-                       sk->sk_dst_pending_confirm = 0;
+               if (READ_ONCE(n->confirmed) != now)
+                       WRITE_ONCE(n->confirmed, now);
+               if (sk && READ_ONCE(sk->sk_dst_pending_confirm))
+                       WRITE_ONCE(sk->sk_dst_pending_confirm, 0);
        }
 }