Re: [patch] sched: fix b5d9d734 blunder in task_new_fair()

Peter Zijlstra
2009-11-26T16:26:25Z

On Sun, 2009-11-22 at 13:07 +0100, Mike Galbraith wrote:
> @@ -2589,16 +2588,10 @@ void sched_fork(struct task_struct *p, i
> */
> p->prio = current->normal_prio;
>
> - if (!rt_prio(p->prio))
> + if (!task_has_rt_policy(p))
> p->sched_class = &fair_sched_class;
>
> -#ifdef CONFIG_SMP
> - cpu = p->sched_class->select_task_rq(p, SD_BALANCE_FORK, 0);
> -#endif
> - local_irq_save(flags);
> - update_rq_clock(cpu_rq(cpu));
> - set_task_cpu(p, cpu);
> - local_irq_restore(flags);
> + __set_task_cpu(p, cpu);

OK, so I figured out why it was in sched_fork() and not in
wake_up_new_task().

It is because in sched_fork() the new task isn't in the tasklist yet and
can therefore not race with any other migration logic.