Bug 783827

Summary: Guest CPU usage is truncated at 100%.
Product: Red Hat Enterprise Linux 6 Reporter: Yaniv Lavi <ylavi>
Component: vdsmAssignee: Dan Kenigsberg <danken>
Status: CLOSED NOTABUG QA Contact: yeylon <yeylon>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.2CC: abaron, bazulay, iheim, srevivo, ykaul
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-01-22 21:04:37 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Yaniv Lavi 2012-01-22 16:16:17 UTC
Description of problem:
Guest CPU usage is collected from the VM process CPU usage.
If you have a multi-core host the CPU usage can be higher than 100%.
Current the VM CPU samples are truncated at 100% and don't reflect the CPUs usage on the guest level (VM's CPU Usage = Host's CPU Usage / VM's CPUs). 
The result should still truncated at 100% to avoid overhead that will return more than 100%, but be divided by VM's CPUs to reflect the correct stats.

Version-Release number of selected component (if applicable):
vdsm-4.9-112.3.el6.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Run VM with more than one core.
2. Load it beyond 100% CPU Usage. 
3. Check Guest CPU Usage.
  
Actual results:
Guest sees less usage than reported.

Expected results:
Reported result should be close to the one reported on the guest.

Comment 2 Dan Kenigsberg 2012-01-22 21:04:37 UTC
I'm sorry to have mislead you: a closer review of the code shows that vdsm reports cpu consumption of qemu processes similarly to top(1). For mutli-vcpu VMs, cpuUser+cpuSys may exceed 100% considerably.

        jiffies = (vms1.pidcpu.user - vms0.pidcpu.user) % 2**32
        stats['cpuUser'] = jiffies / interval

cpuUser is the jiffies per second, allocated to the qemu-kvm process (each host cpu provides 100 jiffies per second)