summaryrefslogtreecommitdiffstats
path: root/kernel/workqueue.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2010-07-14 11:31:20 +0200
committerTejun Heo <tj@kernel.org>2010-07-14 11:31:20 +0200
commit9f9c23644b07e7a51f6f39064e61c150be712932 (patch)
tree831849ae8bfd602b3333e8ea8e3beb2cf0dee348 /kernel/workqueue.c
parent083b804c4d3e1e3d0eace56bdbc0f674946d2847 (diff)
downloadop-kernel-dev-9f9c23644b07e7a51f6f39064e61c150be712932.zip
op-kernel-dev-9f9c23644b07e7a51f6f39064e61c150be712932.tar.gz
workqueue: fix locking in retry path of maybe_create_worker()
maybe_create_worker() mismanaged locking when worker creation fails and it has to retry. Fix locking and simplify lock manipulation. Signed-off-by: Tejun Heo <tj@kernel.org> Reported-by: Yong Zhang <yong.zhang@windriver.com>
Diffstat (limited to 'kernel/workqueue.c')
-rw-r--r--kernel/workqueue.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 20d6237..aca9472 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -1442,14 +1442,14 @@ static bool maybe_create_worker(struct global_cwq *gcwq)
if (!need_to_create_worker(gcwq))
return false;
restart:
+ spin_unlock_irq(&gcwq->lock);
+
/* if we don't make progress in MAYDAY_INITIAL_TIMEOUT, call for help */
mod_timer(&gcwq->mayday_timer, jiffies + MAYDAY_INITIAL_TIMEOUT);
while (true) {
struct worker *worker;
- spin_unlock_irq(&gcwq->lock);
-
worker = create_worker(gcwq, true);
if (worker) {
del_timer_sync(&gcwq->mayday_timer);
@@ -1462,15 +1462,13 @@ restart:
if (!need_to_create_worker(gcwq))
break;
- spin_unlock_irq(&gcwq->lock);
__set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(CREATE_COOLDOWN);
- spin_lock_irq(&gcwq->lock);
+
if (!need_to_create_worker(gcwq))
break;
}
- spin_unlock_irq(&gcwq->lock);
del_timer_sync(&gcwq->mayday_timer);
spin_lock_irq(&gcwq->lock);
if (need_to_create_worker(gcwq))
OpenPOWER on IntegriCloud