linux-hyperv.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] x86/hyperv: Set X86_FEATURE_TSC_KNOWN_FREQ when Hyper-V provides frequency
@ 2024-06-06  2:55 mhkelley58
  2024-06-11 14:51 ` Roman Kisel
  0 siblings, 1 reply; 5+ messages in thread
From: mhkelley58 @ 2024-06-06  2:55 UTC (permalink / raw)
  To: kys, haiyangz, wei.liu, decui, tglx, mingo, bp, dave.hansen, x86,
	hpa, linux-hyperv, linux-kernel

From: Michael Kelley <mhklinux@outlook.com>

A Linux guest on Hyper-V gets the TSC frequency from a synthetic MSR, if
available. In this case, set X86_FEATURE_TSC_KNOWN_FREQ so that Linux
doesn't unnecessarily do refined TSC calibration when setting up the TSC
clocksource.

With this change, a message such as this is no longer output during boot
when the TSC is used as the clocksource:

[    1.115141] tsc: Refined TSC clocksource calibration: 2918.408 MHz

Furthermore, the guest and host will have exactly the same view of the
TSC frequency, which is important for features such as the TSC deadline
timer that are emulated by the Hyper-V host.

Signed-off-by: Michael Kelley <mhklinux@outlook.com>
---
 arch/x86/kernel/cpu/mshyperv.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index e0fd57a8ba84..c3e38eaf6d2f 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -424,6 +424,7 @@ static void __init ms_hyperv_init_platform(void)
 	    ms_hyperv.misc_features & HV_FEATURE_FREQUENCY_MSRS_AVAILABLE) {
 		x86_platform.calibrate_tsc = hv_get_tsc_khz;
 		x86_platform.calibrate_cpu = hv_get_tsc_khz;
+		setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
 	}
 
 	if (ms_hyperv.priv_high & HV_ISOLATION) {
-- 
2.25.1


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

* Re: [PATCH 1/1] x86/hyperv: Set X86_FEATURE_TSC_KNOWN_FREQ when Hyper-V provides frequency
  2024-06-06  2:55 [PATCH 1/1] x86/hyperv: Set X86_FEATURE_TSC_KNOWN_FREQ when Hyper-V provides frequency mhkelley58
@ 2024-06-11 14:51 ` Roman Kisel
  2024-08-02 23:49   ` Wei Liu
  0 siblings, 1 reply; 5+ messages in thread
From: Roman Kisel @ 2024-06-11 14:51 UTC (permalink / raw)
  To: mhklinux, kys, haiyangz, wei.liu, decui, tglx, mingo, bp,
	dave.hansen, x86, hpa, linux-hyperv, linux-kernel



On 6/5/2024 7:55 PM, mhkelley58@gmail.com wrote:
> From: Michael Kelley <mhklinux@outlook.com>
> 
> A Linux guest on Hyper-V gets the TSC frequency from a synthetic MSR, if
> available. In this case, set X86_FEATURE_TSC_KNOWN_FREQ so that Linux
> doesn't unnecessarily do refined TSC calibration when setting up the TSC
> clocksource.
> 
> With this change, a message such as this is no longer output during boot
> when the TSC is used as the clocksource:
> 
> [    1.115141] tsc: Refined TSC clocksource calibration: 2918.408 MHz
> 
> Furthermore, the guest and host will have exactly the same view of the
> TSC frequency, which is important for features such as the TSC deadline
> timer that are emulated by the Hyper-V host.
> 
> Signed-off-by: Michael Kelley <mhklinux@outlook.com>
> ---
>   arch/x86/kernel/cpu/mshyperv.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
> index e0fd57a8ba84..c3e38eaf6d2f 100644
> --- a/arch/x86/kernel/cpu/mshyperv.c
> +++ b/arch/x86/kernel/cpu/mshyperv.c
> @@ -424,6 +424,7 @@ static void __init ms_hyperv_init_platform(void)
>   	    ms_hyperv.misc_features & HV_FEATURE_FREQUENCY_MSRS_AVAILABLE) {
>   		x86_platform.calibrate_tsc = hv_get_tsc_khz;
>   		x86_platform.calibrate_cpu = hv_get_tsc_khz;
> +		setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
>   	}
>   
>   	if (ms_hyperv.priv_high & HV_ISOLATION) {

LGTM

Reviewed-by: Roman Kisel <romank@linux.microsoft.com>

-- 
Thank you,
Roman

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

* Re: [PATCH 1/1] x86/hyperv: Set X86_FEATURE_TSC_KNOWN_FREQ when Hyper-V provides frequency
  2024-06-11 14:51 ` Roman Kisel
@ 2024-08-02 23:49   ` Wei Liu
  2024-08-06  2:01     ` Michael Kelley
  0 siblings, 1 reply; 5+ messages in thread
From: Wei Liu @ 2024-08-02 23:49 UTC (permalink / raw)
  To: Roman Kisel
  Cc: mhklinux, kys, haiyangz, wei.liu, decui, tglx, mingo, bp,
	dave.hansen, x86, hpa, linux-hyperv, linux-kernel

On Tue, Jun 11, 2024 at 07:51:48AM -0700, Roman Kisel wrote:
> 
> 
> On 6/5/2024 7:55 PM, mhkelley58@gmail.com wrote:
> > From: Michael Kelley <mhklinux@outlook.com>
> > 
> > A Linux guest on Hyper-V gets the TSC frequency from a synthetic MSR, if
> > available. In this case, set X86_FEATURE_TSC_KNOWN_FREQ so that Linux
> > doesn't unnecessarily do refined TSC calibration when setting up the TSC
> > clocksource.
> > 
> > With this change, a message such as this is no longer output during boot
> > when the TSC is used as the clocksource:
> > 
> > [    1.115141] tsc: Refined TSC clocksource calibration: 2918.408 MHz
> > 
> > Furthermore, the guest and host will have exactly the same view of the
> > TSC frequency, which is important for features such as the TSC deadline
> > timer that are emulated by the Hyper-V host.
> > 
> > Signed-off-by: Michael Kelley <mhklinux@outlook.com>
> > ---
> >   arch/x86/kernel/cpu/mshyperv.c | 1 +
> >   1 file changed, 1 insertion(+)
> > 
> > diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
> > index e0fd57a8ba84..c3e38eaf6d2f 100644
> > --- a/arch/x86/kernel/cpu/mshyperv.c
> > +++ b/arch/x86/kernel/cpu/mshyperv.c
> > @@ -424,6 +424,7 @@ static void __init ms_hyperv_init_platform(void)
> >   	    ms_hyperv.misc_features & HV_FEATURE_FREQUENCY_MSRS_AVAILABLE) {
> >   		x86_platform.calibrate_tsc = hv_get_tsc_khz;
> >   		x86_platform.calibrate_cpu = hv_get_tsc_khz;
> > +		setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
> >   	}
> >   	if (ms_hyperv.priv_high & HV_ISOLATION) {
> 
> LGTM
> 
> Reviewed-by: Roman Kisel <romank@linux.microsoft.com>

Applied to hyperv-fixes. Thanks!

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

* RE: [PATCH 1/1] x86/hyperv: Set X86_FEATURE_TSC_KNOWN_FREQ when Hyper-V provides frequency
  2024-08-02 23:49   ` Wei Liu
@ 2024-08-06  2:01     ` Michael Kelley
  2024-08-23 21:51       ` Wei Liu
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Kelley @ 2024-08-06  2:01 UTC (permalink / raw)
  To: Wei Liu, Roman Kisel
  Cc: kys@microsoft.com, haiyangz@microsoft.com, decui@microsoft.com,
	tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
	dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com,
	linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org

From: Wei Liu <wei.liu@kernel.org> Sent: Friday, August 2, 2024 4:50 PM
> 
> On Tue, Jun 11, 2024 at 07:51:48AM -0700, Roman Kisel wrote:
> >
> >
> > On 6/5/2024 7:55 PM, mhkelley58@gmail.com wrote:
> > > From: Michael Kelley <mhklinux@outlook.com>
> > >
> > > A Linux guest on Hyper-V gets the TSC frequency from a synthetic MSR, if
> > > available. In this case, set X86_FEATURE_TSC_KNOWN_FREQ so that Linux
> > > doesn't unnecessarily do refined TSC calibration when setting up the TSC
> > > clocksource.
> > >
> > > With this change, a message such as this is no longer output during boot
> > > when the TSC is used as the clocksource:
> > >
> > > [    1.115141] tsc: Refined TSC clocksource calibration: 2918.408 MHz
> > >
> > > Furthermore, the guest and host will have exactly the same view of the
> > > TSC frequency, which is important for features such as the TSC deadline
> > > timer that are emulated by the Hyper-V host.
> > >
> > > Signed-off-by: Michael Kelley <mhklinux@outlook.com>
> > > ---
> > >   arch/x86/kernel/cpu/mshyperv.c | 1 +
> > >   1 file changed, 1 insertion(+)
> > >
> > > diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
> > > index e0fd57a8ba84..c3e38eaf6d2f 100644
> > > --- a/arch/x86/kernel/cpu/mshyperv.c
> > > +++ b/arch/x86/kernel/cpu/mshyperv.c
> > > @@ -424,6 +424,7 @@ static void __init ms_hyperv_init_platform(void)
> > >   	    ms_hyperv.misc_features & HV_FEATURE_FREQUENCY_MSRS_AVAILABLE) {
> > >   		x86_platform.calibrate_tsc = hv_get_tsc_khz;
> > >   		x86_platform.calibrate_cpu = hv_get_tsc_khz;
> > > +		setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
> > >   	}
> > >   	if (ms_hyperv.priv_high & HV_ISOLATION) {
> >
> > LGTM
> >
> > Reviewed-by: Roman Kisel <romank@linux.microsoft.com>
> 
> Applied to hyperv-fixes. Thanks!

Wei --

hyperv-fixes isn't showing this patch, or any of the others that your
emails said you applied last Friday.  Hence the patches aren't in
linux-next either.  Did something go awry?

Michael

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

* Re: [PATCH 1/1] x86/hyperv: Set X86_FEATURE_TSC_KNOWN_FREQ when Hyper-V provides frequency
  2024-08-06  2:01     ` Michael Kelley
@ 2024-08-23 21:51       ` Wei Liu
  0 siblings, 0 replies; 5+ messages in thread
From: Wei Liu @ 2024-08-23 21:51 UTC (permalink / raw)
  To: Michael Kelley
  Cc: Wei Liu, Roman Kisel, kys@microsoft.com, haiyangz@microsoft.com,
	decui@microsoft.com, tglx@linutronix.de, mingo@redhat.com,
	bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org,
	hpa@zytor.com, linux-hyperv@vger.kernel.org,
	linux-kernel@vger.kernel.org

On Tue, Aug 06, 2024 at 02:01:55AM +0000, Michael Kelley wrote:
> From: Wei Liu <wei.liu@kernel.org> Sent: Friday, August 2, 2024 4:50 PM
> > 
> > On Tue, Jun 11, 2024 at 07:51:48AM -0700, Roman Kisel wrote:
> > >
> > >
> > > On 6/5/2024 7:55 PM, mhkelley58@gmail.com wrote:
> > > > From: Michael Kelley <mhklinux@outlook.com>
> > > >
> > > > A Linux guest on Hyper-V gets the TSC frequency from a synthetic MSR, if
> > > > available. In this case, set X86_FEATURE_TSC_KNOWN_FREQ so that Linux
> > > > doesn't unnecessarily do refined TSC calibration when setting up the TSC
> > > > clocksource.
> > > >
> > > > With this change, a message such as this is no longer output during boot
> > > > when the TSC is used as the clocksource:
> > > >
> > > > [    1.115141] tsc: Refined TSC clocksource calibration: 2918.408 MHz
> > > >
> > > > Furthermore, the guest and host will have exactly the same view of the
> > > > TSC frequency, which is important for features such as the TSC deadline
> > > > timer that are emulated by the Hyper-V host.
> > > >
> > > > Signed-off-by: Michael Kelley <mhklinux@outlook.com>
> > > > ---
> > > >   arch/x86/kernel/cpu/mshyperv.c | 1 +
> > > >   1 file changed, 1 insertion(+)
> > > >
> > > > diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
> > > > index e0fd57a8ba84..c3e38eaf6d2f 100644
> > > > --- a/arch/x86/kernel/cpu/mshyperv.c
> > > > +++ b/arch/x86/kernel/cpu/mshyperv.c
> > > > @@ -424,6 +424,7 @@ static void __init ms_hyperv_init_platform(void)
> > > >   	    ms_hyperv.misc_features & HV_FEATURE_FREQUENCY_MSRS_AVAILABLE) {
> > > >   		x86_platform.calibrate_tsc = hv_get_tsc_khz;
> > > >   		x86_platform.calibrate_cpu = hv_get_tsc_khz;
> > > > +		setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
> > > >   	}
> > > >   	if (ms_hyperv.priv_high & HV_ISOLATION) {
> > >
> > > LGTM
> > >
> > > Reviewed-by: Roman Kisel <romank@linux.microsoft.com>
> > 
> > Applied to hyperv-fixes. Thanks!
> 
> Wei --
> 
> hyperv-fixes isn't showing this patch, or any of the others that your
> emails said you applied last Friday.  Hence the patches aren't in
> linux-next either.  Did something go awry?

The push was not successful. They should show up now.

Sorry for the delay.

Thanks,
Wei.

> 
> Michael

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

end of thread, other threads:[~2024-08-23 21:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-06  2:55 [PATCH 1/1] x86/hyperv: Set X86_FEATURE_TSC_KNOWN_FREQ when Hyper-V provides frequency mhkelley58
2024-06-11 14:51 ` Roman Kisel
2024-08-02 23:49   ` Wei Liu
2024-08-06  2:01     ` Michael Kelley
2024-08-23 21:51       ` 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).