Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=36aa9dfc39bf473780439f5629c30f59d677e793
Commit:     36aa9dfc39bf473780439f5629c30f59d677e793
Parent:     d721304dce0ced0b3b0366996cc02929669708a8
Author:     Oleg Nesterov <[EMAIL PROTECTED]>
AuthorDate: Wed May 9 02:34:08 2007 -0700
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Wed May 9 12:30:52 2007 -0700

    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 <[EMAIL PROTECTED]>
    Cc: Srivatsa Vaddagiri <[EMAIL PROTECTED]>
    Cc: "Pallipadi, Venkatesh" <[EMAIL PROTECTED]>
    Cc: Gautham shenoy <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 kernel/workqueue.c |   15 +++++----------
 1 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 1d1933c..398c34f 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -625,17 +625,12 @@ EXPORT_SYMBOL_GPL(__create_workqueue);
 
 static void cleanup_workqueue_thread(struct workqueue_struct *wq, int cpu)
 {
-       struct cpu_workqueue_struct *cwq;
-       unsigned long flags;
-       struct task_struct *p;
+       struct cpu_workqueue_struct *cwq = per_cpu_ptr(wq->cpu_wq, cpu);
 
-       cwq = per_cpu_ptr(wq->cpu_wq, cpu);
-       spin_lock_irqsave(&cwq->lock, flags);
-       p = cwq->thread;
-       cwq->thread = NULL;
-       spin_unlock_irqrestore(&cwq->lock, flags);
-       if (p)
-               kthread_stop(p);
+       if (cwq->thread) {
+               kthread_stop(cwq->thread);
+               cwq->thread = NULL;
+       }
 }
 
 /**
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to