Skip to content

Commit 4edc540

Browse files
committed
Remove affinity pinning for Intel CPUs.
1 parent ca59953 commit 4edc540

2 files changed

Lines changed: 6 additions & 16 deletions

File tree

arch/x86/kvm/vmx.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7409,12 +7409,18 @@ static void __declspec(noinline) vmx_vcpu_run(struct kvm_vcpu *vcpu)
74097409
do_print1 = 0;
74107410
}
74117411

7412+
for (i = 0; i < m->nr; i++)
7413+
if (m->host[i].index == MSR_GS_BASE)
7414+
rdmsrl(m->host[i].index, m->host[i].value);
74127415
for (i = 0; i < m->nr; i++)
74137416
wrmsrl(m->guest[i].index, m->guest[i].value);
74147417
kvm_load_guest_fpu(vcpu);
74157418
/* Calls to low-level assembly functions*/
74167419
__asm_vmx_vcpu_run(vmx);
74177420
kvm_save_guest_fpu(vcpu);
7421+
for (i = 0; i < m->nr; i++)
7422+
if (m->guest[i].index == MSR_GS_BASE)
7423+
rdmsrl(m->guest[i].index, m->guest[i].value);
74187424
for (i = 0; i < m->nr; i++)
74197425
wrmsrl(m->host[i].index, m->host[i].value);
74207426

virt/kvm/kvm_main.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,7 +1762,6 @@ static int kvm_vm_ioctl_create_vcpu(PDEVICE_OBJECT pDevObj, PIRP pIrp, void *arg
17621762
struct kvm *kvm = devext->PrivData;
17631763
HANDLE handle;
17641764
int id = *(int *)arg;
1765-
KAFFINITY Affinity;
17661765

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

1823-
if (is_Intel()) {
1824-
Affinity = (KAFFINITY)1 << (
1825-
cpu_online_count - 1
1826-
- 2 * vcpu->vcpu_id / cpu_online_count % 2
1827-
- vcpu->vcpu_id * 2 % cpu_online_count);
1828-
KeSetSystemAffinityThread(Affinity);
1829-
}
18301822
return r;
18311823

18321824
unlock_vcpu_destroy:
@@ -1865,7 +1857,6 @@ NTSTATUS kvm_vcpu_fast_ioctl_run(PDEVICE_OBJECT pDevObj)
18651857
struct kvm_vcpu *vcpu = devext->PrivData;
18661858
LARGE_INTEGER expire;
18671859
expire.QuadPart = (u64)-10000000;
1868-
KAFFINITY Affinity;
18691860
int r = -EINVAL;
18701861

18711862
if (vcpu->kvm->process != IoGetCurrentProcess())
@@ -1880,13 +1871,6 @@ NTSTATUS kvm_vcpu_fast_ioctl_run(PDEVICE_OBJECT pDevObj)
18801871
NULL,
18811872
KernelMode,
18821873
NULL);
1883-
if (is_Intel()) {
1884-
Affinity = (KAFFINITY)1 << (
1885-
cpu_online_count - 1
1886-
- 2 * vcpu->vcpu_id / cpu_online_count % 2
1887-
- vcpu->vcpu_id * 2 % cpu_online_count);
1888-
KeSetSystemAffinityThread(Affinity);
1889-
}
18901874
}
18911875
/* vcpu_run has to return to user space periodically otherwise
18921876
* vcpu thread could hang when process terminates.

0 commit comments

Comments
 (0)