History

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.

Lai Jiangshan committed 14 years ago

Commit 9f4bd4c1 parent b3f9f401 file · +21 −5Browse files

Showing the changes to kernel/workqueue.c (1 of 1 file). Show all

Unified · Split

kernel/workqueue.c+21−5
@@ -3366,6 +3366,26 @@ void destroy_workqueue(struct workqueue_struct *wq) · 3365 unmodified lines
3366}3366}
3367EXPORT_SYMBOL_GPL(destroy_workqueue);3367EXPORT_SYMBOL_GPL(destroy_workqueue);
3368 3368
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
3369/**3389/**
3370 * workqueue_set_max_active - adjust max_active of a workqueue3390 * workqueue_set_max_active - adjust max_active of a workqueue
3371 * @wq: target workqueue3391 * @wq: target workqueue
@@ -3792,11 +3812,7 @@ void thaw_workqueues(void) · 420 unmodified lines
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)