From nobody Wed Mar 09 23:57:33 2022 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 452B71A12551; Wed, 9 Mar 2022 23:57:35 +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 4KDTdp4xDPz4c6T; Wed, 9 Mar 2022 23:57:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646870255; 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=mopjq56VO33Wop6UAGRwc7S1kXcRJq149lr8rLgpiDc=; b=Fx52tnUl53b+naBNW9rKATUz1yfMxjWZYjmSK/pYpXx4FHMgSIKHuYqXFhBM0hvHEkkNCu alj7NfuyAN+q55V9Vhct8GSDPRyqRkVMsehP78KRjmmmOlUH6SIJQrBGXJI1Njy7HaGK1p vqoqdD5eNf3kBpnx5fBvtNoXPjuANkrUwIXeRohqebXZrJ5oNYpPJgvBcuvQ8K5U+NtF0I jMM6mUv7RO7RdZBiQD28dNE9a2jiEi/agxBi8DmpT6nGzgatdU2DAXouoQKpItWD3jWLuz KNjrIG0LbL81SVXoU1fLNYAaWA6LHKqhDAkwENYDbvh9uZYIAlprifV653xxJQ== 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 B73F81A72D; Wed, 9 Mar 2022 23:57:33 +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 229NvX3A004773; Wed, 9 Mar 2022 23:57:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 229NvXXE004772; Wed, 9 Mar 2022 23:57:33 GMT (envelope-from git) Date: Wed, 9 Mar 2022 23:57:33 GMT Message-Id: <202203092357.229NvXXE004772@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 7261f82156fb - main - bhyve: Allocate dynamic arrays to hold per-VCPU state. 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: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7261f82156fb35d4a5e928769041c5987f700cda Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646870255; 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=mopjq56VO33Wop6UAGRwc7S1kXcRJq149lr8rLgpiDc=; b=VoZEhMDSkWVI9k+uCbRy/HUTNKLqEBn6sDgWPAGUV6B8yVVDig7rV2GaJNUeyPmIPhr/j/ SQlqjaM5GzZdOD9iX9N7/6fAuMmalD6zgahqBzblxPo4h6TXnJ5MvwLw17wGeEcwBfldA5 m0rOc8uU/3VYPYq1VnCDw0C/bIls+BPKtxQQiqkFYbQIXBr86SFjJbe2VyHCMuZAG4ZkFo A5s8Dh/UUzJMPBfT5RT/qGOW3ECHB9S0coKFqf3tEfemXOmstYKotu2reZsnWLMKc4hgsw 0RCligMLJhBQoSlI2ZVSFFhidnVQs0VRvgqu88p1ZqfRfLK6yF5Ev22lPxWW8g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646870255; a=rsa-sha256; cv=none; b=rE84nq2kgBq7mp9OH+8lUJFFI/zvMePOCo56y1oDaRjdhDdF/rGxGVWxpWPA7gAHAmdtN8 TBLTjkLhvKNq6A3Isf3fJ3I/NsdTwlkqB4aiDGJXTQ8QMoJ3i0MKhCBfMnM1jl1hXTsIoU xsmdnXVKiUGbx9BsezPMjARfVbSEiQOnxxpNxcuWzbr94zJwBAXSGIbgf1BPweHBE7ZsZT M20rNJdSdYSW4GC/rNc5dYlH8lD4kKzbqwCwGML3LSzibs6vPwnCKzuPdsEeFCnT52koEb I9/e6L6MbiellA/VtBxKoEtwsa9w3/aqAIxVlDeHevhyhnsXTAZX06Py/9NVGw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=7261f82156fb35d4a5e928769041c5987f700cda commit 7261f82156fb35d4a5e928769041c5987f700cda Author: John Baldwin AuthorDate: 2022-03-09 23:39:08 +0000 Commit: John Baldwin CommitDate: 2022-03-09 23:39:08 +0000 bhyve: Allocate dynamic arrays to hold per-VCPU state. This avoids hardcoding VM_MAXCPU in userspace. Reviewed by: grehan Differential Revision: https://reviews.freebsd.org/D34491 --- usr.sbin/bhyve/bhyverun.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c index 0f3c6e60e1d9..72e95c0e4627 100644 --- a/usr.sbin/bhyve/bhyverun.c +++ b/usr.sbin/bhyve/bhyverun.c @@ -196,7 +196,7 @@ static cpuset_t cpumask; static void vm_loop(struct vmctx *ctx, int vcpu, uint64_t rip); -static struct vm_exit vmexit[VM_MAXCPU]; +static struct vm_exit *vmexit; struct bhyvestats { uint64_t vmexit_bogus; @@ -213,9 +213,9 @@ struct mt_vmm_info { pthread_t mt_thr; struct vmctx *mt_ctx; int mt_vcpu; -} mt_vmm_info[VM_MAXCPU]; +} *mt_vmm_info; -static cpuset_t *vcpumap[VM_MAXCPU] = { NULL }; +static cpuset_t **vcpumap; static void usage(int code) @@ -472,6 +472,7 @@ build_vcpumaps(void) const char *value; int vcpu; + vcpumap = calloc(guest_ncpus, sizeof(*vcpumap)); for (vcpu = 0; vcpu < guest_ncpus; vcpu++) { snprintf(key, sizeof(key), "vcpu.%d.cpuset", vcpu); value = get_config_value(key); @@ -1574,6 +1575,10 @@ main(int argc, char *argv[]) vm_restore_time(ctx); #endif + /* Allocate per-VCPU resources. */ + vmexit = calloc(guest_ncpus, sizeof(*vmexit)); + mt_vmm_info = calloc(guest_ncpus, sizeof(*mt_vmm_info)); + /* * Add CPU 0 */