From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757067AbbEUQpe (ORCPT ); Thu, 21 May 2015 12:45:34 -0400 Received: from mail-lb0-f176.google.com ([209.85.217.176]:36589 "EHLO mail-lb0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757036AbbEUQpc (ORCPT ); Thu, 21 May 2015 12:45:32 -0400 MIME-Version: 1.0 In-Reply-To: <20150521160223.GA23652@pd.tnic> References: <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> <20150520201553.GI3645@pd.tnic> <20150521145632.GC22642@hr-slim.amd.com> <20150521160223.GA23652@pd.tnic> From: Andy Lutomirski Date: Thu, 21 May 2015 09:45:10 -0700 Message-ID: Subject: Re: [RFC PATCH 2/4] x86, mwaitt: introduce mwaitx idle with a configurable timer To: Borislav Petkov Cc: Huang Rui , Thomas Gleixner , One Thousand Gnomes , Ingo Molnar , Len Brown , "Rafael J. Wysocki" , "x86@kernel.org" , "linux-kernel@vger.kernel.org" , Fengguang Wu , Aaron Lu , "Li, Tony" , =?UTF-8?B?RnLDqWTDqXJpYyBXZWlzYmVja2Vy?= Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 21, 2015 at 9:02 AM, Borislav Petkov wrote: > On Thu, May 21, 2015 at 10:56:32PM +0800, Huang Rui wrote: >> Looks like good use case. Boris, could we try to implement it? > > Andy had some suggestions on how to do it here: > > https://lkml.kernel.org/r/555D3629.8080002@kernel.org > > which should be doable. Also, you'd probably need to set ECX[0]=0b too, > so that MWAITX doesn't get woken up by interrupts while MWAIT-ing with > interrupts disabled. I.e., this sequence: > > cli > rdtsc > shove the computed timeout into ebx > mov $2,%ecx # this enables the timer and disables IRQs while MWAITing > mwaitx > sti I must be missing something. In this sequence, you're sleeping with IF=0 and ECX[0] = 0, so an IRQ won't get handled. Don't we want ECX[0] = 1? > > The NMI argument is a problem though - if and NMI gets you out of > MWAITX, a simple perf tool workload would kill all MWAITX executions. > Which is bad. :-\ I'm not sure it's a show-stopper. NMI handlers are meant to be fast. If an NMI comes in between rdtsc and mwaitx, then we oversleep, but by at most the time it takes to handle an NMI, and nothing would have stopped us from oversleeping that long if an NMI came in right after mwaitx returned. --Andy