net: reduce RTNL hold duration in unregister_netdevice_many_notify() (part 1)
Two synchronize_net() calls are currently done while holding RTNL. This is source of RTNL contention in workloads adding and deleting many network namespaces per second, because synchronize_rcu() and synchronize_rcu_expedited() can use 60+ ms in some cases. For cleanup_net() use, temporarily release RTNL while calling the last synchronize_net(). This should be safe, because devices are no longer visible to other threads at this point. In any case, the new netdev_lock() / netdev_unlock() infrastructure that we are adding should allow to fix potential issues, with a combination of a per-device mutex and dev->reg_state awareness. Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Jesse Brandeburg <jbrandeburg@cloudflare.com> Link: https://patch.msgid.link/20250114205531.967841-5-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
cfa579f666
commit
ae646f1a0b
1 changed files with 3 additions and 0 deletions
|
@ -11629,6 +11629,7 @@ void unregister_netdevice_many_notify(struct list_head *head,
|
||||||
rtnl_drop_if_cleanup_net();
|
rtnl_drop_if_cleanup_net();
|
||||||
flush_all_backlogs();
|
flush_all_backlogs();
|
||||||
rtnl_acquire_if_cleanup_net();
|
rtnl_acquire_if_cleanup_net();
|
||||||
|
/* TODO: move this before the prior rtnl_acquire_if_cleanup_net() */
|
||||||
synchronize_net();
|
synchronize_net();
|
||||||
|
|
||||||
list_for_each_entry(dev, head, unreg_list) {
|
list_for_each_entry(dev, head, unreg_list) {
|
||||||
|
@ -11689,7 +11690,9 @@ void unregister_netdevice_many_notify(struct list_head *head,
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rtnl_drop_if_cleanup_net();
|
||||||
synchronize_net();
|
synchronize_net();
|
||||||
|
rtnl_acquire_if_cleanup_net();
|
||||||
|
|
||||||
list_for_each_entry(dev, head, unreg_list) {
|
list_for_each_entry(dev, head, unreg_list) {
|
||||||
netdev_put(dev, &dev->dev_registered_tracker);
|
netdev_put(dev, &dev->dev_registered_tracker);
|
||||||
|
|
Loading…
Add table
Reference in a new issue