The full picture
🎬 Interrupts + DMA: how I/O really happens
1 / 5The CPU needs 4KB from disk. Naive option — POLLING: the CPU sits in a loop asking 'done yet?', and then copies every byte itself. At disk speeds, that's millions of wasted cycles.
- Top/bottom half discipline: hard IRW context can't sleep or take long — so ack + queue, then softirq/workqueue does the heavy lifting with interrupts enabled. This split is why 'interrupt latency' and 'throughput work' don't fight.
- Interrupt storms & mitigation: NICs at line rate switch to NAPI — take one interrupt, then poll until the queue drains, re-enable interrupts when idle: an adaptive hybrid that is the textbook answer to 'interrupts or polling?' — 'both, switching by load'.
- Affinity matters operationally:
/proc/interrupts, irqbalance, pinning NIC queues to cores (RSS) — tail latency on network-heavy boxes is often IRQ-affinity tuning, a very real SRE task. - Exceptions vs interrupts: same vectoring machinery, different trigger — exceptions are synchronous (page fault, divide-by-zero, syscall), interrupts asynchronous (timer, devices). The timer interrupt deserves its sentence: it is what makes preemptive multitasking exist.