Commit 449f4544267e73d5db372971da63634707c32299

Authored by Eric Dumazet
Committed by David S. Miller
1 parent 034cfe48d0

macvlan: remove one synchronize_rcu() call

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>

Showing 3 changed files with 9 additions and 6 deletions Side-by-side Diff

drivers/net/macvlan.c
... ... @@ -70,16 +70,17 @@
70 70 hlist_add_head_rcu(&vlan->hlist, &port->vlan_hash[addr[5]]);
71 71 }
72 72  
73   -static void macvlan_hash_del(struct macvlan_dev *vlan)
  73 +static void macvlan_hash_del(struct macvlan_dev *vlan, bool sync)
74 74 {
75 75 hlist_del_rcu(&vlan->hlist);
76   - synchronize_rcu();
  76 + if (sync)
  77 + synchronize_rcu();
77 78 }
78 79  
79 80 static void macvlan_hash_change_addr(struct macvlan_dev *vlan,
80 81 const unsigned char *addr)
81 82 {
82   - macvlan_hash_del(vlan);
  83 + macvlan_hash_del(vlan, true);
83 84 /* Now that we are unhashed it is safe to change the device
84 85 * address without confusing packet delivery.
85 86 */
... ... @@ -345,7 +346,7 @@
345 346 dev_uc_del(lowerdev, dev->dev_addr);
346 347  
347 348 hash_del:
348   - macvlan_hash_del(vlan);
  349 + macvlan_hash_del(vlan, !dev->dismantle);
349 350 return 0;
350 351 }
351 352  
include/linux/netdevice.h
... ... @@ -1293,7 +1293,9 @@
1293 1293 NETREG_UNREGISTERED, /* completed unregister todo */
1294 1294 NETREG_RELEASED, /* called free_netdev */
1295 1295 NETREG_DUMMY, /* dummy device for NAPI poll */
1296   - } reg_state:16;
  1296 + } reg_state:8;
  1297 +
  1298 + bool dismantle; /* device is going do be freed */
1297 1299  
1298 1300 enum {
1299 1301 RTNL_LINK_INITIALIZED,
... ... @@ -5126,7 +5126,7 @@
5126 5126 list_del(&dev->unreg_list);
5127 5127 continue;
5128 5128 }
5129   -
  5129 + dev->dismantle = true;
5130 5130 BUG_ON(dev->reg_state != NETREG_REGISTERED);
5131 5131 }
5132 5132