$linuxjunkies
>

IRQ affinity

also: CPU affinity for IRQs, smp_affinity

IRQ affinity is the binding of interrupt requests (IRQs) to specific CPU cores, controlling which processors handle particular hardware interrupts.

IRQ affinity allows you to assign hardware interrupts to specific CPU cores instead of letting the kernel distribute them freely. This improves performance by reducing cache misses and keeping interrupt processing on the same CPU that uses the related data.

On modern multi-core systems, interrupts from devices (network cards, disks, etc.) can bounce between different CPUs, causing inefficiency. By setting affinity, you can pin a network card's interrupts to CPU 0-1 and disk interrupts to CPU 2-3, for example.

You manage IRQ affinity through /proc/irq/[IRQ_NUM]/smp_affinity, which uses a bitmask to specify allowed CPUs. For instance, echo 0f > /proc/irq/40/smp_affinity binds IRQ 40 to cores 0-3. Tools like irqbalance can automate this optimization.

Related terms