Re: sched: current instead rq->current
From: Peter Zijlstra
Date: Thu Aug 18 2016 - 08:00:55 EST
On Wed, Aug 17, 2016 at 09:39:41PM +0200, Colin Vidal wrote:
> On Mon, 2016-08-15 at 21:30 +0200, Colin Vidal wrote:
> > Hello,
> >
> > At the beginning of __schedule (kernel/sched/core.c), the current
> > task
> > is get with rq->curr. I try to to understand why not directly using
> > current instead?
> > - int cpu;
> >
> > - cpu = smp_processor_id();
> > - rq = cpu_rq(cpu);
> > - prev = rq->curr;
> > + rq = cpu_rq(smp_processor_id());
> > + prev = current;
> >
> > and it seems to work (only tested on x86-64), but... To simple?
its more expensive, rq->curr is a simple dereference (and we need that
cacheline anyway), while current is a weird macro that expands to
potentially a lot of code, depending on the arch.