Linux Internals
INTx vs MSI vs MSI-X: How Modern Linux Servers Handle Interrupts
By NileVPS Team · Published · 5 min read
اقرأ المقال بالعربيA device that finishes a job needs a way to tell the CPU. That signal is an interrupt, and the way it is delivered has a direct effect on how well a server scales across cores. On older hardware a handful of shared interrupt lines served every device. Modern servers use MSI-X, which lets a single network card or NVMe drive raise many independent interrupts, each aimed at a specific CPU. This article walks through the three generations of PCI interrupts, explains why multi-queue devices depend on MSI-X, and shows how to inspect interrupts on a Linux VPS.
Legacy INTx: shared wires
The original PCI specification gave each device up to four interrupt pins, named INTA# through INTD#. These are level-triggered signals: the device holds the line asserted until the driver services it. Because there were only a few lines, devices often had to share them. When a shared interrupt fired, the kernel called every handler registered on that line, and each driver had to read its device's status register to check whether the interrupt was really its own.
INTx has several drawbacks:
- Sharing overhead: several handlers run for one event, and a misbehaving device can cause an "interrupt storm" for everyone on the line.
- One vector per device: there is no way to direct different kinds of events to different CPUs.
- Ordering issues: the interrupt travels on a separate wire from the data, so the driver may need an extra register read to make sure DMA writes have landed in memory before it processes them.
PCI Express kept INTx for compatibility by sending virtual "assert" and "deassert" messages, but the limitations remain.
MSI: interrupts as memory writes
Message Signaled Interrupts (MSI) replace the wire with a memory write. The device writes a small value to a special address configured by the OS; the platform's interrupt controller recognizes the address and delivers an interrupt to the target CPU. Since the write travels the same path as the device's DMA traffic, it naturally arrives after the data it announces.
MSI is edge-triggered and not shared, which removes the "is this mine?" check. It supports up to 32 vectors per device, but they must be allocated as a contiguous power-of-two block, and on many platforms all of them share a single target address, so steering individual vectors to different CPUs is limited.
MSI-X: many independent vectors
MSI-X extends the idea. A device can expose up to 2048 vectors. Each vector has its own entry in a table stored in device memory, with its own address, data, and mask bit. That means each vector can be routed to a different CPU and masked individually.
This is exactly what multi-queue hardware needs.
Multi-queue NICs
A modern network card has several receive and transmit queues. With Receive Side Scaling (RSS), the NIC hashes each incoming flow (source and destination address and port) and places its packets in one of the receive queues. Each queue has its own MSI-X vector, pinned to a CPU. Packets for a given connection are processed on the same core consistently, caches stay warm, and the load spreads across the machine instead of piling up on CPU 0.
NVMe queues
NVMe follows the same pattern. The driver usually creates one I/O queue pair per CPU (or per group of CPUs) and assigns each queue an MSI-X vector with matching affinity. A core submits a request on its own queue and receives the completion interrupt on that same core, which avoids cross-core traffic and lock contention. See our article on DMA and NVMe for the data path side.
NAPI and interrupt moderation
High packet rates would still generate too many interrupts if every packet raised one. Linux uses NAPI: after the first interrupt, the driver disables further interrupts for that queue and polls it until it is empty, then re-enables interrupts. NICs also support interrupt coalescing, which delays an interrupt until a certain number of packets arrive or a short timer expires. You can view and adjust this with ethtool -c and ethtool -C where the driver supports it.
Inspecting interrupts on your VPS
On a KVM-based VPS, virtio devices use MSI-X too. virtio-net with multiple queues and virtio-blk with multi-queue each get their own vectors, so the same tools apply.
# Show interrupt counts per CPU, per vector
cat /proc/interrupts
# Watch which vectors are increasing
watch -n1 -d "grep -E 'virtio|nvme|eth' /proc/interrupts"
# See which CPUs a given IRQ may run on
cat /proc/irq/<IRQ>/smp_affinity_list
# Check how many queues the NIC has and how many are in use
ethtool -l eth0
# Check the device's MSI-X capability
sudo lspci -vv | grep -A2 MSI-XIn /proc/interrupts each row is one interrupt source and each column is a CPU. Names such as virtio0-input.0, virtio0-output.0, or nvme0q1 tell you which queue the vector belongs to. If all the counts for a busy NIC are stacking up in a single CPU column, that core will become the bottleneck long before the others are busy.
irqbalance
irqbalance is a daemon that periodically redistributes IRQ affinity across CPUs based on load and topology. On most general-purpose servers it is a sensible default:
systemctl status irqbalance
sudo systemctl enable --now irqbalanceFor specialized workloads, such as a packet-processing appliance, a low-latency trading service, or a system using CPU isolation, administrators sometimes disable irqbalance and set affinities manually so that interrupts stay away from isolated cores. Many modern drivers also use "managed" interrupts, where the kernel sets affinity automatically and irqbalance cannot move them; that is expected behavior, not a fault.
Practical tips
- Give your VPS enough vCPUs to match the number of network queues you plan to use; more queues than CPUs adds little.
- After resizing a VPS, recheck
ethtool -land raise the combined queue count withethtool -L eth0 combined Nif the driver allows it. - Treat changes as experiments: measure latency and throughput before and after, rather than assuming a change helped.
If you need more cores to spread network and storage load, compare the vCPU options on our pricing page.
FAQ
Is MSI-X always better than legacy INTx?
For modern hardware, yes in practice. MSI-X avoids interrupt sharing, guarantees ordering with DMA writes, and allows per-queue CPU steering. INTx remains only as a fallback for old devices or broken firmware.
Why are all my interrupts on CPU 0?
Common causes are a single-queue network configuration, irqbalance not running, or a VPS with only one vCPU. Check ethtool -l, confirm irqbalance status, and look at the smp_affinity_list of the busy IRQs.
Should I disable irqbalance for better performance?
Usually not. It is a reasonable default for most servers. Disable it only when you have a clear plan for manual affinity, such as CPU isolation for latency-sensitive work, and measure the result.