Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2eec7343 authored by Jan Kiszka's avatar Jan Kiszka Committed by Avi Kivity
Browse files

KVM: x86: Avoid issuing wbinvd twice



Micro optimization to avoid calling wbinvd twice on the CPU that has to
emulate it. As we might be preempted between smp_call_function_many and
the local wbinvd, the cache might be filled again so that real work
could be done uselessly.

Signed-off-by: default avatarJan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: default avatarMarcelo Tosatti <mtosatti@redhat.com>
parent aac87636
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -4007,12 +4007,14 @@ int kvm_emulate_wbinvd(struct kvm_vcpu *vcpu)
		return X86EMUL_CONTINUE;

	if (kvm_x86_ops->has_wbinvd_exit()) {
		preempt_disable();
		int cpu = get_cpu();

		cpumask_set_cpu(cpu, vcpu->arch.wbinvd_dirty_mask);
		smp_call_function_many(vcpu->arch.wbinvd_dirty_mask,
				wbinvd_ipi, NULL, 1);
		preempt_enable();
		put_cpu();
		cpumask_clear(vcpu->arch.wbinvd_dirty_mask);
	}
	} else
		wbinvd();
	return X86EMUL_CONTINUE;
}