Skip to content

Commit

Permalink
net: Remove net_rwsem from {, un}register_netdevice_notifier()
Browse files Browse the repository at this point in the history
These functions take net_rwsem, while wireless_nlevent_flush()
also takes it. But down_read() can't be taken recursive,
because of rw_semaphore design, which prevents it to be occupied
by only readers forever.

Since we take pernet_ops_rwsem in {,un}register_netdevice_notifier(),
net list can't change, so these down_read()/up_read() can be removed.

Fixes: f0b07bb "net: Introduce net_rwsem to protect net_namespace_list"
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Kirill Tkhai authored and David S. Miller committed Apr 1, 2018
1 parent c679f6a commit fc1dd36
Showing 1 changed file with 0 additions and 5 deletions.
5 changes: 0 additions & 5 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1633,7 +1633,6 @@ int register_netdevice_notifier(struct notifier_block *nb)
goto unlock;
if (dev_boot_phase)
goto unlock;
down_read(&net_rwsem);
for_each_net(net) {
for_each_netdev(net, dev) {
err = call_netdevice_notifier(nb, NETDEV_REGISTER, dev);
Expand All @@ -1647,7 +1646,6 @@ int register_netdevice_notifier(struct notifier_block *nb)
call_netdevice_notifier(nb, NETDEV_UP, dev);
}
}
up_read(&net_rwsem);

unlock:
rtnl_unlock();
Expand All @@ -1671,7 +1669,6 @@ int register_netdevice_notifier(struct notifier_block *nb)
}

outroll:
up_read(&net_rwsem);
raw_notifier_chain_unregister(&netdev_chain, nb);
goto unlock;
}
Expand Down Expand Up @@ -1704,7 +1701,6 @@ int unregister_netdevice_notifier(struct notifier_block *nb)
if (err)
goto unlock;

down_read(&net_rwsem);
for_each_net(net) {
for_each_netdev(net, dev) {
if (dev->flags & IFF_UP) {
Expand All @@ -1715,7 +1711,6 @@ int unregister_netdevice_notifier(struct notifier_block *nb)
call_netdevice_notifier(nb, NETDEV_UNREGISTER, dev);
}
}
up_read(&net_rwsem);
unlock:
rtnl_unlock();
up_write(&pernet_ops_rwsem);
Expand Down

0 comments on commit fc1dd36

Please sign in to comment.