Skip to contentSkip to conversation

bonding: get netdev_rx_handler_unregister out of locks

PATCH Applied Veaceslav Falico 3 participants 4 messages Apr 2, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bonding: get netdev_rx_handler_unregister out of locks

Now that netdev_rx_handler_unregister contains synchronize_net(), we need to call it outside of bond->lock, cause it might sleep. Also, remove the already unneded synchronize_net().

---
 drivers/net/bonding/bond_main.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/net/bonding/bond_main.c +1 -2
index 11a8cb3..78c9e2d 100644
@@ -1975,12 +1975,11 @@ static int __bond_release_one(struct net_device *bond_dev,
 		return -EINVAL;
 	}
 
+	write_unlock_bh(&bond->lock);
 	/* unregister rx_handler early so bond_handle_frame wouldn't be called
 	 * for this slave anymore.
 	 */
 	netdev_rx_handler_unregister(slave_dev);
-	write_unlock_bh(&bond->lock);
-	synchronize_net();
 	write_lock_bh(&bond->lock);
 
 	if (!all && !bond->params.fail_over_mac) {
Signature · 1 line
1.7.1
Acked-by on v1 1/1
#1 lore raw
Quoted 17 lines · Veaceslav Falico

Now that netdev_rx_handler_unregister contains synchronize_net(), we need to call it outside of bond->lock, cause it might sleep. Also, remove the already unneded synchronize_net().

---
 drivers/net/bonding/bond_main.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/net/bonding/bond_main.c +0 -0
index 11a8cb3..78c9e2d 100644
@@ -1975,12 +1975,11 @@ static int __bond_release_one(struct net_device *bond_dev,
 		return -EINVAL;
 	}
 

drivers/net/bonding/bond_main.c static int __bond_release_one(struct net_device *bond_dev, · line 1985

Quoted 10 lines
drivers/net/bonding/bond_main.c +1 -2
+	write_unlock_bh(&bond->lock);
 	/* unregister rx_handler early so bond_handle_frame wouldn't be called
 	 * for this slave anymore.
 	 */
 	netdev_rx_handler_unregister(slave_dev);
-	write_unlock_bh(&bond->lock);
-	synchronize_net();
 	write_lock_bh(&bond->lock);
 
 	if (!all && !bond->params.fail_over_mac) {

Good catch, thanks !

I'll send a net-next patch to remove the synchronize_net() from bridge code as well.

#2 lore raw
Quoted 27 lines · Eric Dumazet
Quoted 26 lines · Veaceslav Falico

Now that netdev_rx_handler_unregister contains synchronize_net(), we need to call it outside of bond->lock, cause it might sleep. Also, remove the already unneded synchronize_net().

---
 drivers/net/bonding/bond_main.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/net/bonding/bond_main.c +1 -2
index 11a8cb3..78c9e2d 100644
@@ -1975,12 +1975,11 @@ static int __bond_release_one(struct net_device *bond_dev,
 		return -EINVAL;
 	}
 
+	write_unlock_bh(&bond->lock);
 	/* unregister rx_handler early so bond_handle_frame wouldn't be called
 	 * for this slave anymore.
 	 */
 	netdev_rx_handler_unregister(slave_dev);
-	write_unlock_bh(&bond->lock);
-	synchronize_net();
 	write_lock_bh(&bond->lock);
 
Quoted 8 lines

drivers/net/bonding/bond_main.c static int __bond_release_one(struct net_device *bond_dev, · line 1985

Quoted 1 line
drivers/net/bonding/bond_main.c +0 -0
 	if (!all && !bond->params.fail_over_mac) {

Good catch, thanks !

I'll send a net-next patch to remove the synchronize_net() from bridge code as well.

Nice, when I've checked it not to be under other locks I've somehow missed the part where the bridge calls synchronize_net() right after it.

Thank you!

Quoted 3 lines
maintainer Applied
#3 lore raw
In reply to Eric Dumazet

From: Eric Dumazet <[email protected]>
Date: Tue, 02 Apr 2013 08:26:02 -0700

Quoted 6 lines · Veaceslav Falico
Quoted 5 lines

Now that netdev_rx_handler_unregister contains synchronize_net(), we need to call it outside of bond->lock, cause it might sleep. Also, remove the already unneded synchronize_net().

...

Quoted 1 line

Applied, thanks.