From: Gleb Natapov <gleb@redhat.com>
To: "Zhang, Yang Z" <yang.z.zhang@intel.com>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"mtosatti@redhat.com" <mtosatti@redhat.com>,
"Zhang, Xiantao" <xiantao.zhang@intel.com>
Subject: Re: [PATCH v6 5/5] KVM : VMX: Use posted interrupt to deliver virtual interrupt
Date: Tue, 19 Mar 2013 16:51:04 +0200 [thread overview]
Message-ID: <20130319145104.GA19292@redhat.com> (raw)
In-Reply-To: <A9667DDFB95DB7438FA9D7D576C3D87E099E7295@SHSMSX101.ccr.corp.intel.com>
On Tue, Mar 19, 2013 at 01:59:21PM +0000, Zhang, Yang Z wrote:
> Gleb Natapov wrote on 2013-03-19:
> > On Tue, Mar 19, 2013 at 12:42:01PM +0000, Zhang, Yang Z wrote:
> >>>>>> local_irq_disable();
> >>>>>> + kvm_x86_ops->posted_intr_clear_on(vcpu);
> >>>>>> +
> >>>>> Why is this separate from pir_to_irr syncing?
> >>>> This is the result of discussion with Marcelo. It is more reasonable to
> >>>> put it here to avoid unnecessary posted interrupt between:
> >>>>
> >>>> vcpu->mode = IN_GUEST_MODE;
> >>>>
> >>>> <--interrupt may arrived here and this is unnecessary.
> >>>>
> >>>> local_irq_disable();
> >>>>
> >>>
> >>> But this still can happen as far as I see:
> >>>
> >>> vcpu0 vcpu1:
> >>> pi_test_and_set_pir() kvm_make_request(KVM_REQ_EVENT)
> >>> if (KVM_REQ_EVENT)
> >>> sync_pir_to_irr()
> >>> vcpu->mode =
> >>> IN_GUEST_MODE;
> >>> if (vcpu->mode == IN_GUEST_MODE)
> >>> if (!pi_test_and_set_on())
> >>> apic->send_IPI_mask()
> >>> --> IPI arrives here
> >>> local_irq_disable();
> >>> posted_intr_clear_on()
> >> Current solution is trying to block other Posted Interrupt from other VCPUs at
> > same time. It only mitigates it but cannot solve it. The case you mentioned still
> > exists but it should be rare.
> >>
> > I am not sure I follow. What scenario exactly are you talking about. I
> > looked over past discussion about it and saw that Marcelo gives an
> > example how IPI can be lost, but I think that's because we set "on" bit
> > after KVM_REQ_EVENT:
> The IPI will not lost in his example(he misread the patch).
>
> > cpu0 cpu1 vcpu0
> > test_and_set_bit(PIR-A) set KVM_REQ_EVENT
> > process
> > REQ_EVENT
> > PIR-A->IRR
> >
> > vcpu->mode=IN_GUEST
> >
> > if (vcpu0->guest_mode)
> > if (!t_a_s_bit(PIR notif))
> > send IPI
> > linux_pir_handler
> >
> > t_a_s_b(PIR-B)=1
> > no PIR IPI sent
> >
> > But what if on delivery we do:
> > pi_test_and_set_pir()
> > r = pi_test_and_set_on()
> > kvm_make_request(KVM_REQ_EVENT)
> > if (!r)
> > send_IPI_mask() else kvm_vcpu_kick()
> > And on vcpu entry we do:
> > if (kvm_check_request(KVM_REQ_EVENT)
> > if (test_and_clear_bit(on))
> > kvm_apic_update_irr()
> > What are the downsides? Can we lost interrupts this way?
> Need to check guest mode before sending IPI. Otherwise hypervisor may receive IPI.
Of course, forget it. So if (!r) should be if (!r && mode == IN_GUEST)
> I think current logic is ok. Only problem is that when to clear Outstanding Notification bit. Actually I prefer your suggestion to clear it before sync_pir_irr. But Marcelo prefer to clear ON bit after disabling irq.
Marcelo what is the problem with the logic above?
--
Gleb.
next prev parent reply other threads:[~2013-03-19 14:51 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-15 13:31 [PATCH v6 0/5] KVM: VMX: Add Posted Interrupt supporting Yang Zhang
2013-03-15 13:31 ` [PATCH v6 1/5] KVM: VMX: Enable acknowledge interupt on vmexit Yang Zhang
2013-03-15 13:31 ` [PATCH v6 2/5] KVM: VMX: Register a new IPI for posted interrupt Yang Zhang
2013-03-15 13:31 ` [PATCH v6 3/5] KVM: VMX: Check the posted interrupt capability Yang Zhang
2013-03-15 13:31 ` [PATCH v6 4/5] KVM: VMX: Add the algorithm of deliver posted interrupt Yang Zhang
2013-03-15 13:31 ` [PATCH v6 5/5] KVM : VMX: Use posted interrupt to deliver virtual interrupt Yang Zhang
2013-03-19 8:54 ` Gleb Natapov
2013-03-19 12:11 ` Zhang, Yang Z
2013-03-19 12:23 ` Gleb Natapov
2013-03-19 12:42 ` Zhang, Yang Z
2013-03-19 13:29 ` Gleb Natapov
2013-03-19 13:59 ` Zhang, Yang Z
2013-03-19 14:51 ` Gleb Natapov [this message]
2013-03-19 15:12 ` Gleb Natapov
2013-03-19 15:19 ` Marcelo Tosatti
2013-03-19 15:27 ` Marcelo Tosatti
2013-03-19 16:10 ` Gleb Natapov
2013-03-20 11:47 ` Zhang, Yang Z
2013-03-20 11:49 ` Gleb Natapov
2013-03-20 11:52 ` Zhang, Yang Z
2013-03-19 15:30 ` Gleb Natapov
2013-03-19 15:13 ` Marcelo Tosatti
2013-03-19 15:21 ` Gleb Natapov
2013-03-19 15:03 ` Marcelo Tosatti
2013-03-19 15:18 ` Gleb Natapov
2013-03-18 2:49 ` [PATCH v6 0/5] KVM: VMX: Add Posted Interrupt supporting Zhang, Yang Z
2013-03-18 9:16 ` Gleb Natapov
2013-03-18 10:43 ` Zhang, Yang Z
2013-03-18 11:28 ` Gleb Natapov
2013-03-18 11:44 ` Zhang, Yang Z
2013-03-18 22:20 ` Marcelo Tosatti
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=20130319145104.GA19292@redhat.com \
--to=gleb@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=xiantao.zhang@intel.com \
--cc=yang.z.zhang@intel.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