Re: [RFC][PATCH 08/17] sched: Drop the rq argument tosched_class::select_task_rq()

From: Peter Zijlstra
Date: Mon Jan 03 2011 - 06:17:05 EST


On Wed, 2010-12-29 at 22:31 +0800, Yong Zhang wrote:
> On Fri, Dec 24, 2010 at 01:23:46PM +0100, Peter Zijlstra wrote:
> > In preparation of calling select_task_rq() without rq->lock held, drop
> > the dependency on the rq argument.
> >
> > Signed-off-by: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
> > ---
> > @@ -3416,27 +3409,22 @@ void sched_exec(void)
> > {
> > struct task_struct *p = current;
> > unsigned long flags;
> > - struct rq *rq;
> > int dest_cpu;
> >
> > - rq = task_rq_lock(p, &flags);
> > - dest_cpu = p->sched_class->select_task_rq(rq, p, SD_BALANCE_EXEC, 0);
> > + raw_spin_lock_irqsave(&p->pi_lock, flags);
>
> Seems this should go to patch 07/17 ;)

Ah, the reason its here is that this patch removes the rq argument and
thus we no longer need rq->lock. So this part relies on the property
introduced by patch 7.

> > + dest_cpu = p->sched_class->select_task_rq(p, SD_BALANCE_EXEC, 0);
> > if (dest_cpu == smp_processor_id())
> > goto unlock;
> >
> > - /*
> > - * select_task_rq() can race against ->cpus_allowed
> > - */
> > - if (cpumask_test_cpu(dest_cpu, &p->cpus_allowed) &&
> > - likely(cpu_active(dest_cpu)) && migrate_task(p, rq)) {
> > + if (likely(cpu_active(dest_cpu)) && need_migrate_task(p)) {
>
> If we drop rq_lock, need_migrate_task() maybe return true but
> p is already running on other cpu. Thus we do a wrong migration
> call.

Yeah, too bad.. ;-) exec load balancing is more an optimistic thing
anyway, if it got rebalanced under out feet we don't care.
--
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/