aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@tv-sign.ru>2007-05-09 05:34:08 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-09 15:30:52 -0400
commit36aa9dfc39bf473780439f5629c30f59d677e793 (patch)
tree301d615747210733a271c376fc036a7480594207
parentd721304dce0ced0b3b0366996cc02929669708a8 (diff)
workqueue: don't clear cwq->thread until it exits
Pointed out by Srivatsa Vaddagiri. cleanup_workqueue_thread() sets cwq->thread = NULL and does kthread_stop(). This breaks the "if (cwq->thread == current)" logic in flush_cpu_workqueue() and leads to deadlock. Kill the thead first, then clear cwq->thread. workqueue_mutex protects us from create_workqueue_thread() so we don't need cwq->lock. Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru> Cc: Srivatsa Vaddagiri <vatsa@in.ibm.com> Cc: "Pallipadi, Venkatesh" <venkatesh.pallipadi@intel.com> Cc: Gautham shenoy <ego@in.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--kernel/workqueue.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 1d1933cf3778..398c34ff6a54 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -625,17 +625,12 @@ EXPORT_SYMBOL_GPL(__create_workqueue);
625 625
626static void cleanup_workqueue_thread(struct workqueue_struct *wq, int cpu) 626static void cleanup_workqueue_thread(struct workqueue_struct *wq, int cpu)
627{ 627{
628 struct cpu_workqueue_struct *cwq; 628 struct cpu_workqueue_struct *cwq = per_cpu_ptr(wq->cpu_wq, cpu);
629 unsigned long flags;
630 struct task_struct *p;
631 629
632 cwq = per_cpu_ptr(wq->cpu_wq, cpu); 630 if (cwq->thread) {
633 spin_lock_irqsave(&cwq->lock, flags); 631 kthread_stop(cwq->thread);
634 p = cwq->thread; 632 cwq->thread = NULL;
635 cwq->thread = NULL; 633 }
636 spin_unlock_irqrestore(&cwq->lock, flags);
637 if (p)
638 kthread_stop(p);
639} 634}
640 635
641/** 636/**