Commit dd9baec3 authored by Ingo Molnar's avatar Ingo Molnar Committed by Linus Torvalds

[PATCH] idle thread preemption fix

The early bootup stage is pretty fragile because the idle thread is not yet
functioning as such and so we need preemption disabled.  Whether the bootup
fails or not seems to depend on timing details so e.g.  the presence of
SCHED_SMT makes it go away.

Disabling preemption explicitly has another advantage: the atomicity check
in schedule() will catch early-bootup schedule() calls from now on.

The patch also fixes another preempt-bkl buglet: interrupt-driven
forced-preemption didnt go through preempt_schedule() so it resulted in
auto-dropping of the BKL.  Now we go through preempt_schedule() which
properly deals with the BKL.
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 2b5726db
......@@ -184,9 +184,8 @@ need_resched:
jz restore_all
testl $IF_MASK,EFLAGS(%esp) # interrupts off (exception path) ?
jz restore_all
movl $PREEMPT_ACTIVE,TI_preempt_count(%ebp)
sti
call schedule
call preempt_schedule
cli
movl $0,TI_preempt_count(%ebp)
jmp need_resched
......
......@@ -373,6 +373,12 @@ static void noinline rest_init(void)
{
kernel_thread(init, NULL, CLONE_FS | CLONE_SIGHAND);
numa_default_policy();
/*
* Re-enable preemption but disable interrupts to make sure
* we dont get preempted until we schedule() in cpu_idle().
*/
local_irq_disable();
preempt_enable_no_resched();
unlock_kernel();
cpu_idle();
}
......@@ -438,6 +444,7 @@ asmlinkage void __init start_kernel(void)
* time - but meanwhile we still have a functioning scheduler.
*/
sched_init();
preempt_disable();
build_all_zonelists();
page_alloc_init();
printk("Kernel command line: %s\n", saved_command_line);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment