linux-hyperv.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clocksource: hyper-v: make sure Invariant-TSC is used if it is available
@ 2023-04-08 21:03 Dexuan Cui
  2023-04-11 17:28 ` Michael Kelley (LINUX)
  0 siblings, 1 reply; 3+ messages in thread
From: Dexuan Cui @ 2023-04-08 21:03 UTC (permalink / raw)
  To: kys, haiyangz, wei.liu, decui, daniel.lezcano, tglx, linux-hyperv,
	mikelley
  Cc: linux-kernel

If Hyper-V TSC page is unavailable and Invariant-TSC is available,
currently hyperv_cs_msr (rather than Invariant-TSC) is used by default.

Use Invariant-TSC by default by downgrading hyperv_cs_msr.rating in
hv_init_tsc_clocksource(), if Invariant-TSC is available.

Signed-off-by: Dexuan Cui <decui@microsoft.com>
---
 drivers/clocksource/hyperv_timer.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyperv_timer.c
index c0cef92b12b82..7901a88ad9188 100644
--- a/drivers/clocksource/hyperv_timer.c
+++ b/drivers/clocksource/hyperv_timer.c
@@ -506,9 +506,6 @@ static bool __init hv_init_tsc_clocksource(void)
 {
 	union hv_reference_tsc_msr tsc_msr;
 
-	if (!(ms_hyperv.features & HV_MSR_REFERENCE_TSC_AVAILABLE))
-		return false;
-
 	/*
 	 * If Hyper-V offers TSC_INVARIANT, then the virtualized TSC correctly
 	 * handles frequency and offset changes due to live migration,
@@ -525,6 +522,9 @@ static bool __init hv_init_tsc_clocksource(void)
 		hyperv_cs_msr.rating = 250;
 	}
 
+	if (!(ms_hyperv.features & HV_MSR_REFERENCE_TSC_AVAILABLE))
+		return false;
+
 	hv_read_reference_counter = read_hv_clock_tsc;
 
 	/*
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH] clocksource: hyper-v: make sure Invariant-TSC is used if it is available
  2023-04-08 21:03 [PATCH] clocksource: hyper-v: make sure Invariant-TSC is used if it is available Dexuan Cui
@ 2023-04-11 17:28 ` Michael Kelley (LINUX)
  2023-04-13  1:17   ` Wei Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Kelley (LINUX) @ 2023-04-11 17:28 UTC (permalink / raw)
  To: Dexuan Cui, KY Srinivasan, Haiyang Zhang, wei.liu@kernel.org,
	daniel.lezcano@linaro.org, tglx@linutronix.de,
	linux-hyperv@vger.kernel.org
  Cc: linux-kernel@vger.kernel.org

From: Dexuan Cui <decui@microsoft.com> Sent: Saturday, April 8, 2023 2:04 PM
> 
> If Hyper-V TSC page is unavailable and Invariant-TSC is available,
> currently hyperv_cs_msr (rather than Invariant-TSC) is used by default.
> 
> Use Invariant-TSC by default by downgrading hyperv_cs_msr.rating in
> hv_init_tsc_clocksource(), if Invariant-TSC is available.
> 
> Signed-off-by: Dexuan Cui <decui@microsoft.com>
> ---
>  drivers/clocksource/hyperv_timer.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyperv_timer.c
> index c0cef92b12b82..7901a88ad9188 100644
> --- a/drivers/clocksource/hyperv_timer.c
> +++ b/drivers/clocksource/hyperv_timer.c
> @@ -506,9 +506,6 @@ static bool __init hv_init_tsc_clocksource(void)
>  {
>  	union hv_reference_tsc_msr tsc_msr;
> 
> -	if (!(ms_hyperv.features & HV_MSR_REFERENCE_TSC_AVAILABLE))
> -		return false;
> -
>  	/*
>  	 * If Hyper-V offers TSC_INVARIANT, then the virtualized TSC correctly
>  	 * handles frequency and offset changes due to live migration,
> @@ -525,6 +522,9 @@ static bool __init hv_init_tsc_clocksource(void)
>  		hyperv_cs_msr.rating = 250;
>  	}
> 
> +	if (!(ms_hyperv.features & HV_MSR_REFERENCE_TSC_AVAILABLE))
> +		return false;
> +
>  	hv_read_reference_counter = read_hv_clock_tsc;
> 
>  	/*
> --
> 2.25.1

Reviewed-by:  Michael Kelley <mikelley@microsoft.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] clocksource: hyper-v: make sure Invariant-TSC is used if it is available
  2023-04-11 17:28 ` Michael Kelley (LINUX)
@ 2023-04-13  1:17   ` Wei Liu
  0 siblings, 0 replies; 3+ messages in thread
From: Wei Liu @ 2023-04-13  1:17 UTC (permalink / raw)
  To: Michael Kelley (LINUX)
  Cc: Dexuan Cui, KY Srinivasan, Haiyang Zhang, wei.liu@kernel.org,
	daniel.lezcano@linaro.org, tglx@linutronix.de,
	linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org

On Tue, Apr 11, 2023 at 05:28:39PM +0000, Michael Kelley (LINUX) wrote:
> From: Dexuan Cui <decui@microsoft.com> Sent: Saturday, April 8, 2023 2:04 PM
> Reviewed-by:  Michael Kelley <mikelley@microsoft.com>
> 

Applied to hyperv-next. Thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-04-13  1:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-08 21:03 [PATCH] clocksource: hyper-v: make sure Invariant-TSC is used if it is available Dexuan Cui
2023-04-11 17:28 ` Michael Kelley (LINUX)
2023-04-13  1:17   ` Wei Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).