From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1763353AbbA3WCY (ORCPT ); Fri, 30 Jan 2015 17:02:24 -0500 Received: from mailhub.eng.utah.edu ([155.98.110.27]:30383 "EHLO mailhub.eng.utah.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760143AbbA3WCV (ORCPT ); Fri, 30 Jan 2015 17:02:21 -0500 X-Greylist: delayed 2158 seconds by postgrey-1.27 at vger.kernel.org; Fri, 30 Jan 2015 17:02:21 EST Message-ID: <54CBF6F9.5040508@eng.utah.edu> Date: Fri, 30 Jan 2015 14:26:17 -0700 From: Scotty Bauer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: tglx@linutronix.de, mingo@redheat.com, hpa@zytor.com CC: linux-kernel@vger.kernel.org, x86@kernel.org Subject: [PATCH] x86/smpboot: check if CLFLUSH is actually necessary Content-Type: multipart/mixed; boundary="------------020805020704050709050303" X-UCE-Score: -1.9 (-) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a multi-part message in MIME format. --------------020805020704050709050303 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit mwait_play_dead previously issued a CLFLUSH to work around a bug on some xeon processors. We can now determine if the CPU is a buggy CPU. This patch checks if if we're on a buggy CPU which allows non-buggy cpu's to eliminate the CLFLUSH. --------------020805020704050709050303 Content-Type: text/x-diff; name="0001-Add-check-to-determine-if-CLFLUSH-is-actually-necess.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Add-check-to-determine-if-CLFLUSH-is-actually-necess.pa"; filename*1="tch" >>From 3da1be5c998a8d51f98fdba09b3cb477526c5ff3 Mon Sep 17 00:00:00 2001 From: Scott Bauer Date: Fri, 30 Jan 2015 14:10:37 -0700 Subject: [PATCH] Add check to determine if CLFLUSH is actually necessary before monitor/wait Signed-off-by: Scott Bauer --- arch/x86/kernel/smpboot.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 6d7022c..552ff48 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -1384,6 +1384,7 @@ static inline void mwait_play_dead(void) unsigned int highest_subcstate = 0; void *mwait_ptr; int i; + int cpu; if (!this_cpu_has(X86_FEATURE_MWAIT)) return; @@ -1420,6 +1421,7 @@ static inline void mwait_play_dead(void) * content is immaterial as it is not actually modified in any way. */ mwait_ptr = ¤t_thread_info()->flags; + cpu = smp_processor_id(); wbinvd(); @@ -1430,10 +1432,15 @@ static inline void mwait_play_dead(void) * needed, but it should be harmless in either case. * The WBINVD is insufficient due to the spurious-wakeup * case where we return around the loop. + * + * Check if the CLFLUSH is actually necessary before calling */ - mb(); - clflush(mwait_ptr); - mb(); + if (cpu_has_bug(&cpu_data(cpu), X86_BUG_CLFLUSH_MONITOR)) { + mb(); + clflush(mwait_ptr); + mb(); + } + __monitor(mwait_ptr, 0, 0); mb(); __mwait(eax, 0); -- 1.9.1 --------------020805020704050709050303--