'fast interrupts' in Linux

5,474

Solution 1

As of today, you can mostly forget about the SA_INTERRUPT flag.
In between 2.6.18 and 2.6.24 it was just a migration helper for the new IRQF_DISABLED flag.
2.6.24 removed all SA_* flags and replaced them with IRQF_* flags.
2.6.35 marked this "new" flag as deprecated.

If you have a kernel before 2.6.18, you'll probably won't use it (see Justin's answer).

Today's usage of IRQF_DISABLE differs among the architectures. x86 still only uses it for time critical functions (time.c, hpet.c) and some xen stuff.

Concerning the difference; a normal interrupt can be interrupted by an other interrupt (preemption), a "fast" one on the other hand, can not.

Solution 2

There is a good write up here:

Older versions of the Linux kernel took great pains to distinguish between "fast" and "slow" interrupts. Fast interrupts were those that could be handled very quickly, whereas handling slow interrupts took significantly longer. Slow interrupts could be sufficiently demanding of the processor, and it was worthwhile to reenable interrupts while they were being handled. Otherwise, tasks requiring quick attention could be delayed for too long.

In modern kernels, most of the differences between fast and slow interrupts have disappeared. There remains only one: fast interrupts (those that were requested with the SA_INTERRUPT flag) are executed with all other interrupts disabled on the current processor. Note that other processors can still handle interrupts, although you will never see two processors handling the same IRQ at the same time.

So, which type of interrupt should your driver use? On modern systems, SA_INTERRUPT is intended only for use in a few, specific situations such as timer interrupts. Unless you have a strong reason to run your interrupt handler with other interrupts disabled, you should not use SA_INTERRUPT.

So the only difference is the one that you mentioned; that fast interrupt handlers execute with all other interrupt handlers disabled, for faster performance.

Share:
5,474

Related videos on Youtube

Gilles 'SO- stop being evil'
Author by

Gilles 'SO- stop being evil'

Updated on September 17, 2022

Comments

  • Gilles 'SO- stop being evil'
    Gilles 'SO- stop being evil' over 1 year

    as far as I know, Linux has 'fast interrupts', those that were requested with SA_INTERRUPT flag; fast interrupts are executed with all other interrupts disabled on the current CPU. But how does it differ from the normal interrupt handler behavior (where)?

  • David
    David over 6 years
    Fast interrupt handlers aren't for better performance- it's just that you shouldn't ever disable interrupts unless the action you're performing is extremely fast. Normally interrupts are disabled to enforce a form of atomicity in functions that are difficult or impossible to write in a reentrant manner. Even if you happen to have an interrupt handler that runs fast you shouldn't disable other interrupts on the system unless you have a really good reason to do so.