Re: [RFC][PATCH 16/17] sched: Move the second half of ttwu() tothe remote cpu

From: Oleg Nesterov
Date: Tue Jan 04 2011 - 11:14:17 EST


On 01/04, Peter Zijlstra wrote:
>
> On Tue, 2011-01-04 at 16:18 +0100, Oleg Nesterov wrote:
>
> > > I don't think so, nobody should be migrating a TASK_WAKING task.
> >
> > I am not sure...
> >
> > Suppose that p was TASK_INTERRUPTIBLE and p->on_rq == 1 before, when
> > set_cpus_allowed_ptr() was called. To simplify, suppose that
> > the caller is preempted right after it drops p->pi_lock and before
> > it does stop_one_cpu(migration_cpu_stop).
> >
> > After that p can complete chedule() and deactivate itself.
> >
> > Now, try_to_wake_up() can set TASK_WAKING, choose another CPU,
> > and do ttwu_queue_remote().
> >
> > Finally, the caller of set_cpus_allowed_ptr() resumes and
> > schedules migration_cpu_stop.
>
> But __migrate_task() will then find !p->on_rq and not actually do
> anything.

But if it races with ttwu_do_activate() (which can hold another
rq->lock != rq_src/rq_dest), it can check p->on_rq after
activate_task() was already called.



But I think this no longer matters,

> > It is very possible I missed something, but what is the new
> > locking rules for set_task_cpu() anyway? I mean, which rq->lock
> > it needs?
>
> In the patches I just posted: set_task_cpu(p, cpu) callers need to
> either hold task_rq(p)->lock (the old rq) or p->pi_lock.

Yes, thanks, I already noticed v4, and at first glance 11/18 plus
set_task_cpu() in try_to_wake_up() should close the problems...

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/