vhost: fix deadlock with no multiqueue
PATCH 1/1 vhost: fix deadlock with no multiqueue
This deadlock happens when a guest, that had virtio ports with multi queues configured, does not announce the multi q feature in SET_FEATURES.
In such a situation, all vq locks are already taken before calling free_vq(), which itself takes the lock.
As mentioned in the code, in this situation, the virtio device is not running yet and no datapath thread is using the vq. So we can release the lock before calling free_vq().
Bugzilla ID: 1196
--- lib/vhost/vhost_user.c | 3 +++ 1 file changed, 3 insertions(+)
lib/vhost/vhost_user.c +3 -0
@@ -397,6 +397,9 @@ vhost_user_set_features(struct virtio_net **pdev, dev->virtqueue[dev->nr_vring] =NULL ;cleanup_vq (vq,1 );cleanup_vq_inflight (dev, vq); +/* vhost_user_lock_all_queue_pairs locked all qps */ +vq_assert_lock (dev, vq); +rte_spinlock_unlock (&vq->access_lock);free_vq (dev, vq); } }
Signature · 1 line
2.39.2
Quoted 23 lines · David Marchand
This deadlock happens when a guest, that had virtio ports with multi queues configured, does not announce the multi q feature in
SET_FEATURES.
In such a situation, all vq locks are already taken before callingfree_vq(), which itself takes the lock.As mentioned in the code, in this situation, the virtio device is not running yet and no datapath thread is using the vq. So we can release the lock before calling
free_vq().Bugzilla ID: 1196
Fixes 4b02c2673757 ("vhost: annotate async accesses")Signed-off-by David Marchand <[email protected]>--- lib/vhost/vhost_user.c | 3 +++ 1 file changed, 3 insertions(+)lib/vhost/vhost_user.c +0
-0
lib/vhost/vhost_user.c vhost_user_set_features(struct virtio_net **pdev, · line 405
Quoted 9 lines
lib/vhost/vhost_user.c +3
-0@@ -397,6 +397,9 @@ vhost_user_set_features(struct virtio_net **pdev, dev->virtqueue[dev->nr_vring] =NULL ;cleanup_vq (vq,1 );cleanup_vq_inflight (dev, vq); +/* vhost_user_lock_all_queue_pairs locked all qps */ +vq_assert_lock (dev, vq); +rte_spinlock_unlock (&vq->access_lock);free_vq (dev, vq); } }
Thanks,
Maxime
David Marchand
AppliedQuoted 11 lines · Maxime Coquelin
Quoted 10 lines · David Marchand
This deadlock happens when a guest, that had virtio ports with multi queues configured, does not announce the multi q feature in
SET_FEATURES.
In such a situation, all vq locks are already taken before callingfree_vq(), which itself takes the lock.As mentioned in the code, in this situation, the virtio device is not running yet and no datapath thread is using the vq. So we can release the lock before calling
free_vq().
Quoted 5 lines
Quoted 4 lines
Bugzilla ID: 1196
Fixes 4b02c2673757 ("vhost: annotate async accesses")Signed-off-by David Marchand <[email protected]>Reviewed-by Maxime Coquelin <[email protected]>
Applied, thanks.
Signature · 1 line
David Marchand