vdpa_sim: set last_used_idx as last_avail_idx in vdpasim_queue_ready
Eugenio Pérez
maintainerPATCH v2 1/1 vdpa_sim: set last_used_idx as last_avail_idx in vdpasim_queue_ready
Starting from an used_idx different than 0 is needed in use cases like virtual machine migration. Not doing so and letting the caller set an avail idx different than 0 causes destination device to try to use old buffers that source driver already recover and are not available anymore.
Since vdpa_sim does not support receive inflight descriptors as a destination of a migration, let's set both avail_idx and used_idx the same at vq start. This is how vhost-user works in a VHOST_SET_VRING_BASE call.
Although the simple fix is to set last_used_idx at vdpasim_set_vq_state, it would be reset at vdpasim_queue_ready. The last_avail_idx case is fixed with commit a09f493c ("vdpa_sim: not reset state in vdpasim_queue_ready"). Since the only option is to make it equal to last_avail_idx, adding the only change needed here.
This was discovered and tested live migrating the vdpa_sim_net device.
---
Cherry-picked from patch 2/2 of the series [1]. Differences are:
* Set the value of used_idx at vdpasim_queue_ready instead of fetching from the guest vring like vhost-kernel.
v2: Actually update last_used_idx only at vdpasim_queue_ready.
Note that commit id present in the patch text is not in master but in git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git.
[1] https://lkml.org/lkml/2023/1/18/1041
--- drivers/vdpa/vdpa_sim/vdpa_sim.c | 1 + 1 file changed, 1 insertion(+)
drivers/vdpa/vdpa_sim/vdpa_sim.c +1 -0
@@ -68,6 +68,7 @@ static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx) (uintptr_t)vq->device_addr); vq->vring.last_avail_idx = last_avail_idx; + vq->vring.last_used_idx = last_avail_idx; vq->vring.notify = vdpasim_vq_notify; }
Signature · 1 line
2.31.1
Quoted 42 lines · Eugenio Pérez
Starting from an
used_idxdifferent than 0 is needed in use cases like virtual machine migration. Not doing so and letting the caller set an avail idx different than 0 causes destination device to try to use old buffers that source driver already recover and are not available anymore.Since
vdpa_simdoes not support receive inflight descriptors as a destination of a migration, let's set bothavail_idxandused_idxthe same at vq start. This is how vhost-user works in aVHOST_SET_VRING_BASEcall.Although the simple fix is to set
last_used_idxatvdpasim_set_vq_state, it would be reset atvdpasim_queue_ready. Thelast_avail_idxcase is fixed with commita09f493c("vdpa_sim: not reset state invdpasim_queue_ready"). Since the only option is to make it equal tolast_avail_idx, adding the only change needed here.This was discovered and tested live migrating the
vdpa_sim_netdevice.Fixes 2c53d0f64c06 ("vdpasim: vDPA device simulator")Signed-off-by Eugenio Pérez <[email protected]>---
Cherry-picked from patch 2/2 of the series [1]. Differences are:
* Set the value ofused_idxatvdpasim_queue_readyinstead of fetching from the guest vring like vhost-kernel.v2: Actually update
last_used_idxonly atvdpasim_queue_ready.Note that commit id present in the patch text is not in master but in git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git.
[1] https://lkml.org/lkml/2023/1/18/1041
---drivers/vdpa/vdpa_sim/vdpa_sim.c| 1 +1 file changed, 1 insertion(+)drivers/vdpa/vdpa_sim/vdpa_sim.c +0
-0
drivers/vdpa/vdpa_sim/vdpa_sim.c static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx)
Quoted 8 lines
drivers/vdpa/vdpa_sim/vdpa_sim.c +1
-1@@ -68,6 +68,7 @@ static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx) (uintptr_t)vq->device_addr); vq->vring.last_avail_idx = last_avail_idx; + vq->vring.last_used_idx = last_avail_idx; vq->vring.notify = vdpasim_vq_notify; } -- 2.31.1
If you need to resend, I'd add a comment in the code following the commit description.
Anyway, the patch LGTM:
Thanks,
Stefano
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Eugenio Perez Martin
maintainerQuoted 56 lines · Stefano Garzarella
Quoted 42 lines · Eugenio Pérez
Starting from an
used_idxdifferent than 0 is needed in use cases like virtual machine migration. Not doing so and letting the caller set an avail idx different than 0 causes destination device to try to use old buffers that source driver already recover and are not available anymore.Since
vdpa_simdoes not support receive inflight descriptors as a destination of a migration, let's set bothavail_idxandused_idxthe same at vq start. This is how vhost-user works in aVHOST_SET_VRING_BASEcall.Although the simple fix is to set
last_used_idxatvdpasim_set_vq_state, it would be reset atvdpasim_queue_ready. Thelast_avail_idxcase is fixed with commita09f493c("vdpa_sim: not reset state invdpasim_queue_ready"). Since the only option is to make it equal tolast_avail_idx, adding the only change needed here.This was discovered and tested live migrating the
vdpa_sim_netdevice.Fixes 2c53d0f64c06 ("vdpasim: vDPA device simulator")Signed-off-by Eugenio Pérez <[email protected]>---
Cherry-picked from patch 2/2 of the series [1]. Differences are:
* Set the value ofused_idxatvdpasim_queue_readyinstead of fetching from the guest vring like vhost-kernel.v2: Actually update
last_used_idxonly atvdpasim_queue_ready.Note that commit id present in the patch text is not in master but in git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git.
[1] https://lkml.org/lkml/2023/1/18/1041
---drivers/vdpa/vdpa_sim/vdpa_sim.c| 1 +1 file changed, 1 insertion(+)drivers/vdpa/vdpa_sim/vdpa_sim.c +0
-0drivers/vdpa/vdpa_sim/vdpa_sim.c static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx)
Quoted 8 lines
drivers/vdpa/vdpa_sim/vdpa_sim.c +1
-1@@ -68,6 +68,7 @@ static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx) (uintptr_t)vq->device_addr); vq->vring.last_avail_idx = last_avail_idx; + vq->vring.last_used_idx = last_avail_idx; vq->vring.notify = vdpasim_vq_notify; } -- 2.31.1If you need to resend, I'd add a comment in the code following the commit description.
Quoted 4 lines
Anyway, the patch LGTM:
Reviewed-by Stefano Garzarella <[email protected]>
Added in v3, thanks for the review!
Quoted 3 lines
Thanks,
Stefano
Michael S. Tsirkin
maintainerQuoted 26 lines · Eugenio Pérez
Starting from an
used_idxdifferent than 0 is needed in use cases like virtual machine migration. Not doing so and letting the caller set an avail idx different than 0 causes destination device to try to use old buffers that source driver already recover and are not available anymore.Since
vdpa_simdoes not support receive inflight descriptors as a destination of a migration, let's set bothavail_idxandused_idxthe same at vq start. This is how vhost-user works in aVHOST_SET_VRING_BASEcall.Although the simple fix is to set
last_used_idxatvdpasim_set_vq_state, it would be reset atvdpasim_queue_ready. Thelast_avail_idxcase is fixed with commita09f493c("vdpa_sim: not reset state invdpasim_queue_ready"). Since the only option is to make it equal tolast_avail_idx, adding the only change needed here.This was discovered and tested live migrating the
vdpa_sim_netdevice.Fixes 2c53d0f64c06 ("vdpasim: vDPA device simulator")Signed-off-by Eugenio Pérez <[email protected]>---
Cherry-picked from patch 2/2 of the series [1]. Differences are:
* Set the value ofused_idxatvdpasim_queue_readyinstead of fetching from the guest vring like vhost-kernel.
Quoted 6 lines
v2: Actually update
last_used_idxonly atvdpasim_queue_ready.Note that commit id present in the patch text is not in master but in git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git.
Can you post with a fixed hash please?
Quoted 18 lines
--- drivers/vdpa/vdpa_sim/vdpa_sim.c | 1 + 1 file changed, 1 insertion(+)drivers/vdpa/vdpa_sim/vdpa_sim.c +1
-0@@ -68,6 +68,7 @@ static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx) (uintptr_t)vq->device_addr); vq->vring.last_avail_idx = last_avail_idx; + vq->vring.last_used_idx = last_avail_idx; vq->vring.notify = vdpasim_vq_notify; }Signature · 1 line
2.31.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Eugenio Perez Martin
maintainerQuoted 30 lines · Michael S. Tsirkin
Quoted 28 lines · Eugenio Pérez
Starting from an
used_idxdifferent than 0 is needed in use cases like virtual machine migration. Not doing so and letting the caller set an avail idx different than 0 causes destination device to try to use old buffers that source driver already recover and are not available anymore.Since
vdpa_simdoes not support receive inflight descriptors as a destination of a migration, let's set bothavail_idxandused_idxthe same at vq start. This is how vhost-user works in aVHOST_SET_VRING_BASEcall.Although the simple fix is to set
last_used_idxatvdpasim_set_vq_state, it would be reset atvdpasim_queue_ready. Thelast_avail_idxcase is fixed with commita09f493c("vdpa_sim: not reset state invdpasim_queue_ready"). Since the only option is to make it equal tolast_avail_idx, adding the only change needed here.This was discovered and tested live migrating the
vdpa_sim_netdevice.Fixes 2c53d0f64c06 ("vdpasim: vDPA device simulator")Signed-off-by Eugenio Pérez <[email protected]>---
Cherry-picked from patch 2/2 of the series [1]. Differences are:
* Set the value ofused_idxatvdpasim_queue_readyinstead of fetching from the guest vring like vhost-kernel.v2: Actually update
last_used_idxonly atvdpasim_queue_ready.
Quoted 8 lines
Quoted 4 lines
Note that commit id present in the patch text is not in master but in git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git.
Can you post with a fixed hash please?
Sent v3, please let me know if I need to do further modifications.
Thanks!
Quoted 19 lines
Quoted 18 lines
--- drivers/vdpa/vdpa_sim/vdpa_sim.c | 1 + 1 file changed, 1 insertion(+)drivers/vdpa/vdpa_sim/vdpa_sim.c +1
-1@@ -68,6 +68,7 @@ static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx) (uintptr_t)vq->device_addr); vq->vring.last_avail_idx = last_avail_idx; + vq->vring.last_used_idx = last_avail_idx; vq->vring.notify = vdpasim_vq_notify; } --2.31.1