Home | History | Annotate | Download | only in fio

Lines Matching refs:sw

27 	struct submit_worker *sw = NULL;
30 sw = &wq->workers[start];
31 if (sw->flags & SW_F_IDLE)
32 return sw;
33 if (!(*best) || sw->seq < (*best)->seq)
34 *best = sw;
44 struct submit_worker *sw, *best = NULL;
48 sw = __get_submit_worker(wq, next, wq->max_workers - 1, &best);
49 if (!sw && next)
50 sw = __get_submit_worker(wq, 0, next - 1, &best);
55 if (!sw)
56 sw = best;
58 if (sw->index == wq->next_free_worker) {
59 if (sw->index + 1 < wq->max_workers)
60 wq->next_free_worker = sw->index + 1;
65 return sw;
73 struct submit_worker *sw = &wq->workers[i];
75 if (!(sw->flags & SW_F_IDLE))
103 struct submit_worker *sw;
105 sw = get_submit_worker(wq);
106 assert(sw);
108 pthread_mutex_lock(&sw->lock);
109 flist_add_tail(&work->list, &sw->work_list);
110 sw->seq = ++wq->work_seq;
111 sw->flags &= ~SW_F_IDLE;
112 pthread_mutex_unlock(&sw->lock);
114 pthread_cond_signal(&sw->cond);
117 static void handle_list(struct submit_worker *sw, struct flist_head *list)
119 struct workqueue *wq = sw->wq;
125 wq->ops.fn(sw, work);
131 struct submit_worker *sw = data;
132 struct workqueue *wq = sw->wq;
136 sk_out_assign(sw->sk_out);
146 ret = workqueue_init_worker(sw);
148 pthread_mutex_lock(&sw->lock);
149 sw->flags |= SW_F_RUNNING;
151 sw->flags |= SW_F_ERROR;
152 pthread_mutex_unlock(&sw->lock);
158 if (sw->flags & SW_F_ERROR)
162 pthread_mutex_lock(&sw->lock);
164 if (flist_empty(&sw->work_list)) {
165 if (sw->flags & SW_F_EXIT) {
166 pthread_mutex_unlock(&sw->lock);
170 if (workqueue_pre_sleep_check(sw)) {
171 pthread_mutex_unlock(&sw->lock);
172 workqueue_pre_sleep(sw);
173 pthread_mutex_lock(&sw->lock);
180 if (!flist_empty(&sw->work_list))
183 if (sw->flags & SW_F_EXIT) {
184 pthread_mutex_unlock(&sw->lock);
186 } else if (!(sw->flags & SW_F_IDLE)) {
187 sw->flags |= SW_F_IDLE;
188 wq->next_free_worker = sw->index;
193 wq->ops.update_acct_fn(sw);
195 pthread_cond_wait(&sw->cond, &sw->lock);
198 flist_splice_init(&sw->work_list, &local_list);
200 pthread_mutex_unlock(&sw->lock);
201 handle_list(sw, &local_list);
205 wq->ops.update_acct_fn(sw);
212 static void free_worker(struct submit_worker *sw, unsigned int *sum_cnt)
214 struct workqueue *wq = sw->wq;
216 workqueue_exit_worker(sw, sum_cnt);
218 pthread_cond_destroy(&sw->cond);
219 pthread_mutex_destroy(&sw->lock);
222 wq->ops.free_worker_fn(sw);
225 static void shutdown_worker(struct submit_worker *sw, unsigned int *sum_cnt)
227 pthread_join(sw->thread, NULL);
228 free_worker(sw, sum_cnt);
234 struct submit_worker *sw;
241 sw = &wq->workers[i];
243 pthread_mutex_lock(&sw->lock);
244 sw->flags |= SW_F_EXIT;
245 pthread_cond_signal(&sw->cond);
246 pthread_mutex_unlock(&sw->lock);
252 sw = &wq->workers[i];
253 if (sw->flags & SW_F_ACCOUNTED)
255 pthread_mutex_lock(&sw->lock);
256 sw->flags |= SW_F_ACCOUNTED;
257 pthread_mutex_unlock(&sw->lock);
258 shutdown_worker(sw, &sum_cnt);
273 struct submit_worker *sw = &wq->workers[index];
276 INIT_FLIST_HEAD(&sw->work_list);
278 ret = mutex_cond_init_pshared(&sw->lock, &sw->cond);
282 sw->wq = wq;
283 sw->index = index;
284 sw->sk_out = sk_out;
287 ret = wq->ops.alloc_worker_fn(sw);
292 ret = pthread_create(&sw->thread, NULL, worker_thread, sw);
294 pthread_mutex_lock(&sw->lock);
295 sw->flags = SW_F_IDLE;
296 pthread_mutex_unlock(&sw->lock);
300 free_worker(sw, NULL);
342 struct submit_worker *sw;
347 sw = &wq->workers[i];
348 pthread_mutex_lock(&sw->lock);
349 if (sw->flags & SW_F_RUNNING)
351 if (sw->flags & SW_F_ERROR)
353 pthread_mutex_unlock(&sw->lock);