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
33663366 }
33673367 EXPORT_SYMBOL_GPL(destroy_workqueue);
33683368
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+ */
3380+static 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+
33693389 /**
33703390 * workqueue_set_max_active - adjust max_active of a workqueue
33713391 * @wq: target workqueue
@@ -3792,11 +3812,7 @@ void thaw_workqueues(void) · 420 unmodified lines
37923812 continue;
37933813
37943814 /* restore max_active and repopulate worklist */
3795− cwq->max_active = 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);
3815+ cwq_set_max_active(cwq, wq->saved_max_active);
38003816 }
38013817
38023818 for_each_worker_pool(pool, gcwq)