diff mbox series

[bionic:linux-azure-4.15,SRU,v2,2/4] x86/hyperv: Set TSC clocksource as default w/ InvariantTSC

Message ID 20200812184246.14738-3-kelsey.skunberg@canonical.com
State New
Headers show
Series LP#:1875467: Enable invariant TSC | expand

Commit Message

Kelsey Skunberg Aug. 12, 2020, 6:42 p.m. UTC
From: Andrea Parri <parri.andrea@gmail.com>

BugLink: https://bugs.launchpad.net/bugs/1875467

Change the Hyper-V clocksource ratings to 250, below the TSC clocksource
rating of 300.  In configurations where Hyper-V offers an InvariantTSC,
the TSC is not marked "unstable", so the TSC clocksource is available
and preferred.  With the higher rating, it will be the default.  On
older hardware and Hyper-V versions, the TSC is marked "unstable", so no
TSC clocksource is created and the selected Hyper-V clocksource will be
the default.

Signed-off-by: Andrea Parri <parri.andrea@gmail.com>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20200109160650.16150-3-parri.andrea@gmail.com
(backported from commit 9e0333ae38eeb42249e10f95d209244a6e22ac9f)
[KelseyS: changes done in arch/x86/hyperv/hv_init.c instead of
drivers/clocksource/hyperv_timer.c]
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
---
 arch/x86/hyperv/hv_init.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index ce3bb175d739..a4e61bdfd6f0 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -60,9 +60,18 @@  static u64 read_hv_clock_tsc(struct clocksource *arg)
 	return current_tick;
 }
 
+/* The Hyper-V clocksource ratings of 250 are chosen to be below the
+ * TSC clocksource rating of 300.  In configurations where Hyper-V offers
+ * an InvariantTSC, the TSC is not marked "unstable", so the TSC clocksource
+ * is available and preferred.  With the higher rating, it will be the
+ * default.  On older hardware and Hyper-V versions, the TSC is marked
+ * "unstable", so no TSC clocksource is created and the selected Hyper-V
+ * clocksource will be the default.
+ */
+
 static struct clocksource hyperv_cs_tsc = {
 		.name		= "hyperv_clocksource_tsc_page",
-		.rating		= 400,
+		.rating		= 250,
 		.read		= read_hv_clock_tsc,
 		.mask		= CLOCKSOURCE_MASK(64),
 		.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
@@ -83,7 +92,7 @@  static u64 read_hv_clock_msr(struct clocksource *arg)
 
 static struct clocksource hyperv_cs_msr = {
 	.name		= "hyperv_clocksource_msr",
-	.rating		= 400,
+	.rating		= 250,
 	.read		= read_hv_clock_msr,
 	.mask		= CLOCKSOURCE_MASK(64),
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,