From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753931AbbETTMO (ORCPT ); Wed, 20 May 2015 15:12:14 -0400 Received: from www.linutronix.de ([62.245.132.108]:34652 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751519AbbETTML (ORCPT ); Wed, 20 May 2015 15:12:11 -0400 Date: Wed, 20 May 2015 21:12:15 +0200 (CEST) From: Thomas Gleixner To: Borislav Petkov cc: One Thousand Gnomes , Ingo Molnar , Huang Rui , Len Brown , "Rafael J. Wysocki" , x86@kernel.org, linux-kernel@vger.kernel.org, Fengguang Wu , Aaron Lu , Tony Li , =?ISO-8859-15?Q?Fr=E9d=E9ric_Weisbecker?= Subject: Re: [RFC PATCH 2/4] x86, mwaitt: introduce mwaitx idle with a configurable timer In-Reply-To: <20150520160702.GH3645@pd.tnic> Message-ID: References: <20150520085520.GA8566@gmail.com> <20150520091213.GA3645@pd.tnic> <20150520102258.GA21245@gmail.com> <20150520105032.GD3645@pd.tnic> <20150520111120.GA25215@gmail.com> <20150520112110.GG3645@pd.tnic> <20150520114125.GA31212@gmail.com> <20150520145122.GB10374@gmail.com> <20150520165558.24bf2483@lxorguk.ukuu.org.uk> <20150520160702.GH3645@pd.tnic> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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