Message ID | 20241210164456.925060-6-lulu@redhat.com (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show |
Series | vhost: Add support of kthread API | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
On Wed, Dec 11, 2024 at 12:41:44AM +0800, Cindy Lu wrote: >The function vhost_worker_queue() uses a function pointer in >vhost_worker, which is initialized based on the inherit_owner >value. > >Signed-off-by: Cindy Lu <lulu@redhat.com> >--- > drivers/vhost/vhost.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > >diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c >index 0175bbf4d8b3..d1aec41bcd56 100644 >--- a/drivers/vhost/vhost.c >+++ b/drivers/vhost/vhost.c >@@ -237,13 +237,16 @@ EXPORT_SYMBOL_GPL(vhost_poll_stop); > static void vhost_worker_queue(struct vhost_worker *worker, > struct vhost_work *work) > { >+ if (!worker) >+ return; >+ In which scenario can `worker` be NULL? I would like to better understand why it couldn't happen before and now it can. Thanks, Stefano > if (!test_and_set_bit(VHOST_WORK_QUEUED, &work->flags)) { > /* We can only add the work to the list after we're > * sure it was not in the list. > * test_and_set_bit() implies a memory barrier. > */ > llist_add(&work->node, &worker->work_list); >- vhost_task_wake(worker->vtsk); >+ worker->task_wakeup(worker); > } > } > >-- >2.45.0 >
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 0175bbf4d8b3..d1aec41bcd56 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -237,13 +237,16 @@ EXPORT_SYMBOL_GPL(vhost_poll_stop); static void vhost_worker_queue(struct vhost_worker *worker, struct vhost_work *work) { + if (!worker) + return; + if (!test_and_set_bit(VHOST_WORK_QUEUED, &work->flags)) { /* We can only add the work to the list after we're * sure it was not in the list. * test_and_set_bit() implies a memory barrier. */ llist_add(&work->node, &worker->work_list); - vhost_task_wake(worker->vtsk); + worker->task_wakeup(worker); } }
The function vhost_worker_queue() uses a function pointer in vhost_worker, which is initialized based on the inherit_owner value. Signed-off-by: Cindy Lu <lulu@redhat.com> --- drivers/vhost/vhost.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)