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
This commit is contained in:
parent
8487443792
commit
7224a96a55
@ -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));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user