[PATCH] veth: use batched device unregister

Eric Dumazet
2011-05-09T04:44:40Z

veth devices dont use the batched device unregisters yet.

Since veth are a pair of devices, it makes sense to use a batch of two
unregisters, this roughly divide dismantle time by two.

Reported-by: Alex Bligh <alex@alex.org.uk>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Jesse Gross <jesse@nicira.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Ben Greear <greearb@candelatech.com>
---
drivers/net/veth.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 3b99f64..77c4679 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -451,8 +451,16 @@ static void veth_dellink(struct net_device *dev, struct list_head *head)
priv = netdev_priv(dev);
peer = priv->peer;

- unregister_netdevice_queue(dev, head);
- unregister_netdevice_queue(peer, head);
+ if (head == NULL) {
+ LIST_HEAD(list);
+ /* make a batch of two devices to speedup unregister */
+ unregister_netdevice_queue(dev, &list);
+ unregister_netdevice_queue(peer, &list);
+ unregister_netdevice_many(&list);
+ } else {
+ unregister_netdevice_queue(dev, head);
+ unregister_netdevice_queue(peer, head);
+ }
}

static const struct nla_policy veth_policy[VETH_INFO_MAX + 1];