net: avoid dirtying sk->sk_rx_queue_mapping
authorEric Dumazet <edumazet@google.com>
Mon, 25 Oct 2021 16:48:19 +0000 (09:48 -0700)
committerJakub Kicinski <kuba@kernel.org>
Tue, 26 Oct 2021 01:02:13 +0000 (18:02 -0700)
sk_rx_queue_mapping is located in a cache line that should be kept read mostly.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Soheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/net/sock.h

index 99c4194..b4d3744 100644 (file)
@@ -1916,10 +1916,8 @@ static inline void sk_rx_queue_set(struct sock *sk, const struct sk_buff *skb)
        if (skb_rx_queue_recorded(skb)) {
                u16 rx_queue = skb_get_rx_queue(skb);
 
-               if (WARN_ON_ONCE(rx_queue == NO_QUEUE_MAPPING))
-                       return;
-
-               sk->sk_rx_queue_mapping = rx_queue;
+               if (unlikely(READ_ONCE(sk->sk_rx_queue_mapping) != rx_queue))
+                       WRITE_ONCE(sk->sk_rx_queue_mapping, rx_queue);
        }
 #endif
 }