Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

vhost: fix IOTLB locking

Commit 78139c94dc8c ("net: vhost: lock the vqs one by one") moved the vq
lock to improve scalability, but introduced a possible deadlock in
vhost-iotlb. vhost_iotlb_notify_vq() now takes vq->mutex while holding
the device's IOTLB spinlock. And on the vhost_iotlb_miss() path, the
spinlock is taken while holding vq->mutex.

Since calling vhost_poll_queue() doesn't require any lock, avoid the
deadlock by not taking vq->mutex.

Fixes: 78139c94dc8c ("net: vhost: lock the vqs one by one")
Acked-by: Jason Wang <jasowang@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Jean-Philippe Brucker and committed by
David S. Miller
e3f78718 4763c9f9

-3
-3
drivers/vhost/vhost.c
··· 944 944 if (msg->iova <= vq_msg->iova && 945 945 msg->iova + msg->size - 1 >= vq_msg->iova && 946 946 vq_msg->type == VHOST_IOTLB_MISS) { 947 - mutex_lock(&node->vq->mutex); 948 947 vhost_poll_queue(&node->vq->poll); 949 - mutex_unlock(&node->vq->mutex); 950 - 951 948 list_del(&node->node); 952 949 kfree(node); 953 950 }