[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150609092952.GR3644@twins.programming.kicks-ass.net>
Date: Tue, 9 Jun 2015 11:29:52 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Huang Rui <ray.huang@....com>
Cc: Borislav Petkov <bp@...e.de>,
Andy Lutomirski <luto@...capital.net>,
Thomas Gleixner <tglx@...utronix.de>,
"Rafael J. Wysocki" <rjw@...ysocki.net>,
Len Brown <lenb@...nel.org>,
John Stultz <john.stultz@...aro.org>,
Frédéric Weisbecker <fweisbec@...il.com>,
linux-kernel@...r.kernel.org, x86@...nel.org,
Fengguang Wu <fengguang.wu@...el.com>,
Aaron Lu <aaron.lu@...el.com>,
Suravee Suthikulanit <suravee.suthikulpanit@....com>,
Tony Li <tony.li@....com>, Ken Xue <ken.xue@....com>
Subject: Re: [PATCH v2 3/4] x86, mwaitt: introduce mwaix delay with a
configurable timer
On Tue, Jun 09, 2015 at 11:13:40AM +0800, Huang Rui wrote:
> +static void delay_mwaitx(unsigned long __loops)
> +{
> + u32 end, now, delay, addr;
> +
> + delay = __loops;
> + rdtsc_barrier();
> + rdtscl(end);
> + end += delay;
> +
> + while (1) {
> + __monitorx(&addr, 0, 0);
> + mwaitx(delay, true);
> +
> + rdtsc_barrier();
> + rdtscl(now);
> + if (end <= now)
> + break;
> + delay = end - now;
> + }
How about you think instead and do something like:
rdtsc(start);
rdtsc_barrier();
for (;;) {
delay = min(MWAIT_MAX_LOOPS, loops);
__monitorx(&addr, 0, 0);
mwaitx(delay, true);
rdtsc_barrier();
rdtsc(end);
rdtsc_barrier();
loops -= end - start;
if (loops <= 0)
break;
start = end;
}
> +}
> +
> +/*
> * Since we calibrate only once at boot, this
> * function should be set once at boot and not changed
> */
> @@ -118,7 +145,12 @@ int read_current_timer(unsigned long *timer_val)
>
> void __delay(unsigned long loops)
> {
> - delay_fn(loops);
> + if (loops > MWAITX_MAX_LOOPS ||
> + !static_cpu_has_safe(X86_FEATURE_MWAITT) ||
> + boot_option_delay != DELAY_MWAITX)
> + delay_fn(loops);
> + else
> + delay_mwaitx(loops);
> }
Then you can do away with that fallback entirely.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists