From: Scotty Bauer <sbauer@eng.utah.edu>
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
Date: Fri, 30 Jan 2015 14:26:17 -0700 [thread overview]
Message-ID: <54CBF6F9.5040508@eng.utah.edu> (raw)
[-- Attachment #1: Type: text/plain, Size: 243 bytes --]
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.
[-- Attachment #2: 0001-Add-check-to-determine-if-CLFLUSH-is-actually-necess.patch --]
[-- Type: text/x-diff, Size: 1505 bytes --]
>From 3da1be5c998a8d51f98fdba09b3cb477526c5ff3 Mon Sep 17 00:00:00 2001
From: Scott Bauer <sbauer@eng.utah.edu>
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 <sbauer@eng.utah.edu>
---
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
next reply other threads:[~2015-01-30 22:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-30 21:26 Scotty Bauer [this message]
2015-01-30 23:31 ` [PATCH] x86/smpboot: check if CLFLUSH is actually necessary Borislav Petkov
2015-02-06 16:05 ` Borislav Petkov
2015-02-06 16:13 ` [PATCH] x86, smpboot: Call CLFLUSH only on X86_BUG_CLFLUSH_MONITOR-affected CPUs Borislav Petkov
2015-02-11 18:39 ` Scotty Bauer
2015-02-11 20:25 ` Borislav Petkov
2015-02-11 21:55 ` [PATCH] x86/smpboot: check if CLFLUSH is actually necessary H. Peter Anvin
2015-02-11 23:10 ` Scotty Bauer
2015-02-12 9:16 ` Borislav Petkov
2015-02-11 21:55 ` H. Peter Anvin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54CBF6F9.5040508@eng.utah.edu \
--to=sbauer@eng.utah.edu \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redheat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox