Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Mar 2023 12:51:44 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 3b6598f8742c - stable/13 - bhyve: Sleep briefly in the VMEXIT_DEBUG handler
Message-ID:  <202303271251.32RCpi1U005847@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=3b6598f8742cdab079cbce5485e9ddffbacdc1b4

commit 3b6598f8742cdab079cbce5485e9ddffbacdc1b4
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-03-22 13:02:54 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
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);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202303271251.32RCpi1U005847>