Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=a076e4bca2fdabb9e45d86722cc72c0944da5f94
Commit:     a076e4bca2fdabb9e45d86722cc72c0944da5f94
Parent:     49b12d4f5e274517b8bc032d507abf31cc2f4150
Author:     Oleg Nesterov <[EMAIL PROTECTED]>
AuthorDate: Wed May 23 13:57:27 2007 -0700
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Wed May 23 20:14:11 2007 -0700

    freezer: fix kthread_create vs freezer theoretical race
    
    kthread() sleeps in TASK_INTERRUPTIBLE state waiting for the first wakeup.  
In
    theory, this wakeup may come from freeze_process()->signal_wake_up(), so the
    task can disappear even before kthread_create() sets its ->comm.
    
    Change kthread() to use TASK_UNINTERRUPTIBLE.
    
    [EMAIL PROTECTED]: s/BUG_ON/WARN_ON+recover]
    Signed-off-by: Oleg Nesterov <[EMAIL PROTECTED]>
    Acked-by: "Eric W. Biederman" <[EMAIL PROTECTED]>
    Signed-off-by: Rafael J. Wysocki <[EMAIL PROTECTED]>
    Cc: Gautham R Shenoy <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 kernel/kthread.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/kernel/kthread.c b/kernel/kthread.c
index df8a8e8..bbd51b8 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -70,7 +70,7 @@ static int kthread(void *_create)
        data = create->data;
 
        /* OK, tell user we're spawned, wait for stop or wakeup */
-       __set_current_state(TASK_INTERRUPTIBLE);
+       __set_current_state(TASK_UNINTERRUPTIBLE);
        complete(&create->started);
        schedule();
 
@@ -162,7 +162,10 @@ EXPORT_SYMBOL(kthread_create);
  */
 void kthread_bind(struct task_struct *k, unsigned int cpu)
 {
-       BUG_ON(k->state != TASK_INTERRUPTIBLE);
+       if (k->state != TASK_UNINTERRUPTIBLE) {
+               WARN_ON(1);
+               return;
+       }
        /* Must have done schedule() in kthread() before we set_task_cpu */
        wait_task_inactive(k);
        set_task_cpu(k, cpu);
-
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