Linux Labs

Inside the system: resources, kernel, processes / Stage 5 of 12

Who loads the disk

Not running Starting usually ~20 s
Leave the lesson

Step 2 of 6 · theory · 6 min

Waiting for the disk

wa is CPU idle time that has a reason.

When the CPU has nothing to do, it sits idle, and the kernel books that time in id. If at that moment some process is waiting for an answer from the disk, the same idle time goes into wa — iowait. The process waiting for the disk is in the D state: the b column of vmstat and the load average count it.

The bi and bo columns are how many KiB per second the machine reads from the disk and writes to it. In the experience, bo is a few thousand — just a few MB/s — and yet the disk is busy all the time. The export writes in 4 KiB blocks and after each one waits until the block reaches the disk, the way database journals are written. Each write is short, but there are hundreds of waits per second, and the disk almost always has work.

A large wa does not mean the CPU is busy. It is idle time, and any task that needs the CPU gets it at once.

Check yourself 1 question

While the export waits for the disk, you start stress-ng --cpu 1 --timeout 15s — a computation that takes the whole CPU. What will vmstat show in the cpu group?

  • Waiting does not occupy the CPU: wa is idle time. The computation takes it, and vmstat shows us around 97 and wa 0.

  • There is nothing to split: any task that needs the CPU takes the idle time. The computation gets almost all of it — us around 97, wa 0.

wa is idle time, and the computation takes all of it: vmstat shows us around 97 and wa 0. bo still shows thousands — the export keeps writing as before. Check it yourself: stress-ng --cpu 1 --timeout 15s &, then vmstat 1 5.

Key points

  • wa is the time the CPU sits idle while a process waits for the disk; a large wa does not get in the way of tasks that need the CPU.
  • A process waiting for the disk is in the D state; the b column and the load average count it.
  • bi and bo are reads and writes in KiB per second; small writes that each wait for the disk keep it busy with little data.
Ubuntu 24.04
Loading…