From: Breno Leitao <leitao@debian.org>
To: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
Herbert Xu <herbert@gondor.apana.org.au>,
Stephen Hemminger <stephen@networkplumber.org>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Breno Leitao <leitao@debian.org>,
paulmck@kernel.org
Subject: [PATCH net 2/2] netpoll: Use rcu_access_pointer() in netpoll_poll_lock
Date: Mon, 18 Nov 2024 03:15:18 -0800 [thread overview]
Message-ID: <20241118-netpoll_rcu-v1-2-a1888dcb4a02@debian.org> (raw)
In-Reply-To: <20241118-netpoll_rcu-v1-0-a1888dcb4a02@debian.org>
The ndev->npinfo pointer in netpoll_poll_lock() is RCU-protected but is
being accessed directly for a NULL check. While no RCU read lock is held
in this context, we should still use proper RCU primitives for
consistency and correctness.
Replace the direct NULL check with rcu_access_pointer(), which is the
appropriate primitive when only checking for NULL without dereferencing
the pointer. This function provides the necessary ordering guarantees
without requiring RCU read-side protection.
Signed-off-by: Breno Leitao <leitao@debian.org>
Fixes: bea3348eef27 ("[NET]: Make NAPI polling independent of struct net_device objects.")
---
include/linux/netpoll.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h
index cd4e28db0cbd77572a579aff2067b5864d1a904a..959a4daacea1f2f76536e309d198bc14407942a4 100644
--- a/include/linux/netpoll.h
+++ b/include/linux/netpoll.h
@@ -72,7 +72,7 @@ static inline void *netpoll_poll_lock(struct napi_struct *napi)
{
struct net_device *dev = napi->dev;
- if (dev && dev->npinfo) {
+ if (dev && rcu_access_pointer(dev->npinfo)) {
int owner = smp_processor_id();
while (cmpxchg(&napi->poll_owner, -1, owner) != -1)
--
2.43.5
next prev parent reply other threads:[~2024-11-18 11:15 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-18 11:15 [PATCH net 0/2] netpoll: Use RCU primitives for npinfo pointer access Breno Leitao
2024-11-18 11:15 ` [PATCH net 1/2] netpoll: Use rcu_access_pointer() in __netpoll_setup Breno Leitao
2024-11-18 12:18 ` Michal Kubiak
2024-11-19 3:28 ` Herbert Xu
2024-11-19 10:22 ` Breno Leitao
2024-11-20 3:01 ` Herbert Xu
2024-11-20 3:48 ` Herbert Xu
2024-11-20 17:58 ` Breno Leitao
2024-11-18 11:15 ` Breno Leitao [this message]
2024-11-18 12:20 ` [PATCH net 2/2] netpoll: Use rcu_access_pointer() in netpoll_poll_lock Michal Kubiak
2024-11-18 15:37 ` Breno Leitao
2024-11-19 3:02 ` Jakub Kicinski
2024-11-19 3:48 ` Herbert Xu
2024-11-19 3:40 ` [PATCH net 0/2] netpoll: Use RCU primitives for npinfo pointer access patchwork-bot+netdevbpf
2024-11-19 3:53 ` Herbert Xu
2024-11-19 14:34 ` Jakub Kicinski
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=20241118-netpoll_rcu-v1-2-a1888dcb4a02@debian.org \
--to=leitao@debian.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=herbert@gondor.apana.org.au \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=paulmck@kernel.org \
--cc=stephen@networkplumber.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®