Re: [PATCH v5 1/4] kvm: Extend irqfd to support level interrupts

From: Alex Williamson
Date: Wed Jul 18 2012 - 15:07:23 EST


On Wed, 2012-07-18 at 15:42 -0300, Marcelo Tosatti wrote:
> On Wed, Jul 18, 2012 at 06:58:24PM +0300, Michael S. Tsirkin wrote:
> > > > > > > Back to original point though current
> > > > > > > situation is that calling kvm_set_irq() under spinlock is not worse for
> > > > > > > scalability than calling it not under one.
> > > > > >
> > > > > > Yes. Still the specific use can just use an atomic flag,
> > > > > > lock+bool is not needed, and we won't need to undo it later.
> > > > >
> > > > >
> > > > > Actually, no, replacing it with an atomic is racy.
> > > > >
> > > > > CPU0 (inject) CPU1 (EOI)
> > > > > atomic_cmpxchg(&asserted, 0, 1)
> > > > > atomic_cmpxchg(&asserted, 1, 0)
> > > > > kvm_set_irq(0)
> > > > > kvm_set_irq(1)
> > > > > eventfd_signal
> > > > >
> > > > > The interrupt is now stuck on until another interrupt is injected.
> > > > >
> > > >
> > > > Well EOI somehow happened here before interrupt so it's a bug somewhere
> > > > else?
> > >
> > > Interrupts can be shared. We also can't guarantee that the guest won't
> > > write a bogus EOI to the ioapic. The irq ack notifier doesn't filter on
> > > irq source id... I'm not sure it can.
> >
> > I guess if Avi OKs adding another kvm_set_irq under spinlock that's
> > the best we can do for now.
>
> Why can't a mutex be used instead of a spinlock again?

eventfd_signal calls the inject function from atomic context.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/