diff options
author | Lai Jiangshan <laijs@cn.fujitsu.com> | 2012-09-19 10:40:48 -0700 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2012-09-19 10:40:48 -0700 |
commit | 9f4bd4cddbb50d7617353102e10ce511c5ef6df2 (patch) | |
tree | 2f204e107cb878fcc4c0152fe167133570376cc9 /kernel/workqueue.c | |
parent | b3f9f405a21a29c06c31fb2d6ab36ef9ba7c027b (diff) | |
download | linux-9f4bd4cddbb50d7617353102e10ce511c5ef6df2.tar.gz linux-9f4bd4cddbb50d7617353102e10ce511c5ef6df2.tar.bz2 linux-9f4bd4cddbb50d7617353102e10ce511c5ef6df2.zip |
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>
Diffstat (limited to 'kernel/workqueue.c')
-rw-r--r-- | kernel/workqueue.c | 26 |
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) EXPORT_SYMBOL_GPL(destroy_workqueue); /** + * cwq_set_max_active - adjust max_active of a cwq + * @cwq: target cpu_workqueue_struct + * @max_active: new max_active value. + * + * Set @cwq->max_active to @max_active and activate delayed works if + * increased. + * + * CONTEXT: + * spin_lock_irq(gcwq->lock). + */ +static void cwq_set_max_active(struct cpu_workqueue_struct *cwq, int max_active) +{ + cwq->max_active = max_active; + + while (!list_empty(&cwq->delayed_works) && + cwq->nr_active < cwq->max_active) + cwq_activate_first_delayed(cwq); +} + +/** * workqueue_set_max_active - adjust max_active of a workqueue * @wq: target workqueue * @max_active: new max_active value. @@ -3792,11 +3812,7 @@ void thaw_workqueues(void) continue; /* restore max_active and repopulate worklist */ - cwq->max_active = wq->saved_max_active; - - while (!list_empty(&cwq->delayed_works) && - cwq->nr_active < cwq->max_active) - cwq_activate_first_delayed(cwq); + cwq_set_max_active(cwq, wq->saved_max_active); } for_each_worker_pool(pool, gcwq) |