Re: [PATCH v6 04/11] vhost: take worker or vq instead of dev for flushing

2023-04-04 Thread Jason Wang
On Tue, Mar 28, 2023 at 10:17 AM Mike Christie
 wrote:
>
> This patch has the core work flush function take a worker. When we
> support multiple workers we can then flush each worker during device
> removal, stoppage, etc.
>
> Signed-off-by: Mike Christie 

Acked-by: Jason Wang 

Thanks

> ---
>  drivers/vhost/vhost.c | 24 +++-
>  1 file changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> index cc2628ba9a77..6160aa1cc922 100644
> --- a/drivers/vhost/vhost.c
> +++ b/drivers/vhost/vhost.c
> @@ -247,6 +247,20 @@ static void vhost_work_queue_on(struct vhost_worker 
> *worker,
> }
>  }
>
> +static void vhost_work_flush_on(struct vhost_worker *worker)
> +{
> +   struct vhost_flush_struct flush;
> +
> +   if (!worker)
> +   return;
> +
> +   init_completion(_event);
> +   vhost_work_init(, vhost_flush_work);
> +
> +   vhost_work_queue_on(worker, );
> +   wait_for_completion(_event);
> +}
> +
>  void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work)
>  {
> vhost_work_queue_on(dev->worker, work);
> @@ -261,15 +275,7 @@ EXPORT_SYMBOL_GPL(vhost_vq_work_queue);
>
>  void vhost_dev_flush(struct vhost_dev *dev)
>  {
> -   struct vhost_flush_struct flush;
> -
> -   if (dev->worker) {
> -   init_completion(_event);
> -   vhost_work_init(, vhost_flush_work);
> -
> -   vhost_work_queue(dev, );
> -   wait_for_completion(_event);
> -   }
> +   vhost_work_flush_on(dev->worker);
>  }
>  EXPORT_SYMBOL_GPL(vhost_dev_flush);
>
> --
> 2.25.1
>

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

[PATCH v6 04/11] vhost: take worker or vq instead of dev for flushing

2023-03-27 Thread Mike Christie
This patch has the core work flush function take a worker. When we
support multiple workers we can then flush each worker during device
removal, stoppage, etc.

Signed-off-by: Mike Christie 
---
 drivers/vhost/vhost.c | 24 +++-
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index cc2628ba9a77..6160aa1cc922 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -247,6 +247,20 @@ static void vhost_work_queue_on(struct vhost_worker 
*worker,
}
 }
 
+static void vhost_work_flush_on(struct vhost_worker *worker)
+{
+   struct vhost_flush_struct flush;
+
+   if (!worker)
+   return;
+
+   init_completion(_event);
+   vhost_work_init(, vhost_flush_work);
+
+   vhost_work_queue_on(worker, );
+   wait_for_completion(_event);
+}
+
 void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work)
 {
vhost_work_queue_on(dev->worker, work);
@@ -261,15 +275,7 @@ EXPORT_SYMBOL_GPL(vhost_vq_work_queue);
 
 void vhost_dev_flush(struct vhost_dev *dev)
 {
-   struct vhost_flush_struct flush;
-
-   if (dev->worker) {
-   init_completion(_event);
-   vhost_work_init(, vhost_flush_work);
-
-   vhost_work_queue(dev, );
-   wait_for_completion(_event);
-   }
+   vhost_work_flush_on(dev->worker);
 }
 EXPORT_SYMBOL_GPL(vhost_dev_flush);
 
-- 
2.25.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization