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

[PATCH] Tweak idle thread setup semantics

This patch tweaks idle thread setup semantics a bit: instead of setting
NEED_RESCHED in init_idle(), we do an explicit schedule() before calling
into cpu_idle().

This patch, while having no negative side-effects, enables wider use of
cond_resched()s.  (which might happen in the stock kernel too, but it's
particulary important for voluntary-preempt)
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 082cf69e
...@@ -383,6 +383,13 @@ static void noinline rest_init(void) ...@@ -383,6 +383,13 @@ static void noinline rest_init(void)
numa_default_policy(); numa_default_policy();
unlock_kernel(); unlock_kernel();
preempt_enable_no_resched(); preempt_enable_no_resched();
/*
* The boot idle thread must execute schedule()
* at least one to get things moving:
*/
schedule();
cpu_idle(); cpu_idle();
} }
......
...@@ -4166,6 +4166,14 @@ void show_state(void) ...@@ -4166,6 +4166,14 @@ void show_state(void)
read_unlock(&tasklist_lock); read_unlock(&tasklist_lock);
} }
/**
* init_idle - set up an idle thread for a given CPU
* @idle: task in question
* @cpu: cpu the idle task belongs to
*
* NOTE: this function does not set the idle thread's NEED_RESCHED
* flag, to make booting more robust.
*/
void __devinit init_idle(task_t *idle, int cpu) void __devinit init_idle(task_t *idle, int cpu)
{ {
runqueue_t *rq = cpu_rq(cpu); runqueue_t *rq = cpu_rq(cpu);
...@@ -4183,7 +4191,6 @@ void __devinit init_idle(task_t *idle, int cpu) ...@@ -4183,7 +4191,6 @@ void __devinit init_idle(task_t *idle, int cpu)
#if defined(CONFIG_SMP) && defined(__ARCH_WANT_UNLOCKED_CTXSW) #if defined(CONFIG_SMP) && defined(__ARCH_WANT_UNLOCKED_CTXSW)
idle->oncpu = 1; idle->oncpu = 1;
#endif #endif
set_tsk_need_resched(idle);
spin_unlock_irqrestore(&rq->lock, flags); spin_unlock_irqrestore(&rq->lock, flags);
/* Set the preempt count _outside_ the spinlocks! */ /* Set the preempt count _outside_ the spinlocks! */
......
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