mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Sistare <steven.sistare@oracle.com>
To: Eugenio Perez Martin <eperezma@redhat.com>
Cc: virtualization@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Jason Wang <jasowang@redhat.com>,
	Si-Wei Liu <si-wei.liu@oracle.com>,
	Xuan Zhuo <xuanzhuo@linux.alibaba.com>,
	Dragos Tatulea <dtatulea@nvidia.com>, Eli Cohen <elic@nvidia.com>,
	Xie Yongji <xieyongji@bytedance.com>
Subject: Re: [RFC V1 10/13] vdpa_sim: flush workers on suspend
Date: Wed, 17 Jan 2024 15:31:06 -0500	[thread overview]
Message-ID: <e87ca0a4-9912-441a-b31f-d11c41ad6f5d@oracle.com> (raw)
In-Reply-To: <CAJaqyWdTBexyY-ra=UkUfUU75YS2Zncm5-9iHv-0Rqa3_mD=9A@mail.gmail.com>

On 1/16/2024 1:57 PM, Eugenio Perez Martin wrote:
> On Wed, Jan 10, 2024 at 9:40 PM Steve Sistare <steven.sistare@oracle.com> wrote:
>>
>> To pass ownership of a live vdpa device to a new process, the user
>> suspends the device, calls VHOST_NEW_OWNER to change the mm, and calls
>> VHOST_IOTLB_REMAP to change the user virtual addresses to match the new
>> mm.  Flush workers in suspend to guarantee that no worker sees the new
>> mm and old VA in between.
> 
> The worker should already be stopped by the end of the suspend ioctl,
> so maybe we can consider this a fix?

Do you mean: the current behavior is a bug, independently of my new use case,
so I should submit this patch as a separate bug fix?  If yes, then will do.

>> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
>> ---
>>  drivers/vdpa/vdpa_sim/vdpa_sim.c | 13 +++++++++++++
>>  1 file changed, 13 insertions(+)
>>
>> diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c
>> index 6304cb0b4770..8734834983cb 100644
>> --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c
>> +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c
>> @@ -74,6 +74,17 @@ static void vdpasim_worker_change_mm_sync(struct vdpasim *vdpasim,
>>         kthread_flush_work(work);
>>  }
>>
>> +static void flush_work_fn(struct kthread_work *work) {}
>> +
>> +static void vdpasim_flush_work(struct vdpasim *vdpasim)
>> +{
>> +       struct kthread_work work;
>> +
>> +       kthread_init_work(&work, flush_work_fn);
>> +       kthread_queue_work(vdpasim->worker, &work);
>> +       kthread_flush_work(&work);
> 
> Wouldn't it be better to cancel the work with kthread_cancel_work_sync here?

I believe that does not guarantee that currently executing work completes:

  static bool __kthread_cancel_work_sync()
    if (worker->current_work != work)
        goto out_fast;

- Steve

>> +}
>> +
>>  static struct vdpasim *vdpa_to_sim(struct vdpa_device *vdpa)
>>  {
>>         return container_of(vdpa, struct vdpasim, vdpa);
>> @@ -512,6 +523,8 @@ static int vdpasim_suspend(struct vdpa_device *vdpa)
>>         vdpasim->running = false;
>>         mutex_unlock(&vdpasim->mutex);
>>
>> +       vdpasim_flush_work(vdpasim);
>> +
>>         return 0;
>>  }
>>
>> --
>> 2.39.3
>>
> 

  reply	other threads:[~2024-01-17 20:31 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-10 20:40 [RFC V1 00/13] vdpa live update Steve Sistare
2024-01-10 20:40 ` [RFC V1 01/13] vhost-vdpa: count pinned memory Steve Sistare
2024-01-10 22:24   ` Michael S. Tsirkin
2024-01-17 20:34     ` Steven Sistare
2024-01-10 20:40 ` [RFC V1 02/13] vhost-vdpa: pass mm to bind Steve Sistare
2024-01-10 20:40 ` [RFC V1 03/13] vhost-vdpa: VHOST_NEW_OWNER Steve Sistare
2024-01-10 20:40 ` [RFC V1 04/13] vhost-vdpa: VHOST_BACKEND_F_NEW_OWNER Steve Sistare
2024-01-10 20:40 ` [RFC V1 05/13] vhost-vdpa: VHOST_IOTLB_REMAP Steve Sistare
2024-01-11  3:08   ` Jason Wang
2024-01-17 20:31     ` Steven Sistare
2024-01-22  4:05       ` Jason Wang
2024-01-16 18:14   ` Eugenio Perez Martin
2024-02-09 15:49     ` Steven Sistare
2024-01-10 20:40 ` [RFC V1 06/13] vhost-vdpa: VHOST_BACKEND_F_IOTLB_REMAP Steve Sistare
2024-01-10 20:40 ` [RFC V1 07/13] vhost-vdpa: flush workers on suspend Steve Sistare
2024-01-11  3:09   ` Jason Wang
2024-01-11 16:17     ` Mike Christie
2024-01-12  2:28       ` Jason Wang
2024-01-17 20:30         ` Steven Sistare
2024-01-10 20:40 ` [RFC V1 08/13] vduse: " Steve Sistare
2024-01-11  3:09   ` Jason Wang
2024-01-17 20:31     ` Steven Sistare
2024-01-10 20:40 ` [RFC V1 09/13] vdpa_sim: reset must not run Steve Sistare
2024-01-16 18:33   ` Eugenio Perez Martin
2024-01-10 20:40 ` [RFC V1 10/13] vdpa_sim: flush workers on suspend Steve Sistare
2024-01-16 18:57   ` Eugenio Perez Martin
2024-01-17 20:31     ` Steven Sistare [this message]
2024-01-10 20:40 ` [RFC V1 11/13] vdpa/mlx5: new owner capability Steve Sistare
2024-01-10 20:40 ` [RFC V1 12/13] vdpa_sim: " Steve Sistare
2024-01-10 20:40 ` [RFC V1 13/13] vduse: " Steve Sistare
2024-01-11  2:55 ` [RFC V1 00/13] vdpa live update Jason Wang
2024-01-17 20:31   ` Steven Sistare
2024-01-22  4:12     ` 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=e87ca0a4-9912-441a-b31f-d11c41ad6f5d@oracle.com \
    --to=steven.sistare@oracle.com \
    --cc=dtatulea@nvidia.com \
    --cc=elic@nvidia.com \
    --cc=eperezma@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=si-wei.liu@oracle.com \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=xieyongji@bytedance.com \
    --cc=xuanzhuo@linux.alibaba.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®