From ce84d19f63c0596908e80f412c545e5267d9c4eb Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Mon, 25 May 2020 10:34:10 +0200 Subject: [PATCH] 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 --- proxmox/src/sys/linux/procfs.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/proxmox/src/sys/linux/procfs.rs b/proxmox/src/sys/linux/procfs.rs index 8f6ec835..d1aecaad 100644 --- a/proxmox/src/sys/linux/procfs.rs +++ b/proxmox/src/sys/linux/procfs.rs @@ -308,8 +308,6 @@ fn parse_proc_stat(statstr: &str) -> Result { + stat.irq + stat.softirq + stat.steal - + stat.guest - + stat.guest_nice + stat.idle; // returns avg. heuristic for the first request