git: 3dcdb83c85b5 - stable/13 - bhyve: Tidy vCPU pthread startup.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 26 Jan 2023 22:35:04 UTC
The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=3dcdb83c85b5fb65ba9e826efcb7bb34091d80da commit 3dcdb83c85b5fb65ba9e826efcb7bb34091d80da Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2022-12-21 18:33:18 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2023-01-26 22:18:20 +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 (cherry picked from commit 7224a96a55d512e00f390d4477e0fb0a163d7528) --- 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));