]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
Merge branch 'net-reduce-rtnl-pressure-in-unregister_netdevice'
authorJakub Kicinski <kuba@kernel.org>
Thu, 16 Jan 2025 03:17:07 +0000 (19:17 -0800)
committerJakub Kicinski <kuba@kernel.org>
Thu, 16 Jan 2025 03:17:08 +0000 (19:17 -0800)
Eric Dumazet says:

====================
net: reduce RTNL pressure in unregister_netdevice()

One major source of RTNL contention resides in unregister_netdevice()

Due to RCU protection of various network structures, and
unregister_netdevice() being a synchronous function,
it is calling potentially slow functions while holding RTNL.

I think we can release RTNL in two points, so that three
slow functions are called while RTNL can be used
by other threads.

v1: https://lore.kernel.org/netdev/20250107130906.098fc8d6@kernel.org/T/#m398c95f5778e1ff70938e079d3c4c43c050ad2a6
====================

Link: https://patch.msgid.link/20250114205531.967841-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1  2 
net/core/dev.c

diff --cc net/core/dev.c
index b6722ed9767a9e8ec0232e9b4f2f5e6408453fe2,3c87cb1cb87716c249473fbf02e5ce50a012160c..782ae3ff3f8d894789ea685f53b3b1899e1a14b3
@@@ -11724,13 -11623,13 +11772,15 @@@ void unregister_netdevice_many_notify(s
        list_for_each_entry(dev, head, unreg_list) {
                /* And unlink it from device chain. */
                unlist_netdevice(dev);
 +              netdev_lock(dev);
                WRITE_ONCE(dev->reg_state, NETREG_UNREGISTERING);
 +              netdev_unlock(dev);
        }
-       flush_all_backlogs();
  
+       rtnl_drop_if_cleanup_net();
+       flush_all_backlogs();
        synchronize_net();
+       rtnl_acquire_if_cleanup_net();
  
        list_for_each_entry(dev, head, unreg_list) {
                struct sk_buff *skb = NULL;