From: Marcelo Tosatti <mtosatti@redhat.com>
To: Gleb Natapov <gleb@redhat.com>
Cc: "Zhang, Yang Z" <yang.z.zhang@intel.com>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"avi.kivity@gmail.com" <avi.kivity@gmail.com>,
"Zhang, Xiantao" <xiantao.zhang@intel.com>
Subject: Re: [PATCH v4 2/2] KVM: VMX: Add Posted Interrupt supporting
Date: Sun, 24 Feb 2013 15:08:57 -0300 [thread overview]
Message-ID: <20130224180857.GA10477@amt.cnet> (raw)
In-Reply-To: <20130224141917.GC4284@redhat.com>
On Sun, Feb 24, 2013 at 04:19:17PM +0200, Gleb Natapov wrote:
> On Sun, Feb 24, 2013 at 01:55:07PM +0000, Zhang, Yang Z wrote:
> > > I do not think it fixes it. There is no guaranty that IPI will be
> > > processed by remote cpu while sending cpu is still in locked section, so
> > > the same race may happen regardless. As you say above there are 3
> > > contexts, but only two use locks.
> > See following logic, I think the problem you mentioned will not happened with current logic.
> >
> > get lock
> > if test_pir (this will ensure there is no in flight IPI for same interrupt. Since we are taking the lock now, no IPI will be sent before we release the lock and no pir->irr is performed by hardware for same interrupt.)
Does the PIR IPI interrupt returns synchronously _after_ PIR->IRR transfer
is made? Don't think so.
PIR IPI interrupt returns after remote CPU has acked interrupt receival,
not after remote CPU has acked _and_ performed PIR->IRR transfer.
Right? (yes, right, see step 4. below).
Should try to make it easier to drop the lock later, so depend on it as
little as possible (also please document what it protects in detail).
Also note:
"
3. The processor clears the outstanding-notification bit in the
posted-interrupt descriptor. This is done atomically
so as to leave the remainder of the descriptor unmodified (e.g., with a
locked AND operation).
4. The processor writes zero to the EOI register in the local APIC; this
dismisses the interrupt with the postedinterrupt
notification vector from the local APIC.
5. The logical processor performs a logical-OR of PIR into VIRR and
clears PIR. No other agent can read or write a
PIR bit (or group of bits) between the time it is read (to determine
what to OR into VIRR) and when it is cleared.
"
So checking the ON bit does not mean the HW has finished performing
PIR->VIRR transfer (which means ON bit can only be used as an indication
of whether to send interrupt, not whether PIR->VIRR transfer is
finished).
So its fine to do
-> atomic set pir
-> if (atomic_test_and_set(PIR ON bit))
-> send IPI
But HW can transfer two distinct bits, set by different serialized instances
of kvm_set_irq (protected with a lock), in a single PIR->IRR pass.
> I do not see where those assumptions are coming from. Testing pir does
> not guaranty that the IPI is not processed by VCPU right now.
>
> iothread: vcpu:
> send_irq()
> lock(pir)
> check pir and irr
> set pir
> send IPI (*)
> unlock(pir)
>
> send_irq()
> lock(pir)
> receive IPI (*)
> atomic {
> pir_tmp = pir
> pir = 0
> }
> check pir and irr
> irr &= pir_tmp
> set pir
> send IPI
> unlock(pir)
>
> At this point both pir and irr are set and interrupt may be coalesced,
> but it is reported as delivered.
s/"set pir"/"injected = !t_a_s(pir)"/
> So what prevents the scenario above from happening?
>
> --
> Gleb.
next prev parent reply other threads:[~2013-02-24 18:12 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-22 13:42 [PATCH v4 0/2] KVM: VMX: Add Posted Interrupt supporting Yang Zhang
2013-02-22 13:42 ` [PATCH v4 1/2] KVM: VMX: enable acknowledge interupt on vmexit Yang Zhang
2013-02-22 13:42 ` [PATCH v4 2/2] KVM: VMX: Add Posted Interrupt supporting Yang Zhang
2013-02-23 13:43 ` Marcelo Tosatti
2013-02-23 14:05 ` Zhang, Yang Z
2013-02-23 14:35 ` Gleb Natapov
2013-02-23 14:48 ` Marcelo Tosatti
2013-02-23 15:31 ` Gleb Natapov
2013-02-23 17:05 ` Marcelo Tosatti
2013-02-23 19:42 ` Gleb Natapov
2013-02-23 19:52 ` Marcelo Tosatti
2013-02-23 19:59 ` Gleb Natapov
2013-02-24 13:55 ` Zhang, Yang Z
2013-02-24 14:19 ` Gleb Natapov
2013-02-24 14:26 ` Zhang, Yang Z
2013-02-24 14:39 ` Gleb Natapov
2013-02-24 18:08 ` Marcelo Tosatti [this message]
2013-02-24 18:59 ` Avi Kivity
2013-02-25 8:42 ` Zhang, Yang Z
2013-02-25 11:01 ` Gleb Natapov
2013-02-25 11:04 ` Zhang, Yang Z
2013-02-25 11:07 ` Gleb Natapov
2013-02-25 11:13 ` Zhang, Yang Z
2013-02-25 12:49 ` Marcelo Tosatti
2013-02-25 12:52 ` Zhang, Yang Z
2013-02-25 13:34 ` Gleb Natapov
2013-02-25 14:00 ` Marcelo Tosatti
2013-02-25 14:17 ` Marcelo Tosatti
2013-02-25 17:40 ` Gleb Natapov
2013-02-25 22:29 ` Marcelo Tosatti
2013-02-25 16:50 ` Avi Kivity
2013-02-25 17:43 ` Gleb Natapov
2013-02-25 18:56 ` Avi Kivity
2013-02-25 19:01 ` Gleb Natapov
2013-02-26 8:12 ` Gleb Natapov
2013-02-26 16:13 ` Avi Kivity
2013-02-24 17:44 ` Marcelo Tosatti
2013-02-25 7:24 ` Zhang, Yang Z
2013-02-23 14:44 ` Marcelo Tosatti
2013-02-23 15:16 ` Zhang, Yang Z
2013-02-23 16:50 ` Marcelo Tosatti
2013-02-24 13:17 ` Zhang, Yang Z
2013-02-24 17:39 ` Marcelo Tosatti
2013-02-25 6:55 ` Zhang, Yang Z
2013-02-25 13:01 ` Marcelo Tosatti
2013-02-25 14:32 ` Zhang, Yang Z
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=20130224180857.GA10477@amt.cnet \
--to=mtosatti@redhat.com \
--cc=avi.kivity@gmail.com \
--cc=gleb@redhat.com \
--cc=kvm@vger.kernel.org \
--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