Skip to contentSkip to conversation

bridge: switch br_net_exit to batch mode

PATCH In review Eric Dumazet 2 participants 2 messages Feb 18, 2022

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

PATCH 1/1 bridge: switch br_net_exit to batch mode

From: Eric Dumazet <[email protected]>

cleanup_net() is competing with other rtnl users.

Instead of calling br_net_exit() for each netns, call br_net_exit_batch() once.

This gives cleanup_net() ability to group more devices
and call unregister_netdevice_many() only once for all bridge devices.

Cc Roopa Prabhu <[email protected]>
Cc Nikolay Aleksandrov <[email protected]>
---
 net/bridge/br.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
net/bridge/br.c +9 -6
index 1fac72cc617ff7e1851b715860a95e9a1247b9b1..b1dea3febeea49f4e0882a1df64e09fc1db6b3b4 100644
@@ -342,23 +342,26 @@ void br_opt_toggle(struct net_bridge *br, enum net_bridge_opts opt, bool on)
 		clear_bit(opt, &br->options);
 }
 
-static void __net_exit br_net_exit(struct net *net)
+static void __net_exit br_net_exit_batch(struct list_head *net_list)
 {
 	struct net_device *dev;
+	struct net *net;
 	LIST_HEAD(list);
 
 	rtnl_lock();
-	for_each_netdev(net, dev)
-		if (netif_is_bridge_master(dev))
-			br_dev_delete(dev, &list);
+
+	list_for_each_entry(net, net_list, exit_list)
+		for_each_netdev(net, dev)
+			if (netif_is_bridge_master(dev))
+				br_dev_delete(dev, &list);
 
 	unregister_netdevice_many(&list);
+
 	rtnl_unlock();
-
 }
 
 static struct pernet_operations br_net_ops = {
-	.exit	= br_net_exit,
+	.exit_batch	= br_net_exit_batch,
 };
 
 static const struct stp_proto br_stp_proto = {
Signature · 1 line
2.35.1.265.g69c8d7142f-goog
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Eric Dumazet

From: Eric Dumazet <[email protected]>

cleanup_net() is competing with other rtnl users.

Instead of calling br_net_exit() for each netns, call br_net_exit_batch() once.

This gives cleanup_net() ability to group more devices
and call unregister_netdevice_many() only once for all bridge devices.

Quoted 7 lines
Cc Roopa Prabhu <[email protected]>
Cc Nikolay Aleksandrov <[email protected]>
---
 net/bridge/br.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

Thanks,