From: Eric Dumazet Date: Mon, 25 Oct 2021 16:48:18 +0000 (-0700) Subject: net: avoid dirtying sk->sk_napi_id X-Git-Tag: v5.16-rc1~159^2~88^2~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2b13af8ade38ef3afe48d60c518c64010cfa8b0d;p=thirdparty%2Flinux.git net: avoid dirtying sk->sk_napi_id sk_napi_id is located in a cache line that can be kept read mostly. Signed-off-by: Eric Dumazet Acked-by: Soheil Hassas Yeganeh Signed-off-by: Jakub Kicinski --- diff --git a/include/net/busy_poll.h b/include/net/busy_poll.h index 40296ed976a97..4202c609bb0b0 100644 --- a/include/net/busy_poll.h +++ b/include/net/busy_poll.h @@ -130,7 +130,8 @@ static inline void skb_mark_napi_id(struct sk_buff *skb, static inline void sk_mark_napi_id(struct sock *sk, const struct sk_buff *skb) { #ifdef CONFIG_NET_RX_BUSY_POLL - WRITE_ONCE(sk->sk_napi_id, skb->napi_id); + if (unlikely(READ_ONCE(sk->sk_napi_id) != skb->napi_id)) + WRITE_ONCE(sk->sk_napi_id, skb->napi_id); #endif sk_rx_queue_set(sk, skb); }