[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3cbea18a661e9e8dee7ba1d50452bab8d12c54f3.camel@redhat.com>
Date: Thu, 22 Dec 2022 10:39:54 +0100
From: Paolo Abeni <pabeni@...hat.com>
To: Hangbin Liu <liuhangbin@...il.com>,
Eric Dumazet <edumazet@...gle.com>
Cc: "David S . Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>, netdev@...r.kernel.org,
eric.dumazet@...il.com, syzbot <syzkaller@...glegroups.com>,
Jay Vosburgh <j.vosburgh@...il.com>,
Veaceslav Falico <vfalico@...il.com>,
Andy Gospodarek <andy@...yhouse.net>
Subject: Re: [PATCH net] bonding: fix lockdep splat in bond_miimon_commit()
On Wed, 2022-12-21 at 11:33 +0800, Hangbin Liu wrote:
> Another questions is, I'm still a little confused with the mixing usage of
> rcu_access_pointer() and rtnl_dereference() under RTNL. e.g.
>
> In bond_miimon_commit() we use rcu_access_pointer() to check the pointers.
> case BOND_LINK_DOWN:
> if (slave == rcu_access_pointer(bond->curr_active_slave))
> do_failover = true;
>
> In bond_ab_arp_commit() we use rtnl_dereference() to check the pointer
>
> case BOND_LINK_DOWN:
> if (slave == rtnl_dereference(bond->curr_active_slave)) {
> RCU_INIT_POINTER(bond->current_arp_slave, NULL);
> do_failover = true;
> }
> case BOND_LINK_FAIL:
> if (rtnl_dereference(bond->curr_active_slave))
> RCU_INIT_POINTER(bond->current_arp_slave, NULL);
>
> Does it matter to use which one? Should we change to rcu_access_pointer()
> if there is no dereference?
You can use rcu_access_pointer() every time the code does not actually
use the RCU pointer, just checks for NULL value.
rtnl_dereference() needs stronger guarantees (the caller must hold the
RTNL lock at call time). As such it adds additional lockdep-safety, and
should be preferred _when_ the call site meets the requirement.
In the above bond_miimon_commit() example the rcu_access_pointer()
could be replaced with rtnl_dereference() for extra safety and
consistency, but it will be mostly a cosmetic change.
Cheers,
Paolo
Powered by blists - more mailing lists