From owner-dev-commits-src-all@freebsd.org Fri Mar 12 18:43:56 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4EDDC5A9924; Fri, 12 Mar 2021 18:43:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Dxvq01nTqz4j51; Fri, 12 Mar 2021 18:43:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 307681CA9B; Fri, 12 Mar 2021 18:43:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 12CIhuvK045748; Fri, 12 Mar 2021 18:43:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 12CIhuAf045747; Fri, 12 Mar 2021 18:43:56 GMT (envelope-from git) Date: Fri, 12 Mar 2021 18:43:56 GMT Message-Id: <202103121843.12CIhuAf045747@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: ec24f78e5b20 - stable/13 - x86: tsc: deprioritize TSC on VirtualBox MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ec24f78e5b201ea56a69607c6e4438a2faac25c0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Mar 2021 18:43:56 -0000 The branch stable/13 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=ec24f78e5b201ea56a69607c6e4438a2faac25c0 commit ec24f78e5b201ea56a69607c6e4438a2faac25c0 Author: Kyle Evans AuthorDate: 2021-03-08 20:20:10 +0000 Commit: Kyle Evans CommitDate: 2021-03-12 18:43:43 +0000 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 (cherry picked from commit 8cc15b0dfc2f3299662e78f18bd6127f83c14ab4) --- sys/x86/x86/tsc.c | 8 ++++++++ 1 file changed, 8 insertions(+) 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;