Netdev List
 help / color / mirror / Atom feed
From: Breno Leitao <leitao@debian.org>
To: Eric Dumazet <edumazet@google.com>
Cc: Kuniyuki Iwashima <kuniyu@amazon.com>,
	andrew+netdev@lunn.ch, kernel-team@meta.com, kuba@kernel.org,
	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 03:26:14 -0800	[thread overview]
Message-ID: <20250207-adamant-copper-jackrabbit-27e9fc@leitao> (raw)
In-Reply-To: <CANn89iJ0UdSpuA9gMEDeZ1UU+_VwjvD=bdQPeEA0kWfKMBwC8g@mail.gmail.com>

Hello Eric,

On Fri, Feb 07, 2025 at 11:56:53AM +0100, Eric Dumazet wrote:

> > I suppose we will need to move some of definitions around, but, I am
> > NOT confident in which way.
> 
> Note that we have different accessors like rtnl_dereference() and
> rcu_dereference_rtnl()

Makes sense. I suppose that would be a for_each_netdev_rtnl().

> It helps to differentiate expectations, and as self describing code.

The problem with this approach, is that we don't know what lock the
caller of dev_getbyhwaddr_rcu() is using, thus, we cannot leverage
a possible for_each_netdev_rtnl() inside dev_getbyhwaddr_rcu().

> I would not change  for_each_netdev_rcu(), and instead add a new
> dev_getbyhwaddr_rtnl()
> function for contexts holding RTNL.

Initially, I had reservations about this approach, but after further
consideration, it seems that creating separate variants of
dev_getbyhwaddr() might be the most effective solution.

By doing so, we can introduce dev_getbyhwaddr_rcu() and
dev_getbyhwaddr_rtnl(), each tailored to specific locking mechanisms.

To explore this idea further, I'll create a proof-of-concept
implementation to see how these new functions would look in practice.

This will help us determine whether this approach is indeed the best way
forward. Thanks for the suggestion.

> Alternatively, add one rcu_read_lock()/rcu_read_unlock() pair as some
> dev_getbyhwaddr_rcu() callers already do.

Fair, we can do that as well, but, it seemed weird to me to have
something like:

	rtnl_lock();
	rcu_read_lock();
	dev_getbyhwaddr_rcu();

Thanks for chiming in
--breno

  reply	other threads:[~2025-02-07 11:26 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
2025-02-07 10:46   ` Breno Leitao
2025-02-07 10:56     ` Eric Dumazet
2025-02-07 11:26       ` Breno Leitao [this message]
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=20250207-adamant-copper-jackrabbit-27e9fc@leitao \
    --to=leitao@debian.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=edumazet@google.com \
    --cc=kernel-team@meta.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@amazon.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox