[patch 0/4] genirq: add infrastructure for threaded interrupt handlers V2



This patch series implements support for threaded irq handlers for the
generic IRQ layer.

Changes vs. V1:
- review comments addressed
- irq affinity setting for handler threads

Threaded interrupt handlers are not only interesting in the preempt-rt
context. Threaded interrupt handlers can help to address common
problems in the interrupt handling code:

- move long running handlers out of the hard interrupt context

- avoid complex hardirq -> tasklet/softirq interaction and locking
problems by integration of this functionality into the threaded
handler code

- improved debugability of the kernel: faulty handlers do not take
down the system.

- allows prioritizing of the handlers which share an interrupt line

The implementation provides an opt-in mechanism to convert drivers to
the threaded interrupt handler model contrary to the preempt-rt patch
where the threaded handlers are enabled by a brute force switch. The
brute force switch is suboptimal as it does not change the interrupt
handler -> tasklet/softirq interaction problems, but was the only way
which was possible for the limited man power of the preempt-rt
developers.

Converting an interrupt to threaded makes only sense when the handler
code takes advantage of it by integrating tasklet/softirq
functionality and simplifying the locking.

When a driver wants to use threaded interrupt handlers it needs to
provide a quick check handler function, which checks whether the
interrupt was originated from the device or not.

In case it was originated from the device the quick check handler must
disable the interrupt at the device level and return
IRQ_WAKE_THREAD. The generic interrupt handling core then sets the
IRQF_RUNTHREAD in the irqaction of the handler and wakes the
associated thread.

The irqaction is referenced in the threads task_struct so handlers can
check for newly arrived interrupts in action flags. Aside of that the
reference is used to prevent further referencing of the thread in the
interrupt code in the case of segfault to make sure that the system
(minus the now dead interrupt handler) survives and debug information
can be retrieved. In the best case the driver can be restarted, but
dont expect that as a given.

The code was tested with a converted USB EHCI driver. The EHCI shares
an interrupt line with another device and both the threaded and the
non threaded handlers coexist nicely.

Thanks,

tglx

--
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/



Relevant Pages

  • Re: yenta_socket rapid fires interrupts
    ... I can't tell what your handlers are, but there are two of them, and they ... "yenta_socket" handlers for the two slots (sharing the same interrupt). ... before the low-level driver had had a chance ... happened immediately on card insertion, ...
    (Linux-Kernel)
  • Re: Get rid of IRQF_DISABLED - (was [PATCH] genirq: warn about IRQF_SHARED|IRQF_DISABLED)
    ... The TX path is always run outside IRQ context though. ... That can happen now already anyway, regardless of whether IRQ handlers ... pending interrupt sources are actually determined and interrupts enabled ... including the heavier smc91x RX code. ...
    (Linux-Kernel)
  • Re: spurious 8259A interrupt
    ... > Interrupt handlers generally run with the CPU interrupt disable flag ... The obvious thought is it might improve latency of interrupt handlers ... which need reasonably low latency, when other handlers take a long time. ... E.g. if the irq 1 handler takes a long time, ...
    (Linux-Kernel)
  • Re: [PATCH 2/2] Debug handling of early spurious interrupts
    ... handlers tend to dwell in crufty old drivers which not many people use. ... I managed to find some somewhat buggy interrupt handlers. ... incorrect or dubious driver behaviour, and there is value in weeding these ...
    (Linux-Kernel)
  • [RFC patch 0/5] genirq: add infrastructure for threaded interrupt handlers
    ... This patch series implements support for threaded irq handlers for the ... Threaded interrupt handlers are not only interesting in the preempt-rt ...
    (Linux-Kernel)