public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: Avi Kivity <avi@redhat.com>,
	kvm@vger.kernel.org, qemu-devel@nongnu.org, pugs@cisco.com,
	chrisw@redhat.com
Subject: Re: [RFC PATCH 4/5] APIC/IOAPIC EOI callback
Date: Sun, 11 Jul 2010 22:23:30 +0300	[thread overview]
Message-ID: <20100711192330.GA11491@redhat.com> (raw)
In-Reply-To: <1278876078.20397.79.camel@x201>

On Sun, Jul 11, 2010 at 01:21:18PM -0600, Alex Williamson wrote:
> On Sun, 2010-07-11 at 21:54 +0300, Michael S. Tsirkin wrote:
> > On Sun, Jul 11, 2010 at 09:30:59PM +0300, Avi Kivity wrote:
> > > On 07/11/2010 09:26 PM, Alex Williamson wrote:
> > > >On Sun, 2010-07-11 at 21:14 +0300, Avi Kivity wrote:
> > > >>On 07/11/2010 09:09 PM, Alex Williamson wrote:
> > > >>>For device assignment, we need to know when the VM writes an end
> > > >>>of interrupt to the APIC, which allows us to de-assert the interrupt
> > > >>>line and clear the DisINTx bit.  Add a new wrapper for ioapic
> > > >>>generated interrupts with a callback on eoi and create an interface
> > > >>>for drivers to be notified on eoi.
> > > >>>
> > > >>You aren't going to get this with kvm's in-kernel irqchip, so we need a
> > > >>new interface there.
> > > >Registering an eventfd for the eoi seems like a reasonable alternative.
> > > 
> > > I'm worried about that racing (with what?)
> > 
> > With device asserting the interrupt?
> > Need to make sure that all possible scenarious work well:
> > 
> > 	device asserts interrupt
> > 	driver clears interrupt
> > 	device asserts interrupt
> > 	eoi
> > 
> > 	device asserts interrupt
> > 	driver clears interrupt
> > 	eoi
> > 	device asserts interrupt
> > 
> > etc
> > 
> > Not that I see issues, these are things we need to check.
> 
> I think those are all protected by host and qemu vfio drivers managing
> DisINTx.  The way I understand it to work now is:
> 
> 	device asserts interrupt
> 	interrupt lands in host vfio driver
> 	host vfio sets DisINTx on the device
> 	host vfio sends eventfd
> 	eventfd lands in qemu vfio, does a qemu_set_irq
>         ... guest processes
> 	guest writes eoi to apic, lands back in qemu vfio driver
> 	qemu vfio deasserts qemu interrupt
> 	qemu vfio clears DisINTx
> 
> So I don't think there's a race as long as ordering is sane for toggling
> DisINTx.  Thanks,
> 
> Alex
> 

What about threaded interrupts? I think (correct me if I am wrong)
that they work like this:

 	device asserts interrupt
	guest disables interrupt
 	eoi
	guest enables interrupt
 	driver clears interrupt
 	device asserts interrupt

If so, your code will clear DisINTx immediately which
will always get us another host interrupt:
performance will be hurt. I am also not sure
we'll not lose interrupts.

It seems we need to track interrupt disable/enable as well, and only
clear DisINTx after eoi with interrupts enabled.  Not sure what is the
interface for this.


-- 
MST

  reply	other threads:[~2010-07-11 19:28 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-11 18:09 [RFC PATCH 0/5] QEMU VFIO device assignment Alex Williamson
2010-07-11 18:09 ` [RFC PATCH 1/5] qemu_ram_map/unmap: Allow pre-allocated space to be mapped Alex Williamson
2010-07-11 18:09 ` [RFC PATCH 2/5] Minimal RAM API support Alex Williamson
2010-07-11 18:18   ` Alex Williamson
2010-07-11 18:20   ` Avi Kivity
2010-07-11 18:24     ` Alex Williamson
2010-07-11 18:29       ` Avi Kivity
2010-07-11 18:09 ` [RFC PATCH 3/5] RAM API: Make use of it for x86 PC Alex Williamson
2010-07-11 18:09 ` [RFC PATCH 4/5] APIC/IOAPIC EOI callback Alex Williamson
2010-07-11 18:14   ` Avi Kivity
2010-07-11 18:26     ` Alex Williamson
2010-07-11 18:30       ` Avi Kivity
2010-07-11 18:54         ` Michael S. Tsirkin
2010-07-11 19:21           ` Alex Williamson
2010-07-11 19:23             ` Michael S. Tsirkin [this message]
2010-07-11 20:03               ` Alex Williamson
2010-07-11 20:05                 ` Michael S. Tsirkin
2010-07-11 20:12                 ` Michael S. Tsirkin
2010-07-11 21:59                   ` Alex Williamson
2010-07-12  6:33         ` Avi Kivity
2010-07-12  9:05           ` Gleb Natapov
2010-07-12  9:13             ` Avi Kivity
2010-07-11 18:09 ` [RFC PATCH 5/5] VFIO based device assignment Alex Williamson
2010-07-11 18:27   ` Avi Kivity
2010-07-11 19:38     ` Alex Williamson
2010-07-12  6:37       ` Avi Kivity
2010-07-11 18:17 ` [RFC PATCH 0/5] QEMU VFIO " Avi Kivity
2010-07-11 18:37   ` Alex Williamson
2010-07-11 18:43     ` Avi Kivity
2010-07-11 20:24       ` Alex Williamson
2010-07-12  6:29         ` Avi Kivity
2010-07-12 11:03           ` Michael S. Tsirkin

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=20100711192330.GA11491@redhat.com \
    --to=mst@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=avi@redhat.com \
    --cc=chrisw@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=pugs@cisco.com \
    --cc=qemu-devel@nongnu.org \
    /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