From: Tejun Heo <tj@kernel.org>
To: laijs@cn.fujitsu.com
Cc: linux-kernel@vger.kernel.org, js1304@gmail.com,
Tejun Heo <tj@kernel.org>
Subject: [PATCH 3/6] workqueue: protect wq->nr_drainers and ->flags with wq->mutex
Date: Mon, 25 Mar 2013 17:07:26 -0700 [thread overview]
Message-ID: <1364256449-11401-4-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1364256449-11401-1-git-send-email-tj@kernel.org>
From: Lai Jiangshan <laijs@cn.fujitsu.com>
We're expanding wq->mutex to cover all fields specific to each
workqueue with the end goal of replacing pwq_lock which will make
locking simpler and easier to understand.
wq->nr_drainers and ->flags are specific to each workqueue. Protect
->nr_drainers and ->flags with wq->mutex instead of pool_mutex.
tj: Rebased on top of the current dev branch. Updated description.
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
---
kernel/workqueue.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index d448eda..3ac2c4d 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -226,7 +226,7 @@ struct wq_device;
* the appropriate worker_pool through its pool_workqueues.
*/
struct workqueue_struct {
- unsigned int flags; /* PL: WQ_* flags */
+ unsigned int flags; /* WQ: WQ_* flags */
struct pool_workqueue __percpu *cpu_pwqs; /* I: per-cpu pwq's */
struct list_head pwqs; /* WR: all pwqs of this wq */
struct list_head list; /* PL: list of all workqueues */
@@ -242,7 +242,7 @@ struct workqueue_struct {
struct list_head maydays; /* MD: pwqs requesting rescue */
struct worker *rescuer; /* I: rescue worker */
- int nr_drainers; /* PL: drain in progress */
+ int nr_drainers; /* WQ: drain in progress */
int saved_max_active; /* PW: saved pwq max_active */
#ifdef CONFIG_SYSFS
@@ -2684,10 +2684,10 @@ void drain_workqueue(struct workqueue_struct *wq)
* hotter than drain_workqueue() and already looks at @wq->flags.
* Use __WQ_DRAINING so that queue doesn't have to check nr_drainers.
*/
- mutex_lock(&wq_pool_mutex);
+ mutex_lock(&wq->mutex);
if (!wq->nr_drainers++)
wq->flags |= __WQ_DRAINING;
- mutex_unlock(&wq_pool_mutex);
+ mutex_unlock(&wq->mutex);
reflush:
flush_workqueue(wq);
@@ -2714,10 +2714,10 @@ reflush:
local_irq_enable();
- mutex_lock(&wq_pool_mutex);
+ mutex_lock(&wq->mutex);
if (!--wq->nr_drainers)
wq->flags &= ~__WQ_DRAINING;
- mutex_unlock(&wq_pool_mutex);
+ mutex_unlock(&wq->mutex);
}
EXPORT_SYMBOL_GPL(drain_workqueue);
--
1.8.1.4
next prev parent reply other threads:[~2013-03-26 0:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-26 0:07 [PATCHSET wq/for-3.10] workqueue: replace pwq_lock with wq->mutex Tejun Heo
2013-03-26 0:07 ` [PATCH 1/6] workqueue: rename wq_mutex to wq_pool_mutex Tejun Heo
2013-03-26 0:07 ` [PATCH 2/6] workqueue: rename wq->flush_mutex to wq->mutex Tejun Heo
2013-03-26 0:07 ` Tejun Heo [this message]
2013-03-26 0:07 ` [PATCH 4/6] workqueue: protect wq->pwqs and iteration with wq->mutex Tejun Heo
2013-03-26 0:07 ` [PATCH 5/6] workqueue: protect wq->saved_max_active " Tejun Heo
2013-03-26 0:07 ` [PATCH 6/6] workqueue: remove pwq_lock which is no longer used 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=1364256449-11401-4-git-send-email-tj@kernel.org \
--to=tj@kernel.org \
--cc=js1304@gmail.com \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox