public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] workqueue: intruduce cwq_set_max_active() helper for thaw_workqueues()
@ 2012-09-18  8:36 Lai Jiangshan
  2012-09-18  8:36 ` [PATCH 2/2] workqueue: Keep activate-order equals to queue_work()-order Lai Jiangshan
  0 siblings, 1 reply; 8+ messages in thread
From: Lai Jiangshan @ 2012-09-18  8:36 UTC (permalink / raw)
  To: Tejun Heo, linux-kernel; +Cc: Lai Jiangshan

Using a helper instead of open code makes thaw_workqueues() more clear.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
 kernel/workqueue.c |   26 +++++++++++++++++++++-----
 1 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index cd05cf3..d0ca063 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -3412,6 +3412,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 max_active of @cwq to @max_active and activate delayed works
+ * if max_active is 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.
@@ -3837,11 +3857,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)
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-09-19 17:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-18  8:36 [PATCH 1/2] workqueue: intruduce cwq_set_max_active() helper for thaw_workqueues() Lai Jiangshan
2012-09-18  8:36 ` [PATCH 2/2] workqueue: Keep activate-order equals to queue_work()-order Lai Jiangshan
2012-09-18 17:05   ` Tejun Heo
2012-09-18 17:08     ` Tejun Heo
2012-09-19 10:13       ` Lai Jiangshan
2012-09-19 17:42         ` Tejun Heo
2012-09-19  9:57     ` Lai Jiangshan
2012-09-19 17:31       ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox