On Thu, 16 Sep 2021 16:20:50 -0500 Mike Christie wrote: > > static int vhost_worker_create(struct vhost_dev *dev) > { > + DECLARE_COMPLETION_ONSTACK(start_done); Nit, cut it. > struct vhost_worker *worker; > struct task_struct *task; > + char buf[TASK_COMM_LEN]; > int ret; > > worker = kzalloc(sizeof(*worker), GFP_KERNEL_ACCOUNT); > @@ -603,27 +613,30 @@ static int vhost_worker_create(struct vhost_dev *dev) > return -ENOMEM; > > dev->worker = worker; > - worker->dev = dev; > worker->kcov_handle = kcov_common_handle(); > init_llist_head(&worker->work_list); > > - task = kthread_create(vhost_worker, worker, "vhost-%d", current->pid); > - if (IS_ERR(task)) { > - ret = PTR_ERR(task); > + /* > + * vhost used to use the kthread API which ignores all signals by > + * default and the drivers expect this behavior. So we do not want to > + * ineherit the parent's signal handlers and set our worker to ignore > + * everything below. > + */ > + task = kernel_copy_process(vhost_worker, worker, NUMA_NO_NODE, > + CLONE_FS|CLONE_CLEAR_SIGHAND, 0, 1); > + if (IS_ERR(task)) > goto free_worker; > - } > > worker->task = task; > - wake_up_process(task); /* avoid contributing to loadavg */ > > - ret = vhost_attach_cgroups(dev); > - if (ret) > - goto stop_worker; > + snprintf(buf, sizeof(buf), "vhost-%d", current->pid); > + set_task_comm(task, buf); > + > + ignore_signals(task); > > + wake_up_new_task(task); > return 0; > > -stop_worker: > - kthread_stop(worker->task); > free_worker: > kfree(worker); > dev->worker = NULL; > diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h > index 102ce25e4e13..09748694cb66 100644 > --- a/drivers/vhost/vhost.h > +++ b/drivers/vhost/vhost.h > @@ -25,11 +25,16 @@ struct vhost_work { > unsigned long flags; > }; > > +enum { > + VHOST_WORKER_FLAG_STOP, > +}; > + > struct vhost_worker { > struct task_struct *task; > + struct completion *exit_done; > struct llist_head work_list; > - struct vhost_dev *dev; > u64 kcov_handle; > + unsigned long flags; > }; > > /* Poll a file (eventfd or socket) */ > -- > 2.25.1 _______________________________________________ Virtualization mailing list Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linuxfoundation.org/mailman/listinfo/virtualization