macvlan: remove one synchronize_rcu() call
authorEric Dumazet <eric.dumazet@gmail.com>
Thu, 19 May 2011 12:24:16 +0000 (12:24 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 20 May 2011 04:33:18 +0000 (00:33 -0400)
When one macvlan device is dismantled, we can avoid one
synchronize_rcu() call done after deletion from hash list, since caller
will perform a synchronize_net() call after its ndo_stop() call.

Add a new netdev->dismantle field to signal this dismantle intent.

Reduces RTNL hold time.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Patrick McHardy <kaber@trash.net>
CC: Ben Greear <greearb@candelatech.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/macvlan.c
include/linux/netdevice.h
net/core/dev.c

index d7c0bc62da7fd56584fc4c265a79b8f301d72fc5..07bcb8084d787e2dbc275571aad51816ed33e738 100644 (file)
@@ -70,16 +70,17 @@ static void macvlan_hash_add(struct macvlan_dev *vlan)
        hlist_add_head_rcu(&vlan->hlist, &port->vlan_hash[addr[5]]);
 }
 
-static void macvlan_hash_del(struct macvlan_dev *vlan)
+static void macvlan_hash_del(struct macvlan_dev *vlan, bool sync)
 {
        hlist_del_rcu(&vlan->hlist);
-       synchronize_rcu();
+       if (sync)
+               synchronize_rcu();
 }
 
 static void macvlan_hash_change_addr(struct macvlan_dev *vlan,
                                        const unsigned char *addr)
 {
-       macvlan_hash_del(vlan);
+       macvlan_hash_del(vlan, true);
        /* Now that we are unhashed it is safe to change the device
         * address without confusing packet delivery.
         */
@@ -345,7 +346,7 @@ static int macvlan_stop(struct net_device *dev)
        dev_uc_del(lowerdev, dev->dev_addr);
 
 hash_del:
-       macvlan_hash_del(vlan);
+       macvlan_hash_del(vlan, !dev->dismantle);
        return 0;
 }
 
index a134d809125b15d0d5e02cd0b6fb0462f4027e51..ca333e79e10ff92e7fbc83a4908d2d54ccf514b0 100644 (file)
@@ -1293,7 +1293,9 @@ struct net_device {
               NETREG_UNREGISTERED,     /* completed unregister todo */
               NETREG_RELEASED,         /* called free_netdev */
               NETREG_DUMMY,            /* dummy device for NAPI poll */
-       } reg_state:16;
+       } reg_state:8;
+
+       bool dismantle; /* device is going do be freed */
 
        enum {
                RTNL_LINK_INITIALIZED,
index 155de2094e71f3e44ac9ff13b219aa0fbaf002a1..d94537914a7159dbd450b4a9a9bb0c8dd369d6fe 100644 (file)
@@ -5126,7 +5126,7 @@ static void rollback_registered_many(struct list_head *head)
                        list_del(&dev->unreg_list);
                        continue;
                }
-
+               dev->dismantle = true;
                BUG_ON(dev->reg_state != NETREG_REGISTERED);
        }