[PATCH v3 6/9] vhost: Add kthread support in function vhost_worker_destroy()

From: Cindy Lu
Date: Tue Nov 05 2024 - 02:29:43 EST


The function vhost_worker_destroy() will use struct vhost_task_fn and
selects the different mode based on the value of inherit_owner.

Signed-off-by: Cindy Lu <lulu@xxxxxxxxxx>
---
drivers/vhost/vhost.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 8b7ddfb33c61..c17dc01febcc 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -718,12 +718,14 @@ static void vhost_detach_mm(struct vhost_dev *dev)
static void vhost_worker_destroy(struct vhost_dev *dev,
struct vhost_worker *worker)
{
- if (!worker)
+ if (!worker && !worker->fn)
return;

WARN_ON(!llist_empty(&worker->work_list));
xa_erase(&dev->worker_xa, worker->id);
- vhost_task_stop(worker->vtsk);
+ worker->fn->stop(dev->inherit_owner ? (void *)worker->vtsk :
+ (void *)worker->task);
+ kfree(worker->fn);
kfree(worker);
}

--
2.45.0