Commit e3f78718 authored by Jean-Philippe Brucker's avatar Jean-Philippe Brucker Committed by David S. Miller

vhost: fix IOTLB locking

Commit 78139c94 ("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: 78139c94 ("net: vhost: lock the vqs one by one")
Acked-by: default avatarJason Wang <jasowang@redhat.com>
Acked-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarJean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4763c9f9
...@@ -944,10 +944,7 @@ static void vhost_iotlb_notify_vq(struct vhost_dev *d, ...@@ -944,10 +944,7 @@ static void vhost_iotlb_notify_vq(struct vhost_dev *d,
if (msg->iova <= vq_msg->iova && if (msg->iova <= vq_msg->iova &&
msg->iova + msg->size - 1 >= vq_msg->iova && msg->iova + msg->size - 1 >= vq_msg->iova &&
vq_msg->type == VHOST_IOTLB_MISS) { vq_msg->type == VHOST_IOTLB_MISS) {
mutex_lock(&node->vq->mutex);
vhost_poll_queue(&node->vq->poll); vhost_poll_queue(&node->vq->poll);
mutex_unlock(&node->vq->mutex);
list_del(&node->node); list_del(&node->node);
kfree(node); kfree(node);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment