From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756092AbbEUPQi (ORCPT ); Thu, 21 May 2015 11:16:38 -0400 Received: from mail-bn1bbn0105.outbound.protection.outlook.com ([157.56.111.105]:16224 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755385AbbEUPQh (ORCPT ); Thu, 21 May 2015 11:16:37 -0400 Authentication-Results: spf=none (sender IP is 165.204.84.221) smtp.mailfrom=amd.com; gmail.com; dkim=none (message not signed) header.d=none; X-WSS-ID: 0NOPGFY-07-N5J-02 X-M-MSG: Date: Thu, 21 May 2015 22:56:32 +0800 From: Huang Rui To: Borislav Petkov CC: 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" , =?iso-8859-1?Q?Fr=E9d=E9ric?= Weisbecker Subject: Re: [RFC PATCH 2/4] x86, mwaitt: introduce mwaitx idle with a configurable timer Message-ID: <20150521145632.GC22642@hr-slim.amd.com> References: <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> <20150520201553.GI3645@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20150520201553.GI3645@pd.tnic> User-Agent: Mutt/1.5.21 (2010-09-15) X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BN1BFFO11FD047;1:tA8ZgLhFH0In+b2GxbBup3QdKhKuFDVZL/Ag5eC3YfNmTRdk9E4GsNlHe+0CONtbqR7Q1i90/KA29kh2s59yBJgZNRGWoMoqU8N5UtKHRgowcT5+ll6oEvG47j/5k55SnnrgERPJEeEylXEjVuq7jEHm1BLcQz28gnCyh0TdkpRmMI6zFLXcEaNOULN01Sy2hw+41zpF8fmoevdQ1l9/EAwu3YNGK1iuvTe989EactmscxdXS6HxOxHd0LmBLhESM/Ebm8o+wXiAsvaERRtDBMJ/kwqXpKeUb0gvvpTqD37hHeddgF3buvg6JltKPPFpSR9qAS0UB25I1I1mMr6OoA== X-Forefront-Antispam-Report: CIP:165.204.84.221;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(428002)(164054003)(24454002)(189002)(51704005)(199003)(5001830100001)(83506001)(68736005)(2950100001)(53416004)(189998001)(62966003)(77096005)(110136002)(4001540100001)(105586002)(77156002)(97756001)(97736004)(5001860100001)(4001350100001)(92566002)(23726002)(76176999)(54356999)(93886004)(106466001)(50986999)(46102003)(50466002)(64706001)(33656002)(101416001)(46406003)(86362001)(87936001)(47776003)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:BN1PR02MB070;H:atltwp01.amd.com;FPR:;SPF:None;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN1PR02MB070; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:BN1PR02MB070;BCL:0;PCL:0;RULEID:;SRVR:BN1PR02MB070; X-Forefront-PRVS: 0583A86C08 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2015 15:02:24.0161 (UTC) X-MS-Exchange-CrossTenant-Id: fde4dada-be84-483f-92cc-e026cbee8e96 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fde4dada-be84-483f-92cc-e026cbee8e96;Ip=[165.204.84.221];Helo=[atltwp01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN1PR02MB070 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 21, 2015 at 04:15:54AM +0800, Borislav Petkov wrote: > On Wed, May 20, 2015 at 09:12:15PM +0200, Thomas Gleixner wrote: > > 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: > > Yeah, with a check maybe: > > > delay = usec_to_tsc(delay_usec); > > if (delay > ((1 << 32) - 1)) { > mdelay(delay_usec); > return; > } > > > end = rdtsc() + delay; > > while (1) { > > I guess > monitorx( ...); > > first. > > > 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. > > alternative_call(mdelay, mdelayx, X86_FEATURE_MWAITT, /* no output */, timeout); > > Something like that maybe. > > > Not sure if it's worth the trouble. > > Could be a use case for MWAITX in the kernel! > Looks like good use case. Boris, could we try to implement it? Thanks, Rui