@@ -272,6 +272,17 @@ static void vhost_worker_flush(struct vhost_worker *w)
wait_for_completion(&flush.wait_event);
}
+void vhost_work_flush_vq(struct vhost_virtqueue *vq)
+{
+ struct vhost_worker *w = READ_ONCE(vq->worker);
+
+ if (!w)
+ return;
+
+ vhost_worker_flush(w);
+}
+EXPORT_SYMBOL_GPL(vhost_work_flush_vq);
+
void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work)
{
struct vhost_worker *w = &dev->workers[0];
@@ -283,6 +294,17 @@ void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work)
}
EXPORT_SYMBOL_GPL(vhost_work_queue);
+void vhost_work_vqueue(struct vhost_virtqueue *vq, struct vhost_work *work)
+{
+ struct vhost_worker *w = READ_ONCE(vq->worker);
+
+ if (!w)
+ return;
+
+ vhost_work_queue_at_worker(w, work);
+}
+EXPORT_SYMBOL_GPL(vhost_work_vqueue);
+
/* A lockless hint for busy polling code to exit the loop */
bool vhost_has_work(struct vhost_dev *dev)
{
@@ -141,6 +141,11 @@ struct vhost_virtqueue {
struct vhost_worker *worker;
};
+/* Queue the work on virtqueue assigned worker */
+void vhost_work_vqueue(struct vhost_virtqueue *vq, struct vhost_work *work);
+/* Flush virtqueue assigned worker */
+void vhost_work_flush_vq(struct vhost_virtqueue *vq);
+
struct vhost_msg_node {
union {
struct vhost_msg msg;
Add routines to queue works on virtqueue assigned workers Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com> --- drivers/vhost/vhost.c | 22 ++++++++++++++++++++++ drivers/vhost/vhost.h | 5 +++++ 2 files changed, 27 insertions(+)