Skip to content

Commit

Permalink
Remove affinity pinning for Intel CPUs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Taogle2018 committed Jun 5, 2020
1 parent ca59953 commit 4edc540
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
6 changes: 6 additions & 0 deletions arch/x86/kvm/vmx.c
Original file line number Diff line number Diff line change
Expand Up @@ -7409,12 +7409,18 @@ static void __declspec(noinline) vmx_vcpu_run(struct kvm_vcpu *vcpu)
do_print1 = 0;
}

for (i = 0; i < m->nr; i++)
if (m->host[i].index == MSR_GS_BASE)
rdmsrl(m->host[i].index, m->host[i].value);
for (i = 0; i < m->nr; i++)
wrmsrl(m->guest[i].index, m->guest[i].value);
kvm_load_guest_fpu(vcpu);
/* Calls to low-level assembly functions*/
__asm_vmx_vcpu_run(vmx);
kvm_save_guest_fpu(vcpu);
for (i = 0; i < m->nr; i++)
if (m->guest[i].index == MSR_GS_BASE)
rdmsrl(m->guest[i].index, m->guest[i].value);
for (i = 0; i < m->nr; i++)
wrmsrl(m->host[i].index, m->host[i].value);

Expand Down
16 changes: 0 additions & 16 deletions virt/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1762,7 +1762,6 @@ static int kvm_vm_ioctl_create_vcpu(PDEVICE_OBJECT pDevObj, PIRP pIrp, void *arg
struct kvm *kvm = devext->PrivData;
HANDLE handle;
int id = *(int *)arg;
KAFFINITY Affinity;

mutex_lock(&kvm->lock);
if (id >= GVM_MAX_VCPU_ID)
Expand Down Expand Up @@ -1820,13 +1819,6 @@ static int kvm_vm_ioctl_create_vcpu(PDEVICE_OBJECT pDevObj, PIRP pIrp, void *arg
mutex_unlock(&kvm->lock);
kvm_arch_vcpu_postcreate(vcpu);

if (is_Intel()) {
Affinity = (KAFFINITY)1 << (
cpu_online_count - 1
- 2 * vcpu->vcpu_id / cpu_online_count % 2
- vcpu->vcpu_id * 2 % cpu_online_count);
KeSetSystemAffinityThread(Affinity);
}
return r;

unlock_vcpu_destroy:
Expand Down Expand Up @@ -1865,7 +1857,6 @@ NTSTATUS kvm_vcpu_fast_ioctl_run(PDEVICE_OBJECT pDevObj)
struct kvm_vcpu *vcpu = devext->PrivData;
LARGE_INTEGER expire;
expire.QuadPart = (u64)-10000000;
KAFFINITY Affinity;
int r = -EINVAL;

if (vcpu->kvm->process != IoGetCurrentProcess())
Expand All @@ -1880,13 +1871,6 @@ NTSTATUS kvm_vcpu_fast_ioctl_run(PDEVICE_OBJECT pDevObj)
NULL,
KernelMode,
NULL);
if (is_Intel()) {
Affinity = (KAFFINITY)1 << (
cpu_online_count - 1
- 2 * vcpu->vcpu_id / cpu_online_count % 2
- vcpu->vcpu_id * 2 % cpu_online_count);
KeSetSystemAffinityThread(Affinity);
}
}
/* vcpu_run has to return to user space periodically otherwise
* vcpu thread could hang when process terminates.
Expand Down

0 comments on commit 4edc540

Please sign in to comment.