Lines Matching refs:wq

132 __btrfs_destroy_workqueue(struct __btrfs_workqueue *wq);
168 static inline void thresh_queue_hook(struct __btrfs_workqueue *wq) in thresh_queue_hook() argument
170 if (wq->thresh == NO_THRESHOLD) in thresh_queue_hook()
172 atomic_inc(&wq->pending); in thresh_queue_hook()
180 static inline void thresh_exec_hook(struct __btrfs_workqueue *wq) in thresh_exec_hook() argument
186 if (wq->thresh == NO_THRESHOLD) in thresh_exec_hook()
189 atomic_dec(&wq->pending); in thresh_exec_hook()
190 spin_lock(&wq->thres_lock); in thresh_exec_hook()
195 wq->count++; in thresh_exec_hook()
196 wq->count %= (wq->thresh / 4); in thresh_exec_hook()
197 if (!wq->count) in thresh_exec_hook()
199 new_max_active = wq->current_max; in thresh_exec_hook()
205 pending = atomic_read(&wq->pending); in thresh_exec_hook()
206 if (pending > wq->thresh) in thresh_exec_hook()
208 if (pending < wq->thresh / 2) in thresh_exec_hook()
210 new_max_active = clamp_val(new_max_active, 1, wq->max_active); in thresh_exec_hook()
211 if (new_max_active != wq->current_max) { in thresh_exec_hook()
213 wq->current_max = new_max_active; in thresh_exec_hook()
216 spin_unlock(&wq->thres_lock); in thresh_exec_hook()
219 workqueue_set_max_active(wq->normal_wq, wq->current_max); in thresh_exec_hook()
223 static void run_ordered_work(struct __btrfs_workqueue *wq) in run_ordered_work() argument
225 struct list_head *list = &wq->ordered_list; in run_ordered_work()
227 spinlock_t *lock = &wq->list_lock; in run_ordered_work()
268 struct __btrfs_workqueue *wq; in normal_work_helper() local
281 wq = work->wq; in normal_work_helper()
284 thresh_exec_hook(wq); in normal_work_helper()
288 run_ordered_work(wq); in normal_work_helper()
307 static inline void __btrfs_queue_work(struct __btrfs_workqueue *wq, in __btrfs_queue_work() argument
312 work->wq = wq; in __btrfs_queue_work()
313 thresh_queue_hook(wq); in __btrfs_queue_work()
315 spin_lock_irqsave(&wq->list_lock, flags); in __btrfs_queue_work()
316 list_add_tail(&work->ordered_list, &wq->ordered_list); in __btrfs_queue_work()
317 spin_unlock_irqrestore(&wq->list_lock, flags); in __btrfs_queue_work()
320 queue_work(wq->normal_wq, &work->normal_work); in __btrfs_queue_work()
323 void btrfs_queue_work(struct btrfs_workqueue *wq, in btrfs_queue_work() argument
328 if (test_bit(WORK_HIGH_PRIO_BIT, &work->flags) && wq->high) in btrfs_queue_work()
329 dest_wq = wq->high; in btrfs_queue_work()
331 dest_wq = wq->normal; in btrfs_queue_work()
336 __btrfs_destroy_workqueue(struct __btrfs_workqueue *wq) in __btrfs_destroy_workqueue() argument
338 destroy_workqueue(wq->normal_wq); in __btrfs_destroy_workqueue()
339 trace_btrfs_workqueue_destroy(wq); in __btrfs_destroy_workqueue()
340 kfree(wq); in __btrfs_destroy_workqueue()
343 void btrfs_destroy_workqueue(struct btrfs_workqueue *wq) in btrfs_destroy_workqueue() argument
345 if (!wq) in btrfs_destroy_workqueue()
347 if (wq->high) in btrfs_destroy_workqueue()
348 __btrfs_destroy_workqueue(wq->high); in btrfs_destroy_workqueue()
349 __btrfs_destroy_workqueue(wq->normal); in btrfs_destroy_workqueue()
350 kfree(wq); in btrfs_destroy_workqueue()
353 void btrfs_workqueue_set_max(struct btrfs_workqueue *wq, int max) in btrfs_workqueue_set_max() argument
355 if (!wq) in btrfs_workqueue_set_max()
357 wq->normal->max_active = max; in btrfs_workqueue_set_max()
358 if (wq->high) in btrfs_workqueue_set_max()
359 wq->high->max_active = max; in btrfs_workqueue_set_max()