vdpa: Add resume operation
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): 491fb8fe786739958eb9ff3df2250a4188b0bbe5.1665745877.git.sebastien.boeuf@intel.com
Jason Wang
Acked-byQuoted 7 lines · On Fri, Oct 14, 2022 at 7:14 PM <[email protected]> wrote:
From: Sebastien Boeuf <[email protected]>
Add a new operation to allow a vDPA device to be resumed after it has been suspended. Trying to resume a device that wasn't suspended will result in a no-op.
Quoted 5 lines
This operation is optional. If it's not implemented, the associated backend feature bit will not be exposed. And if the feature bit is not exposed, invoking this operation will return an error.
Signed-off-by Sebastien Boeuf <[email protected]>
Quoted 38 lines
--- include/linux/vdpa.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)include/linux/vdpa.h +5
-2@@ -219,7 +219,10 @@ struct vdpa_map_file {* @reset: Reset device * @vdev: vdpa device * Returns integer: success (0) or error (< 0) -* @suspend: Suspend or resume the device (optional) +* @suspend: Suspend the device (optional) +* @vdev: vdpa device +* Returns integer: success (0) or error (< 0) +* @resume: Resume the device (optional) * @vdev: vdpa device * Returns integer: success (0) or error (< 0) * @get_config_size: Get the size of the configuration space includes @@ -324,6 +327,7 @@ struct vdpa_config_ops {void (*set_status)(struct vdpa_device *vdev,u8 status);int (*reset)(struct vdpa_device *vdev);int (*suspend)(struct vdpa_device *vdev); +int (*resume)(struct vdpa_device *vdev);size_t (*get_config_size)(struct vdpa_device *vdev);void (*get_config)(struct vdpa_device *vdev,unsigned int offset,void *buf,unsigned int len); --2.34.1
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company) Registered headquarters: "Les Montalets"- 2, rue de Paris, 92196 Meudon Cedex, France
Registration Number: 302 456 199R.C.S. NANTERRE
Capital: 5 208 026.16 Euros
Quoted 5 lines
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Hi,
I don't know why but it looks that this series wasn't showing up in the list for some reason. Only the recipients in the To or Cc lines seemed able to get it. Would it be possible to fix the mail client or include me to the thread for review?
Thanks,
-Siwei
Quoted 52 lines · Jason Wang
Quoted 11 lines · On Fri, Oct 14, 2022 at 7:14 PM <[email protected]> wrote:
From: Sebastien Boeuf <[email protected]>
Add a new operation to allow a vDPA device to be resumed after it has been suspended. Trying to resume a device that wasn't suspended will result in a no-op.
This operation is optional. If it's not implemented, the associated backend feature bit will not be exposed. And if the feature bit is not exposed, invoking this operation will return an error.
Signed-off-by Sebastien Boeuf <[email protected]>Acked-by Jason Wang <[email protected]>Quoted 38 lines
--- include/linux/vdpa.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)include/linux/vdpa.h +5
-2@@ -219,7 +219,10 @@ struct vdpa_map_file {* @reset: Reset device * @vdev: vdpa device * Returns integer: success (0) or error (< 0) -* @suspend: Suspend or resume the device (optional) +* @suspend: Suspend the device (optional) +* @vdev: vdpa device +* Returns integer: success (0) or error (< 0) +* @resume: Resume the device (optional) * @vdev: vdpa device * Returns integer: success (0) or error (< 0) * @get_config_size: Get the size of the configuration space includes @@ -324,6 +327,7 @@ struct vdpa_config_ops {void (*set_status)(struct vdpa_device *vdev,u8 status);int (*reset)(struct vdpa_device *vdev);int (*suspend)(struct vdpa_device *vdev); +int (*resume)(struct vdpa_device *vdev);size_t (*get_config_size)(struct vdpa_device *vdev);void (*get_config)(struct vdpa_device *vdev,unsigned int offset,void *buf,unsigned int len); --2.34.1
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company) Registered headquarters: "Les Montalets"- 2, rue de Paris, 92196 Meudon Cedex, France
Registration Number: 302 456 199R.C.S. NANTERRE
Capital: 5 208 026.16 Euros
Quoted 10 lines
Quoted 5 lines
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Michael S. Tsirkin
maintainerQuoted 10 lines · Si-Wei Liu
Hi,
I don't know why but it looks that this series wasn't showing up in the list for some reason. Only the recipients in the To or Cc lines seemed able to get it. Would it be possible to fix the mail client or include me to the thread for review?
Thanks,
-Siwei
This is true! I didn't notice.
Sebastien the fix is not to Cc Si-Wei - please fix your setup and repost, confirm the patches are on list. I am not merging patches that were not on the list.
thanks!
Quoted 54 lines · Jason Wang
Quoted 52 lines · On Fri, Oct 14, 2022 at 7:14 PM <[email protected]> wrote:
Quoted 11 lines
From: Sebastien Boeuf <[email protected]>
Add a new operation to allow a vDPA device to be resumed after it has been suspended. Trying to resume a device that wasn't suspended will result in a no-op.
This operation is optional. If it's not implemented, the associated backend feature bit will not be exposed. And if the feature bit is not exposed, invoking this operation will return an error.
Signed-off-by Sebastien Boeuf <[email protected]>Acked-by Jason Wang <[email protected]>Quoted 38 lines
--- include/linux/vdpa.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)include/linux/vdpa.h +5
-2@@ -219,7 +219,10 @@ struct vdpa_map_file {* @reset: Reset device * @vdev: vdpa device * Returns integer: success (0) or error (< 0) -* @suspend: Suspend or resume the device (optional) +* @suspend: Suspend the device (optional) +* @vdev: vdpa device +* Returns integer: success (0) or error (< 0) +* @resume: Resume the device (optional) * @vdev: vdpa device * Returns integer: success (0) or error (< 0) * @get_config_size: Get the size of the configuration space includes @@ -324,6 +327,7 @@ struct vdpa_config_ops {void (*set_status)(struct vdpa_device *vdev,u8 status);int (*reset)(struct vdpa_device *vdev);int (*suspend)(struct vdpa_device *vdev); +int (*resume)(struct vdpa_device *vdev);size_t (*get_config_size)(struct vdpa_device *vdev);void (*get_config)(struct vdpa_device *vdev,unsigned int offset,void *buf,unsigned int len); --2.34.1
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company) Registered headquarters: "Les Montalets"- 2, rue de Paris, 92196 Meudon Cedex, France
Registration Number: 302 456 199R.C.S. NANTERRE
Capital: 5 208 026.16 Euros
Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
A message that is not in the archive (sent off-list or not yet received): df57ddc44ed8950dc79c63597e3091b1da551959.1665745877.git.sebastien.boeuf@intel.com
Jason Wang
Acked-byRe: [PATCH v2 2/4] vhost-vdpa: Introduce RESUME backend feature bit
Quoted 11 lines · On Fri, Oct 14, 2022 at 7:15 PM <[email protected]> wrote:
From: Sebastien Boeuf <[email protected]>
Userspace knows if the device can be resumed or not by checking this feature bit.
It's only exposed if the vdpa driver backend implements the
resume()operation callback. Userspace trying to negotiate this feature when it hasn't been exposed will result in an error.Signed-off-by Sebastien Boeuf <[email protected]>
Quoted 72 lines
--- drivers/vhost/vdpa.c | 16 +++++++++++++++- include/uapi/linux/vhost_types.h | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-)drivers/vhost/vdpa.c +15
-1@@ -355,6 +355,14 @@ static bool vhost_vdpa_can_suspend(const struct vhost_vdpa *v)return ops->suspend; } +static bool vhost_vdpa_can_resume (const struct vhost_vdpa *v) +{ +struct vdpa_device *vdpa = v->vdpa; +const struct vdpa_config_ops *ops = vdpa->config; + +return ops->resume; +} +static long vhost_vdpa_get_features (struct vhost_vdpa *v,u64 __user *featurep) {struct vdpa_device *vdpa = v->vdpa;@@ -602,11 +610,15 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep,if (copy_from_user (&features, featurep,sizeof (features)))return -EFAULT ;if (features & ~(VHOST_VDPA_BACKEND_FEATURES | -BIT_ULL (VHOST_BACKEND_F_SUSPEND ))) +BIT_ULL (VHOST_BACKEND_F_SUSPEND ) | +BIT_ULL (VHOST_BACKEND_F_RESUME )))return -EOPNOTSUPP ;if ((features &BIT_ULL (VHOST_BACKEND_F_SUSPEND )) && !vhost_vdpa_can_suspend (v))return -EOPNOTSUPP ; +if ((features &BIT_ULL (VHOST_BACKEND_F_RESUME )) && + !vhost_vdpa_can_resume (v)) +return -EOPNOTSUPP ;vhost_set_backend_features (&v->vdev, features);return 0 ; }@@ -658,6 +670,8 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep, features =VHOST_VDPA_BACKEND_FEATURES ;if (vhost_vdpa_can_suspend (v)) features |=BIT_ULL (VHOST_BACKEND_F_SUSPEND ); +if (vhost_vdpa_can_resume (v)) + features |=BIT_ULL (VHOST_BACKEND_F_RESUME );if (copy_to_user (featurep, &features,sizeof (features))) r = -EFAULT ;break ;include/uapi/linux/vhost_types.h +2
-1@@ -163,5 +163,7 @@ struct vhost_vdpa_iova_range {#define VHOST_BACKEND_F_IOTLB_ASID 0x3/* Device can be suspended */ #define VHOST_BACKEND_F_SUSPEND 0x4 +/* Device can be resumed */ +#define VHOST_BACKEND_F_RESUME 0x5#endif --2.34.1
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company) Registered headquarters: "Les Montalets"- 2, rue de Paris, 92196 Meudon Cedex, France
Registration Number: 302 456 199R.C.S. NANTERRE
Capital: 5 208 026.16 Euros
Quoted 5 lines
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
A message that is not in the archive (sent off-list or not yet received): d23b16abdc15f5e2aa1430cf48101dd256638809.1665745877.git.sebastien.boeuf@intel.com
Jason Wang
Acked-byRe: [PATCH v2 3/4] vhost-vdpa: uAPI to resume the device
Quoted 8 lines · On Fri, Oct 14, 2022 at 7:15 PM <[email protected]> wrote:
From: Sebastien Boeuf <[email protected]>
This new ioctl adds support for resuming the device from userspace.
This is required when trying to restore the device in a functioning state after it's been suspended. It is already possible to reset a suspended device,
Nit: And should we allow resume a non suspended device? Do we need to document this requirement somewhere?
Quoted 10 lines
but that means the device must be reconfigured and
all the IOMMU/IOTLB mappings must be recreated. This new operation allows the device to be resumed without going through a full reset.This is particularly useful when trying to perform offline migration of a virtual machine (also known as snapshot/restore) as it allows the VMM to resume the virtual machine back to a running state after the snapshot is performed.
Signed-off-by Sebastien Boeuf <[email protected]>
Quoted 68 lines
--- drivers/vhost/vdpa.c | 18 ++++++++++++++++++ include/uapi/linux/vhost.h | 8 ++++++++ 2 files changed, 26 insertions(+)drivers/vhost/vdpa.c +18
-0@@ -502,6 +502,21 @@ static long vhost_vdpa_suspend(struct vhost_vdpa *v)return ops->suspend (vdpa); } +/* After a successful return of this ioctl the device resumes processing +* virtqueue descriptors. The device becomes fully operational the same way it +* was before it was suspended. +*/ +static long vhost_vdpa_resume (struct vhost_vdpa *v) +{ +struct vdpa_device *vdpa = v->vdpa; +const struct vdpa_config_ops *ops = vdpa->config; + +if (!ops->resume) +return -EOPNOTSUPP ; + +return ops->resume (vdpa); +} +static long vhost_vdpa_vring_ioctl (struct vhost_vdpa *v,unsigned int cmd,void __user *argp) {@@ -687,6 +702,9 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep,case VHOST_VDPA_SUSPEND : r =vhost_vdpa_suspend (v);break ; +case VHOST_VDPA_RESUME : + r =vhost_vdpa_resume (v); +break ;default : r =vhost_dev_ioctl (&v->vdev, cmd, argp);if (r == -ENOIOCTLCMD )include/uapi/linux/vhost.h +8
-1@@ -180,4 +180,12 @@*/ #define VHOST_VDPA_SUSPEND _IO(VHOST_VIRTIO, 0x7D) +/* Resume a device so it can resume processing virtqueue requests +* +* After the return of this ioctl the device will have restored all the +* necessary states and it is fully operational to continue processing the +* virtqueue descriptors. +*/ +#define VHOST_VDPA_RESUME _IO(VHOST_VIRTIO, 0x7E) +#endif --2.34.1
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company) Registered headquarters: "Les Montalets"- 2, rue de Paris, 92196 Meudon Cedex, France
Registration Number: 302 456 199R.C.S. NANTERRE
Capital: 5 208 026.16 Euros
Quoted 5 lines
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
A message that is not in the archive (sent off-list or not yet received): bdbf1921652c93e372b1e283cd9367a9b5f31447.1665745877.git.sebastien.boeuf@intel.com
Re: [PATCH v2 4/4] vdpa_sim: Implement resume vdpa op
Quoted 17 lines · On Fri, Oct 14, 2022 at 7:15 PM <[email protected]> wrote:
From: Sebastien Boeuf <[email protected]>
Implement resume operation for
vdpa_simdevices, so vhost-vdpa will offer that backend feature and userspace can effectively resume the device.Signed-off-by Sebastien Boeuf <[email protected]>--- drivers/vdpa/vdpa_sim/vdpa_sim.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/vdpa/vdpa_sim/vdpa_sim.c +0
-0
drivers/vdpa/vdpa_sim/vdpa_sim.c static int vdpasim_suspend(struct vdpa_device *vdpa) · line 536
Quoted 10 lines
drivers/vdpa/vdpa_sim/vdpa_sim.c +7
-0@@ -527,6 +527,17 @@ static int vdpasim_suspend(struct vdpa_device *vdpa)return 0 ; } +static int vdpasim_resume (struct vdpa_device *vdpa) +{ +struct vdpasim *vdpasim =vdpa_to_sim (vdpa); + +spin_lock (&vdpasim->lock); + vdpasim->running = true; +spin_unlock (&vdpasim->lock);
Do we need to schedule work here? Or the assumption is that the individual should take care to make sure no kick is lost during a suspend/resume?
Thanks
Quoted 33 lines
drivers/vdpa/vdpa_sim/vdpa_sim.c +6
-1+ +return 0 ; +} +static size_t vdpasim_get_config_size (struct vdpa_device *vdpa) {struct vdpasim *vdpasim =vdpa_to_sim (vdpa);@@ -717,6 +728,7 @@ static const struct vdpa_config_ops vdpasim_config_ops = { .set_status = vdpasim_set_status, .reset = vdpasim_reset, .suspend = vdpasim_suspend, + .resume = vdpasim_resume, .get_config_size = vdpasim_get_config_size, .get_config = vdpasim_get_config, .set_config = vdpasim_set_config,@@ -750,6 +762,7 @@ static const struct vdpa_config_ops vdpasim_batch_config_ops = { .set_status = vdpasim_set_status, .reset = vdpasim_reset, .suspend = vdpasim_suspend, + .resume = vdpasim_resume, .get_config_size = vdpasim_get_config_size, .get_config = vdpasim_get_config, .set_config = vdpasim_set_config, --2.34.1
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company) Registered headquarters: "Les Montalets"- 2, rue de Paris, 92196 Meudon Cedex, France
Registration Number: 302 456 199R.C.S. NANTERRE
Capital: 5 208 026.16 Euros
Quoted 5 lines
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): CAJaqyWeLi+mmOFi8-+65XwurFbBcAnCe5XFKjQ=4Gbo4hwhdUw@mail.gmail.com
A message that is not in the archive (sent off-list or not yet received): [email protected]
Michael S. Tsirkin
maintainerRe: [PATCH v2 4/4] vdpa_sim: Implement resume vdpa op
Quoted 63 lines · Sebastien
Quoted 62 lines · Eugenio Perez Martin
Quoted 49 lines · Sebastien
Quoted 27 lines · Jason Wang
Quoted 25 lines · On Fri, Oct 14, 2022 at 7:15 PM <[email protected]> wrote:
From: Sebastien Boeuf <[email protected]>
Implement resume operation for
vdpa_simdevices, so vhost-vdpa will
offer that backend feature and userspace can effectively resume the
device.Signed-off-by Sebastien Boeuf <[email protected]>---
drivers/vdpa/vdpa_sim/vdpa_sim.c | 13 +++++++++++++1 file changed, 13 insertions(+)drivers/vdpa/vdpa_sim/vdpa_sim.c +0
-0@@ -527,6 +527,17 @@ static int vdpasim_suspend(struct
vdpa_device
*vdpa)
return 0;
}Quoted 11 lines
drivers/vdpa/vdpa_sim/vdpa_sim.c
Quoted 7 lines
drivers/vdpa/vdpa_sim/vdpa_sim.c +7
-0+static int vdpasim_resume (struct vdpa_device *vdpa) +{ + struct vdpasim *vdpasim = vdpa_to_sim(vdpa); + + spin_lock(&vdpasim->lock); + vdpasim->running = true; + spin_unlock(&vdpasim->lock);Do we need to schedule work here? Or the assumption is that the individual should take care to make sure no kick is lost during a suspend/resume?
The guest vCPU should be paused, meaning no kick should come from the
guest while the backend is suspended. But I don't think it would cause
any harm to schedule some work when resuming the device as this would
provide a more permissive implementation.Quoted 2 lines
Please let me know what you think about it.
We should enable the case where the device is suspended by the VMM but
the vCPU continues running in my opinion.I preemptively scheduled work to accommodate this use case in previous
versions of the suspend patch [1].
Quoted 7 lines
Quoted 4 lines
[1] https://lkml.org/lkml/2022/5/24/768
Thanks!
Sounds good, I'm going to update the patch to kick the queues on resume.
I am not sure the right thing is to kick on resume, that will bring all kind of issues around startup. Save and restore state fully.
Quoted 9 lines
Thanks,
Sebastien
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company) Registered headquarters: "Les Montalets"- 2, rue de Paris, 92196 Meudon Cedex, France
Registration Number: 302 456 199R.C.S. NANTERRE
Capital: 5 208 026.16 Euros
Quoted 4 lines
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization