All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: "Paul E. McKenney" <paulmck@kernel.org>
Cc: Eric Dumazet <edumazet@google.com>,
	"David S . Miller" <davem@davemloft.net>,
	Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org, Kuniyuki Iwashima <kuniyu@amazon.com>,
	Simon Horman <horms@kernel.org>,
	eric.dumazet@gmail.com, rcu@vger.kernel.org
Subject: Re: [PATCH v3 net 11/16] ipv6: input: convert to dev_net_rcu()
Date: Tue, 4 Feb 2025 13:30:25 -0800	[thread overview]
Message-ID: <20250204133025.78c466ec@kernel.org> (raw)
In-Reply-To: <39a1fde2-63f7-4092-870f-ae20156fbb9e@paulmck-laptop>

On Tue, 4 Feb 2025 13:17:08 -0800 Paul E. McKenney wrote:
> > > TBH I'm slightly confused by this, and the previous warnings.
> > >
> > > The previous one was from a timer callback.
> > >
> > > This one is with BH disabled.
> > >
> > > I thought BH implies RCU protection. We certainly depend on that
> > > in NAPI for XDP. And threaded NAPI does the exact same thing as
> > > xfrm_trans_reinject(), a bare local_bh_disable().
> > >
> > > RCU folks, did something change or is just holes in my brain again?  
> > 
> > Nope, BH does not imply rcu_read_lock()  
> 
> You are both right?  ;-)
> 
> The synchronize_rcu() function will wait for all types of RCU readers,
> including BH-disabled regions of code.  However, lockdep can distinguish
> between the various sorts of readers.  So for example
> 
> 	lockdep_assert_in_rcu_read_lock_bh();
> 
> will complain unless you did rcu_read_lock_bh(), even if you did something
> like disable_bh().  If you don't want to distinguish and are happy with
> any type of RCU reader, you can use
> 
> 	lockdep_assert_in_rcu_reader();
> 
> I have been expecting that CONFIG_PREEMPT_RT=y kernels will break this
> any day now, but so far so good.  ;-)

Thanks Paul! So IIUC in this case we could:

diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index 0f5eb9db0c62..58ec1eb9ae6a 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -401,7 +401,7 @@ static inline struct net *read_pnet(const possible_net_t *pnet)
 static inline struct net *read_pnet_rcu(possible_net_t *pnet)
 {
 #ifdef CONFIG_NET_NS
-	return rcu_dereference(pnet->net);
+	return rcu_dereference_check(pnet->net, rcu_read_lock_bh_held());
 #else
 	return &init_net;
 #endif

Sorry for the sideline, Eric, up to you how to proceed..
I'll try to remember the details better next time :)

  reply	other threads:[~2025-02-04 21:30 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-04 13:23 [PATCH v3 net 00/16] net: first round to use dev_net_rcu() Eric Dumazet
2025-02-04 13:23 ` [PATCH v3 net 01/16] net: add dev_net_rcu() helper Eric Dumazet
2025-02-04 13:23 ` [PATCH v3 net 02/16] ipv4: add RCU protection to ip4_dst_hoplimit() Eric Dumazet
2025-02-04 13:23 ` [PATCH v3 net 03/16] ipv4: use RCU protection in ip_dst_mtu_maybe_forward() Eric Dumazet
2025-02-04 13:23 ` [PATCH v3 net 04/16] ipv4: use RCU protection in ipv4_default_advmss() Eric Dumazet
2025-02-04 13:23 ` [PATCH v3 net 05/16] ipv4: use RCU protection in rt_is_expired() Eric Dumazet
2025-02-04 13:23 ` [PATCH v3 net 06/16] tcp: convert to dev_net_rcu() Eric Dumazet
2025-02-04 13:23 ` [PATCH v3 net 07/16] net: gro: convert four dev_net() calls Eric Dumazet
2025-02-04 13:23 ` [PATCH v3 net 08/16] udp: convert to dev_net_rcu() Eric Dumazet
2025-02-04 13:23 ` [PATCH v3 net 09/16] ipv4: icmp: " Eric Dumazet
2025-02-04 13:23 ` [PATCH v3 net 10/16] ipv6: " Eric Dumazet
2025-02-04 13:23 ` [PATCH v3 net 11/16] ipv6: input: " Eric Dumazet
2025-02-04 20:09   ` Jakub Kicinski
2025-02-04 20:10     ` Eric Dumazet
2025-02-04 21:00       ` Jakub Kicinski
2025-02-04 21:06         ` Eric Dumazet
2025-02-04 21:17           ` Paul E. McKenney
2025-02-04 21:30             ` Jakub Kicinski [this message]
2025-02-04 23:25               ` Paul E. McKenney
2025-02-05  7:57               ` Eric Dumazet
2025-02-05  8:05                 ` Eric Dumazet
2025-02-04 13:23 ` [PATCH v3 net 12/16] ipv6: output: " Eric Dumazet
2025-02-04 13:23 ` [PATCH v3 net 13/16] ipv6: use RCU protection in ip6_default_advmss() Eric Dumazet
2025-02-04 13:23 ` [PATCH v3 net 14/16] net: filter: convert to dev_net_rcu() Eric Dumazet
2025-02-04 13:23 ` [PATCH v3 net 15/16] flow_dissector: use rcu protection to fetch dev_net() Eric Dumazet
2025-02-04 13:23 ` [PATCH v3 net 16/16] ipv4: use RCU protection in inet_select_addr() Eric Dumazet

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=20250204133025.78c466ec@kernel.org \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=horms@kernel.org \
    --cc=kuniyu@amazon.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=paulmck@kernel.org \
    --cc=rcu@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.