x86/tsc: Use X86_FEATURE_TSC_ADJUST in detect_art()
authorThomas Gleixner <tglx@linutronix.de>
Sat, 19 Nov 2016 13:47:33 +0000 (13:47 +0000)
committerThomas Gleixner <tglx@linutronix.de>
Tue, 29 Nov 2016 18:23:15 +0000 (19:23 +0100)
The art detection uses rdmsrl_safe() to detect the availablity of the
TSC_ADJUST MSR.

That's pointless because we have a feature bit for this. Use it.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Link: http://lkml.kernel.org/r/20161119134017.483561692@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
arch/x86/kernel/tsc.c

index 0ff1ec61d1e4447bb3f482fcf0843fa061b0e264..2b27c5ae9d1fdd5c9d2f1d6583d98c57c8d8afdc 100644 (file)
@@ -1057,18 +1057,20 @@ static void detect_art(void)
        if (boot_cpu_data.cpuid_level < ART_CPUID_LEAF)
                return;
 
-       cpuid(ART_CPUID_LEAF, &art_to_tsc_denominator,
-             &art_to_tsc_numerator, unused, unused+1);
-
-       /* Don't enable ART in a VM, non-stop TSC required */
+       /* Don't enable ART in a VM, non-stop TSC and TSC_ADJUST required */
        if (boot_cpu_has(X86_FEATURE_HYPERVISOR) ||
            !boot_cpu_has(X86_FEATURE_NONSTOP_TSC) ||
-           art_to_tsc_denominator < ART_MIN_DENOMINATOR)
+           !boot_cpu_has(X86_FEATURE_TSC_ADJUST))
                return;
 
-       if (rdmsrl_safe(MSR_IA32_TSC_ADJUST, &art_to_tsc_offset))
+       cpuid(ART_CPUID_LEAF, &art_to_tsc_denominator,
+             &art_to_tsc_numerator, unused, unused+1);
+
+       if (art_to_tsc_denominator < ART_MIN_DENOMINATOR)
                return;
 
+       rdmsrl(MSR_IA32_TSC_ADJUST, art_to_tsc_offset);
+
        /* Make this sticky over multiple CPU init calls */
        setup_force_cpu_cap(X86_FEATURE_ART);
 }