procfs: don't count guest and guest_nice times twice

See the following kernel code snippet from
kernel/sched/cputime.c's account_guest_time():

    /* Add guest time to cpustat. */
    if (task_nice(p) > 0) {
        cpustat[CPUTIME_NICE] += cputime;
        cpustat[CPUTIME_GUEST_NICE] += cputime;
    } else {
        cpustat[CPUTIME_USER] += cputime;
        cpustat[CPUTIME_GUEST] += cputime;
    }

So the old sum was wrong as some time frames were counted
double in the `total` value.

The data will likely still deviate from PVE, but we should
check by how much, as this version does seem more accurate.
We can still fix it to just use the same math as pve if it
seems off.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2020-05-25 10:34:10 +02:00
parent c5b2694a44
commit ce84d19f63

View File

@ -308,8 +308,6 @@ fn parse_proc_stat(statstr: &str) -> Result<ProcFsStat, Error> {
+ stat.irq + stat.irq
+ stat.softirq + stat.softirq
+ stat.steal + stat.steal
+ stat.guest
+ stat.guest_nice
+ stat.idle; + stat.idle;
// returns avg. heuristic for the first request // returns avg. heuristic for the first request