netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Ahern <dsahern@kernel.org>
To: Eric Dumazet <edumazet@google.com>,
	"David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>,
	Willem de Bruijn <willemb@google.com>,
	Kuniyuki Iwashima <kuniyu@google.com>,
	netdev@vger.kernel.org, eric.dumazet@gmail.com
Subject: Re: [PATCH net-next 03/10] ipv6: np->rxpmtu race annotation
Date: Wed, 17 Sep 2025 09:34:16 -0600	[thread overview]
Message-ID: <27179899-2e67-474e-bb93-82f52c793028@kernel.org> (raw)
In-Reply-To: <20250916160951.541279-4-edumazet@google.com>

On 9/16/25 10:09 AM, Eric Dumazet wrote:
> Add READ_ONCE() annotations because np->rxpmtu can be changed
> while udpv6_recvmsg() and rawv6_recvmsg() read it.
> 
> Since this is a very rarely used feature, and that udpv6_recvmsg()
> and rawv6_recvmsg() read np->rxopt anyway, change the test order
> so that np->rxpmtu does not need to be in a hot cache line.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> ---
>  net/ipv6/raw.c | 2 +-
>  net/ipv6/udp.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
> index 4ae07a67b4d4f1be6730c252d246e79ff9c73d4c..e369f54844dd9456a819db77435eaef33d162932 100644
> --- a/net/ipv6/raw.c
> +++ b/net/ipv6/raw.c
> @@ -445,7 +445,7 @@ static int rawv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
>  	if (flags & MSG_ERRQUEUE)
>  		return ipv6_recv_error(sk, msg, len, addr_len);
>  
> -	if (np->rxpmtu && np->rxopt.bits.rxpmtu)
> +	if (np->rxopt.bits.rxpmtu && READ_ONCE(np->rxpmtu))
>  		return ipv6_recv_rxpmtu(sk, msg, len, addr_len);
>  
>  	skb = skb_recv_datagram(sk, flags, &err);
> diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
> index b70369f3cd3223cfde07556b1cb1636e8bc78d49..e87d0ef861f88af3ff7bf9dd5045c4d4601036e3 100644
> --- a/net/ipv6/udp.c
> +++ b/net/ipv6/udp.c
> @@ -479,7 +479,7 @@ int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
>  	if (flags & MSG_ERRQUEUE)
>  		return ipv6_recv_error(sk, msg, len, addr_len);
>  
> -	if (np->rxpmtu && np->rxopt.bits.rxpmtu)
> +	if (np->rxopt.bits.rxpmtu && READ_ONCE(np->rxpmtu))
>  		return ipv6_recv_rxpmtu(sk, msg, len, addr_len);
>  
>  try_again:

if that pattern is needed again, it should be a helper ...

Reviewed-by: David Ahern <dsahern@kernel.org>


  parent reply	other threads:[~2025-09-17 15:34 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-16 16:09 [PATCH net-next 00/10] udp: increase RX performance under stress Eric Dumazet
2025-09-16 16:09 ` [PATCH net-next 01/10] ipv6: make ipv6_pinfo.saddr_cache a boolean Eric Dumazet
2025-09-17 14:59   ` Willem de Bruijn
2025-09-17 15:30   ` David Ahern
2025-09-17 17:56   ` Kuniyuki Iwashima
2025-09-16 16:09 ` [PATCH net-next 02/10] ipv6: make ipv6_pinfo.daddr_cache " Eric Dumazet
2025-09-17 14:59   ` Willem de Bruijn
2025-09-17 15:33   ` David Ahern
2025-09-17 17:57   ` Kuniyuki Iwashima
2025-09-16 16:09 ` [PATCH net-next 03/10] ipv6: np->rxpmtu race annotation Eric Dumazet
2025-09-17 14:59   ` Willem de Bruijn
2025-09-17 15:34   ` David Ahern [this message]
2025-09-17 17:59   ` Kuniyuki Iwashima
2025-09-16 16:09 ` [PATCH net-next 04/10] ipv6: reorganise struct ipv6_pinfo Eric Dumazet
2025-09-17 15:00   ` Willem de Bruijn
2025-09-17 15:36   ` David Ahern
2025-09-17 18:01   ` Kuniyuki Iwashima
2025-09-16 16:09 ` [PATCH net-next 05/10] udp: refine __udp_enqueue_schedule_skb() test Eric Dumazet
2025-09-17 15:00   ` Willem de Bruijn
2025-09-17 15:57     ` Eric Dumazet
2025-09-17 17:53       ` Kuniyuki Iwashima
2025-09-17 19:07         ` Willem de Bruijn
2025-09-17 15:39   ` David Ahern
2025-09-16 16:09 ` [PATCH net-next 06/10] udp: update sk_rmem_alloc before busylock acquisition Eric Dumazet
2025-09-17 15:01   ` Willem de Bruijn
2025-09-17 16:07     ` Eric Dumazet
2025-09-17 19:14       ` Willem de Bruijn
2025-09-17 15:44   ` David Ahern
2025-09-17 18:02   ` Kuniyuki Iwashima
2025-09-16 16:09 ` [PATCH net-next 07/10] net: group sk_backlog and sk_receive_queue Eric Dumazet
2025-09-17 15:01   ` Willem de Bruijn
2025-09-17 15:45   ` David Ahern
2025-09-17 18:11   ` Kuniyuki Iwashima
2025-09-16 16:09 ` [PATCH net-next 08/10] udp: add udp_drops_inc() helper Eric Dumazet
2025-09-17 15:02   ` Willem de Bruijn
2025-09-17 15:47   ` David Ahern
2025-09-17 18:13   ` Kuniyuki Iwashima
2025-09-16 16:09 ` [PATCH net-next 09/10] udp: make busylock per socket Eric Dumazet
2025-09-16 16:31   ` Willem de Bruijn
2025-09-16 17:10     ` Eric Dumazet
2025-09-16 19:15       ` Willem de Bruijn
2025-09-17 15:03   ` Willem de Bruijn
2025-09-17 15:52   ` David Ahern
2025-09-17 18:15   ` Kuniyuki Iwashima
2025-09-16 16:09 ` [PATCH net-next 10/10] udp: use skb_attempt_defer_free() Eric Dumazet
2025-09-17 15:03   ` Willem de Bruijn
2025-09-17 15:55   ` David Ahern
2025-09-17 16:15   ` Paolo Abeni
2025-09-17 16:32     ` Eric Dumazet
2025-09-18  6:38       ` Paolo Abeni
2025-09-17 18:20   ` Kuniyuki Iwashima
2025-10-13 21:44   ` [REGRESSION] xfrm issue bisected to 6471658dc66c ("udp: use skb_attempt_defer_free()") Michal Kubecek
2025-10-13 22:12     ` Eric Dumazet
2025-09-18  1:03 ` [PATCH net-next 00/10] udp: increase RX performance under stress Jakub Kicinski
2025-09-18  8:40 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=27179899-2e67-474e-bb93-82f52c793028@kernel.org \
    --to=dsahern@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).