linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/1] Fix for a recent regression in kvm/queue (guest using 100% cpu time)
@ 2020-12-03 14:33 Maxim Levitsky
  2020-12-03 14:33 ` [PATCH 1/1] KVM: x86: ignore SIPIs that are received while not in wait-for-sipi state Maxim Levitsky
  0 siblings, 1 reply; 3+ messages in thread
From: Maxim Levitsky @ 2020-12-03 14:33 UTC (permalink / raw)
  To: kvm
  Cc: Sean Christopherson, Joerg Roedel, Ingo Molnar,
	maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	H. Peter Anvin, Vitaly Kuznetsov, Paolo Bonzini, Borislav Petkov,
	Jim Mattson, Wanpeng Li, linux-kernel, Thomas Gleixner,
	Maxim Levitsky

I did a quick bisect yesterday after noticing that my VMs started
to take 100% cpu time.

Looks like we don't ignore SIPIs that are received while the CPU isn't
waiting for them, and that makes KVM think that CPU always has
pending events which makes it never enter an idle state.

Best regards,
	Maxim Levitsky

Maxim Levitsky (1):
  KVM: x86: ignore SIPIs that are received while not in wait-for-sipi
    state

 arch/x86/kvm/lapic.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

-- 
2.26.2



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

* [PATCH 1/1] KVM: x86: ignore SIPIs that are received while not in wait-for-sipi state
  2020-12-03 14:33 [PATCH 0/1] Fix for a recent regression in kvm/queue (guest using 100% cpu time) Maxim Levitsky
@ 2020-12-03 14:33 ` Maxim Levitsky
  2020-12-03 17:36   ` Paolo Bonzini
  0 siblings, 1 reply; 3+ messages in thread
From: Maxim Levitsky @ 2020-12-03 14:33 UTC (permalink / raw)
  To: kvm
  Cc: Sean Christopherson, Joerg Roedel, Ingo Molnar,
	maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	H. Peter Anvin, Vitaly Kuznetsov, Paolo Bonzini, Borislav Petkov,
	Jim Mattson, Wanpeng Li, linux-kernel, Thomas Gleixner,
	Maxim Levitsky

In the commit 1c96dcceaeb3
("KVM: x86: fix apic_accept_events vs check_nested_events"),

we accidently started latching SIPIs that are received while the cpu is not
waiting for them.

This causes vCPUs to never enter a halted state.

Fixes: 1c96dcceaeb3 ("KVM: x86: fix apic_accept_events vs check_nested_events")
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
---
 arch/x86/kvm/lapic.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index e3ee597ff5404..6a87623aa578e 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -2892,14 +2892,15 @@ void kvm_apic_accept_events(struct kvm_vcpu *vcpu)
 		else
 			vcpu->arch.mp_state = KVM_MP_STATE_INIT_RECEIVED;
 	}
-	if (test_bit(KVM_APIC_SIPI, &pe) &&
-	    vcpu->arch.mp_state == KVM_MP_STATE_INIT_RECEIVED) {
+	if (test_bit(KVM_APIC_SIPI, &pe)) {
 		clear_bit(KVM_APIC_SIPI, &apic->pending_events);
-		/* evaluate pending_events before reading the vector */
-		smp_rmb();
-		sipi_vector = apic->sipi_vector;
-		kvm_vcpu_deliver_sipi_vector(vcpu, sipi_vector);
-		vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE;
+		if (vcpu->arch.mp_state == KVM_MP_STATE_INIT_RECEIVED) {
+			/* evaluate pending_events before reading the vector */
+			smp_rmb();
+			sipi_vector = apic->sipi_vector;
+			kvm_vcpu_deliver_sipi_vector(vcpu, sipi_vector);
+			vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE;
+		}
 	}
 }
 
-- 
2.26.2


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

* Re: [PATCH 1/1] KVM: x86: ignore SIPIs that are received while not in wait-for-sipi state
  2020-12-03 14:33 ` [PATCH 1/1] KVM: x86: ignore SIPIs that are received while not in wait-for-sipi state Maxim Levitsky
@ 2020-12-03 17:36   ` Paolo Bonzini
  0 siblings, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2020-12-03 17:36 UTC (permalink / raw)
  To: Maxim Levitsky, kvm
  Cc: Sean Christopherson, Joerg Roedel, Ingo Molnar,
	maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	H. Peter Anvin, Vitaly Kuznetsov, Borislav Petkov, Jim Mattson,
	Wanpeng Li, linux-kernel, Thomas Gleixner

On 03/12/20 15:33, Maxim Levitsky wrote:
> In the commit 1c96dcceaeb3
> ("KVM: x86: fix apic_accept_events vs check_nested_events"),
> 
> we accidently started latching SIPIs that are received while the cpu is not
> waiting for them.
> 
> This causes vCPUs to never enter a halted state.
> 
> Fixes: 1c96dcceaeb3 ("KVM: x86: fix apic_accept_events vs check_nested_events")
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> ---
>  arch/x86/kvm/lapic.c | 15 ++++++++-------


Indeed, it was done by the xchg before that commit, even if 
vcpu->arch.mp_state != KVM_MP_STATE_INIT_RECEIVED.

Paolo


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

end of thread, other threads:[~2020-12-03 17:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-03 14:33 [PATCH 0/1] Fix for a recent regression in kvm/queue (guest using 100% cpu time) Maxim Levitsky
2020-12-03 14:33 ` [PATCH 1/1] KVM: x86: ignore SIPIs that are received while not in wait-for-sipi state Maxim Levitsky
2020-12-03 17:36   ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).