Irqbalance

From Leo's Notes
This page was last edited on 16 November 2021, at 01:39.

irqbalance is a utility that helps balance interrupts across all available CPUs on a system. The tool does the balancing by setting the appropriate CPU affinities for each IRQ source.

Interrupts overloading a single CPU

Without irqbalance, you might see a single ksoftirqd process running with a high CPU utilization. On a busy system, you might see this stuck at 100% CPU. To confirm what's happening, run:

$ watch -d -n 1 "cat /proc/interrupts"

## To ignore inactive interrupts
$ watch -d -n 1 "cat /proc/interrupts | grep -vE '^\s*[0-9]+:[ 0]*  [A-Za-Z]+'"

Using watch and the --diff option, you can see how fast the number of interrupts are increasing for each IRQ source. If you see large numbers within a single column, you should try running irqbalance to help balance out the IRQ sources across multiple CPU cores.

Under the hood

What irqbalance does is it reads /proc/interrupts and determines the IRQ sources. It then tries to balance out the IRQs across all CPU cores by setting the appropriate CPU affinity flags under /proc/irq/<irq>/smp_affinity.

If you need to manually balance out IRQs, you can turn off irqbalance and tweak the smp affinities yourself.