Commit e51b9624 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

net: remove dev_base_lock from register_netdevice() and friends.

RTNL already protects writes to dev->reg_state, we no longer need to hold
dev_base_lock to protect the readers.

unlist_netdevice() second argument can be removed.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2dd4d828
...@@ -414,7 +414,7 @@ static void list_netdevice(struct net_device *dev) ...@@ -414,7 +414,7 @@ static void list_netdevice(struct net_device *dev)
/* Device list removal /* Device list removal
* caller must respect a RCU grace period before freeing/reusing dev * caller must respect a RCU grace period before freeing/reusing dev
*/ */
static void unlist_netdevice(struct net_device *dev, bool lock) static void unlist_netdevice(struct net_device *dev)
{ {
struct netdev_name_node *name_node; struct netdev_name_node *name_node;
struct net *net = dev_net(dev); struct net *net = dev_net(dev);
...@@ -427,12 +427,10 @@ static void unlist_netdevice(struct net_device *dev, bool lock) ...@@ -427,12 +427,10 @@ static void unlist_netdevice(struct net_device *dev, bool lock)
netdev_name_node_del(name_node); netdev_name_node_del(name_node);
/* Unlink dev from the device chain */ /* Unlink dev from the device chain */
if (lock)
write_lock(&dev_base_lock); write_lock(&dev_base_lock);
list_del_rcu(&dev->dev_list); list_del_rcu(&dev->dev_list);
netdev_name_node_del(dev->name_node); netdev_name_node_del(dev->name_node);
hlist_del_rcu(&dev->index_hlist); hlist_del_rcu(&dev->index_hlist);
if (lock)
write_unlock(&dev_base_lock); write_unlock(&dev_base_lock);
dev_base_seq_inc(dev_net(dev)); dev_base_seq_inc(dev_net(dev));
...@@ -10338,9 +10336,9 @@ int register_netdevice(struct net_device *dev) ...@@ -10338,9 +10336,9 @@ int register_netdevice(struct net_device *dev)
goto err_ifindex_release; goto err_ifindex_release;
ret = netdev_register_kobject(dev); ret = netdev_register_kobject(dev);
write_lock(&dev_base_lock);
WRITE_ONCE(dev->reg_state, ret ? NETREG_UNREGISTERED : NETREG_REGISTERED); WRITE_ONCE(dev->reg_state, ret ? NETREG_UNREGISTERED : NETREG_REGISTERED);
write_unlock(&dev_base_lock);
if (ret) if (ret)
goto err_uninit_notify; goto err_uninit_notify;
...@@ -10629,9 +10627,7 @@ void netdev_run_todo(void) ...@@ -10629,9 +10627,7 @@ void netdev_run_todo(void)
continue; continue;
} }
write_lock(&dev_base_lock);
WRITE_ONCE(dev->reg_state, NETREG_UNREGISTERED); WRITE_ONCE(dev->reg_state, NETREG_UNREGISTERED);
write_unlock(&dev_base_lock);
linkwatch_sync_dev(dev); linkwatch_sync_dev(dev);
} }
...@@ -11138,10 +11134,8 @@ void unregister_netdevice_many_notify(struct list_head *head, ...@@ -11138,10 +11134,8 @@ void unregister_netdevice_many_notify(struct list_head *head,
list_for_each_entry(dev, head, unreg_list) { list_for_each_entry(dev, head, unreg_list) {
/* And unlink it from device chain. */ /* And unlink it from device chain. */
write_lock(&dev_base_lock); unlist_netdevice(dev);
unlist_netdevice(dev, false);
WRITE_ONCE(dev->reg_state, NETREG_UNREGISTERING); WRITE_ONCE(dev->reg_state, NETREG_UNREGISTERING);
write_unlock(&dev_base_lock);
} }
flush_all_backlogs(); flush_all_backlogs();
...@@ -11323,7 +11317,7 @@ int __dev_change_net_namespace(struct net_device *dev, struct net *net, ...@@ -11323,7 +11317,7 @@ int __dev_change_net_namespace(struct net_device *dev, struct net *net,
dev_close(dev); dev_close(dev);
/* And unlink it from device chain */ /* And unlink it from device chain */
unlist_netdevice(dev, true); unlist_netdevice(dev);
synchronize_net(); synchronize_net();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment