On 04/16/2012 02:33 AM, Zhihua Che wrote:
> Hi, everyone
> I'm using libvirt and resort to virDomainGetCPUStats for cpu
> usage by one domain. In my system, Ubuntu-11.10 64bit with 2 cores and
> Qemu Hyperviser, this function returns something like this:
> virTypedParameter[0]
> {
> field: "cpu_time"
> type: 4
> value.ul 51640610899
> }
> virTypedParameter[1]
> {
> field: "cpu_time"
> type: 4
> value.ul 55302820304
> }
>
> This 51640610899 and 55302820304 kind of conflict the result
> returned by "cat /proc/stat | grep cpu"
> cpu 449224 6812 89433 4407261 50327 1 2443 0 13041 0
> cpu0 224251 2603 43144 2195672 34682 0 2350 0 6692 0
> cpu1 224972 4209 46289 2211589 15644 0 93 0 6349 0
>
> I know the precision of /proc/stat is 1/HZ, so what's the precision
> of CPU stats returned by virDomainGetCPUStats?Per libvirt.h: /** * VIR_DOMAIN_CPU_STATS_CPUTIME: * cpu usage in nanoseconds, as a ullong */ #define VIR_DOMAIN_CPU_STATS_CPUTIME "cpu_time" /** * VIR_DOMAIN_CPU_STATS_USERTIME: * cpu time charged to user instructions in nanoseconds, as a ullong */ #define VIR_DOMAIN_CPU_STATS_USERTIME "user_time" Also, it helps to know that virDomainGetCPUStats gets its information from the cpuacct cgroup; I have no idea how the kernel code relates cpuacct tracking to /proc/stat tracking, so you'll have to track down that relationship before you can expect any sanity checking between the two values. -- Eric Blake [email protected] +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
_______________________________________________ libvirt-users mailing list [email protected] https://www.redhat.com/mailman/listinfo/libvirt-users
