[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250108162255.1306392-5-edumazet@google.com>
Date: Wed, 8 Jan 2025 16:22:55 +0000
From: Eric Dumazet <edumazet@...gle.com>
To: "David S . Miller" <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>
Cc: netdev@...r.kernel.org, Simon Horman <horms@...nel.org>, eric.dumazet@...il.com,
Eric Dumazet <edumazet@...gle.com>
Subject: [PATCH v2 net-next 4/4] net: reduce RTNL hold duration in unregister_netdevice_many_notify()
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 10+ ms in some cases.
For cleanup_net() use, temporarily release RTNL
while calling synchronize_net().
This should be safe, because devices are no longer visible
to other threads after the call to unlist_netdevice(),
and the netns are in dismantle phase.
Signed-off-by: Eric Dumazet <edumazet@...gle.com>
---
net/core/dev.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index 86fa9ae29d31a25dca8204c75fd39974ef84707d..dde5d40e8f6b1ad5309ebc6a6e163ddb96f66f73 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -11563,8 +11563,8 @@ void unregister_netdevice_many_notify(struct list_head *head,
rtnl_drop_if_cleanup_net();
flush_all_backlogs();
- rtnl_acquire_if_cleanup_net();
synchronize_net();
+ rtnl_acquire_if_cleanup_net();
list_for_each_entry(dev, head, unreg_list) {
struct sk_buff *skb = NULL;
@@ -11624,7 +11624,9 @@ void unregister_netdevice_many_notify(struct list_head *head,
#endif
}
+ rtnl_drop_if_cleanup_net();
synchronize_net();
+ rtnl_acquire_if_cleanup_net();
list_for_each_entry(dev, head, unreg_list) {
netdev_put(dev, &dev->dev_registered_tracker);
--
2.47.1.613.gc27f4b7a9f-goog
Powered by blists - more mailing lists