Re: [RFC PATCH] sched: find the latest idle cpu

From: Nicolas Pitre
Date: Thu Jan 16 2014 - 21:40:37 EST

On Thu, 16 Jan 2014, Daniel Lezcano wrote:

> The question raised when I looked closely how to fully integrate cpuidle with
> the scheduler; in particular, the idle time.
> The scheduler idle time is not the same than the cpuidle idle time.
> A cpu can be idle for the scheduler 1s but it could be interrupted several
> times by an interrupt thus the idle time for cpuidle is different. But anyway
> ...

The idle task would run each time an interrupt has been serviced, either
to yield to a newly awaken task or to put the CPU back to sleep. In the
later case the idle task may simply do extra idleness accounting
locally. If the former case happens most of the time then the scheduler
idle time would be most representative already.

And if threaded IRQs are used then the the scheduler idle time would be
the same as cpuidle's.

> > We need the idle task, since we need to DO something to go idle, the
> > scheduler needs to pick a task to go do that something. This is the idle
> > task.
> >
> > You cannot get rid of that.
> >
> > In fact, the 'doing' of that task is running much of the cpuidle code,
> > so by getting rid of it, there's nobody left to execute that code.
> >
> > Also, since its already running that cpuidle stuff, integrating it more
> > closely with the scheduler will not in fact change much, it will still
> > run it.
> >
> > Could of course be I'm not reading what you meant to write, if so, do
> > try again ;-)
> Well, I wanted to have a clarification of what was your feeling about how to
> integrate cpuidle in the scheduler. If removing the idle task (in the future)
> does not make sense for you, I will not insist. Let's see how the code evolves
> by integrating cpuidle and we will figure out what will be the impact on the
> idle task.

I think we should be able to get rid of architecture specific idle
loops. The idle loop could be moved close to the scheduler and
architectures would only need to provide a default CPU halt method for
when there is nothing else registered with the cpuidle subsystem.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at