public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Chao Gao <chao.gao@intel.com>
To: Sean Christopherson <seanjc@google.com>
Cc: "Longpeng (Mike,
	Cloud Infrastructure Service Product Dept.)" 
	<longpeng2@huawei.com>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"Gonglei (Arei)" <arei.gonglei@huawei.com>,
	Huangzhichao <huangzhichao@huawei.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: The vcpu won't be wakened for a long time
Date: Wed, 22 Dec 2021 14:07:36 +0800	[thread overview]
Message-ID: <20211222060735.GA22521@gao-cwp> (raw)
In-Reply-To: <YcHyReHoF+qjIVTy@google.com>

On Tue, Dec 21, 2021 at 03:27:01PM +0000, Sean Christopherson wrote:
>On Sat, Dec 18, 2021, Longpeng (Mike, Cloud Infrastructure Service Product Dept.) wrote:
>> > Hmm, that strongly suggests the "vcpu != kvm_get_running_vcpu()" is at fault.
>> > Can you try running with the below commit?  It's currently sitting in kvm/queue,
>> > but not marked for stable because I didn't think it was possible for the check
>> > to a cause a missed wake event in KVM's current code base.
>> > 
>> 
>> The below commit can fix the bug, we have just completed  the tests.
>> Thanks.
>
>Aha!  Somehow I missed this call chain when analyzing the change.
>
>  irqfd_wakeup()
>  |
>  |->kvm_arch_set_irq_inatomic()
>     |
>     |-> kvm_irq_delivery_to_apic_fast()
>         |
>	 |-> kvm_apic_set_irq()
>
>
>Paolo, can the changelog be amended to the below, and maybe even pull the commit
>into 5.16?
>
>
>KVM: VMX: Wake vCPU when delivering posted IRQ even if vCPU == this vCPU
>
>Drop a check that guards triggering a posted interrupt on the currently
>running vCPU,

Can we move (add) this check to kvm_vcpu_trigger_posted_interrupt()?

	if (vcpu->mode == IN_GUEST_MODE) {
[...]
-		apic->send_IPI_mask(get_cpu_mask(vcpu->cpu), pi_vec);
+		if (vcpu != kvm_get_running_vcpu())
+			apic->send_IPI_mask(get_cpu_mask(vcpu->cpu), pi_vec);
 		return true;

It can achieve the purpose of the original patch without (re-)introducing
this bug.

  parent reply	other threads:[~2021-12-22  5:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-14 13:55 The vcpu won't be wakened for a long time Longpeng (Mike, Cloud Infrastructure Service Product Dept.)
2021-12-14 17:36 ` Sean Christopherson
2021-12-16 14:03   ` Longpeng (Mike, Cloud Infrastructure Service Product Dept.)
2021-12-16 15:42     ` Sean Christopherson
2021-12-17  2:11       ` Wanpeng Li
2021-12-17  5:51         ` Longpeng (Mike, Cloud Infrastructure Service Product Dept.)
2021-12-18  9:08       ` Longpeng (Mike, Cloud Infrastructure Service Product Dept.)
2021-12-21 15:27         ` Sean Christopherson
2021-12-21 15:34           ` Paolo Bonzini
2021-12-22  6:07           ` Chao Gao [this message]
2021-12-22 15:44             ` Sean Christopherson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211222060735.GA22521@gao-cwp \
    --to=chao.gao@intel.com \
    --cc=arei.gonglei@huawei.com \
    --cc=huangzhichao@huawei.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longpeng2@huawei.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox