Skip to content

Commit 86213f8

Browse files
edumazetkuba-moo
authored andcommitted
net: avoid quadratic behavior in netdev_wait_allrefs_any()
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. Fixes: faab39f ("net: allow out-of-order netdev unregistration") Signed-off-by: Eric Dumazet <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 086d490 commit 86213f8

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

net/core/dev.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9828,9 +9828,6 @@ static struct net_device *netdev_wait_allrefs_any(struct list_head *list)
98289828
struct net_device *dev;
98299829
int wait = 0;
98309830

9831-
list_for_each_entry(dev, list, todo_list)
9832-
linkwatch_forget_dev(dev);
9833-
98349831
rebroadcast_time = warning_time = jiffies;
98359832

98369833
list_for_each_entry(dev, list, todo_list)
@@ -9951,6 +9948,7 @@ void netdev_run_todo(void)
99519948
}
99529949

99539950
dev->reg_state = NETREG_UNREGISTERED;
9951+
linkwatch_forget_dev(dev);
99549952
}
99559953

99569954
while (!list_empty(&list)) {

0 commit comments

Comments
 (0)