[tip:x86/timers] x86/tsc: Skip TSC test and error messages if already unstable

From: tip-bot for mike.travis@xxxxxxx
Date: Mon Oct 16 2017 - 17:20:06 EST


Commit-ID: 9514ececa52e9f1436e7682e98c852d1338b699f
Gitweb: https://git.kernel.org/tip/9514ececa52e9f1436e7682e98c852d1338b699f
Author: mike.travis@xxxxxxx <mike.travis@xxxxxxx>
AuthorDate: Thu, 12 Oct 2017 11:32:03 -0500
Committer: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
CommitDate: Mon, 16 Oct 2017 22:50:36 +0200

x86/tsc: Skip TSC test and error messages if already unstable

If the TSC has already been determined to be unstable, then checking
TSC ADJUST values is a waste of time and generates unnecessary error
messages.

Signed-off-by: Mike Travis <mike.travis@xxxxxxx>
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Reviewed-by: Dimitri Sivanich <dimitri.sivanich@xxxxxxx>
Reviewed-by: Russ Anderson <russ.anderson@xxxxxxx>
Reviewed-by: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Prarit Bhargava <prarit@xxxxxxxxxx>
Cc: Andrew Banman <andrew.banman@xxxxxxx>
Cc: Bin Gao <bin.gao@xxxxxxxxxxxxxxx>
Link: https://lkml.kernel.org/r/20171012163202.060777495@xxxxxxxxxxxxxxxxxxxxxxxxxx

---
arch/x86/kernel/tsc_sync.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/arch/x86/kernel/tsc_sync.c b/arch/x86/kernel/tsc_sync.c
index 3873dcd..3bdb983 100644
--- a/arch/x86/kernel/tsc_sync.c
+++ b/arch/x86/kernel/tsc_sync.c
@@ -52,6 +52,10 @@ void tsc_verify_tsc_adjust(bool resume)
if (!boot_cpu_has(X86_FEATURE_TSC_ADJUST))
return;

+ /* Skip unnecessary error messages if TSC already unstable */
+ if (check_tsc_unstable())
+ return;
+
/* Rate limit the MSR check */
if (!resume && time_before(jiffies, adj->nextcheck))
return;
@@ -114,6 +118,10 @@ bool __init tsc_store_and_check_tsc_adjust(bool bootcpu)
if (!boot_cpu_has(X86_FEATURE_TSC_ADJUST))
return false;

+ /* Skip unnecessary error messages if TSC already unstable */
+ if (check_tsc_unstable())
+ return false;
+
rdmsrl(MSR_IA32_TSC_ADJUST, bootval);
cur->bootval = bootval;
cur->nextcheck = jiffies + HZ;