Skip to contentSkip to conversation

x86/acrn: Set X86_FEATURE_TSC_KNOWN_FREQ

PATCH Superseded Fei Li 2 participants 6 messages Nov 1, 2022 – Nov 21, 2022 x86

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Fei Li

author
#0 lore raw

PATCH v2 1/1 x86/acrn: Set X86_FEATURE_TSC_KNOWN_FREQ

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

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.

---
v2:
- Detail the commit message

---
 arch/x86/include/asm/acrn.h | 5 -----
 arch/x86/kernel/cpu/acrn.c  | 6 ++++++
 2 files changed, 6 insertions(+), 5 deletions(-)
arch/x86/include/asm/acrn.h +0 -5
index 1dd14381bcb6..aa12c74ea959 100644
@@ -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
  *
arch/x86/kernel/cpu/acrn.c +6 -0
index 485441b7f030..c5ff75b6a949 100644
@@ -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: 5aaef24b5c6d4246b2cac1be949869fa36577737

Signature · 1 line
2.34.1
author
#1 lore raw
Quoted 7 lines · Fei Li

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

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.

Quoted 6 lines

---
v2:
- Detail the commit message

Ping ...

Quoted 43 lines
---
 arch/x86/include/asm/acrn.h | 5 -----
 arch/x86/kernel/cpu/acrn.c  | 6 ++++++
 2 files changed, 6 insertions(+), 5 deletions(-)
arch/x86/include/asm/acrn.h +0 -5
index 1dd14381bcb6..aa12c74ea959 100644
@@ -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
  *
arch/x86/kernel/cpu/acrn.c +6 -0
index 485441b7f030..c5ff75b6a949 100644
@@ -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: 5aaef24b5c6d4246b2cac1be949869fa36577737

Signature · 1 line
2.34.1
maintainer
#2 lore raw
In reply to Fei Li
Quoted 2 lines · Fei Li

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

What if the HV has unstable TSCs? How do you handle that?

Quoted 1 line

Avoiding recalibration by setting X86_FEATURE_TSC_KNOWN_FREQ.

Pls read section "2) Describe your changes" in Documentation/process/submitting-patches.rst for more details on how to write your commit message.

Quoted 2 lines

This patch also removes inline for acrn_get_tsc_khz() since it doesn't make sense.

Avoid having "This patch" or "This commit" in the commit message. It is tautologically useless.

Also, do

$ git grep 'This patch' Documentation/process

for more details.

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
author
#3 lore raw
Quoted 3 lines · Borislav Petkov
Quoted 2 lines · Fei Li

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

Hi Borislav

Thanks for your comments. So sorry to reply you late.

Quoted 3 lines

What if the HV has unstable TSCs? How do you handle that?

ACRN hypervisor assumes:
a) The TSC runs at a constant rate in all ACPI P-, C-. and T-states (i.e. invariant TSC)
b) The invariant TSC is based on only one invariant timekeeping hardware (called Always Running Timer or ART). ACRN main target uses for IoT devices which are typically one-socket
c) ACRN lives with temperature influence on TSC frequency

Quoted 5 lines
Quoted 1 line

Avoiding recalibration by setting X86_FEATURE_TSC_KNOWN_FREQ.

Pls read section "2) Describe your changes" in Documentation/process/submitting-patches.rst for more details on how to write your commit message.

OK, will refine the commit message in v3. Thanks.

Quoted 4 lines
Quoted 3 lines

This patch also removes inline for acrn_get_tsc_khz() since it doesn't make sense.

Quoted 8 lines

Avoid having "This patch" or "This commit" in the commit message. It is tautologically useless.

Also, do

$ git grep 'This patch' Documentation/process

for more details.

OK. Thanks.

Quoted 8 lines

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
author
#4 lore raw
Quoted 5 lines

Hi Borislav

Thanks for your comments. So sorry to reply you late.

Quoted 1 line
Quoted 9 lines
Quoted 2 lines

What if the HV has unstable TSCs? How do you handle that?

ACRN hypervisor assumes:
a) The TSC runs at a constant rate in all ACPI P-, C-. and T-states (i.e. invariant TSC)
b) The invariant TSC is based on only one invariant timekeeping hardware (called Always Running Timer or ART). ACRN main target uses for IoT devices which are typically one-socket
c) ACRN lives with temperature influence on TSC frequency

Hi Borislav

Kindly ping for any comments here ?

maintainer
#5 lore raw
In reply to Fei Li
Quoted 1 line · Fei Li

ACRN hypervisor assumes:

So ACRN assumes the HV has a good TSC and if it doesn't, oh well, tough luck.

At least this is how I read this.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette