virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/vmware: Skip lapic calibration on VMware.
@ 2016-10-04 20:11 Renat Valiullin
  0 siblings, 0 replies; 3+ messages in thread
From: Renat Valiullin @ 2016-10-04 20:11 UTC (permalink / raw)
  To: Alok Kataria, Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86,
	virtualization, linux-kernel

In virtualized environment the APIC timer calibration could go wrong
when the host is overcommitted or the guest is running nested,
this would result in the APIC timers operating at an incorrect frequency.
Since VMware supports a mechanism to retrieve the local APIC frequency
we can ask the hypervisor for it and skip this APIC calibration loop.

Signed-off-by: Renat Valiullin <rvaliullin@vmware.com>
Acked-by: Alok N Kataria <akataria@vmware.com>
---
 arch/x86/kernel/cpu/vmware.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
index 1ff0598..8116057 100644
--- a/arch/x86/kernel/cpu/vmware.c
+++ b/arch/x86/kernel/cpu/vmware.c
@@ -27,6 +27,7 @@
 #include <asm/div64.h>
 #include <asm/x86_init.h>
 #include <asm/hypervisor.h>
+#include <asm/apic.h>
 
 #define CPUID_VMWARE_INFO_LEAF	0x40000000
 #define VMWARE_HYPERVISOR_MAGIC	0x564D5868
@@ -82,10 +83,17 @@ static void __init vmware_platform_setup(void)
 
 	VMWARE_PORT(GETHZ, eax, ebx, ecx, edx);
 
-	if (ebx != UINT_MAX)
+	if (ebx != UINT_MAX) {
 		x86_platform.calibrate_tsc = vmware_get_tsc_khz;
-	else
+#ifdef CONFIG_X86_LOCAL_APIC
+		/* Skip lapic calibration since we know the bus frequency. */
+		lapic_timer_frequency = ecx / HZ;
+		pr_info("Host bus clock speed read from hypervisor : %u Hz\n",
+			ecx);
+#endif
+	} else {
 		pr_warn("Failed to get TSC freq from the hypervisor\n");
+	}
 }
 
 /*
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread
[parent not found: <9FDEBA6F-7CB2-4637-BFC7-EA336B97EDAD@vmware.com>]
* [PATCH] x86/vmware: Skip lapic calibration on VMware.
@ 2016-09-29 17:51 Renat Valiullin
  0 siblings, 0 replies; 3+ messages in thread
From: Renat Valiullin @ 2016-09-29 17:51 UTC (permalink / raw)
  To: Alok Kataria, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
	x86@kernel.org, virtualization@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org

In virtualized environment the APIC timer calibration could go wrong
when the host is overcommitted or the guest is running nested,
this would result in the APIC timers operating at an incorrect frequency.
Since VMware supports a mechanism to retrieve the local APIC frequency
we can ask the hypervisor for it and skip this APIC calibration loop.

Signed-off-by: Renat Valiullin <rvaliullin@vmware.com>
Acked-by: Alok N Kataria <akataria@vmware.com>
---
 arch/x86/kernel/cpu/vmware.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
index 1ff0598..6316240 100644
--- a/arch/x86/kernel/cpu/vmware.c
+++ b/arch/x86/kernel/cpu/vmware.c
@@ -27,6 +27,7 @@
 #include <asm/div64.h>
 #include <asm/x86_init.h>
 #include <asm/hypervisor.h>
+#include <asm/apic.h>

 #define CPUID_VMWARE_INFO_LEAF 0x40000000
 #define VMWARE_HYPERVISOR_MAGIC        0x564D5868
@@ -82,9 +83,15 @@ static void __init vmware_platform_setup(void)

        VMWARE_PORT(GETHZ, eax, ebx, ecx, edx);

-       if (ebx != UINT_MAX)
+       if (ebx != UINT_MAX) {
                x86_platform.calibrate_tsc = vmware_get_tsc_khz;
-       else
+#ifdef CONFIG_X86_LOCAL_APIC
+               /* Skip lapic calibration since we know the bus frequency. */
+               lapic_timer_frequency = ecx / HZ;
+               pr_info("Host bus clock speed read from hypervisor : %u Hz\n",
+                       ecx);
+#endif
+       } else
                pr_warn("Failed to get TSC freq from the hypervisor\n");
 }

-- 
2.7.4


_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

end of thread, other threads:[~2016-10-04 20:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-04 20:11 [PATCH] x86/vmware: Skip lapic calibration on VMware Renat Valiullin
     [not found] <9FDEBA6F-7CB2-4637-BFC7-EA336B97EDAD@vmware.com>
2016-09-30  8:52 ` Thomas Gleixner
  -- strict thread matches above, loose matches on Subject: below --
2016-09-29 17:51 Renat Valiullin

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