Skip to content

Commit ae646f1

Browse files
edumazetkuba-moo
authored andcommitted
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>
1 parent cfa579f commit ae646f1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

net/core/dev.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11629,6 +11629,7 @@ void unregister_netdevice_many_notify(struct list_head *head,
1162911629
rtnl_drop_if_cleanup_net();
1163011630
flush_all_backlogs();
1163111631
rtnl_acquire_if_cleanup_net();
11632+
/* TODO: move this before the prior rtnl_acquire_if_cleanup_net() */
1163211633
synchronize_net();
1163311634

1163411635
list_for_each_entry(dev, head, unreg_list) {
@@ -11689,7 +11690,9 @@ void unregister_netdevice_many_notify(struct list_head *head,
1168911690
#endif
1169011691
}
1169111692

11693+
rtnl_drop_if_cleanup_net();
1169211694
synchronize_net();
11695+
rtnl_acquire_if_cleanup_net();
1169311696

1169411697
list_for_each_entry(dev, head, unreg_list) {
1169511698
netdev_put(dev, &dev->dev_registered_tracker);

0 commit comments

Comments
 (0)