Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1465205

Re: sched: current instead rq->current

From Peter Zijlstra <peterz@infradead.org>
Newsgroups linux.kernel
Subject Re: sched: current instead rq->current
Date 2016-08-18 14:10 +0200
Message-ID <s7uiZ-82P-7@gated-at.bofh.it> (permalink)
References <s6vTP-1iQ-13@gated-at.bofh.it> <s7eQV-5ow-25@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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.

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

sched: current instead rq->current Colin Vidal <colin@cvidal.org> - 2016-08-15 21:40 +0200
  Re: sched: current instead rq->current Colin Vidal <colin@cvidal.org> - 2016-08-17 21:40 +0200
    Re: sched: current instead rq->current Peter Zijlstra <peterz@infradead.org> - 2016-08-18 14:10 +0200

csiph-web