All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/14] vhost: add vhost_worker pointer to vhost_virtqueue
@ 2023-04-28 16:31 Mike Christie
  2023-04-28 16:31 ` [PATCH 02/14] vhost, vhost_net: add helper to check if vq has work Mike Christie
                   ` (13 more replies)
  0 siblings, 14 replies; 18+ messages in thread
From: Mike Christie @ 2023-04-28 16:31 UTC (permalink / raw)
  To: virtualization, mst, sgarzare, jasowang, stefanha

This patchset allows userspace to map vqs to different workers. This
patch adds a worker pointer to the vq so we can store that info.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Acked-by: Jason Wang <jasowang@redhat.com>
---
 drivers/vhost/vhost.c | 24 +++++++++++++-----------
 drivers/vhost/vhost.h |  1 +
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 10bf35a3db6e..7a8eef246e1f 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -486,6 +486,7 @@ void vhost_dev_init(struct vhost_dev *dev,
 		vq->log = NULL;
 		vq->indirect = NULL;
 		vq->heads = NULL;
+		vq->worker = NULL;
 		vq->dev = dev;
 		mutex_init(&vq->mutex);
 		vhost_vq_reset(dev, vq);
@@ -554,16 +555,15 @@ static void vhost_worker_free(struct vhost_dev *dev)
 	kfree(worker);
 }
 
-static int vhost_worker_create(struct vhost_dev *dev)
+static struct vhost_worker *vhost_worker_create(struct vhost_dev *dev)
 {
 	struct vhost_worker *worker;
 	struct vhost_task *vtsk;
 	char name[TASK_COMM_LEN];
-	int ret;
 
 	worker = kzalloc(sizeof(*worker), GFP_KERNEL_ACCOUNT);
 	if (!worker)
-		return -ENOMEM;
+		return NULL;
 
 	dev->worker = worker;
 	worker->kcov_handle = kcov_common_handle();
@@ -571,25 +571,24 @@ static int vhost_worker_create(struct vhost_dev *dev)
 	snprintf(name, sizeof(name), "vhost-%d", current->pid);
 
 	vtsk = vhost_task_create(vhost_worker, worker, name);
-	if (!vtsk) {
-		ret = -ENOMEM;
+	if (!vtsk)
 		goto free_worker;
-	}
 
 	worker->vtsk = vtsk;
 	vhost_task_start(vtsk);
-	return 0;
+	return worker;
 
 free_worker:
 	kfree(worker);
 	dev->worker = NULL;
-	return ret;
+	return NULL;
 }
 
 /* Caller should have device mutex */
 long vhost_dev_set_owner(struct vhost_dev *dev)
 {
-	int err;
+	struct vhost_worker *worker;
+	int err, i;
 
 	/* Is there an owner already? */
 	if (vhost_dev_has_owner(dev)) {
@@ -600,9 +599,12 @@ long vhost_dev_set_owner(struct vhost_dev *dev)
 	vhost_attach_mm(dev);
 
 	if (dev->use_worker) {
-		err = vhost_worker_create(dev);
-		if (err)
+		worker = vhost_worker_create(dev);
+		if (!worker)
 			goto err_worker;
+
+		for (i = 0; i < dev->nvqs; i++)
+			dev->vqs[i]->worker = worker;
 	}
 
 	err = vhost_dev_alloc_iovecs(dev);
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
index 0308638cdeee..e72b665ba3a5 100644
--- a/drivers/vhost/vhost.h
+++ b/drivers/vhost/vhost.h
@@ -74,6 +74,7 @@ struct vhost_vring_call {
 /* The virtqueue structure describes a queue attached to a device. */
 struct vhost_virtqueue {
 	struct vhost_dev *dev;
+	struct vhost_worker *worker;
 
 	/* The actual ring of buffers. */
 	struct mutex mutex;
-- 
2.25.1

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

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2023-06-02 11:50 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-28 16:31 [PATCH 01/14] vhost: add vhost_worker pointer to vhost_virtqueue Mike Christie
2023-04-28 16:31 ` [PATCH 02/14] vhost, vhost_net: add helper to check if vq has work Mike Christie
2023-04-28 16:31 ` [PATCH 03/14] vhost: take worker or vq instead of dev for queueing Mike Christie
2023-04-28 16:31 ` [PATCH 04/14] vhost: take worker or vq instead of dev for flushing Mike Christie
2023-04-28 16:31 ` [PATCH 05/14] vhost: convert poll work to be vq based Mike Christie
2023-04-28 16:31 ` [PATCH 06/14] vhost_sock: convert to vhost_vq_work_queue Mike Christie
2023-04-28 16:31 ` [PATCH 07/14] vhost_scsi: make SCSI cmd completion per vq Mike Christie
2023-04-28 16:31 ` [PATCH 08/14] vhost_scsi: convert to vhost_vq_work_queue Mike Christie
2023-04-28 16:31 ` [PATCH 09/14] vhost: remove vhost_work_queue Mike Christie
2023-04-28 16:31 ` [PATCH 10/14] vhost_scsi: flush IO vqs then send TMF rsp Mike Christie
2023-04-28 16:31 ` [PATCH 11/14] vhost: add helper to parse userspace vring state/file Mike Christie
2023-04-28 16:31 ` [PATCH 12/14] vhost: replace single worker pointer with xarray Mike Christie
2023-04-28 16:31 ` [PATCH 13/14] vhost: allow userspace to create workers Mike Christie
2023-05-17  3:10   ` Jason Wang
2023-05-18 23:21     ` Mike Christie
2023-04-28 16:31 ` [PATCH 14/14] vhost_scsi: add support for worker ioctls Mike Christie
2023-04-28 16:35 ` [PATCH v7 00/14] vhost: multiple worker support michael.christie
2023-06-02 11:49   ` Michael S. Tsirkin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.