From 5cf8ac1bc2881c6724897cf2cd32273e7580dd10 Mon Sep 17 00:00:00 2001 From: Mike Silbersack Date: Mon, 22 Aug 2011 03:10:29 +0000 Subject: [PATCH] Disable TSC usage inside SMP VM environments. On my VMware ESXi 4.1 environment with a core i5-2500K, operation in this mode causes timeouts from the mpt driver. Switching to the ACPI-fast timer resolves this issue. Switching the VM back to single CPU mode also works, which is why I have not disabled the TSC in that mode. I did not test with KVM or other VM environments, but I am being cautious and assuming that the TSC is not reliable in SMP mode there as well. Reviewed by: kib Approved by: re (kib) MFC after: Not applicable, the timecounter code is new for 9.x --- sys/x86/x86/tsc.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sys/x86/x86/tsc.c b/sys/x86/x86/tsc.c index 0b383bf7ef21..4d1618f14b79 100644 --- a/sys/x86/x86/tsc.c +++ b/sys/x86/x86/tsc.c @@ -464,11 +464,16 @@ init_TSC_tc(void) * synchronized. If the user is sure that the system has synchronized * TSCs, set kern.timecounter.smp_tsc tunable to a non-zero value. * We also limit the frequency even lower to avoid "temporal anomalies" - * as much as possible. + * as much as possible. The TSC seems unreliable in virtualized SMP + * environments, so it is set to a negative quality in those cases. */ if (smp_cpus > 1) { - tsc_timecounter.tc_quality = test_smp_tsc(); - max_freq >>= 8; + if (vm_guest != 0) { + tsc_timecounter.tc_quality = -100; + } else { + tsc_timecounter.tc_quality = test_smp_tsc(); + max_freq >>= 8; + } } else #endif if (tsc_is_invariant)