From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: <leitao@debian.org>
Cc: <andrew+netdev@lunn.ch>, <edumazet@google.com>,
<kernel-team@meta.com>, <kuba@kernel.org>, <kuniyu@amazon.com>,
<netdev@vger.kernel.org>, <ushankar@purestorage.com>
Subject: Re: for_each_netdev_rcu() protected by RTNL and CONFIG_PROVE_RCU_LIST
Date: Fri, 7 Feb 2025 12:38:22 +0900 [thread overview]
Message-ID: <20250207033822.47317-1-kuniyu@amazon.com> (raw)
In-Reply-To: <20250206-scarlet-ermine-of-improvement-1fcac5@leitao>
From: Breno Leitao <leitao@debian.org>
Date: Thu, 6 Feb 2025 07:51:55 -0800
> Hello,
>
> We're seeing CONFIG_PROVE_RCU_LIST warnings when for_each_netdev_rcu()
> is called with RTNL held. While RTNL provides sufficient locking, the
> RCU list checker isn't aware of this relationship, leading to false
> positives like:
>
> WARNING: suspicious RCU usage
> net/core/dev.c:1143 RCU-list traversed in non-reader section!!
>
> The initial discussion popped up in:
>
> https://lore.kernel.org/all/20250205-flying-coucal-of-influence-0dcbc3@leitao/
>
> I've attempted a solution by modifying for_each_netdev_rcu():
>
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 2a59034a5fa2f..59b18b58fa927 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -3210,13 +3210,14 @@ netdev_notifier_info_to_extack(const struct netdev_notifier_info *info)
> int call_netdevice_notifiers(unsigned long val, struct net_device *dev);
> int call_netdevice_notifiers_info(unsigned long val,
> struct netdev_notifier_info *info);
> +bool lockdep_rtnl_net_is_held(struct net *net);
>
> #define for_each_netdev(net, d) \
> list_for_each_entry(d, &(net)->dev_base_head, dev_list)
> #define for_each_netdev_reverse(net, d) \
> list_for_each_entry_reverse(d, &(net)->dev_base_head, dev_list)
> #define for_each_netdev_rcu(net, d) \
> - list_for_each_entry_rcu(d, &(net)->dev_base_head, dev_list)
> + list_for_each_entry_rcu(d, &(net)->dev_base_head, dev_list, lockdep_rtnl_net_is_held(net))
> #define for_each_netdev_safe(net, d, n) \
> list_for_each_entry_safe(d, n, &(net)->dev_base_head, dev_list)
> #define for_each_netdev_continue(net, d) \
>
> However, I have concerns about using lockdep_rtnl_net_is_held() since it
> has a dependency on CONFIG_DEBUG_NET_SMALL_RTNL.
>
> Are there better approaches to silence these warnings when RTNL is held?
> Any suggestions would be appreciated.
We can't use lockdep_rtnl_net_is_held() there yet because most users are
not converted to per-netns RTNL, so it will complain loudly.
next prev parent reply other threads:[~2025-02-07 3:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-06 15:51 for_each_netdev_rcu() protected by RTNL and CONFIG_PROVE_RCU_LIST Breno Leitao
2025-02-07 3:38 ` Kuniyuki Iwashima [this message]
2025-02-07 10:46 ` Breno Leitao
2025-02-07 10:56 ` Eric Dumazet
2025-02-07 11:26 ` Breno Leitao
2025-02-07 12:17 ` Breno Leitao
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=20250207033822.47317-1-kuniyu@amazon.com \
--to=kuniyu@amazon.com \
--cc=andrew+netdev@lunn.ch \
--cc=edumazet@google.com \
--cc=kernel-team@meta.com \
--cc=kuba@kernel.org \
--cc=leitao@debian.org \
--cc=netdev@vger.kernel.org \
--cc=ushankar@purestorage.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 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.