From: Steven Sistare <steven.sistare@oracle.com>
To: Jason Wang <jasowang@redhat.com>
Cc: virtualization@lists.linux-foundation.org,
linux-kernel@vger.kernel.org,
"Michael S. Tsirkin" <mst@redhat.com>,
Si-Wei Liu <si-wei.liu@oracle.com>,
Eugenio Perez Martin <eperezma@redhat.com>,
Xie Yongji <xieyongji@bytedance.com>,
Stefano Garzarella <sgarzare@redhat.com>
Subject: Re: [PATCH V3 2/3] vduse: suspend
Date: Tue, 21 May 2024 09:38:52 -0400 [thread overview]
Message-ID: <b55cccfc-67b0-4f21-9070-127af6fd07a7@oracle.com> (raw)
In-Reply-To: <CACGkMEtfjHzdBBwgUWgRHDc5opekvgTuXp-_z4ku6L5cqOeAJA@mail.gmail.com>
On 5/20/2024 10:30 PM, Jason Wang wrote:
> On Mon, May 20, 2024 at 11:21 PM Steve Sistare
> <steven.sistare@oracle.com> wrote:
>>
>> Support the suspend operation. There is little to do, except flush to
>> guarantee no workers are running when suspend returns.
>>
>> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
>> ---
>> drivers/vdpa/vdpa_user/vduse_dev.c | 24 ++++++++++++++++++++++++
>> 1 file changed, 24 insertions(+)
>>
>> diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c
>> index 73c89701fc9d..7dc46f771f12 100644
>> --- a/drivers/vdpa/vdpa_user/vduse_dev.c
>> +++ b/drivers/vdpa/vdpa_user/vduse_dev.c
>> @@ -472,6 +472,18 @@ static void vduse_dev_reset(struct vduse_dev *dev)
>> up_write(&dev->rwsem);
>> }
>>
>> +static void vduse_flush_work(struct vduse_dev *dev)
>> +{
>> + flush_work(&dev->inject);
>> +
>> + for (int i = 0; i < dev->vq_num; i++) {
>> + struct vduse_virtqueue *vq = dev->vqs[i];
>> +
>> + flush_work(&vq->inject);
>> + flush_work(&vq->kick);
>> + }
>> +}
>> +
>> static int vduse_vdpa_set_vq_address(struct vdpa_device *vdpa, u16 idx,
>> u64 desc_area, u64 driver_area,
>> u64 device_area)
>> @@ -724,6 +736,17 @@ static int vduse_vdpa_reset(struct vdpa_device *vdpa)
>> return ret;
>> }
>>
>> +static int vduse_vdpa_suspend(struct vdpa_device *vdpa)
>> +{
>> + struct vduse_dev *dev = vdpa_to_vduse(vdpa);
>> +
>> + down_write(&dev->rwsem);
>> + vduse_flush_work(dev);
>> + up_write(&dev->rwsem);
>
> Can this forbid the new work to be scheduled?
Are you suggesting I return an error below if the dev is suspended?
I can do that.
However, I now suspect this implementation of vduse_vdpa_suspend is not
complete in other ways, so I withdraw this patch pending future work.
Thanks for looking at it.
- Steve
> static int vduse_dev_queue_irq_work(struct vduse_dev *dev,
> struct work_struct *irq_work,
> int irq_effective_cpu)
> {
> int ret = -EINVAL;
>
> down_read(&dev->rwsem);
> if (!(dev->status & VIRTIO_CONFIG_S_DRIVER_OK))
> goto unlock;
>
> ret = 0;
> if (irq_effective_cpu == IRQ_UNBOUND)
> queue_work(vduse_irq_wq, irq_work);
> else
> queue_work_on(irq_effective_cpu,
> vduse_irq_bound_wq, irq_work);
> unlock:
> up_read(&dev->rwsem);
>
> return ret;
> }
>
> Thanks
>
>> +
>> + return 0;
>> +}
>> +
>> static u32 vduse_vdpa_get_generation(struct vdpa_device *vdpa)
>> {
>> struct vduse_dev *dev = vdpa_to_vduse(vdpa);
>> @@ -806,6 +829,7 @@ static const struct vdpa_config_ops vduse_vdpa_config_ops = {
>> .set_vq_affinity = vduse_vdpa_set_vq_affinity,
>> .get_vq_affinity = vduse_vdpa_get_vq_affinity,
>> .reset = vduse_vdpa_reset,
>> + .suspend = vduse_vdpa_suspend,
>> .set_map = vduse_vdpa_set_map,
>> .free = vduse_vdpa_free,
>> };
>> --
>> 2.39.3
>>
>
next prev parent reply other threads:[~2024-05-21 13:39 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-20 15:20 [PATCH V3 0/3] flush workers on suspend Steve Sistare
2024-05-20 15:21 ` [PATCH V3 1/3] vhost-vdpa: " Steve Sistare
2024-05-21 2:28 ` Jason Wang
2024-05-21 13:38 ` Steven Sistare
2024-05-22 3:41 ` Jason Wang
2024-05-20 15:21 ` [PATCH V3 2/3] vduse: suspend Steve Sistare
2024-05-21 2:30 ` Jason Wang
2024-05-21 13:38 ` Steven Sistare [this message]
2024-05-22 3:40 ` Jason Wang
2024-05-20 15:21 ` [PATCH V3 3/3] vdpa_sim: flush workers on suspend Steve Sistare
2024-05-21 2:32 ` Jason Wang
2024-05-21 13:39 ` Steven Sistare
2024-05-22 3:39 ` Jason Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b55cccfc-67b0-4f21-9070-127af6fd07a7@oracle.com \
--to=steven.sistare@oracle.com \
--cc=eperezma@redhat.com \
--cc=jasowang@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=sgarzare@redhat.com \
--cc=si-wei.liu@oracle.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=xieyongji@bytedance.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®