Lines Matching refs:wq

144 __btrfs_destroy_workqueue(struct __btrfs_workqueue *wq);
180 static inline void thresh_queue_hook(struct __btrfs_workqueue *wq) in thresh_queue_hook() argument
182 if (wq->thresh == NO_THRESHOLD) in thresh_queue_hook()
184 atomic_inc(&wq->pending); in thresh_queue_hook()
192 static inline void thresh_exec_hook(struct __btrfs_workqueue *wq) in thresh_exec_hook() argument
198 if (wq->thresh == NO_THRESHOLD) in thresh_exec_hook()
201 atomic_dec(&wq->pending); in thresh_exec_hook()
202 spin_lock(&wq->thres_lock); in thresh_exec_hook()
207 wq->count++; in thresh_exec_hook()
208 wq->count %= (wq->thresh / 4); in thresh_exec_hook()
209 if (!wq->count) in thresh_exec_hook()
211 new_current_active = wq->current_active; in thresh_exec_hook()
217 pending = atomic_read(&wq->pending); in thresh_exec_hook()
218 if (pending > wq->thresh) in thresh_exec_hook()
220 if (pending < wq->thresh / 2) in thresh_exec_hook()
222 new_current_active = clamp_val(new_current_active, 1, wq->limit_active); in thresh_exec_hook()
223 if (new_current_active != wq->current_active) { in thresh_exec_hook()
225 wq->current_active = new_current_active; in thresh_exec_hook()
228 spin_unlock(&wq->thres_lock); in thresh_exec_hook()
231 workqueue_set_max_active(wq->normal_wq, wq->current_active); in thresh_exec_hook()
235 static void run_ordered_work(struct __btrfs_workqueue *wq) in run_ordered_work() argument
237 struct list_head *list = &wq->ordered_list; in run_ordered_work()
239 spinlock_t *lock = &wq->list_lock; in run_ordered_work()
280 struct __btrfs_workqueue *wq; in normal_work_helper() local
293 wq = work->wq; in normal_work_helper()
296 thresh_exec_hook(wq); in normal_work_helper()
300 run_ordered_work(wq); in normal_work_helper()
319 static inline void __btrfs_queue_work(struct __btrfs_workqueue *wq, in __btrfs_queue_work() argument
324 work->wq = wq; in __btrfs_queue_work()
325 thresh_queue_hook(wq); in __btrfs_queue_work()
327 spin_lock_irqsave(&wq->list_lock, flags); in __btrfs_queue_work()
328 list_add_tail(&work->ordered_list, &wq->ordered_list); in __btrfs_queue_work()
329 spin_unlock_irqrestore(&wq->list_lock, flags); in __btrfs_queue_work()
332 queue_work(wq->normal_wq, &work->normal_work); in __btrfs_queue_work()
335 void btrfs_queue_work(struct btrfs_workqueue *wq, in btrfs_queue_work() argument
340 if (test_bit(WORK_HIGH_PRIO_BIT, &work->flags) && wq->high) in btrfs_queue_work()
341 dest_wq = wq->high; in btrfs_queue_work()
343 dest_wq = wq->normal; in btrfs_queue_work()
348 __btrfs_destroy_workqueue(struct __btrfs_workqueue *wq) in __btrfs_destroy_workqueue() argument
350 destroy_workqueue(wq->normal_wq); in __btrfs_destroy_workqueue()
351 trace_btrfs_workqueue_destroy(wq); in __btrfs_destroy_workqueue()
352 kfree(wq); in __btrfs_destroy_workqueue()
355 void btrfs_destroy_workqueue(struct btrfs_workqueue *wq) in btrfs_destroy_workqueue() argument
357 if (!wq) in btrfs_destroy_workqueue()
359 if (wq->high) in btrfs_destroy_workqueue()
360 __btrfs_destroy_workqueue(wq->high); in btrfs_destroy_workqueue()
361 __btrfs_destroy_workqueue(wq->normal); in btrfs_destroy_workqueue()
362 kfree(wq); in btrfs_destroy_workqueue()
365 void btrfs_workqueue_set_max(struct btrfs_workqueue *wq, int limit_active) in btrfs_workqueue_set_max() argument
367 if (!wq) in btrfs_workqueue_set_max()
369 wq->normal->limit_active = limit_active; in btrfs_workqueue_set_max()
370 if (wq->high) in btrfs_workqueue_set_max()
371 wq->high->limit_active = limit_active; in btrfs_workqueue_set_max()