Re: [patch] Re: There is something with scheduler (was Re: [patch]Re: [regression bisect -next] BUG: using smp_processor_id() in preemptible[00000000] code: rmmod)

From: Mike Galbraith
Date: Thu Nov 05 2009 - 23:46:52 EST


On Fri, 2009-11-06 at 10:31 +0800, Lai Jiangshan wrote:
>
> > +/*
> > + * cpu_rq_lock - lock the runqueue a given task resides on and disable
> > + * interrupts. Note the ordering: we can safely lookup the cpu_rq without
> > + * explicitly disabling preemption.
> > + */
> > +static struct rq *cpu_rq_lock(int cpu, unsigned long *flags)
> > + __acquires(rq->lock)
> > +{
> > + struct rq *rq;
> > +
> > + for (;;) {
> > + local_irq_save(*flags);
> > + rq = cpu_rq(cpu);
> > + spin_lock(&rq->lock);
> > + if (likely(rq == cpu_rq(cpu)))
> > + return rq;
> > + spin_unlock_irqrestore(&rq->lock, *flags);
> > + }
> > +}
> > +
> > +static inline void cpu_rq_unlock(struct rq *rq, unsigned long *flags)
> > + __releases(rq->lock)
> > +{
> > + spin_unlock_irqrestore(&rq->lock, *flags);
> > +}
> > +
>
> The above code is totally garbage, cpu_rq(cpu) is constant.

No, that's not the garbage bit. The true hazard of late late night is
that you can't _see_ anymore. cpu_rq_lock + spin_unlock :)))))

Now I'm _really_ puzzled. Embarrassing, but funny.

-Mike

--
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/