Re: [PATCH v3 2/4] genirq: Inform handler about line sharing state

Michael S. Tsirkin
2010-12-18T18:11:37Z

On Fri, Dec 17, 2010 at 05:32:46PM +0100, Thomas Gleixner wrote:
> On Fri, 17 Dec 2010, Jan Kiszka wrote:
> > Am 17.12.2010 16:25, Thomas Gleixner wrote:
> > > Your aproach with disable_irq_nosync() is completely flawed, simply
> > > because you try to pretend that your interrupt handler is done, while
> > > it is not done at all. The threaded interrupt handler is done when
> > > user space completes. Everything else is just hacking around the
> > > problem and creates all that nasty transitional problems.
> >
> > disable_irq_nosync is the pattern currently used in KVM, it's nothing
> > new in fact.
>
> That does not make it less flawed :)
>
> > The approach looks interesting but requires separate code for
> > non-PCI-2.3 devices, i.e. when we have no means to mask at device level.
>
> Why? You can have the same code, you just can't request COND_ONESHOT
> handlers for it, so it needs unshared ONESHOT or it won't work at all,
> no matter what approach you chose. No device level mask, no sharing,
> it's that simple.
>
> > Further drawbacks - unless I missed something on first glance:
> >
> > - prevents any future optimizations that would work without IRQ thread
> > ping-pong (ie. once we allow guest IRQ injection from hardirq context
> > for selected but typical setups)
> > - two additional, though light-weight, context switches on each
> > interrupt completion
>
> The drawback of these two points is way less than the horror which you
> need to introduce to do the whole async handler disable, userspace
> enable dance. Robust and simple solutions really a preferred over
> complex and fragile horror which has a questionable runtime benefit.

I'd like to note that the overhead of involving the scheduler in
interrupt injection for an assigned device should be easily measurable:
just make the MSI handlers threaded and see what the result is.

In the case of emulated devices, when we had an extra thread
involved in MSI handling, the vcpu thread and the
interrupt injection thread were competing for cpu with strange
fluctuations in performance as the result
(i.e. sometimes we would get good speed as threading would introduce
a kind of interrupt coalescing, sometimes we would get huge latency).

> > - continuous polling if user space decides to leave the interrupt
> > unhandled (e.g. because the virtual IRQ line is masked)
>
> That should be a solvable problem.
>
> Thanks,
>
> tglx