Linux Interrupt Handling in User Space

Brandon E Taylor picture Brandon E Taylor · Nov 2, 2011 · Viewed 23.8k times · Source

In Linux, what are the options for handling device interrupts in user space code rather than in kernel space?

Answer

Dan Aloni picture Dan Aloni · Nov 2, 2011

Experience tells it is possible to write good and stable user-space drivers for almost any PCI adapter. It just requires some sophistication and a small proxying layer in the kernel. UIO is a step in that direction, but If you want to correctly handle interrupts in user-space then UIO might not be enough, for example if the device doesn't support the PCI-spec's interrupt disable bit which UIO relies on.

Notice that process wakeup latencies are a few microsecs so if your implementation requires very low latency then user-space might be a drag on it.

If I were to implement a user-space driver, I would reduce the kernel ISR to just a "disable & ack & wakeup-userpace" operation, handle the interrupt inside the waked-up process, and then re-enable the interrupt (of course, by writing to mapped PCI memory from the userspace process).