[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: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Ingo Molnar and committed by Linus Torvalds f340c0d1 082cf69e

+15 -1
+7
init/main.c
··· 383 383 numa_default_policy(); 384 384 unlock_kernel(); 385 385 preempt_enable_no_resched(); 386 + 387 + /* 388 + * The boot idle thread must execute schedule() 389 + * at least one to get things moving: 390 + */ 391 + schedule(); 392 + 386 393 cpu_idle(); 387 394 } 388 395
+8 -1
kernel/sched.c
··· 4166 4166 read_unlock(&tasklist_lock); 4167 4167 } 4168 4168 4169 + /** 4170 + * init_idle - set up an idle thread for a given CPU 4171 + * @idle: task in question 4172 + * @cpu: cpu the idle task belongs to 4173 + * 4174 + * NOTE: this function does not set the idle thread's NEED_RESCHED 4175 + * flag, to make booting more robust. 4176 + */ 4169 4177 void __devinit init_idle(task_t *idle, int cpu) 4170 4178 { 4171 4179 runqueue_t *rq = cpu_rq(cpu); ··· 4191 4183 #if defined(CONFIG_SMP) && defined(__ARCH_WANT_UNLOCKED_CTXSW) 4192 4184 idle->oncpu = 1; 4193 4185 #endif 4194 - set_tsk_need_resched(idle); 4195 4186 spin_unlock_irqrestore(&rq->lock, flags); 4196 4187 4197 4188 /* Set the preempt count _outside_ the spinlocks! */