/proc/stat lists CPU usage, in the form:
cpu ...
cpu0 ...
cpu1 ...
...
cpuN ...
where the first line is a summary line. We’ve been using the CPU
numbers from /proc/stat to index into our internal stats array.
This doesn’t work on systems where the core IDs aren’t
consecutive. Examples of such systems are SMT systems with SMT
disabled. Here, /proc/stat may look like this instead:
cpu ...
cpu0 ...
cpu2 ...
cpu4 ...
...
With this patch, we ignore the CPU ID from /proc/stat. Instead, we use
a simple counter that is incremented for each (valid) cpu line found
in /proc/stat. To protect against corrupt /proc/stat content, stop
parsing /proc/stat if the number of parsed CPU lines exceed what we
consider to the be total number of CPUs in the system.
Closes#172