All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org,
	joshhunt00-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org,
	rni-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
	vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	vwadekar-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org,
	herbert-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org,
	davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org,
	linux-crypto-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	swhiteho-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	bpm-sJ/iWh9BUns@public.gmane.org,
	elder-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	xfs-VZNHf3L845pBDgjK7y7TUQ@public.gmane.org,
	marcel-kz+m5ild9QBg9hUCZPvPmw@public.gmane.org,
	gustavo-THi1TnShQwVAfugRpC6u6w@public.gmane.org,
	johan.hedberg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	linux-bluetooth-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	martin.petersen-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org,
	Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Subject: [PATCH 1/6] workqueue: don't use WQ_HIGHPRI for unbound workqueues
Date: Mon,  9 Jul 2012 11:41:50 -0700	[thread overview]
Message-ID: <1341859315-17759-2-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1341859315-17759-1-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>

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-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
---
 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

WARNING: multiple messages have this Message-ID (diff)
From: Tejun Heo <tj@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: torvalds@linux-foundation.org, joshhunt00@gmail.com,
	axboe@kernel.dk, rni@google.com, vgoyal@redhat.com,
	vwadekar@nvidia.com, herbert@gondor.hengli.com.au,
	davem@davemloft.net, linux-crypto@vger.kernel.org,
	swhiteho@redhat.com, bpm@sgi.com, elder@kernel.org,
	xfs@oss.sgi.com, marcel@holtmann.org, gustavo@padovan.org,
	johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org,
	martin.petersen@oracle.com, Tejun Heo <tj@kernel.org>
Subject: [PATCH 1/6] workqueue: don't use WQ_HIGHPRI for unbound workqueues
Date: Mon,  9 Jul 2012 11:41:50 -0700	[thread overview]
Message-ID: <1341859315-17759-2-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1341859315-17759-1-git-send-email-tj@kernel.org>

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@kernel.org>
---
 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


WARNING: multiple messages have this Message-ID (diff)
From: Tejun Heo <tj@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: axboe@kernel.dk, elder@kernel.org, rni@google.com,
	martin.petersen@oracle.com, linux-bluetooth@vger.kernel.org,
	torvalds@linux-foundation.org, marcel@holtmann.org,
	vwadekar@nvidia.com, swhiteho@redhat.com,
	herbert@gondor.hengli.com.au, bpm@sgi.com,
	linux-crypto@vger.kernel.org, gustavo@padovan.org,
	Tejun Heo <tj@kernel.org>,
	xfs@oss.sgi.com, joshhunt00@gmail.com, davem@davemloft.net,
	vgoyal@redhat.com, johan.hedberg@gmail.com
Subject: [PATCH 1/6] workqueue: don't use WQ_HIGHPRI for unbound workqueues
Date: Mon,  9 Jul 2012 11:41:50 -0700	[thread overview]
Message-ID: <1341859315-17759-2-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1341859315-17759-1-git-send-email-tj@kernel.org>

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@kernel.org>
---
 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

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  parent reply	other threads:[~2012-07-09 18:41 UTC|newest]

Thread overview: 96+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-09 18:41 [PATCHSET] workqueue: reimplement high priority using a separate worker pool Tejun Heo
2012-07-09 18:41 ` Tejun Heo
     [not found] ` <1341859315-17759-1-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2012-07-09 18:41   ` Tejun Heo [this message]
2012-07-09 18:41     ` [PATCH 1/6] workqueue: don't use WQ_HIGHPRI for unbound workqueues Tejun Heo
2012-07-09 18:41     ` Tejun Heo
2012-07-09 18:41 ` [PATCH 2/6] workqueue: factor out worker_pool from global_cwq Tejun Heo
2012-07-09 18:41   ` Tejun Heo
2012-07-09 18:41   ` Tejun Heo
2012-07-10  4:48   ` Namhyung Kim
2012-07-10  4:48     ` Namhyung Kim
2012-07-10  4:48     ` Namhyung Kim
2012-07-12 17:07     ` Tejun Heo
2012-07-12 17:07       ` Tejun Heo
2012-07-12 17:07       ` Tejun Heo
     [not found]   ` <1341859315-17759-3-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2012-07-12 21:49     ` [PATCH UPDATED " Tejun Heo
2012-07-12 21:49       ` Tejun Heo
2012-07-12 21:49       ` Tejun Heo
2012-07-09 18:41 ` [PATCH 3/6] workqueue: use @pool instead of @gcwq or @cpu where applicable Tejun Heo
2012-07-09 18:41   ` Tejun Heo
2012-07-09 18:41   ` Tejun Heo
     [not found]   ` <1341859315-17759-4-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2012-07-10 23:30     ` Tony Luck
2012-07-10 23:30       ` Tony Luck
2012-07-10 23:30       ` Tony Luck
2012-07-12 17:06       ` Tejun Heo
2012-07-12 17:06         ` Tejun Heo
2012-07-12 17:06         ` Tejun Heo
2012-07-09 18:41 ` [PATCH 4/6] workqueue: separate out worker_pool flags Tejun Heo
2012-07-09 18:41   ` Tejun Heo
2012-07-09 18:41   ` Tejun Heo
2012-07-09 18:41 ` [PATCH 5/6] workqueue: introduce NR_WORKER_POOLS and for_each_worker_pool() Tejun Heo
2012-07-09 18:41   ` Tejun Heo
2012-07-09 18:41   ` Tejun Heo
2012-07-14  3:55   ` Tejun Heo
2012-07-14  3:55     ` Tejun Heo
2012-07-14  3:55     ` Tejun Heo
2012-07-14  4:27     ` Linus Torvalds
2012-07-14  4:27       ` Linus Torvalds
2012-07-14  4:27       ` Linus Torvalds
     [not found]       ` <CA+55aFyeauqCqrWsx4U2TB2ENrugZXYj+4vw3Fd0kGaeWBP3RA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-07-14  4:44         ` Tejun Heo
2012-07-14  4:44           ` Tejun Heo
2012-07-14  4:44           ` Tejun Heo
2012-07-14  5:00           ` Linus Torvalds
2012-07-14  5:00             ` Linus Torvalds
2012-07-14  5:00             ` Linus Torvalds
2012-07-14  5:07             ` Tejun Heo
2012-07-14  5:07               ` Tejun Heo
2012-07-14  5:07               ` Tejun Heo
2012-07-16 19:31             ` Peter Seebach
     [not found]   ` <1341859315-17759-6-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2012-07-14  5:21     ` [PATCH UPDATED " Tejun Heo
2012-07-14  5:21       ` Tejun Heo
2012-07-14  5:21       ` Tejun Heo
2012-07-09 18:41 ` [PATCH 6/6] workqueue: reimplement WQ_HIGHPRI using a separate worker_pool Tejun Heo
2012-07-09 18:41   ` Tejun Heo
2012-07-09 18:41   ` Tejun Heo
     [not found]   ` <1341859315-17759-7-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2012-07-12 13:06     ` Fengguang Wu
2012-07-12 13:06       ` Fengguang Wu
2012-07-12 13:06       ` Fengguang Wu
2012-07-12 17:05       ` Tejun Heo
2012-07-12 17:05         ` Tejun Heo
2012-07-12 17:05         ` Tejun Heo
2012-07-12 21:45         ` Tejun Heo
2012-07-12 21:45           ` Tejun Heo
2012-07-12 21:45           ` Tejun Heo
2012-07-12 22:16           ` Tony Luck
2012-07-12 22:16             ` Tony Luck
2012-07-12 22:16             ` Tony Luck
2012-07-12 22:32             ` Tejun Heo
2012-07-12 22:32               ` Tejun Heo
2012-07-12 22:32               ` Tejun Heo
2012-07-12 23:24               ` Tony Luck
2012-07-12 23:24                 ` Tony Luck
2012-07-12 23:24                 ` Tony Luck
2012-07-12 23:36                 ` Tejun Heo
2012-07-12 23:36                   ` Tejun Heo
2012-07-12 23:36                   ` Tejun Heo
2012-07-12 23:46                   ` Tony Luck
2012-07-12 23:46                     ` Tony Luck
2012-07-12 23:46                     ` Tony Luck
2012-07-13 17:51                     ` Tony Luck
2012-07-13 17:51                       ` Tony Luck
2012-07-13 17:51                       ` Tony Luck
2012-07-13  2:08           ` Fengguang Wu
2012-07-13  2:08             ` Fengguang Wu
2012-07-13  2:08             ` Fengguang Wu
2012-07-14  3:41             ` Tejun Heo
2012-07-14  3:41               ` Tejun Heo
2012-07-14  3:41               ` Tejun Heo
2012-07-14  3:56   ` [PATCH UPDATED " Tejun Heo
2012-07-14  3:56     ` Tejun Heo
2012-07-14  3:56     ` Tejun Heo
2012-07-14  8:18     ` Fengguang Wu
2012-07-14  8:18       ` Fengguang Wu
2012-07-14  8:18       ` Fengguang Wu
2012-07-14  5:24   ` [PATCH UPDATED v3 " Tejun Heo
2012-07-14  5:24     ` Tejun Heo
2012-07-14  5:24     ` Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1341859315-17759-2-git-send-email-tj@kernel.org \
    --to=tj-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org \
    --cc=bpm-sJ/iWh9BUns@public.gmane.org \
    --cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
    --cc=elder-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=gustavo-THi1TnShQwVAfugRpC6u6w@public.gmane.org \
    --cc=herbert-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org \
    --cc=johan.hedberg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=joshhunt00-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-bluetooth-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-crypto-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=marcel-kz+m5ild9QBg9hUCZPvPmw@public.gmane.org \
    --cc=martin.petersen-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
    --cc=rni-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=swhiteho-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
    --cc=vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=vwadekar-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
    --cc=xfs-VZNHf3L845pBDgjK7y7TUQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.