Re: [PATCH 3/7] idle, thermal, acpi: Remove home grown idle implementations

Peter Zijlstra
2013-11-21T16:30:11Z

On Thu, Nov 21, 2013 at 08:07:16AM -0800, Paul E. McKenney wrote:
> On Thu, Nov 21, 2013 at 09:21:51AM +0100, Peter Zijlstra wrote:
> > On Wed, Nov 20, 2013 at 04:54:06PM -0800, Jacob Pan wrote:
> > > On Wed, 20 Nov 2013 17:04:53 +0100
> > > Peter Zijlstra <peterz@infradead.org> wrote:
> > >
> > > > People are starting to grow their own idle implementations in various
> > > > disgusting ways. Collapse the lot and use the generic idle code to
> > > > provide a proper idle cycle implementation.
> > > >
> > > +Paul
> > >
> > > RCU and others rely on is_idle_task() might be broken with the
> > > consolidated idle code since caller of do_idle may have pid != 0.
> > >
> > > Should we use TS_POLL or introduce a new flag to identify idle task?
> >
> > PF_IDLE would be my preference, I checked and we seem to have a grand
> > total of 2 unused task_struct::flags left ;-)
>
> As long as RCU has some reliable way to identify an idle task, I am
> good. But I have to ask -- why can't idle injection coordinate with
> the existing idle tasks rather than temporarily making alternative
> idle tasks?

Because that'd completely wreck how the scheduler selects tasks for just
these 2 arguably insane drivers.

We'd have to somehow teach it to pick the actual idle task instead of
this one task, but keep scheduling the rest of the tasks like normal --
we very much should keep higher priority tasks running like normal.

And we'd need a way to make it stop doing this 'proxy' execution.

That said, once we manage to replace the entire PI implementation with a
proper proxy execution scheme, the above would be possible by having a
resource (rt_mutex) associated with every idle task, and always held by
that task.

At that point we can do something like:

rt_mutex_lock_timeout(cpu_idle_lock(cpu), jiffies);

And get the idle thread executing in our stead.

That said, idle is _special_ and I'd not be surprised we'd find a few
'funnies' along the way of trying to get that to actually work.

For now I'd rather not go there quite yet.