net: avoid quadratic behavior in netdev_wait_allrefs_any()
Subsystems (2)
PATCH 1/1 net: avoid quadratic behavior in netdev_wait_allrefs_any()
From: Eric Dumazet <[email protected]>
If the list of devices has N elements, netdev_wait_allrefs_any() is called N times, and linkwatch_forget_dev() is called N*(N-1)/2 times.
Fix this by calling linkwatch_forget_dev() only once per device.
--- net/core/dev.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
net/core/dev.c +1 -3
@@ -9828,9 +9828,6 @@ static struct net_device *netdev_wait_allrefs_any(struct list_head *list)struct net_device *dev;int wait =0 ; -list_for_each_entry (dev, list, todo_list) -linkwatch_forget_dev (dev); - rebroadcast_time = warning_time = jiffies;list_for_each_entry (dev, list, todo_list)
@@ -9951,6 +9948,7 @@ void netdev_run_todo(void) } dev->reg_state =NETREG_UNREGISTERED ; +linkwatch_forget_dev (dev); }while (!list_empty (&list)) {
Signature · 1 line
2.35.1.265.g69c8d7142f-goog
Jakub Kicinski
maintainerQuoted 9 lines · On Thu, 17 Feb 2022 22:54:30 -0800 Eric Dumazet wrote:
From: Eric Dumazet <[email protected]>
If the list of devices has N elements,
netdev_wait_allrefs_any()is called N times, andlinkwatch_forget_dev()is called N*(N-1)/2 times.Fix this by calling
linkwatch_forget_dev()only once per device.Fixes faab39f63c1f ("net: allow out-of-order netdev unregistration")Signed-off-by Eric Dumazet <[email protected]>
Yup, I was on the fence on this one, I went for keeping all linkwatch stuff in one function and minimal changes. Clearly underestimated the number of netdevs your cases are destroying at once :)
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Thu, 17 Feb 2022 22:54:30 -0800 you wrote:
From: Eric Dumazet <[email protected]>
If the list of devices has N elements,
netdev_wait_allrefs_any()is called N times, andlinkwatch_forget_dev()is called N*(N-1)/2 times.Fix this by calling
linkwatch_forget_dev()only once per device.[...]
Here is the summary with links:
- [net-next] net: avoid quadratic behavior in netdev_wait_allrefs_any()
https://git.kernel.org/netdev/net-next/c/86213f80da1b
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html