linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/acrn: Set X86_FEATURE_TSC_KNOWN_FREQ
@ 2022-10-25  8:41 Fei Li
  2022-10-25 13:22 ` Peter Zijlstra
  0 siblings, 1 reply; 3+ messages in thread
From: Fei Li @ 2022-10-25  8:41 UTC (permalink / raw)
  To: linux-kernel, x86
  Cc: dave.hansen, gregkh, tglx, mingo, bp, dave.hansen, hpa, Yu1.Wang,
	conghui.chen, fengwei.yin

Avoiding recalibration by setting X86_FEATURE_TSC_KNOWN_FREQ.
This patch also removes `inline` for acrn_get_tsc_khz() since
it doesn't make sense.

Signed-off-by: Fei Li <fei1.li@intel.com>
Reviewed-by: Yin, Fengwei <fengwei.yin@intel.com>
---
 arch/x86/include/asm/acrn.h | 5 -----
 arch/x86/kernel/cpu/acrn.c  | 6 ++++++
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/arch/x86/include/asm/acrn.h b/arch/x86/include/asm/acrn.h
index 1dd14381bcb6..aa12c74ea959 100644
--- a/arch/x86/include/asm/acrn.h
+++ b/arch/x86/include/asm/acrn.h
@@ -30,11 +30,6 @@ static inline u32 acrn_cpuid_base(void)
 	return 0;
 }
 
-static inline unsigned long acrn_get_tsc_khz(void)
-{
-	return cpuid_eax(ACRN_CPUID_TIMING_INFO);
-}
-
 /*
  * Hypercalls for ACRN
  *
diff --git a/arch/x86/kernel/cpu/acrn.c b/arch/x86/kernel/cpu/acrn.c
index 485441b7f030..c5ff75b6a949 100644
--- a/arch/x86/kernel/cpu/acrn.c
+++ b/arch/x86/kernel/cpu/acrn.c
@@ -24,6 +24,12 @@ static u32 __init acrn_detect(void)
 	return acrn_cpuid_base();
 }
 
+static unsigned long acrn_get_tsc_khz(void)
+{
+	setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
+	return cpuid_eax(ACRN_CPUID_TIMING_INFO);
+}
+
 static void __init acrn_init_platform(void)
 {
 	/* Setup the IDT for ACRN hypervisor callback */

base-commit: 1a2dcbdde82e3a5f1db9b2f4c48aa1aeba534fb2
-- 
2.34.1


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

* Re: [PATCH] x86/acrn: Set X86_FEATURE_TSC_KNOWN_FREQ
  2022-10-25  8:41 [PATCH] x86/acrn: Set X86_FEATURE_TSC_KNOWN_FREQ Fei Li
@ 2022-10-25 13:22 ` Peter Zijlstra
  2022-10-26  3:32   ` Fei Li
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Zijlstra @ 2022-10-25 13:22 UTC (permalink / raw)
  To: Fei Li
  Cc: linux-kernel, x86, dave.hansen, gregkh, tglx, mingo, bp,
	dave.hansen, hpa, Yu1.Wang, conghui.chen, fengwei.yin

On Tue, Oct 25, 2022 at 04:41:47PM +0800, Fei Li wrote:
> Avoiding recalibration by setting X86_FEATURE_TSC_KNOWN_FREQ.
> This patch also removes `inline` for acrn_get_tsc_khz() since
> it doesn't make sense.

Can we have a few words on how this is supposed to work at all?

Supposedly the HV is providing host rate through this ACRN CPUID leaf?
How does it deal with systems where TSC isn't known stable?


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

* Re: [PATCH] x86/acrn: Set X86_FEATURE_TSC_KNOWN_FREQ
  2022-10-25 13:22 ` Peter Zijlstra
@ 2022-10-26  3:32   ` Fei Li
  0 siblings, 0 replies; 3+ messages in thread
From: Fei Li @ 2022-10-26  3:32 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: linux-kernel, x86, dave.hansen, gregkh, tglx, mingo, bp,
	dave.hansen, hpa, Yu1.Wang, conghui.chen, fengwei.yin

On 2022-10-25 at 15:22:58 +0200, Peter Zijlstra wrote:
> On Tue, Oct 25, 2022 at 04:41:47PM +0800, Fei Li wrote:
> > Avoiding recalibration by setting X86_FEATURE_TSC_KNOWN_FREQ.
> > This patch also removes `inline` for acrn_get_tsc_khz() since
> > it doesn't make sense.
> 
Hi Peter

Thanks for your comments.

> Can we have a few words on how this is supposed to work at all?

If the TSC frequency is known from the acrn_get_tsc_khz(),
the TSC frequency does not need to be recalibrated.

We can avoid recalibration by setting X86_FEATURE_TSC_KNOWN_FREQ.
> 
> Supposedly the HV is providing host rate through this ACRN CPUID leaf?
ACRN would provide the calibrated TSC frequency, not just the
host rate through this CPUID leaf.

> How does it deal with systems where TSC isn't known stable?
> 

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

end of thread, other threads:[~2022-10-26  3:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-25  8:41 [PATCH] x86/acrn: Set X86_FEATURE_TSC_KNOWN_FREQ Fei Li
2022-10-25 13:22 ` Peter Zijlstra
2022-10-26  3:32   ` Fei Li

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).