提交 c051cdf1 编写于 作者: E Eric Dumazet 提交者: Zheng Zengkai

net: avoid quadratic behavior in netdev_wait_allrefs_any()

net-next inclusion
from net-next-v5.17-rc5
commit 86213f80
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4VZN0?from=project-issue

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=86213f80da1b1d007721cc22e04b5f5d0da33127

--------------------------------

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: faab39f6 ("net: allow out-of-order netdev unregistration")
Signed-off-by: NEric Dumazet <edumazet@google.com>
Link: https://lore.kernel.org/r/20220218065430.2613262-1-eric.dumazet@gmail.comSigned-off-by: NJakub Kicinski <kuba@kernel.org>
Signed-off-by: NZiyang Xuan <william.xuanziyang@huawei.com>
Reviewed-by: NWei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 8755374c
...@@ -10261,9 +10261,6 @@ static struct net_device *netdev_wait_allrefs_any(struct list_head *list) ...@@ -10261,9 +10261,6 @@ static struct net_device *netdev_wait_allrefs_any(struct list_head *list)
struct net_device *dev; struct net_device *dev;
int wait = 0; int wait = 0;
list_for_each_entry(dev, list, todo_list)
linkwatch_forget_dev(dev);
rebroadcast_time = warning_time = jiffies; rebroadcast_time = warning_time = jiffies;
list_for_each_entry(dev, list, todo_list) list_for_each_entry(dev, list, todo_list)
...@@ -10380,6 +10377,7 @@ void netdev_run_todo(void) ...@@ -10380,6 +10377,7 @@ void netdev_run_todo(void)
} }
dev->reg_state = NETREG_UNREGISTERED; dev->reg_state = NETREG_UNREGISTERED;
linkwatch_forget_dev(dev);
} }
while (!list_empty(&list)) { while (!list_empty(&list)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册