| To: | linux-kernel@xxxxxxxxxxxxxxx |
|---|---|
| Subject: | [PATCH 1/6] workqueue: don't use WQ_HIGHPRI for unbound workqueues |
| From: | Tejun Heo <tj@xxxxxxxxxx> |
| Date: | Mon, 9 Jul 2012 11:41:50 -0700 |
| Cc: | torvalds@xxxxxxxxxxxxxxxxxxxx, joshhunt00@xxxxxxxxx, axboe@xxxxxxxxx, rni@xxxxxxxxxx, vgoyal@xxxxxxxxxx, vwadekar@xxxxxxxxxx, herbert@xxxxxxxxxxxxxxxxxxxx, davem@xxxxxxxxxxxxx, linux-crypto@xxxxxxxxxxxxxxx, swhiteho@xxxxxxxxxx, bpm@xxxxxxx, elder@xxxxxxxxxx, xfs@xxxxxxxxxxx, marcel@xxxxxxxxxxxx, gustavo@xxxxxxxxxxx, johan.hedberg@xxxxxxxxx, linux-bluetooth@xxxxxxxxxxxxxxx, martin.petersen@xxxxxxxxxx, Tejun Heo <tj@xxxxxxxxxx> |
| Dkim-signature: | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=n6CAr3CM9MO053onXpQGf50nvrSmDuh/szceEOLfIs8=; b=jwMf0DY6y88EC5KZX1WvZGOur+aXps87JLaRDAvrlt9OongXGv4yjTihVKUgPvOc9J TsJ1atPnhEwllSgDnfY5rk2z461PGh86N28lqfRupGUuoUl4k/roZvxC923jALveEn+T 8BfwPt8/Vi4F/Phs6RO4I5T0sZkMEVkC7wXHoUpHEBUnaAGwhLvJxKE9Yczl8en30S92 70dWvC2dQdL3Qw4FnI8DUPm1Z+oO/WIrrfnBZKL9sc+3bztAY0fwUAMDLHHfbL+5NP1v FrWITlbyxb4/HdWDULWCRzVMcbwkuSXYgwPSHxFsMh4rwre7PJmouI8rtLBHmvl3OJma 0saA== |
| In-reply-to: | <1341859315-17759-1-git-send-email-tj@xxxxxxxxxx> |
| References: | <1341859315-17759-1-git-send-email-tj@xxxxxxxxxx> |
| Sender: | Tejun Heo <htejun@xxxxxxxxx> |
Unbound wqs aren't concurrency-managed and try to execute work items
as soon as possible. This is currently achieved by implicitly setting
%WQ_HIGHPRI on all unbound workqueues; however, WQ_HIGHPRI
implementation is about to be restructured and this usage won't be
valid anymore.
Add an explicit chain-wakeup path for unbound workqueues in
process_one_work() instead of piggy backing on %WQ_HIGHPRI.
Signed-off-by: Tejun Heo <tj@xxxxxxxxxx>
---
kernel/workqueue.c | 18 +++++++++++-------
1 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 9a3128d..27637c2 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -580,6 +580,10 @@ static bool __need_more_worker(struct global_cwq *gcwq)
/*
* Need to wake up a worker? Called from anything but currently
* running workers.
+ *
+ * Note that, because unbound workers never contribute to nr_running, this
+ * function will always return %true for unbound gcwq as long as the
+ * worklist isn't empty.
*/
static bool need_more_worker(struct global_cwq *gcwq)
{
@@ -1867,6 +1871,13 @@ __acquires(&gcwq->lock)
if (unlikely(cpu_intensive))
worker_set_flags(worker, WORKER_CPU_INTENSIVE, true);
+ /*
+ * Unbound gcwq isn't concurrency managed and work items should be
+ * executed ASAP. Wake up another worker if necessary.
+ */
+ if ((worker->flags & WORKER_UNBOUND) && need_more_worker(gcwq))
+ wake_up_worker(gcwq);
+
spin_unlock_irq(&gcwq->lock);
work_clear_pending(work);
@@ -2984,13 +2995,6 @@ struct workqueue_struct *__alloc_workqueue_key(const
char *fmt,
if (flags & WQ_MEM_RECLAIM)
flags |= WQ_RESCUER;
- /*
- * Unbound workqueues aren't concurrency managed and should be
- * dispatched to workers immediately.
- */
- if (flags & WQ_UNBOUND)
- flags |= WQ_HIGHPRI;
-
max_active = max_active ?: WQ_DFL_ACTIVE;
max_active = wq_clamp_max_active(max_active, flags, wq->name);
--
1.7.7.3
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | [PATCHSET] workqueue: reimplement high priority using a separate worker pool, Tejun Heo |
|---|---|
| Next by Date: | [PATCH 2/6] workqueue: factor out worker_pool from global_cwq, Tejun Heo |
| Previous by Thread: | [PATCHSET] workqueue: reimplement high priority using a separate worker pool, Tejun Heo |
| Next by Thread: | [PATCH 2/6] workqueue: factor out worker_pool from global_cwq, Tejun Heo |
| Indexes: | [Date] [Thread] [Top] [All Lists] |