netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] bonding: remove locking from bond_set_rx_mode()
@ 2013-08-05 12:56 Veaceslav Falico
  2013-08-05 13:45 ` Nikolay Aleksandrov
  2013-08-05 19:23 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Veaceslav Falico @ 2013-08-05 12:56 UTC (permalink / raw)
  To: netdev
  Cc: Veaceslav Falico, Jay Vosburgh, Andy Gospodarek, Nikolay Aleksandrov

We're already protected by RTNL lock, so nothing can happen to bond/its
slaves, and thus the locking is useless here (both bond->lock and
bond->curr_active_slave).

Also, add ASSERT_RTNL() both to bond_set_rx_mode() and bond_hw_addr_swap()
to catch possible uses of it without RTNL locking.

This patch also saves us from a lockdep false-positive in
bond_set_rx_mode() vs bond_hw_addr_swap().

CC: Jay Vosburgh <fubar@us.ibm.com>
CC: Andy Gospodarek <andy@greyhouse.net>
CC: Nikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
---
 drivers/net/bonding/bond_main.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 476df7d..77501d4 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -776,6 +776,8 @@ static void bond_hw_addr_flush(struct net_device *bond_dev,
 static void bond_hw_addr_swap(struct bonding *bond, struct slave *new_active,
 			      struct slave *old_active)
 {
+	ASSERT_RTNL();
+
 	if (old_active) {
 		if (bond->dev->flags & IFF_PROMISC)
 			dev_set_promiscuity(old_active->dev, -1);
@@ -3571,24 +3573,20 @@ static void bond_set_rx_mode(struct net_device *bond_dev)
 	struct bonding *bond = netdev_priv(bond_dev);
 	struct slave *slave;
 
-	read_lock(&bond->lock);
+	ASSERT_RTNL();
 
 	if (USES_PRIMARY(bond->params.mode)) {
-		read_lock(&bond->curr_slave_lock);
-		slave = bond->curr_active_slave;
+		slave = rtnl_dereference(bond->curr_active_slave);
 		if (slave) {
 			dev_uc_sync(slave->dev, bond_dev);
 			dev_mc_sync(slave->dev, bond_dev);
 		}
-		read_unlock(&bond->curr_slave_lock);
 	} else {
 		bond_for_each_slave(bond, slave) {
 			dev_uc_sync_multiple(slave->dev, bond_dev);
 			dev_mc_sync_multiple(slave->dev, bond_dev);
 		}
 	}
-
-	read_unlock(&bond->lock);
 }
 
 static int bond_neigh_init(struct neighbour *n)
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] bonding: remove locking from bond_set_rx_mode()
  2013-08-05 12:56 [PATCH net-next] bonding: remove locking from bond_set_rx_mode() Veaceslav Falico
@ 2013-08-05 13:45 ` Nikolay Aleksandrov
  2013-08-05 19:23 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Nikolay Aleksandrov @ 2013-08-05 13:45 UTC (permalink / raw)
  To: Veaceslav Falico; +Cc: netdev, Jay Vosburgh, Andy Gospodarek

On 08/05/2013 02:56 PM, Veaceslav Falico wrote:
> We're already protected by RTNL lock, so nothing can happen to bond/its
> slaves, and thus the locking is useless here (both bond->lock and
> bond->curr_active_slave).
> 
> Also, add ASSERT_RTNL() both to bond_set_rx_mode() and bond_hw_addr_swap()
> to catch possible uses of it without RTNL locking.
> 
> This patch also saves us from a lockdep false-positive in
> bond_set_rx_mode() vs bond_hw_addr_swap().
> 
> CC: Jay Vosburgh <fubar@us.ibm.com>
> CC: Andy Gospodarek <andy@greyhouse.net>
> CC: Nikolay Aleksandrov <nikolay@redhat.com>
> Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
> ---

Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] bonding: remove locking from bond_set_rx_mode()
  2013-08-05 12:56 [PATCH net-next] bonding: remove locking from bond_set_rx_mode() Veaceslav Falico
  2013-08-05 13:45 ` Nikolay Aleksandrov
@ 2013-08-05 19:23 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2013-08-05 19:23 UTC (permalink / raw)
  To: vfalico; +Cc: netdev, fubar, andy, nikolay

From: Veaceslav Falico <vfalico@redhat.com>
Date: Mon,  5 Aug 2013 14:56:06 +0200

> We're already protected by RTNL lock, so nothing can happen to bond/its
> slaves, and thus the locking is useless here (both bond->lock and
> bond->curr_active_slave).
> 
> Also, add ASSERT_RTNL() both to bond_set_rx_mode() and bond_hw_addr_swap()
> to catch possible uses of it without RTNL locking.
> 
> This patch also saves us from a lockdep false-positive in
> bond_set_rx_mode() vs bond_hw_addr_swap().
> 
> CC: Jay Vosburgh <fubar@us.ibm.com>
> CC: Andy Gospodarek <andy@greyhouse.net>
> CC: Nikolay Aleksandrov <nikolay@redhat.com>
> Signed-off-by: Veaceslav Falico <vfalico@redhat.com>

Applied.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-08-05 19:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-05 12:56 [PATCH net-next] bonding: remove locking from bond_set_rx_mode() Veaceslav Falico
2013-08-05 13:45 ` Nikolay Aleksandrov
2013-08-05 19:23 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).