On Tue, Dec 01, 2020 at 11:45:25AM -0800, Linus Torvalds wrote:
> On Mon, Nov 30, 2020 at 11:56 PM Peter Zijlstra <pet...@infradead.org> wrote:
> >
> > So even if an architecture needs to enable interrupts on idle, we need
> > it disabled again when coming out. So we might as well have the arch
> > idle routine then be: STI; HLT; CLI; because then architectures than can
> > idle with interrupts disabled can avoid mucking about with the interrupt
> > state entirely.
> 
> But that's not what the code is doing.
> 
> Go look at it.
> 
> It does sti;hlt;cli;pushf;cli;sti.
> 
> All for no good reason - because the code is structured so that even
> if all the tracking and lockdep is disabled, the pointless "let's
> protect the tracking from interrupts" is still there.
> 
> See what I am complaining about?

Absolutely.

  default_idle()
    arch_cpu_idle()
      sti; hlt;
    cli;
    rcu_idle_exit()
      pushf;
      cli;
      rcu_eqs_exit(false);
      popf;
    sti;

is what it currently looks like, and that's completely insane, no
argument.

What I would like to end up with is:

  default_idle()
    arch_cpu_idle()
      sti; hlt; cli
    rcu_idle_exit()
      rcu_eqs_exit(false);
    sti;

Which would allow architectures that can idle with IRQs disabled to do
so. But that needs a little more work:

 - make arch_cpu_idle() IRQ invariant (we enter and exit with IRQs off)
 - make cpuidle drivers do similar
 - audit all rcu_idle_exit() callers and remove save/restore

Reply via email to