* sched: current instead rq->current
@ 2016-08-15 19:30 Colin Vidal
2016-08-17 19:39 ` Colin Vidal
0 siblings, 1 reply; 3+ messages in thread
From: Colin Vidal @ 2016-08-15 19:30 UTC (permalink / raw)
To: linux-kernel
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: sched: current instead rq->current
2016-08-15 19:30 sched: current instead rq->current Colin Vidal
@ 2016-08-17 19:39 ` Colin Vidal
2016-08-18 11:28 ` Peter Zijlstra
0 siblings, 1 reply; 3+ messages in thread
From: Colin Vidal @ 2016-08-17 19:39 UTC (permalink / raw)
To: linux-kernel; +Cc: mingo, peterz
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: sched: current instead rq->current
2016-08-17 19:39 ` Colin Vidal
@ 2016-08-18 11:28 ` Peter Zijlstra
0 siblings, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2016-08-18 11:28 UTC (permalink / raw)
To: Colin Vidal; +Cc: linux-kernel, mingo
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-08-18 12:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-15 19:30 sched: current instead rq->current Colin Vidal
2016-08-17 19:39 ` Colin Vidal
2016-08-18 11:28 ` Peter Zijlstra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).