On Mon, Jun 22, 2026 at 16:32:52 +0200, Claudio Fontana wrote:
> Hello Peter, Daniel,
> 
> is this new commit message better?

Looks better,

> 
> Thanks,
> 
> Claudio
> 
> On 6/17/26 18:14, Claudio Fontana wrote:
> > 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: b5878727c714
> > ("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: b5878727c714d813c820ad4a1b695fbbb5ffc84e
> > Signed-off-by: Claudio Fontana <[email protected]>
> > ---
> >  src/util/virhostcpu.c                         | 2 +-
> >  tests/virhostcpudata/linux-cpustat-24cpu.out  | 8 ++++----
> >  tests/virhostcpudata/linux-cpustat-24cpu.stat | 4 ++--
> >  3 files changed, 7 insertions(+), 7 deletions(-)

Reviewed-by: Peter Krempa <[email protected]>

and pushed.

Reply via email to