git: ef0ac973dbc8 - main - bhyve: Sleep briefly in the VMEXIT_DEBUG handler
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 22 Mar 2023 13:19:36 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=ef0ac973dbc8c54214ac8c61891abd832cd5b700
commit ef0ac973dbc8c54214ac8c61891abd832cd5b700
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-03-22 13:02:54 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-03-22 13:19:27 +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
---
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 665fec73e48c..dd30eb4405ef 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);
}