Re: [PATCH 0/8][v2] MSI-X mask emulation support for assigned device

Alex Williamson
2010-10-20T18:31:08Z

On Wed, 2010-10-20 at 17:59 +0200, Michael S. Tsirkin wrote:
> On Wed, Oct 20, 2010 at 05:54:20PM +0200, Avi Kivity wrote:
> > On 10/20/2010 05:38 PM, Alex Williamson wrote:
> > >> > We'll need to optimize interrupt injection and eoi via KVM,
> > >> > but it should only be a performance optimization, not a functional
> > >> > requirement.
> > >>
> > >> For level-triggered interrupts only, yes? MSI EOI does not involve any
> > >> device or interrupt controller visible action?
> > >
> > >Right, the EOI is for legacy interrupts only. Perhaps we don't care
> > >enough about performance of those to route it through KVM so long as we
> > >can co-exist with the KVM APIC.
> >
> > We will need a way to get the EOI out to userspace, then.
> >
> > Perhaps that will give us motivation to split the ioapic from the
> > kernel (though I suppose fear of regressions will stop us).
> >
> > Anyway EOI notifiers are also useful for timekeeping.
> >
> > > MSIs are currently still bouncing from
> > >VFIO to QEMU to the guest, which seems inefficient.
> >
> > Why is that? Can't you use irqfd like vhost-net?

Hope so, just haven't done it yet.

> > >> > It would probably make sense to request a mask/unmask ioctl in VFIO for
> > >> > MSI-X, then perhaps the pending bits would only support read/write (no
> > >> > mmap), so we could avoid an ioctl there.
> > >>
> > >> I would much like to see in-band information (which mask/unmask is for
> > >> older Linux) done via eventfds so userspace is not involved.
> > >
> > >Hmm, I'm not sure how to do that yet.
> >
> > One ugly way is to use two eventfds, one counting mask events, one
> > counting unmask events. The difference is the value if the masked
> > bit.
> >
> > Another option is to use
> > http://permalink.gmane.org/gmane.linux.kernel.commits.head/188038
> > which allows kvm to maintain a counter using eventfd. The vfio
> > state machine then looks like:
> >
> > interrupt:
> > if counter == 0 mask interrupts, set pending bit, wait for counter
> > to become 1
> > if counter == 1 forward it
> > counter becomes 1: unmask, forward interrupt if pending
>
> One issue is that this page has a ton of other info.
> KVM would have to keep all that in kernel...

Yeah, I'm a little confused about who is setting and who is receiving
the eventfd. KVM is going to trap that page, filter out the mask bit,
do the eventfd thing for the msix vector table, and forward the rest to
qemu? I'd like to see some benchmarks to know if that's really
worthwhile.

Alex