From: Lai Jiangshan <laijs@cn.fujitsu.com>
To: Tejun Heo <tj@kernel.org>, linux-kernel@vger.kernel.org
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Subject: [V2 for-3.6-fixes PATCH 1/7] workqueue: clear WORKER_REBIND unconditionaly in busy_worker_rebind_fn()
Date: Mon, 17 Sep 2012 23:46:42 +0800 [thread overview]
Message-ID: <1347896808-2398-2-git-send-email-laijs@cn.fujitsu.com> (raw)
In-Reply-To: <1347896808-2398-1-git-send-email-laijs@cn.fujitsu.com>
We must clear this WORKER_REBIND before busy_worker_rebind_fn() returns,
otherise the worker may go to call idle_worker_rebind() wrongly, which
may access to the invalid ->idle_rebind and sleep forever in ->rebind_hold.
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
kernel/workqueue.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 7b91332..cc49593 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -1655,8 +1655,17 @@ static void busy_worker_rebind_fn(struct work_struct *work)
struct worker *worker = container_of(work, struct worker, rebind_work);
struct global_cwq *gcwq = worker->pool->gcwq;
- if (worker_maybe_bind_and_lock(worker))
- worker_clr_flags(worker, WORKER_REBIND);
+ worker_maybe_bind_and_lock(worker);
+
+ /*
+ * If hotplug has happened after rebind_workers(), a new %UNBOUND will
+ * have been set in worker->flags, so we can clear WORKER_REBIND
+ * unconditionaly(even the above worker_maybe_bind_and_lock() failed).
+ *
+ * And we must clear this WORKER_REBIND before return, otherwise
+ * this worker may go to call idle_worker_rebind() wrongly.
+ */
+ worker_clr_flags(worker, WORKER_REBIND);
spin_unlock_irq(&gcwq->lock);
}
@@ -2362,8 +2371,7 @@ woke_up:
spin_lock_irq(&gcwq->lock);
/*
- * DIE can be set only while idle and REBIND set while busy has
- * @worker->rebind_work scheduled. Checking here is enough.
+ * DIE or REBIND can be set only while idle. Checking here is enough.
*/
if (unlikely(worker->flags & (WORKER_REBIND | WORKER_DIE))) {
spin_unlock_irq(&gcwq->lock);
--
1.7.4.4
next prev parent reply other threads:[~2012-09-17 15:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-17 15:46 [V2 for-next PATCH 0/7] workqueue: async idle rebinding and cleanup for hotplug Lai Jiangshan
2012-09-17 15:46 ` Lai Jiangshan [this message]
2012-09-17 15:46 ` [V2 for-next PATCH 2/7] workqueue: async idle rebinding Lai Jiangshan
2012-09-17 15:46 ` [V2 for-next PATCH 3/7] workqueue: new day don't need WORKER_REBIND for busy rebinding Lai Jiangshan
2012-09-17 15:46 ` [V2 for-next PATCH 4/7] workqueue: remove WORKER_REBIND Lai Jiangshan
2012-09-17 15:46 ` [V2 for-next PATCH 5/7] workqueue: rename manager_mutex to assoc_mutex Lai Jiangshan
2012-09-17 15:46 ` [V2 for-next PATCH 6/7] workqueue: use __cpuinit instead of __devinit for cpu callback Lai Jiangshan
2012-09-17 15:46 ` [V2 for-next PATCH 7/7] workqueue: use hotcpu_notifier() for workqueue_cpu_down_callback() Lai Jiangshan
2012-09-18 9:40 ` [V2 for-next PATCH 0/7] workqueue: async idle rebinding and cleanup for hotplug Lai Jiangshan
2012-09-18 17:03 ` 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=1347896808-2398-2-git-send-email-laijs@cn.fujitsu.com \
--to=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@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
Powered by JetHome