From nobody Mon Mar 27 12:51:44 2023 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PlXkn3YHJz42Dll; Mon, 27 Mar 2023 12:51:45 +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 4PlXkn1cCTz3mJL; Mon, 27 Mar 2023 12:51:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679921505; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Y01ZkfQoaloapD+Ofky5J2IESwmkR4Sy23/xTFu0X4g=; b=P42dx4AnXB5OsJVPvvuiwi9c6WYIn0dbacbur+REaHaiB7OeNqt0AGPOLmIhg6y3pI8HPP zU4NNF5jrQSsGW5sHhVLrhSENgfgv5cSIbOdlXzobnTN3ebGV7iuGHLAKFNgYWrlnirNKE yf85PrVN200sTQZP54sDqeK07s9GjRa5JJ2px6au45WWsCdqWKmfjY9xnDS4IZoKjQ7cLs aCfb0gYv4M6VsFPX7shyTj/0L1ULS5eraSCW2qzx/u3dGyp0Ged00JZCExqt++2+V/eYlK vsZcH1m3nFlKM8tqQ97DJuvarx8u133qzeDfGFSGb7OUepiCRXSVFvO+eIWbpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679921505; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Y01ZkfQoaloapD+Ofky5J2IESwmkR4Sy23/xTFu0X4g=; b=hoe/dVJKLa99yjuhUA+E0TnnqbPKQopgPvW6AM3bN339WcOQKhSoQwGV6pixbWDkAxKMkV whDmmtSMKHvieEbXzX74OSAAo7PjgSCOvzezVpwMBqQSI9Klp8OBgtRieo2vnLSP5Z3BN4 xcrY/WDEMYziU94PQz1LJk7oVeqqq+OppE4nmDD7TscumhY6VOS2Hxb0952XKAYDAs1YWI vCutRUCysvmmpsepCY/2hnFtvJ/bwkuZzVLtzHAlHpW+VssQBo9rKmtzNTEU4zJR2ltrzU obpBjdd6GUgM2RVi3LAD43il3modHjkxz1DTDNxsz0niqllbowCphNxIljQf1g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1679921505; a=rsa-sha256; cv=none; b=M/8h/bTeLITaN4N2H8i7QEoOiEsMKEJC71YZFYV0J5COyyIDTPiqn3LDd66n5QeNsQbCuo /ObP8q1CnRVB8XgWlYzlekIWKJYnVu/RrBBo9BwLQk9tOZJGToP/VahsHpRGB+gXh6Yez2 dK8m9KJeOVTgZn6BD1JqXbH9rkpYj3HSOSyC4U0v9GwmG50naERxnfCA/uj7UGDTWZmwFU KE8hjTyG1nZ99F1cuHSz2q0HHZ38CqmgtDlC4Ipc154q7uXKTuk0kPG5/KQJIaTqNuB+hX 07sjN2AKbDi0jZkplwmmQm3zcMcIfBasTK88MYVzfVSqph1YzQNdI6v8tCiQDQ== 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 4PlXkn0cGmzN7s; Mon, 27 Mar 2023 12:51:45 +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 32RCpiTB005848; Mon, 27 Mar 2023 12:51:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32RCpi1U005847; Mon, 27 Mar 2023 12:51:44 GMT (envelope-from git) Date: Mon, 27 Mar 2023 12:51:44 GMT Message-Id: <202303271251.32RCpi1U005847@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 3b6598f8742c - stable/13 - bhyve: Sleep briefly in the VMEXIT_DEBUG handler List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3b6598f8742cdab079cbce5485e9ddffbacdc1b4 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=3b6598f8742cdab079cbce5485e9ddffbacdc1b4 commit 3b6598f8742cdab079cbce5485e9ddffbacdc1b4 Author: Mark Johnston AuthorDate: 2023-03-22 13:02:54 +0000 Commit: Mark Johnston CommitDate: 2023-03-27 12:50:12 +0000 bhyve: Sleep briefly in the VMEXIT_DEBUG handler As of commit 0bda8d3e9f7a ("vmm: permit some IPIs to be handled by userspace") and commit 9cc9abf409cc ("bhyve: create all vcpus on startup"), we have a misbehaviour where AP vCPU threads spin until they receive a SIPI. In particular, since they are "suspended", they simply call the VMEXIT_DEBUG handler in a loop, but the handler is a no-op by default. This is tricky to fix since the gdb stub isn't aware of whether a given vCPU is supposed to be running. For 13.2's sake, introduce a simple workaround wherein the VMEXIT_DEBUG handler sleeps for a short period. This ensures that host CPU usage remains sane when VMs are starting without penalizing users of VMEXIT_DEBUG too much. Reviewed by: corvink, jhb MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39174 (cherry picked from commit ef0ac973dbc8c54214ac8c61891abd832cd5b700) --- usr.sbin/bhyve/bhyverun.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c index 1becf998b976..5c8265571be9 100644 --- a/usr.sbin/bhyve/bhyverun.c +++ b/usr.sbin/bhyve/bhyverun.c @@ -911,6 +911,11 @@ vmexit_debug(struct vmctx *ctx __unused, struct vm_exit *vme __unused, #ifdef BHYVE_SNAPSHOT checkpoint_cpu_resume(*pvcpu); #endif + /* + * XXX-MJ sleep for a short period to avoid chewing up the CPU in the + * window between activation of the vCPU thread and the STARTUP IPI. + */ + usleep(1000); return (VMEXIT_CONTINUE); }