Skip to content

top: fix cpu utilization display issue when virtual machine is present

hdzhoujie requested to merge hdzhoujie/procps:master into master

The v3.3.17 version is different from the v4.0.0 version to obtain the total time method

v3.3.17:

total = user + nice + system + idle + iowait + irq + softirq + steal

v4.0.0:

total = user + nice + system + idle + iowait + irq + softirq + steal + guest + guest_nice

When the physical machine has multiple virtual machines, the cpu utilization rate display is different, and the disp lay results of the two versions are different as follows:

version v3.3.17:

%cpu0 :100.0 us, 0.0 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st

version v4.0.0:

%Cpu0 : 50.1 us, 0.0 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st

Add the missing 'guest' tics to existing system ('sy') percentages. After modification, the result is shown as follows:

%Cpu0 : 50.1 us, 49.9 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st

signed-off-by:zhoujie zhoujie133@huawei.com

Edited by hdzhoujie

Merge request reports