Lines Matching refs:worker
236 static void vhost_worker_queue(struct vhost_worker *worker,
244 llist_add(&work->node, &worker->work_list);
245 vhost_task_wake(worker->vtsk);
251 struct vhost_worker *worker;
255 worker = rcu_dereference(vq->worker);
256 if (worker) {
258 vhost_worker_queue(worker, work);
279 * vhost_worker_flush - flush a worker
280 * @worker: worker to flush
282 * This does not use RCU to protect the worker, so the device or worker
285 static void vhost_worker_flush(struct vhost_worker *worker)
292 vhost_worker_queue(worker, &flush.work);
298 struct vhost_worker *worker;
301 xa_for_each(&dev->worker_xa, i, worker) {
302 mutex_lock(&worker->mutex);
303 if (!worker->attachment_cnt) {
304 mutex_unlock(&worker->mutex);
307 vhost_worker_flush(worker);
308 mutex_unlock(&worker->mutex);
316 struct vhost_worker *worker;
320 worker = rcu_dereference(vq->worker);
321 if (worker && !llist_empty(&worker->work_list))
390 rcu_assign_pointer(vq->worker, NULL);
397 struct vhost_worker *worker = data;
401 node = llist_del_all(&worker->work_list);
410 kcov_remote_start_common(worker->kcov_handle);
567 /* vDPA device does not use worker thead, so there's
592 struct vhost_worker *worker)
594 if (!worker)
597 WARN_ON(!llist_empty(&worker->work_list));
598 xa_erase(&dev->worker_xa, worker->id);
599 vhost_task_stop(worker->vtsk);
600 kfree(worker);
605 struct vhost_worker *worker;
612 rcu_assign_pointer(dev->vqs[i]->worker, NULL);
614 * Free the default worker we created and cleanup workers userspace
617 xa_for_each(&dev->worker_xa, i, worker)
618 vhost_worker_destroy(dev, worker);
624 struct vhost_worker *worker;
630 worker = kzalloc(sizeof(*worker), GFP_KERNEL_ACCOUNT);
631 if (!worker)
636 vtsk = vhost_task_create(vhost_worker, worker, name);
640 mutex_init(&worker->mutex);
641 init_llist_head(&worker->work_list);
642 worker->kcov_handle = kcov_common_handle();
643 worker->vtsk = vtsk;
647 ret = xa_alloc(&dev->worker_xa, &id, worker, xa_limit_32b, GFP_KERNEL);
650 worker->id = id;
652 return worker;
657 kfree(worker);
663 struct vhost_worker *worker)
667 old_worker = rcu_dereference_check(vq->worker,
670 mutex_lock(&worker->mutex);
671 worker->attachment_cnt++;
672 mutex_unlock(&worker->mutex);
673 rcu_assign_pointer(vq->worker, worker);
678 * Take the worker mutex to make sure we see the work queued from
705 /* Make sure new vq queue/flush/poll calls see the new worker */
718 struct vhost_worker *worker;
723 worker = xa_find(&dev->worker_xa, &index, UINT_MAX, XA_PRESENT);
724 if (!worker || worker->id != info->worker_id)
727 __vhost_vq_attach_worker(vq, worker);
735 struct vhost_worker *worker;
737 worker = vhost_worker_create(dev);
738 if (!worker)
741 info->worker_id = worker->id;
750 struct vhost_worker *worker;
752 worker = xa_find(&dev->worker_xa, &index, UINT_MAX, XA_PRESENT);
753 if (!worker || worker->id != info->worker_id)
756 mutex_lock(&worker->mutex);
757 if (worker->attachment_cnt) {
758 mutex_unlock(&worker->mutex);
761 mutex_unlock(&worker->mutex);
763 vhost_worker_destroy(dev, worker);
794 struct vhost_worker *worker;
810 /* dev worker ioctls */
820 /* vring worker ioctls */
842 worker = rcu_dereference_check(vq->worker,
844 if (!worker) {
850 ring_worker.worker_id = worker->id;
867 struct vhost_worker *worker;
887 * while we free the worker.
889 worker = vhost_worker_create(dev);
890 if (!worker) {
896 __vhost_vq_attach_worker(dev->vqs[i], worker);