mirror of
https://github.com/libvirt/libvirt.git
synced 2026-10-02 12:20:06 -05:00
On Linux the accounting stats come from /proc/stat entries and the mapping is: https://www.kernel.org/doc/html/latest/filesystems/proc.html VIR_NODE_CPU_STATS_KERNEL = (system + irq + softirq) VIR_NODE_CPU_STATS_USER = (user + nice) VIR_NODE_CPU_STATS_IDLE = idle <VIR_NODE_CPU_STATS_INTR> = N/A, irq is accounted by libvirt as KERNEL VIR_NODE_CPU_STATS_IOWAIT = iowait VIR_NODE_CPU_STATS_GUEST = guest VIR_NODE_CPU_STATS_GUEST was introduced in:b5878727c7("util: virHostCPUGetStatsLinux: support VIR_NODE_CPU_STATS_GUEST") with the goal of specifically accounting the CPU time spent running guest VCPUs. Unfortunately at the time it was not considered that to get a measure of this time, "guest" is not sufficient, because any guest that is "niced" is accounted in a separate category, "guest_nice". This patch rectifies the situation by adding the guest_nice counter, so that VIR_NODE_CPU_STATS_GUEST = (guest + guest_nice) which makes the statistic useful to the caller, as the totals sum up correctly. In order to find the total USER time spent running host tasks, for example: cpu_user_host = VIR_NODE_CPU_STATS_USER - VIR_NODE_CPU_STATS_GUEST this follows from the fact that "guest" is included in "user" accounting, and "guest_nice" is included in "nice" accounting. Extend the existing tests artificially to capture this specific case. Fixes:b5878727c7Signed-off-by: Claudio Fontana <cfontana@suse.de> Reviewed-by: Peter Krempa <pkrempa@redhat.com>