aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLai Jiangshan <laijs@cn.fujitsu.com>2012-09-19 13:40:48 -0400
committerTejun Heo <tj@kernel.org>2012-09-19 13:40:48 -0400
commit9f4bd4cddbb50d7617353102e10ce511c5ef6df2 (patch)
tree2f204e107cb878fcc4c0152fe167133570376cc9
parentb3f9f405a21a29c06c31fb2d6ab36ef9ba7c027b (diff)
workqueue: introduce cwq_set_max_active() helper for thaw_workqueues()
Using a helper instead of open code makes thaw_workqueues() clearer. The helper will also be used by the next patch. tj: Slight update to comment and description. Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com> Signed-off-by: Tejun Heo <tj@kernel.org>
-rw-r--r--kernel/workqueue.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 3e324aae3c98..b5d722548ffd 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -3367,6 +3367,26 @@ void destroy_workqueue(struct workqueue_struct *wq)
3367EXPORT_SYMBOL_GPL(destroy_workqueue); 3367EXPORT_SYMBOL_GPL(destroy_workqueue);
3368 3368
3369/** 3369/**
3370 * cwq_set_max_active - adjust max_active of a cwq
3371 * @cwq: target cpu_workqueue_struct
3372 * @max_active: new max_active value.
3373 *
3374 * Set @cwq->max_active to @max_active and activate delayed works if
3375 * increased.
3376 *
3377 * CONTEXT:
3378 * spin_lock_irq(gcwq->lock).
3379 */
3380static void cwq_set_max_active(struct cpu_workqueue_struct *cwq, int max_active)
3381{
3382 cwq->max_active = max_active;
3383
3384 while (!list_empty(&cwq->delayed_works) &&
3385 cwq->nr_active < cwq->max_active)
3386 cwq_activate_first_delayed(cwq);
3387}
3388
3389/**
3370 * workqueue_set_max_active - adjust max_active of a workqueue 3390 * workqueue_set_max_active - adjust max_active of a workqueue
3371 * @wq: target workqueue 3391 * @wq: target workqueue
3372 * @max_active: new max_active value. 3392 * @max_active: new max_active value.
@@ -3792,11 +3812,7 @@ void thaw_workqueues(void)
3792 continue; 3812 continue;
3793 3813
3794 /* restore max_active and repopulate worklist */ 3814 /* restore max_active and repopulate worklist */
3795 cwq->max_active = wq->saved_max_active; 3815 cwq_set_max_active(cwq, wq->saved_max_active);
3796
3797 while (!list_empty(&cwq->delayed_works) &&
3798 cwq->nr_active < cwq->max_active)
3799 cwq_activate_first_delayed(cwq);
3800 } 3816 }
3801 3817
3802 for_each_worker_pool(pool, gcwq) 3818 for_each_worker_pool(pool, gcwq)