inaabi / Guides / high iowait

high iowait

Confirm the CPUs are waiting on disk, name the device that moved, and see what ionice does not change on mq-deadline.

Tested on Ubuntu 22.04.5 LTS amd64 and Debian 12 amd64, 2026-12-04.

High iowait means the CPU had no task to run because a disk request was still outstanding. It shows up as %iowait in mpstat and as wa in vmstat. High CPU user time is a different number. The commands that split them are on linux performance tuning commands.

The mpstat and vmstat lines below are from an Ubuntu 22.04.5 container. The device delta, the 4096-byte write, and ionice are from Debian 12. Both used kernel 6.8.12-43-pve on 2026-12-04. No sysctl was written. The Ubuntu container script that printed the mpstat, vmstat, and pressure lines exited 0. On Debian 12, ionice read, idle, and best-effort each exited 0, the 4096-byte write-and-remove exited 0, and reading /proc/diskstats for sda exited 0.

Confirm the CPUs are in iowait

mpstat -P ALL 1 1
vmstat 1 3
cat /proc/pressure/io

One second across all CPUs:

Average:     all   14.07    0.28    6.75   22.70    0.00    0.05    0.00    0.69    0.00   55.46

%iowait is the fourth percentage, 22.70. %idle is the last, 55.46. A host can report high iowait and still have idle CPUs. Adding CPUs does not drain the disk.

The one-second vmstat lines (the first vmstat line is since boot, and these are the later lines):

 r  b  us sy id wa st
14 16  28  9 43 20  0
11 15  19  7 53 21  0

wa matches that iowait. b is tasks in uninterruptible sleep.

some avg10=42.45 avg60=44.84 avg300=48.05 total=269066856851
full avg10=34.65 avg60=36.70 avg300=38.96 total=251745330232

IO full at 34.65 over ten minutes means non-idle tasks were all stalled on disk for that share of the window. The file format is in the kernel's pressure stall document. This sample was taken while packages were being installed on the host. It is one reading, not a benchmark.

Name the device

cat /sys/block/sda/queue/scheduler
cat /sys/block/sda/queue/rotational

On Debian 12 those printed:

none [mq-deadline]
1

The name in brackets is the active scheduler. 1 means the kernel treats the device as rotational. Two one-second snapshots of /proc/diskstats (sectors read plus sectors written) gave the largest gain to sda and to partition sda3, both 4248 sectors. A sector here is 512 bytes, so that is 2174976 bytes, about 2.1 MiB, in that second. The partition and the whole disk moved together, so the traffic was on sda3.

How to repeat it without naming a tool that was not installed:

awk '$3=="sda" {print $3, $6+$10}' /proc/diskstats
sleep 1
awk '$3=="sda" {print $3, $6+$10}' /proc/diskstats

Subtract the second number. $6 is sectors read and $10 is sectors written. The kernel's diskstats fields are the source for those columns.

See the writing process

/proc/PID/io has write_bytes, which counts bytes sent to storage after they leave the page cache. On Debian 12 a short Python process wrote 4096 bytes to a file under /tmp, called fsync, and removed the file:

write_bytes_before 0
write_bytes_after 4096
delta 4096
file_gone True

The command shape:

cat /proc/PID/io

Replace PID with the process you suspect. A write_bytes value that climbs while %iowait is high is a writer. The test file was removed. write_bytes on that process stayed at 4096 because the process then exited.

Set an IO scheduling class, and leave the shell alone

ionice -p $$
ionice -c 3 bash -c 'ionice -p $$'
ionice -c 2 -n 4 bash -c 'ionice -p $$'

Printed:

self_before none: prio 0
idle_child idle
parent_after none: prio 0
be_child best-effort: prio 4

The shell started at none: prio 0. A child set to idle class 3 read back idle. The shell still read none: prio 0 after that child exited. A second child set to best-effort class 2, priority 4, read back best-effort: prio 4. ionice(1) documents the classes.

The busy device was on mq-deadline. Idle and best-effort are classes BFQ applies when it is the scheduler. The kernel describes that in BFQ. This test did not switch sda off mq-deadline, and it did not show a lower r_await after the class change. Setting the class proved the value is stored on the process. It did not retune the device. Switching the scheduler is a write to /sys/block/sda/queue/scheduler, documented in switching the scheduler, and that write was not run.

Verify

Run mpstat 1 1 again after the writer you stopped is gone. %iowait and IO full avg10 are the numbers that should fall. ionice -p PID should print the class you set, on that pid only.

Undo

The idle child and the best-effort child exited, so there was no long-lived pid to restore. The shell still printed none: prio 0. The 4096-byte file was removed and a second check saw it gone. The scheduler file was not written, so there is no scheduler value to put back.

Questions

Is high iowait the same as high CPU?

No. In the one-second sample, %idle was 55.46 and %iowait was 22.70. User time was 14.07. The CPUs had room. The wait was disk.

Does ionice fix a disk that is on mq-deadline?

The class is stored on the process. This disk's active scheduler was mq-deadline, and the test did not change it. BFQ is the scheduler that uses the idle and best-effort classes. ionice on a child did not change sda.

What was actually changed on disk?

A 4096-byte file was written, flushed, and deleted. write_bytes for that process went from 0 to 4096. No sysctl and no scheduler was written.