Lines Matching refs:wq
109 struct io_wq *wq; member
238 atomic_dec(&wqe->wq->user->processes); in io_worker_exit()
253 if (refcount_dec_and_test(&wqe->wq->refs)) in io_worker_exit()
254 complete(&wqe->wq->done); in io_worker_exit()
310 wake_up_process(wqe->wq->manager); in io_wqe_wake_worker()
369 atomic_dec(&wqe->wq->user->processes); in __io_worker_busy()
374 atomic_inc(&wqe->wq->user->processes); in __io_worker_busy()
535 struct io_wq *wq = wqe->wq; in io_worker_handle_work() local
569 if (test_bit(IO_WQ_BIT_CANCEL, &wq->state)) in io_worker_handle_work()
573 linked = wq->do_work(work); in io_worker_handle_work()
581 wq->free_work(old_work); in io_worker_handle_work()
605 struct io_wq *wq = wqe->wq; in io_wqe_worker() local
609 while (!test_bit(IO_WQ_BIT_EXIT, &wq->state)) { in io_wqe_worker()
629 if (test_bit(IO_WQ_BIT_EXIT, &wq->state) || in io_wqe_worker()
634 if (test_bit(IO_WQ_BIT_EXIT, &wq->state)) { in io_wqe_worker()
684 static bool create_io_worker(struct io_wq *wq, struct io_wqe *wqe, int index) in create_io_worker() argument
718 atomic_inc(&wq->user->processes); in create_io_worker()
720 refcount_inc(&wq->refs); in create_io_worker()
778 struct io_wq *wq = data; in io_wq_manager() local
782 refcount_set(&wq->refs, 1); in io_wq_manager()
786 if (create_io_worker(wq, wq->wqes[node], IO_WQ_ACCT_BOUND)) in io_wq_manager()
788 set_bit(IO_WQ_BIT_ERROR, &wq->state); in io_wq_manager()
789 set_bit(IO_WQ_BIT_EXIT, &wq->state); in io_wq_manager()
793 complete(&wq->done); in io_wq_manager()
800 struct io_wqe *wqe = wq->wqes[node]; in io_wq_manager()
813 create_io_worker(wq, wqe, IO_WQ_ACCT_BOUND); in io_wq_manager()
815 create_io_worker(wq, wqe, IO_WQ_ACCT_UNBOUND); in io_wq_manager()
825 if (refcount_dec_and_test(&wq->refs)) { in io_wq_manager()
826 complete(&wq->done); in io_wq_manager()
830 if (test_bit(IO_WQ_BIT_ERROR, &wq->state)) { in io_wq_manager()
833 io_wq_for_each_worker(wq->wqes[node], io_wq_worker_wake, NULL); in io_wq_manager()
855 if (atomic_read(&wqe->wq->user->processes) >= acct->max_workers && in io_wq_can_queue()
864 struct io_wq *wq = wqe->wq; in io_run_cancel() local
870 work = wq->do_work(work); in io_run_cancel()
871 wq->free_work(old_work); in io_run_cancel()
923 void io_wq_enqueue(struct io_wq *wq, struct io_wq_work *work) in io_wq_enqueue() argument
925 struct io_wqe *wqe = wq->wqes[numa_node_id()]; in io_wq_enqueue()
942 void io_wq_cancel_all(struct io_wq *wq) in io_wq_cancel_all() argument
946 set_bit(IO_WQ_BIT_CANCEL, &wq->state); in io_wq_cancel_all()
950 struct io_wqe *wqe = wq->wqes[node]; in io_wq_cancel_all()
1038 enum io_wq_cancel io_wq_cancel_cb(struct io_wq *wq, work_cancel_fn *cancel, in io_wq_cancel_cb() argument
1054 struct io_wqe *wqe = wq->wqes[node]; in io_wq_cancel_cb()
1068 struct io_wqe *wqe = wq->wqes[node]; in io_wq_cancel_cb()
1085 struct io_wq *wq; in io_wq_create() local
1092 wq = kzalloc(sizeof(*wq), GFP_KERNEL); in io_wq_create()
1093 if (!wq) in io_wq_create()
1096 wq->wqes = kcalloc(nr_node_ids, sizeof(struct io_wqe *), GFP_KERNEL); in io_wq_create()
1097 if (!wq->wqes) in io_wq_create()
1100 ret = cpuhp_state_add_instance_nocalls(io_wq_online, &wq->cpuhp_node); in io_wq_create()
1104 wq->free_work = data->free_work; in io_wq_create()
1105 wq->do_work = data->do_work; in io_wq_create()
1108 wq->user = data->user; in io_wq_create()
1120 wq->wqes[node] = wqe; in io_wq_create()
1124 if (wq->user) { in io_wq_create()
1129 wqe->wq = wq; in io_wq_create()
1136 init_completion(&wq->done); in io_wq_create()
1138 wq->manager = kthread_create(io_wq_manager, wq, "io_wq_manager"); in io_wq_create()
1139 if (!IS_ERR(wq->manager)) { in io_wq_create()
1140 wake_up_process(wq->manager); in io_wq_create()
1141 wait_for_completion(&wq->done); in io_wq_create()
1142 if (test_bit(IO_WQ_BIT_ERROR, &wq->state)) { in io_wq_create()
1146 refcount_set(&wq->use_refs, 1); in io_wq_create()
1147 reinit_completion(&wq->done); in io_wq_create()
1148 return wq; in io_wq_create()
1151 ret = PTR_ERR(wq->manager); in io_wq_create()
1152 complete(&wq->done); in io_wq_create()
1154 cpuhp_state_remove_instance_nocalls(io_wq_online, &wq->cpuhp_node); in io_wq_create()
1156 kfree(wq->wqes[node]); in io_wq_create()
1158 kfree(wq->wqes); in io_wq_create()
1160 kfree(wq); in io_wq_create()
1164 bool io_wq_get(struct io_wq *wq, struct io_wq_data *data) in io_wq_get() argument
1166 if (data->free_work != wq->free_work || data->do_work != wq->do_work) in io_wq_get()
1169 return refcount_inc_not_zero(&wq->use_refs); in io_wq_get()
1172 static void __io_wq_destroy(struct io_wq *wq) in __io_wq_destroy() argument
1176 cpuhp_state_remove_instance_nocalls(io_wq_online, &wq->cpuhp_node); in __io_wq_destroy()
1178 set_bit(IO_WQ_BIT_EXIT, &wq->state); in __io_wq_destroy()
1179 if (wq->manager) in __io_wq_destroy()
1180 kthread_stop(wq->manager); in __io_wq_destroy()
1184 io_wq_for_each_worker(wq->wqes[node], io_wq_worker_wake, NULL); in __io_wq_destroy()
1187 wait_for_completion(&wq->done); in __io_wq_destroy()
1190 kfree(wq->wqes[node]); in __io_wq_destroy()
1191 kfree(wq->wqes); in __io_wq_destroy()
1192 kfree(wq); in __io_wq_destroy()
1195 void io_wq_destroy(struct io_wq *wq) in io_wq_destroy() argument
1197 if (refcount_dec_and_test(&wq->use_refs)) in io_wq_destroy()
1198 __io_wq_destroy(wq); in io_wq_destroy()
1201 struct task_struct *io_wq_get_task(struct io_wq *wq) in io_wq_get_task() argument
1203 return wq->manager; in io_wq_get_task()
1221 struct io_wq *wq = hlist_entry_safe(node, struct io_wq, cpuhp_node); in io_wq_cpu_online() local
1226 io_wq_for_each_worker(wq->wqes[i], io_wq_worker_affinity, NULL); in io_wq_cpu_online()