Search code examples
kerneldriversembeddedinterrupt

How fast can kernel module handle interrupts?


I'm writing a kernel module on embedded Linux (Yocto distribution), and I wanted to handle some high-frequency interrupts from one of the hardware timers. However, I see that 1us resolution is too high for Linux(?) - I think so because the values are incorrect. The code is simple:

static irqreturn_t pmodule_ref2_irq(int irq, void *lp)
{
        unsigned long int temp;
        ns++;
        temp = ioread32(temp_base_addr + TTC1_INTERRUPT_REGISTER);
        return IRQ_HANDLED;
}

Changing Interval value to 100x higher fixes the problem but my resolution is not satisfactory.

My question is: can anyone tell me how fast the kernel module Interrupt can be handled, or how can I check it?


Solution

  • The latency depends on your final hardware. You can have an idea of what to expect (when using preempt-rt) here: https://www.osadl.org/Combined-latency-plot-of-all-systems-und.qa-latencyplot-all.0.html?latencies=&showno=&slider=159

    Basically, you should expect a maximum latency between 30 to 200 us. That value is including the kernelspace to userspace switch but that can give you an idea.