From: Jakub Kicinski Date: Thu, 16 Jan 2025 03:17:07 +0000 (-0800) Subject: Merge branch 'net-reduce-rtnl-pressure-in-unregister_netdevice' X-Git-Tag: v6.14-rc1~162^2~48 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=707ec6279dd12b785677976c045e0b9896ca1f2e;p=thirdparty%2Flinux.git Merge branch 'net-reduce-rtnl-pressure-in-unregister_netdevice' 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 --- 707ec6279dd12b785677976c045e0b9896ca1f2e diff --cc net/core/dev.c index b6722ed9767a9,3c87cb1cb8771..782ae3ff3f8d8 --- a/net/core/dev.c +++ b/net/core/dev.c @@@ -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;