On Sun, 7 Apr 2013, Borislav Petkov wrote:

> On Sun, Apr 07, 2013 at 11:20:10AM +0200, Thomas Gleixner wrote:
> > And it's even more bogus because the cpu to which we would bind in
> > kthread_create_on_cpu() is not yet online.
> 
> In case you guys are wondering about reproducibility, I saw the same
> BUG_ON yesterday on a 32-bit atom smp qemu guest too (don't ask why?
> :-))

I don't have to ask. It's caused by massive brain failure on my side.

Does the patch below fix the issue ?

Thanks,

        tglx
---
Index: linux-2.6/kernel/kthread.c
===================================================================
--- linux-2.6.orig/kernel/kthread.c
+++ linux-2.6/kernel/kthread.c
@@ -131,8 +131,14 @@ static void __kthread_parkme(struct kthr
                schedule();
                __set_current_state(TASK_INTERRUPTIBLE);
        }
-       clear_bit(KTHREAD_IS_PARKED, &self->flags);
        __set_current_state(TASK_RUNNING);
+       clear_bit(KTHREAD_IS_PARKED, &self->flags);
+
+       /* Rebind ourself to the target cpu */
+       if (test_bit(KTHREAD_IS_PER_CPU, &self->flags)) {
+               set_cpus_allowed_ptr(currrent, cpumask_of(self->cpu));
+               current->flags |= PF_THREAD_BOUND;
+       }
 }
 
 void kthread_parkme(void)
@@ -344,11 +350,8 @@ void kthread_unpark(struct task_struct *
                 * park before that happens we'd see the IS_PARKED bit
                 * which might be about to be cleared.
                 */
-               if (test_and_clear_bit(KTHREAD_IS_PARKED, &kthread->flags)) {
-                       if (test_bit(KTHREAD_IS_PER_CPU, &kthread->flags))
-                               __kthread_bind(k, kthread->cpu);
+               if (test_and_clear_bit(KTHREAD_IS_PARKED, &kthread->flags))
                        wake_up_process(k);
-               }
        }
        put_task_struct(k);
 }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to