All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: x86: directly call wbinvd for local cpu when emulate wbinvd
@ 2021-09-28  9:27 Li RongQing
  2021-10-04 22:56 ` Andy Lutomirski
  0 siblings, 1 reply; 4+ messages in thread
From: Li RongQing @ 2021-09-28  9:27 UTC (permalink / raw)
  To: kvm, wanpengli, jan.kiszka, x86

directly call wbinvd for local pCPU, which can avoid ipi for
itself and calling of get_cpu/on_each_cpu_mask/etc.

In fact, This change reverts commit 2eec73437487 ("KVM: x86: Avoid
issuing wbinvd twice"), since smp_call_function_many is skiping the
local cpu (as description of c2162e13d6e2f), wbinvd is not issued
twice

and reverts commit c2162e13d6e2f ("KVM: X86: Fix missing local pCPU
when executing wbinvd on all dirty pCPUs") too, which fixed the
previous patch, when revert previous patch, it is not needed.

Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
 arch/x86/kvm/x86.c |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 28ef141..ee65941 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -6984,15 +6984,14 @@ static int kvm_emulate_wbinvd_noskip(struct kvm_vcpu *vcpu)
 		return X86EMUL_CONTINUE;
 
 	if (static_call(kvm_x86_has_wbinvd_exit)()) {
-		int cpu = get_cpu();
-
-		cpumask_set_cpu(cpu, vcpu->arch.wbinvd_dirty_mask);
-		on_each_cpu_mask(vcpu->arch.wbinvd_dirty_mask,
+		preempt_disable();
+		smp_call_function_many(vcpu->arch.wbinvd_dirty_mask,
 				wbinvd_ipi, NULL, 1);
-		put_cpu();
+		preempt_enable();
 		cpumask_clear(vcpu->arch.wbinvd_dirty_mask);
-	} else
-		wbinvd();
+	}
+
+	wbinvd();
 	return X86EMUL_CONTINUE;
 }
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-10-12  8:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-28  9:27 [PATCH] KVM: x86: directly call wbinvd for local cpu when emulate wbinvd Li RongQing
2021-10-04 22:56 ` Andy Lutomirski
2021-10-05  8:04   ` 答复: " Li,Rongqing
2021-10-12  8:48   ` Li,Rongqing

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.