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


Groups > linux.kernel > #1463127 > unrolled thread

sched: current instead rq->current

Started byColin Vidal <colin@cvidal.org>
First post2016-08-15 21:40 +0200
Last post2016-08-18 14:10 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  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

#1463127 — sched: current instead rq->current

FromColin Vidal <colin@cvidal.org>
Date2016-08-15 21:40 +0200
Subjectsched: current instead rq->current
Message-ID<s6vTP-1iQ-13@gated-at.bofh.it>
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?

Since a runqueue is specific to a CPU, it dosen't make sense to get the
the current task of another CPU's runqueue. Yes?

I try the following of Linus's master branch

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

Thanks!

Colin

[toc] | [next] | [standalone]


#1464751

FromColin Vidal <colin@cvidal.org>
Date2016-08-17 21:40 +0200
Message-ID<s7eQV-5ow-25@gated-at.bofh.it>
In reply to#1463127
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?
> 
> Since a runqueue is specific to a CPU, it dosen't make sense to get
> the
> the current task of another CPU's runqueue. Yes?
> 
> I try the following of Linus's master branch
> 
> -       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?
> 
> Thanks!
> 
> Colin

I realize that I have forgotten to add scheduler subsystem in CC... So
I do it now. Sorry for double post.

Thanks

Colin

[toc] | [prev] | [next] | [standalone]


#1465205

FromPeter Zijlstra <peterz@infradead.org>
Date2016-08-18 14:10 +0200
Message-ID<s7uiZ-82P-7@gated-at.bofh.it>
In reply to#1464751
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.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web