aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2021-03-08 20:20:10 +0000
committerKyle Evans <kevans@FreeBSD.org>2021-03-14 19:44:04 +0000
commit1a15924593931b91aee31875fa75782a592a7436 (patch)
tree3563e3732fcbeae38f16cb992a96503f4a5c8713
parent45910f663893fab38eaf95c70aaeff75035334c1 (diff)
downloadsrc-1a15924593931b91aee31875fa75782a592a7436.tar.gz
src-1a15924593931b91aee31875fa75782a592a7436.zip
x86: tsc: deprioritize TSC on VirtualBox
Misbehavior has been observed with TSC under VirtualBox, where threads doing small sleeps (~1 second) may miss their wake up and hang around in a sleep state indefinitely. Switching back to ACPI-fast decidedly fixes it, so stop using TSC on VirtualBox at least for the time being. This partially reverts 84eaf2ccc6aa, applying it only to VirtualBox and increasing the quality to 0. Negative qualities can never be chosen and cannot be chosen with the tunable recently added. If we do not have a timecounter with a higher quality than 0, then TSC does at least leave the system mostly usable. PR: 253087 Approved by: re (gjb) (cherry picked from commit 8cc15b0dfc2f3299662e78f18bd6127f83c14ab4) (cherry picked from commit ec24f78e5b201ea56a69607c6e4438a2faac25c0)
-rw-r--r--sys/x86/x86/tsc.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/x86/x86/tsc.c b/sys/x86/x86/tsc.c
index de0a1505c2f6..5ffbb64229e9 100644
--- a/sys/x86/x86/tsc.c
+++ b/sys/x86/x86/tsc.c
@@ -503,6 +503,14 @@ test_tsc(int adj_max_count)
if ((!smp_tsc && !tsc_is_invariant))
return (-100);
+ /*
+ * Misbehavior of TSC under VirtualBox has been observed. In
+ * particular, threads doing small (~1 second) sleeps may miss their
+ * wakeup and hang around in sleep state, causing hangs on shutdown.
+ */
+ if (vm_guest == VM_GUEST_VBOX)
+ return (0);
+
size = (mp_maxid + 1) * 3;
data = malloc(sizeof(*data) * size * N, M_TEMP, M_WAITOK);
adj = 0;