[bionic:linux-azure-4.15][PATCH 2/2] x86/hyperv: Set TSC clocksource as default w/ InvariantTSC

Kelsey Skunberg kelsey.skunberg at canonical.com
Wed Jun 10 04:20:08 UTC 2020


From: Andrea Parri <parri.andrea at gmail.com>

BugLink: http://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 at gmail.com>
Reviewed-by: Michael Kelley <mikelley at microsoft.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano at linaro.org>
Link: https://lore.kernel.org/r/20200109160650.16150-3-parri.andrea@gmail.com
(backported from commit 9e0333ae38eeb42249e10f95d209244a6e22ac9f)
[KelseyS: Changes are the same, though done in arch/x86/hyperv/hv_init.c
instead of drivers/clocksource/hyperv_timer.c]
Signed-off-by: Kelsey Skunberg <kelsey.skunberg at canonical.com>
---
 arch/x86/hyperv/hv_init.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

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,
-- 
2.25.1




More information about the kernel-team mailing list