Re: [RFC PATCH 2/4] x86, mwaitt: introduce mwaitx idle with a configurable timer

From: Huang Rui
Date: Sun May 24 2015 - 23:00:48 EST


On Wed, May 20, 2015 at 07:11:20PM +0800, Ingo Molnar wrote:
>
> * Borislav Petkov <bp@xxxxxxx> wrote:
>
> > On Wed, May 20, 2015 at 12:22:58PM +0200, Ingo Molnar wrote:
> >
> > > Well, HLT does not get any hint from the OS how long the idling is
> > > expected to last.
> >
> > MWAIT on AMD doesn't either:
>
> Yeah, MWAIT clearly doesn't, but I was talking about MWAITX, which
> takes a timeout parameter as per these patches.
>
> > > Another MWAITX round - we've got no crystal ball, so the hint
> > > might be wrong if an external event occurs that we did not
> > > anticipate.
> >
> > So if we end up doing a bunch of MWAITX rounds instead of HLT and
> > MWAITX saves less power than HLT, then we practically are worse.
>
> So the way I think it would work ideally is (and note that this is
> different from how you think it works):
>
> - MWAITX takes a 'timeout' parameter, but otherwise behaves exactly
> like MWAIT: i.e. once idle it won't exit idle on its own
>
> - based on the 'timeout' hint, MWAITX can internally optimize how
> deep sleep it enters. If the timeout is large it goes deep, if
> it's small, it goes shallow. This does not change the fact that no
> matter which state it enters, it will come back the moment an
> interrupt is posted.

No, the timeout value doesn't decide how 'deep' the power state enters.
Basically, the same power consumption with any timeout.

I summarized the comparison of mwait and mwaitx

MWAIT MWAITX
opcode 0f 01 c9 | 0f 01 fb
ECX[0] value of RFLAGS.IF seen by instruction
ECX[1] unused/#GP if set | enable timer if set
ECX[31:2] unused/#GP if set
EAX unused
EBX[31:0] unused | max wait time (loops)


MONITOR MONITORX
opcode 0f 01 c8 | 0f 01 fa
EAX (logical) address to monitor
ECX #GP if not zero

Thanks,
Rui
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/