sched: Fix crash trying to dequeue/enqueue the idle thread
authorPeter Zijlstra <peterz@infradead.org>
Thu, 13 Aug 2015 21:09:29 +0000 (23:09 +0200)
committerIngo Molnar <mingo@kernel.org>
Fri, 18 Sep 2015 07:17:50 +0000 (09:17 +0200)
commitde9b8f5dcbd94bfb1d249907a635f1fb1968e19c
tree82744e9ef61c2cd985c7f9af1f6af287255464ac
parenta7d5c189719846889c029c34e24e166a465368fa
sched: Fix crash trying to dequeue/enqueue the idle thread

Sasha reports that his virtual machine tries to schedule the idle
thread since commit 6c37067e2786 ("sched: Change the
sched_class::set_cpus_allowed() calling context").

Hit trace shows this happening from idle_thread_get()->init_idle(),
which is the _second_ init_idle() invocation on that task_struct, the
first being done through idle_init()->fork_idle(). (this code is
insane...)

Because we call init_idle() twice in a row, its ->sched_class ==
&idle_sched_class and ->on_rq = TASK_ON_RQ_QUEUED. This means
do_set_cpus_allowed() think we're queued and will call dequeue_task(),
which is implemented with BUG() for the idle class, seeing how
dequeueing the idle task is a daft thing.

Aside of the whole insanity of calling init_idle() _twice_, change the
code to call set_cpus_allowed_common() instead as this is 'obviously'
before the idle task gets ran etc..

Reported-by: Sasha Levin <sasha.levin@oracle.com>
Tested-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: 6c37067e2786 ("sched: Change the sched_class::set_cpus_allowed() calling context")
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/sched/core.c
This page took 0.024719 seconds and 5 git commands to generate.