* [PATCH 0/2] vhost: Get vring base from vq, not svq
@ 2022-07-15 7:25 Eugenio Pérez
2022-07-15 7:25 ` [PATCH 1/2] " Eugenio Pérez
2022-07-15 7:25 ` [PATCH 2/2] vhost: Move SVQ queue rewind to the destination Eugenio Pérez
0 siblings, 2 replies; 3+ messages in thread
From: Eugenio Pérez @ 2022-07-15 7:25 UTC (permalink / raw)
To: qemu-devel; +Cc: Jason Wang, Michael S. Tsirkin
The SVQ vring used idx usually match with the guest visible one, as long
as all the guest buffers (GPA) maps to exactly one buffer within qemu's
VA. However, as we can see in virtqueue_map_desc, a single guest buffer
could map to many buffers in SVQ vring.
The solution is to stop using the device's used idx and check for the
last avail idx. Since we cannot report in-flight descriptors with vdpa,
let's rewind all of them.
Also, move this rewind to the destination, so we keep migrating the in-flight
ones in case the destnation backend support them (vhost-kernel, emulated virtio
in qemu, etc.)
Eugenio Pérez (2):
vhost: Get vring base from vq, not svq
vhost: Move SVQ queue rewind to the destination
hw/virtio/vhost-vdpa.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
--
2.31.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] vhost: Get vring base from vq, not svq
2022-07-15 7:25 [PATCH 0/2] vhost: Get vring base from vq, not svq Eugenio Pérez
@ 2022-07-15 7:25 ` Eugenio Pérez
2022-07-15 7:25 ` [PATCH 2/2] vhost: Move SVQ queue rewind to the destination Eugenio Pérez
1 sibling, 0 replies; 3+ messages in thread
From: Eugenio Pérez @ 2022-07-15 7:25 UTC (permalink / raw)
To: qemu-devel; +Cc: Jason Wang, Michael S. Tsirkin
The SVQ vring used idx usually match with the guest visible one, as long
as all the guest buffers (GPA) maps to exactly one buffer within qemu's
VA. However, as we can see in virtqueue_map_desc, a single guest buffer
could map to many buffers in SVQ vring.
The solution is to stop using the device's used idx and check for the
last avail idx. Since we cannot report in-flight descriptors with vdpa,
let's rewind all of them.
Fixes: 6d0b22266633 ("vdpa: Adapt vhost_vdpa_get_vring_base to SVQ")
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
hw/virtio/vhost-vdpa.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 795ed5a049..18820498b3 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -1194,11 +1194,10 @@ static int vhost_vdpa_get_vring_base(struct vhost_dev *dev,
struct vhost_vring_state *ring)
{
struct vhost_vdpa *v = dev->opaque;
- int vdpa_idx = ring->index - dev->vq_index;
int ret;
if (v->shadow_vqs_enabled) {
- VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, vdpa_idx);
+ VirtQueue *vq = virtio_get_queue(dev->vdev, ring->index);
/*
* Setting base as last used idx, so destination will see as available
@@ -1208,7 +1207,10 @@ static int vhost_vdpa_get_vring_base(struct vhost_dev *dev,
* TODO: This is ok for networking, but other kinds of devices might
* have problems with these retransmissions.
*/
- ring->num = svq->last_used_idx;
+ while (virtqueue_rewind(vq, 1)) {
+ continue;
+ }
+ ring->num = virtio_queue_get_last_avail_idx(dev->vdev, ring->index);
return 0;
}
--
2.31.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] vhost: Move SVQ queue rewind to the destination
2022-07-15 7:25 [PATCH 0/2] vhost: Get vring base from vq, not svq Eugenio Pérez
2022-07-15 7:25 ` [PATCH 1/2] " Eugenio Pérez
@ 2022-07-15 7:25 ` Eugenio Pérez
1 sibling, 0 replies; 3+ messages in thread
From: Eugenio Pérez @ 2022-07-15 7:25 UTC (permalink / raw)
To: qemu-devel; +Cc: Jason Wang, Michael S. Tsirkin
Migration with SVQ already migrate the inflight descriptors, so the
destination can perform the work.
This makes easier to migrate between backends or to recover them in
vhost devices that support set in flight descriptors.
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
hw/virtio/vhost-vdpa.c | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 18820498b3..4458c8d23e 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -1178,7 +1178,18 @@ static int vhost_vdpa_set_vring_base(struct vhost_dev *dev,
struct vhost_vring_state *ring)
{
struct vhost_vdpa *v = dev->opaque;
+ VirtQueue *vq = virtio_get_queue(dev->vdev, ring->index);
+ /*
+ * vhost-vdpa devices does not support in-flight requests. Set all of them
+ * as available.
+ *
+ * TODO: This is ok for networking, but other kinds of devices might
+ * have problems with these retransmissions.
+ */
+ while (virtqueue_rewind(vq, 1)) {
+ continue;
+ }
if (v->shadow_vqs_enabled) {
/*
* Device vring base was set at device start. SVQ base is handled by
@@ -1197,19 +1208,6 @@ static int vhost_vdpa_get_vring_base(struct vhost_dev *dev,
int ret;
if (v->shadow_vqs_enabled) {
- VirtQueue *vq = virtio_get_queue(dev->vdev, ring->index);
-
- /*
- * Setting base as last used idx, so destination will see as available
- * all the entries that the device did not use, including the in-flight
- * processing ones.
- *
- * TODO: This is ok for networking, but other kinds of devices might
- * have problems with these retransmissions.
- */
- while (virtqueue_rewind(vq, 1)) {
- continue;
- }
ring->num = virtio_queue_get_last_avail_idx(dev->vdev, ring->index);
return 0;
}
--
2.31.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-07-15 7:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-15 7:25 [PATCH 0/2] vhost: Get vring base from vq, not svq Eugenio Pérez
2022-07-15 7:25 ` [PATCH 1/2] " Eugenio Pérez
2022-07-15 7:25 ` [PATCH 2/2] vhost: Move SVQ queue rewind to the destination Eugenio Pérez
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).