IRQ Affinity & irqbalance Tuning Review Prompt
Review interrupt distribution across CPUs — diagnose a single hot core drowning in softirqs, decide between irqbalance and manual smp_affinity pinning, and tune RPS/RFS/XPS for network and storage IRQs.
- Target user
- Senior Linux admins and SREs tuning interrupt handling on high-throughput hosts
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior Linux performance engineer who has tuned interrupt handling on network appliances, NVMe storage servers, and NUMA database hosts. You understand hardware IRQs, softirqs, MSI-X vectors, irqbalance's hint-based placement, manual smp_affinity, and the RPS/RFS/XPS software-steering layer. You know that most "one core is at 100% while the others idle" problems are interrupt-distribution problems, not application problems. I will provide: - Symptom: one CPU pegged in `%irq`/`%soft` while others idle, packet drops at high pps, uneven NVMe latency, or `ksoftirqd/N` burning a core - `mpstat -P ALL 1` output (per-CPU us/sy/irq/soft breakdown) - `cat /proc/interrupts` (or a summarized view of the busy device's IRQ lines and per-CPU counts) - The device in question: NIC (driver, queue count) or NVMe/HBA - Whether `irqbalance` is running (`systemctl status irqbalance`) and any `IRQBALANCE_BANNED_CPUS` / policy config - NUMA topology (`lscpu`, `numactl -H`) and where the device lives (`cat /sys/class/net/<if>/device/numa_node`) - Workload character: bulk throughput, low-latency RPC, or mixed Your job: 1. **Confirm it is actually an IRQ-distribution problem**: in `mpstat -P ALL`, a single CPU high in `%irq`/`%soft` with the rest idle, correlated with one hot line in `/proc/interrupts`, is the signature. Rule out a single-threaded app (that shows as `%usr`, not `%soft`) and `ksoftirqd` runaway (softirq backlog, often RPS-fixable). 2. **Map the device's interrupt model**: - Multi-queue NIC → one MSI-X vector per rx/tx queue; the goal is one queue per core, each IRQ pinned to a distinct CPU. - Single-queue NIC or a virtio device with one vector → hardware can't spread; you MUST use software steering (RPS/RFS) to fan out across cores. - NVMe → one completion queue per core is ideal; check `nvme` IRQ lines are already spread. 3. **Decide irqbalance vs manual pinning** and justify it: - `irqbalance` (with driver affinity hints) is correct for general-purpose and mixed hosts — recommend keeping it unless there is a measured reason not to. - Manual `smp_affinity` pinning (with irqbalance stopped or the IRQs banned) is for latency-sensitive, statically-provisioned hosts where you want deterministic placement and cache locality. Warn that manual pins are lost on driver reload/reboot unless persisted. 4. **Respect NUMA**: pin a device's IRQs (and RPS CPUs) to cores on the SAME NUMA node as the device. Cross-node interrupt handling adds latency and QPI/UPI traffic. Use the device's `numa_node` and `local_cpulist`. 5. **Apply the right software-steering layer when hardware queues are insufficient**: - **RPS** (`/sys/class/net/<if>/queues/rx-N/rps_cpus`) spreads receive processing across CPUs in software — essential for single-queue devices. - **RFS** (`rps_flow_cnt` + `net.core.rps_sock_flow_entries`) steers a flow to the CPU where its app runs, improving cache hit rate for RPC workloads. - **XPS** (`xps_cpus`) does the same for transmit. 6. **Give exact commands** including the smp_affinity_list bitmask/list syntax, how to iterate a NIC's queue IRQs, and how to persist (udev rule, driver options, systemd unit, or `/etc/sysconfig`/tuned profile), since raw `/proc` writes do not survive reboot. 7. **Warn about anti-patterns**: pinning all IRQs to CPU0 (the default worst case), pinning IRQs onto the same cores your latency-critical app threads run on, or fighting irqbalance by writing smp_affinity while it is still running (it will overwrite you). Mark anything that could disrupt a live host: stopping irqbalance fleet-wide, re-pinning IRQs on a production NIC during peak (brief packet reordering possible), or changing queue counts (`ethtool -L`) which resets affinity. Give me: (1) the diagnosis with the specific hot IRQ/CPU identified, (2) irqbalance-vs-manual recommendation with reasoning, (3) exact commands to apply and persist, and (4) how to verify the spread improved. --- Symptom: [describe — hot core, drops, latency] `mpstat -P ALL 1`: ``` [PASTE] ``` `/proc/interrupts` (busy device lines): ``` [PASTE] ``` Device + driver + queue count: [...] irqbalance status: [running? banned CPUs?] NUMA topology + device numa_node: [...] Workload: [throughput | low-latency | mixed]
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Why this prompt works
The classic “one CPU is at 100%, the other 31 are idle, and throughput is capped” report is almost always an interrupt-steering problem, but it gets misdiagnosed as an application or scaling problem for weeks. This prompt anchors on the actual evidence — per-CPU %soft/%irq from mpstat correlated with a single hot line in /proc/interrupts — and then walks the real decision tree: hardware multi-queue vs software RPS/RFS, irqbalance vs static pinning, and NUMA locality. It also insists on persistence, because the number-one reason tuning “doesn’t work” is that /proc writes vanish on the next reboot or driver reload.
How to use it
- Capture
mpstat -P ALL 1under load — the per-CPU softirq column is the smoking gun. - Grab the device’s IRQ lines from
/proc/interruptsso the model can see whether interrupts are landing on one CPU or already spread. - State the NUMA node of the device so affinity recommendations stay local.
- Say whether the workload is throughput or latency — it changes whether RFS/flow-steering is worth enabling.
Useful commands
# Per-CPU breakdown: look for one CPU high in %soft/%irq while others idle
mpstat -P ALL 1 5
# See where each device's interrupts are landing (per-CPU counts)
cat /proc/interrupts | grep -E 'eth0|ens|nvme'
# NUMA + device locality
lscpu | grep -i numa
numactl -H
cat /sys/class/net/eth0/device/numa_node
cat /sys/class/net/eth0/device/local_cpulist
# irqbalance state
systemctl status irqbalance
grep -H '' /etc/sysconfig/irqbalance 2>/dev/null || grep -H '' /etc/default/irqbalance
# Read/set affinity for a specific IRQ (list form is easiest)
cat /proc/irq/142/smp_affinity_list
echo 3 | sudo tee /proc/irq/142/smp_affinity_list # pin IRQ 142 to CPU 3
# Software receive steering for a single-queue device (RPS)
echo 'ffff' | sudo tee /sys/class/net/eth0/queues/rx-0/rps_cpus
sysctl -w net.core.rps_sock_flow_entries=32768 # RFS global table
echo 2048 | sudo tee /sys/class/net/eth0/queues/rx-0/rps_flow_cnt
Pinning one IRQ per queue to consecutive local cores
# Stop irqbalance from fighting the manual pins first
sudo systemctl stop irqbalance
# Spread each of eth0's queue IRQs onto its own CPU
cpu=0
for irq in $(grep 'eth0-' /proc/interrupts | awk -F: '{print $1}'); do
echo "$cpu" | sudo tee /proc/irq/"$irq"/smp_affinity_list
cpu=$((cpu + 1))
done
Persist it with a systemd unit or udev rule that reruns this after the interface appears, because driver reload and reboot both reset affinity.
Common findings this catches
- Single-queue / virtio NIC capping at one core’s softirq budget — fixed with RPS, not hardware pinning.
- All IRQs defaulting to CPU0 on a host where irqbalance was disabled by a hardening script.
- Cross-NUMA interrupt placement adding latency because IRQs landed on the wrong socket relative to the NIC.
- Tuning that “reverts on reboot” because
/procwrites were never persisted via udev/tuned/systemd. - IRQs colliding with app cores on a latency host that should be using
isolcpus/nohz_fullisolation.
When to escalate
- Hardware that genuinely exposes only one interrupt vector and cannot benefit further from RPS — the fix is a different NIC or SR-IOV, not more tuning.
ksoftirqdsaturation that persists after correct spreading — look at packet rate vs capacity, XDP/eBPF offload, or driver bugs.- Latency requirements tight enough to need full CPU isolation (
isolcpus,nohz_full, RCU offload) — that is a boot-parameter and scheduling redesign, coordinate with the app team.
Related prompts
-
sysctl Kernel Parameter Tuning Audit Prompt
Review and tune /etc/sysctl.d kernel parameters for a server's role — network stack, VM/dirty-page behavior, file handles, and security toggles — with a safe, persistent, reversible rollout.
-
Linux kexec Fast Reboot Setup Prompt
Design and validate a kexec-based fast-reboot workflow that skips firmware/POST to cut kernel-upgrade downtime, with safe fallback to a full reboot when hardware re-init is required.
-
cpupower Frequency Governor Tuning Prompt
Tune CPU frequency scaling governors, energy-performance bias, and turbo behavior with cpupower to trade latency against power for a given workload profile.
-
Magic SysRq Key Emergency Configuration Prompt
Configure the magic SysRq key safely so administrators can trigger a controlled emergency sync and reboot or capture diagnostics on a hung server without an unclean power cycle.
More Linux Admins prompts & error guides
Browse every Linux Admins prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.