I have been looking into the iowait
property shown in top utility output as shown below.
top - 07:30:58 up 3:37, 1 user, load average: 0.00, 0.01, 0.05
Tasks: 86 total, 1 running, 85 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.0 us, 0.3 sy, 0.0 ni, 99.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
iowait
is generally defined as follows:
"It is the time during which CPU is idle and there is some IO pending."
It is my understanding that a process is run on a single CPU. After it gets de-scheduled either because it has used up its time slot or after it gets blocked, it can eventually be scheduled again on any one CPU again.
In case of IO request, a CPU that puts a process in uninterruptible sleep is responsible for tracking the iowait
time. The other CPUs would be reporting the same time as idle time on their end as they really are idle. Is this assumption correct?
Furthermore, assuming there is a long IO request (meaning the process had several opportunities to get scheduled but didn't get scheduled because the IO wasn't complete), how does a CPU know there is "pending IO"? Where is that kind of information fetched from? How can a CPU simply find out that some process was put to sleep some time for an IO to complete as any of the CPUs could have put that process to sleep. How is this status of "pending IO" confirmed?