“b3a3c03c38666a9d6e0d5ff52e81d7e4135f689e”上不存在“...net/ethernet/git@gitcode.net:openharmony/kernel_linux.git”
提交 762ac965 编写于 作者: J Jeff Dike 提交者: Yang Yingliang

virtio_net: Fix recursive call to cpus_read_lock()

stable inclusion
from linux-4.19.167
commit 6413249a00b145454cc111a17742a6eda821b60b

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

[ Upstream commit de33212f ]

virtnet_set_channels can recursively call cpus_read_lock if CONFIG_XPS
and CONFIG_HOTPLUG are enabled.

The path is:
    virtnet_set_channels - calls get_online_cpus(), which is a trivial
wrapper around cpus_read_lock()
    netif_set_real_num_tx_queues
    netif_reset_xps_queues_gt
    netif_reset_xps_queues - calls cpus_read_lock()

This call chain and potential deadlock happens when the number of TX
queues is reduced.

This commit the removes netif_set_real_num_[tr]x_queues calls from
inside the get/put_online_cpus section, as they don't require that it
be held.

Fixes: 47be2479 ("virtio-net: fix the set affinity bug when CPU IDs are not consecutive")
Signed-off-by: NJeff Dike <jdike@akamai.com>
Acked-by: NJason Wang <jasowang@redhat.com>
Acked-by: NMichael S. Tsirkin <mst@redhat.com>
Link: https://lore.kernel.org/r/20201223025421.671-1-jdike@akamai.comSigned-off-by: NJakub Kicinski <kuba@kernel.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NCheng Jian <cj.chengjian@huawei.com>
上级 c772b032
...@@ -2075,14 +2075,16 @@ static int virtnet_set_channels(struct net_device *dev, ...@@ -2075,14 +2075,16 @@ static int virtnet_set_channels(struct net_device *dev,
get_online_cpus(); get_online_cpus();
err = _virtnet_set_queues(vi, queue_pairs); err = _virtnet_set_queues(vi, queue_pairs);
if (!err) { if (err) {
netif_set_real_num_tx_queues(dev, queue_pairs); put_online_cpus();
netif_set_real_num_rx_queues(dev, queue_pairs); goto err;
virtnet_set_affinity(vi);
} }
virtnet_set_affinity(vi);
put_online_cpus(); put_online_cpus();
netif_set_real_num_tx_queues(dev, queue_pairs);
netif_set_real_num_rx_queues(dev, queue_pairs);
err:
return err; return err;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册