From nobody Wed Dec 21 18:34:06 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 4Ncht66Rzcz1Gj1c; Wed, 21 Dec 2022 18:34:06 +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 4Ncht66225z418j; Wed, 21 Dec 2022 18:34:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1671647646; 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=JJlCcdkxtWFVpSK45Bf3ozNAbQCepl7UZBijs2lCr+M=; b=dgX75HCunAlQlIBj/oCnoP3AleSbm4jMS+GmG73DA/ADFN5ev7YQR/ZnOeH9inJq34S5O2 KRhWZt7kVYxJ+LMexwP4Tfg9NW3BTnN2q8vMMG1d8ih5YAsKC6qODdBHsUfX57katmD+nI Hbcp2YLuD5kngegxgAJCLC8ESgtrylvuZf5hEq3uVMXb2es7eeolRRjNxVY/b9Cipwpw1y hLtUo4bj+AsDwgBiKBRvxL7kPXJSOxwdzPgTov+yzmVBybDNaCUkBO9NMwxmjzU4bHeuUd hd+9AS7M1Yl+3ivYnAwrKVN+PbCU/yrFnYo7YfEtGYX0pk7nIMIBW3IY9aUWiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1671647646; 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=JJlCcdkxtWFVpSK45Bf3ozNAbQCepl7UZBijs2lCr+M=; b=M+RAPK+axGK+82rHDP+9dYDIipxMBmW0ArjX62PbHtIZ7RIiYZdcd8eczqIfEhKWkMe+FP 6iTHEfbltwtyNR4PvNBWVQOugK8Yhi1I5avY9NhVeEbBs9oR6y1V6+cVPvYZEP3N+38A2Q EjFvo2uPuST0lfa8UyQ8WhL1rbPxAg0t0h+JCcwbQK8d8A4mxk23rASZ9eDH6uxqILb5gN XHe+fyoN1p2PTEAj2gU3V4vF/2GkHwfoKo4UFQkehuaSzJlZkmIssVlNxF/oEMZ3hMOZqd e9/c+XCwj+t4hcIrgtGjAY+N7VsnaBO4Ppxw2o0uEL392sgi4PNdQZJffub/xA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1671647646; a=rsa-sha256; cv=none; b=BvTqDr5Aksy9DOxvQhi1fvxz5I44Zuw0p7K/z2wDlUIF7fBy+lmsdRx5N2KGl/+6zfxtv5 +5WQd7WYPSwu7cCCQWmIEUDO5Ja7svnAGdSEA+EVy9oF49+oUC1gRFK9cchlgB+0YCFcG4 nAc88zKJXn4Lr7hQQkHLSrGSaI42t53hVQ0vkB7v3oOr/1jHt6omuNJxrncPERWdJlpEq4 HdyaAceFgYFbR+DF1cBRef62pGo6IgtNGvtk20z7BP8VCizNEk8+zbiEJFlZmetKozq+KJ nFfTWox9mm6YCsSBdNt4mwnj8LnIGjVPetDSC91oX1q3geUA2/BSgfpWrI0Caw== 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 4Ncht655jGzQLv; Wed, 21 Dec 2022 18:34:06 +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 2BLIY66p068949; Wed, 21 Dec 2022 18:34:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2BLIY6ZX068948; Wed, 21 Dec 2022 18:34:06 GMT (envelope-from git) Date: Wed, 21 Dec 2022 18:34:06 GMT Message-Id: <202212211834.2BLIY6ZX068948@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: 7224a96a55d5 - main - bhyve: Tidy vCPU pthread startup. 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: 7224a96a55d512e00f390d4477e0fb0a163d7528 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=7224a96a55d512e00f390d4477e0fb0a163d7528 commit 7224a96a55d512e00f390d4477e0fb0a163d7528 Author: John Baldwin AuthorDate: 2022-12-21 18:33:18 +0000 Commit: John Baldwin CommitDate: 2022-12-21 18:33:18 +0000 bhyve: Tidy vCPU pthread startup. Set the thread affinity in fbsdrun_start_thread next to where the thread name is set. This keeps all the pthread initialization operations at the start of a thread in one place. Reviewed by: corvink, markj Differential Revision: https://reviews.freebsd.org/D37646 --- usr.sbin/bhyve/bhyverun.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c index c110fecf31b0..aeafed1d0c69 100644 --- a/usr.sbin/bhyve/bhyverun.c +++ b/usr.sbin/bhyve/bhyverun.c @@ -525,7 +525,7 @@ fbsdrun_start_thread(void *param) { char tname[MAXCOMLEN + 1]; struct mt_vmm_info *mtp; - int vcpu; + int error, vcpu; mtp = param; vcpu = mtp->mt_vcpu; @@ -533,6 +533,12 @@ fbsdrun_start_thread(void *param) snprintf(tname, sizeof(tname), "vcpu %d", vcpu); pthread_set_name_np(mtp->mt_thr, tname); + if (vcpumap[vcpu] != NULL) { + error = pthread_setaffinity_np(mtp->mt_thr, sizeof(cpuset_t), + vcpumap[vcpu]); + assert(error == 0); + } + #ifdef BHYVE_SNAPSHOT checkpoint_cpu_add(vcpu); #endif @@ -971,12 +977,6 @@ vm_loop(struct vmctx *ctx, int vcpu) enum vm_exitcode exitcode; cpuset_t active_cpus; - if (vcpumap[vcpu] != NULL) { - error = pthread_setaffinity_np(pthread_self(), - sizeof(cpuset_t), vcpumap[vcpu]); - assert(error == 0); - } - error = vm_active_cpus(ctx, &active_cpus); assert(CPU_ISSET(vcpu, &active_cpus));