Re: [libvirt] VM cpuTime from libvirt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Mar 22, 2009 at 02:28:00PM +0200, Zvi Dubitzky wrote:
> Currently the  cat  /proc/pid/stat    where pid is the pid of the VM Qemu 
> process gives the utime + stime of the  VM according to libvirt.
> 
> Unfortunately I notice  that this is actually the elapsed time of the host 
>  . I find this by using libvirt  , sampling  the cputime of each VM 
> process and compare it to the total elapsed time (of the Host Linux 
> machine) . Roughly  assuming full VM vcpu utlization,  the cpu utilization 
> of every VM is actually : ( # of VM  vcpus / total  # of Host cpus) .This 
> implies that there is  no  idle time per VM (while actually there is) . We 
> only know the idle time of the  Host via the  top command  at the Host .
> Is the cputime of a VM (from cat /proc/pid/stat of the Qemu process as 
> used by libvirt)  realy the cputime of the VM ?
> 
> I  tested with  a host having 2 sockets  X 4cpus =8  totally and assigned 
> 4 cpus to  VM1 and VM2 . libvirt gave equal cputime for each VM  which is 
> equal to the total machine elapsed time. But even if  VM1 has 4 vcpus and 
> VM2 have 8 vcpus the cputime of each VM 
> (from cat  /proc/pid/stat)  is the elapsed time.
> 
> The truth is that I am running the libvirt application on the host machine 
> and do the application wait there . Should that  matter much?
> 
> Each  guest idle time  is needed from the KVM for real cpu utilization 
> calc   to be independent from the guest OS .
> At least for Linux we can manually run 'top'  at  each guest  terminal 
> window , but I do not know if it will show the real idle time or the total 
> machine (host) idle time .At least linux has no idle process . Besides 
> this is not a good programmatic way  to get the VM idle time.
> 
> Is there a cure or I am missing something ?

I have a host machine with 8 cpus

I run 2 guests, one with 4 vcpus, and one with 1 vcpu.

Inside the first guest I run 4 copies of 

  while /bin/true ; do /bin/true ; done

This generates 100% cpu usage within the guest

If I run 'virt-top' on the host machine, I see that guest reported
as using 50% cpu. This is accurate because 4 cpus in guest, 100%
utilized is 1/2 of the total resources available to the host which
has 8 cpus.

Similarly if i run that load generator on the 2nd guest, which only
has 1 vcpu, then virt-top again correctly shows that guest as using
12.5% of total host CPU resources (100% / 8 == 12.5%)

So AFAICT, everything is working exactly as designed.

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]