vhost: flush dev once during vhost_dev_stop
authorMike Christie <michael.christie@oracle.com>
Tue, 17 May 2022 18:08:44 +0000 (13:08 -0500)
committerMichael S. Tsirkin <mst@redhat.com>
Tue, 31 May 2022 16:45:10 +0000 (12:45 -0400)
When vhost_work_dev_flush returns all work queued at that time will have
completed. There is then no need to flush after every vhost_poll_stop
call, and we can move the flush call to after the loop that stops the
pollers.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Message-Id: <20220517180850.198915-3-michael.christie@oracle.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/vhost/vhost.c

index 43f6ac2d21cd16f1afe96149ee4ba5b542d61634..d82b9394d89a46f66be5743d5787c1b1504b60d1 100644 (file)
@@ -653,11 +653,11 @@ void vhost_dev_stop(struct vhost_dev *dev)
        int i;
 
        for (i = 0; i < dev->nvqs; ++i) {
-               if (dev->vqs[i]->kick && dev->vqs[i]->handle_kick) {
+               if (dev->vqs[i]->kick && dev->vqs[i]->handle_kick)
                        vhost_poll_stop(&dev->vqs[i]->poll);
-                       vhost_work_dev_flush(dev->vqs[i]->poll.dev);
-               }
        }
+
+       vhost_work_dev_flush(dev);
 }
 EXPORT_SYMBOL_GPL(vhost_dev_stop);