From nobody Wed Mar 22 13:19:36 2023 X-Original-To: dev-commits-src-all@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 4PhTbF0dqHz40qL8; Wed, 22 Mar 2023 13:19:37 +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 4PhTbF04ccz4WS7; Wed, 22 Mar 2023 13:19:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679491177; 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=RGfrkAZ8C11of76PM48M8qj0//vCX8TgbFFxaK2icl0=; b=eHD91YDE+kjd3tDKOwHhP+VlXMOrZNTyT27LdxWfsS25YGX35erJE3T5ujENQG8AIjkJUl F+JKKDd1ymcO5Of47ycsIEcXU/RB5JJSQPVLSddi+rC3u4AL+UVwvRhSsYIRIGQ2BwESv+ jIGNztsiD+Af8aEsehUcYrnNdyyD2kx2/TwMWFxPPW/Xju0EK7u3Nmp3xwHb0nx5rbPONB yAAFEEBKOwjlN9Sjzib6goxmlmLuMbkLaliAyTyrcUJuv767rjAQq7mrgjVENoRqJEeiUs PvSKHtigp+d2ljIVUJaSpxCKhSaY/lqC3xaYX6MqFwym+Sd7m/KrYbwIQ2vvNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679491177; 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=RGfrkAZ8C11of76PM48M8qj0//vCX8TgbFFxaK2icl0=; b=Tc6mZ2DhRZ4AjZ2MZy9YqmL2xmMqtbT5/AxJ5E2+MUs9wD9omLdh0W/jAIq/lsexQUM844 4+psQBCgVfm18R5v9HmaFpAujzm5nWOFZVczfa503heFvtJtX4k2UJzDZqyYWIGojCKQkt 7PjY+tgQ6iYbfziF9jc9e8PNgszlqufFQkhsc1Sy4CsVGhH6T7HY/aGqBEsH+968f7DR1a N9/O8klSbJdHaEdhxz2jeSXyAKbwYuAbvVZLFprIbpgrZ3DaIqxZlh5Laq/48jn/kN+5Pv L7f+Ws5YT+VNFLnt8qFSc6e7x/6EPihS4OsQcnswW8KryajpEmQqpd8gXr/LQQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1679491177; a=rsa-sha256; cv=none; b=J87z+3cqVKBsfQeLAhf/q7Z6Y7MaE5N4MlzdaZ2ozsOhD7sDFCC6M0Cgc/XTt/Ps7AzHBj pIuO6xnob6cKxlp7wVkPO4KZ+603g0IwEGKB5LYeBjT5IWZ2NqAWP73IVpjgrVPrNyDa2F rnnvkPt0tBFpGSjx2wwNTlfqcBPzWw/7vWI0PAlcdyjEFVc2Jgz2UgHocUAoteVHBAQCJy 5k9JPTo1iaXS1TQT8qy6EQty2JLW17z3Nl6Pcs9FC8R0UtPEoJhxjeCUkemMjdiWbacvHW PllDCi+z7U6hxt5+7or03YlxHvH8qtkfAOlNpRzY67UesVQ1FP35SLed6kAPKw== 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 4PhTbD6Htjzvdk; Wed, 22 Mar 2023 13:19:36 +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 32MDJaBk097064; Wed, 22 Mar 2023 13:19:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32MDJal8097063; Wed, 22 Mar 2023 13:19:36 GMT (envelope-from git) Date: Wed, 22 Mar 2023 13:19:36 GMT Message-Id: <202303221319.32MDJal8097063@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: ef0ac973dbc8 - main - bhyve: Sleep briefly in the VMEXIT_DEBUG handler List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/main X-Git-Reftype: branch X-Git-Commit: ef0ac973dbc8c54214ac8c61891abd832cd5b700 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=ef0ac973dbc8c54214ac8c61891abd832cd5b700 commit ef0ac973dbc8c54214ac8c61891abd832cd5b700 Author: Mark Johnston AuthorDate: 2023-03-22 13:02:54 +0000 Commit: Mark Johnston 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); }