Skip to content

Commit 83419b6

Browse files
edumazetkuba-moo
authored andcommitted
net: reduce RTNL hold duration in unregister_netdevice_many_notify() (part 2)
One synchronize_net() call is 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 after unlist_netdevice() call and setting dev->reg_state to NETREG_UNREGISTERING. 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-6-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent ae646f1 commit 83419b6

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

net/core/dev.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11628,9 +11628,8 @@ void unregister_netdevice_many_notify(struct list_head *head,
1162811628

1162911629
rtnl_drop_if_cleanup_net();
1163011630
flush_all_backlogs();
11631-
rtnl_acquire_if_cleanup_net();
11632-
/* TODO: move this before the prior rtnl_acquire_if_cleanup_net() */
1163311631
synchronize_net();
11632+
rtnl_acquire_if_cleanup_net();
1163411633

1163511634
list_for_each_entry(dev, head, unreg_list) {
1163611635
struct sk_buff *skb = NULL;

0 commit comments

Comments
 (0)