Skip to content

Commit

Permalink
Merge branch 'net-avoid-slow-rcu'
Browse files Browse the repository at this point in the history
Eric Dumazet says:

====================
net: avoid slow rcu synchronizations in cleanup_net()

RTNL is a contended mutex, we prefer to expedite rcu synchronizations
in contexts we hold RTNL.

Similarly, cleanup_net() is a single threaded critical component and
should also use synchronize_rcu_expedited() even when not holding RTNL.

First patch removes a barrier with no clear purpose in ipv6_mc_down()
====================

Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
davem330 committed Feb 12, 2024
2 parents 03f568a + 1ebb85f commit 0f37666
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions net/bridge/br_vlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ void br_vlan_flush(struct net_bridge *br)
vg = br_vlan_group(br);
__vlan_flush(br, NULL, vg);
RCU_INIT_POINTER(br->vlgrp, NULL);
synchronize_rcu();
synchronize_net();
__vlan_group_free(vg);
}

Expand Down Expand Up @@ -1372,7 +1372,7 @@ void nbp_vlan_flush(struct net_bridge_port *port)
vg = nbp_vlan_group(port);
__vlan_flush(port->br, port, vg);
RCU_INIT_POINTER(port->vlgrp, NULL);
synchronize_rcu();
synchronize_net();
__vlan_group_free(vg);
}

Expand Down
2 changes: 1 addition & 1 deletion net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ int dev_change_name(struct net_device *dev, const char *newname)
netdev_name_node_del(dev->name_node);
write_unlock(&dev_base_lock);

synchronize_rcu();
synchronize_net();

write_lock(&dev_base_lock);
netdev_name_node_add(net, dev->name_node);
Expand Down
2 changes: 1 addition & 1 deletion net/core/net_namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ static void cleanup_net(struct work_struct *work)
* the rcu_barrier() below isn't sufficient alone.
* Also the pre_exit() and exit() methods need this barrier.
*/
synchronize_rcu();
synchronize_rcu_expedited();

rtnl_lock();
list_for_each_entry_reverse(ops, &pernet_list, list) {
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/fib_trie.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ static void tnode_free(struct key_vector *tn)

if (tnode_free_size >= READ_ONCE(sysctl_fib_sync_mem)) {
tnode_free_size = 0;
synchronize_rcu();
synchronize_net();
}
}

Expand Down
1 change: 0 additions & 1 deletion net/ipv6/mcast.c
Original file line number Diff line number Diff line change
Expand Up @@ -2719,7 +2719,6 @@ void ipv6_mc_down(struct inet6_dev *idev)
/* Should stop work after group drop. or we will
* start work again in mld_ifc_event()
*/
synchronize_net();
mld_query_stop_work(idev);
mld_report_stop_work(idev);

Expand Down
2 changes: 1 addition & 1 deletion net/netfilter/nf_conntrack_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2530,7 +2530,7 @@ void nf_conntrack_cleanup_net_list(struct list_head *net_exit_list)
* netfilter framework. Roll on, two-stage module
* delete...
*/
synchronize_net();
synchronize_rcu_expedited();
i_see_dead_people:
busy = 0;
list_for_each_entry(net, net_exit_list, exit_list) {
Expand Down

0 comments on commit 0f37666

Please sign in to comment.