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

    workqueues: shift kthread_bind() from CPU_UP_PREPARE to CPU_ONLINE
    
    CPU_UP_PREPARE binds cwq->thread to the new CPU.  So CPU_UP_CANCELED tries 
to
    wake up the task which is bound to the failed CPU.
    
    With this patch we don't bind cwq->thread until CPU becomes online.  The 
first
    wake_up() after kthread_create() is a bit special, make a simple helper for
    that.
    
    Signed-off-by: Oleg Nesterov <[EMAIL PROTECTED]>
    Cc: Gautham R Shenoy <[EMAIL PROTECTED]>
    Cc: "Rafael J. Wysocki" <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 kernel/workqueue.c |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index e858e93..7d1ebfc 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -668,15 +668,21 @@ static int create_workqueue_thread(struct 
cpu_workqueue_struct *cwq, int cpu)
 
        cwq->thread = p;
        cwq->should_stop = 0;
-       if (!is_single_threaded(wq))
-               kthread_bind(p, cpu);
-
-       if (is_single_threaded(wq) || cpu_online(cpu))
-               wake_up_process(p);
 
        return 0;
 }
 
+static void start_workqueue_thread(struct cpu_workqueue_struct *cwq, int cpu)
+{
+       struct task_struct *p = cwq->thread;
+
+       if (p != NULL) {
+               if (cpu >= 0)
+                       kthread_bind(p, cpu);
+               wake_up_process(p);
+       }
+}
+
 struct workqueue_struct *__create_workqueue(const char *name,
                                            int singlethread, int freezeable)
 {
@@ -702,6 +708,7 @@ struct workqueue_struct *__create_workqueue(const char 
*name,
        if (singlethread) {
                cwq = init_cpu_workqueue(wq, singlethread_cpu);
                err = create_workqueue_thread(cwq, singlethread_cpu);
+               start_workqueue_thread(cwq, -1);
        } else {
                mutex_lock(&workqueue_mutex);
                list_add(&wq->list, &workqueues);
@@ -711,6 +718,7 @@ struct workqueue_struct *__create_workqueue(const char 
*name,
                        if (err || !cpu_online(cpu))
                                continue;
                        err = create_workqueue_thread(cwq, cpu);
+                       start_workqueue_thread(cwq, cpu);
                }
                mutex_unlock(&workqueue_mutex);
        }
@@ -808,12 +816,11 @@ static int __devinit workqueue_cpu_callback(struct 
notifier_block *nfb,
                        return NOTIFY_BAD;
 
                case CPU_ONLINE:
-                       wake_up_process(cwq->thread);
+                       start_workqueue_thread(cwq, cpu);
                        break;
 
                case CPU_UP_CANCELED:
-                       if (cwq->thread)
-                               wake_up_process(cwq->thread);
+                       start_workqueue_thread(cwq, -1);
                case CPU_DEAD:
                        cleanup_workqueue_thread(cwq, cpu);
                        break;
-
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