[virt-tools-list] Attribute vm load to individual physical cpu

Richard W.M. Jones rjones at redhat.com
Fri Dec 9 11:27:18 UTC 2011


On Fri, Dec 09, 2011 at 07:24:07PM +0800, Fury kerry wrote:
> I'm trying to figure out a way to attribute the VM CPU% into individual
> physical CPU or at least find out whether it is possible. Based on the FAQ
> of virt-top ( http://people.redhat.com/~rjones/virt-top/faq.html#pcpu ) ,
> it seems currently libvirt don't support it.
> 
> For KVM, attributing VM load into individual physical CPU equals to account
> the task cpu times spent at each CPU.  Linux kernel export some scheduling
> statistics  in /proc/<pid>/schedstat and /proc/schedstat, but I can not
> find a way to derive or calculate the per CPU task time from there. Do you
> guys know how to calculate or *approximate* per CPU task time, ( possiblly
> from existing kernel statistics ), can you give me some directions? Or the
> task itself e.g. KVM has to maintain such statistics.
> 
> Per the FAQ of virt-top,  there are only 2 workaround:
> 
>    1. Pin all your virtual CPUs to physical CPUs. Then there is no
>    ambiguity.
>    2. Assume that CPU affinity works and assume the domain is running on
>    the '#'-marked CPU(s).
> 
> Workaround #2 seems promising but I'm not sure how accurate it is.

The FAQ describes the current situation.

There's a open bug which is scheduled to be fixed in the RHEL 6.3
timeframe (next 6 months) to make this work properly using the new
virNodeGetCPUStats API in libvirt.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v




More information about the virt-tools-list mailing list