3 ms·
It seems to me that the CPU utlization metric (from /proc/stat) has far more problems than misreporting memory stalls. As far as I understand it, the metric wo
by heinrichhartman 9y ago
It seems to me that the CPU utlization metric (from /proc/stat) has far more problems than misreporting memory stalls.
As far as I understand it, the metric works as follows: At every clock interrupt (every 4ms on my machine) the system checks which process is currently running, before invoking the scheduler:
- If the idle process idle time is accounted.
- Otherwise the processer is regarded as utilized.
(This is what I got from reading the docs, and digging into the source code. I am not 100% confident I understand this completely at this point. If you know better please tell me!)
There are many problems with this approach:
Every time slice (4ms) is accounte either as completely utilized on completely free. There are many reasons for processes going on CPU or off CPU outside of clock interrupts. Blocking syscalls are the most obvious one.
In the end a time slice might be utilized by multiple different processes and interrupt handlers but if at the very end of the time slice the idle thread is scheduled on CPU the whole slice is counted as idle time!
See also:
https://github.com/torvalds/linux/blob/master/Documentation/cpu-load.txt https://github.com/torvalds/linux/blob/master/Documentation/...