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

Thomas Gleixner
2015-05-20T19:12:14Z

On Wed, 20 May 2015, Borislav Petkov wrote:

> On Wed, May 20, 2015 at 04:55:58PM +0100, One Thousand Gnomes wrote:
> > > That's not what appears to be happening here though: the MWAITX will
> > > return after the timeout.
> > >
> > > Which isn't really useful unless we use it to drive timers.
> >
> > What about things like mdelay() ?
>
> It has an upper limit on the max timeout though: u32 TSC cycles.

Which would be good enough for mdelay/udelay I think, but we'd need to
measure the time spend in MWAITT so we wont return early.

Something like this:

delay = usec_to_tsc(delay);
end = rdtsc() + delay;
while (1) {
MWAITT(delay);
now = rdtsc();
if (end <= now)
break;
delay = end - now;
}

Now we'd need to add alternatives or some other mechanism to it to
make this conditionally for those machines.

Not sure if it's worth the trouble.

Thanks,

tglx