[PATCH] Add check to determine if CLFLUSH is actually necessary before monitor/wait

From: Scott Bauer
Date: Fri Jan 30 2015 - 16:10:37 EST


Signed-off-by: Scott Bauer <sbauer@xxxxxxxxxxxx>
---
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 = &current_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--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/