
On Tue, 19 Apr 2011 12:29:05 +0100 "Daniel P. Berrange" <berrange@redhat.com> wrote:
On Fri, Apr 15, 2011 at 04:43:03PM +0900, KAMEZAWA Hiroyuki wrote:
On Fri, 15 Apr 2011 09:43:15 +0200 Matthias Bolte <matthias.bolte@googlemail.com> wrote:
2011/4/15 KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>: Also do you really need the absolute CPU time? yes, for virt-top -1.
I don't think that is correct. What virt-top ultimately displays to the end user is a % utilization. So it would be happy to get data in either % util & display that directly, or get absolute CPU time and calculate deltas to display % util.
virt-top calculate delta by itself.
I wonder if we could provide an API that could be used to provide either per-VCPU or per-PCPU statistics in one go, so that we can finally have an API for cpu time that works well for VMWare.
VMWare ?
eg
typedef struct _virDomainCPUTime virDomainCPUTime; typedef virDomainCPUTime *virDomainCPUTimePtr;
#define VIR_DOMAIN_CPUTIME_ABS "abs" #define VIR_DOMAIN_CPUTIME_UTIL "util" ...define more stats later if desired...
To calculate 'util', we need 'interval' for calculating it. What interval do we use ? The libvirt need to calculate it periodically by making a thread ? "util" can be very easily calculated by util = cpuTime-delta / (interval(sec) * 1000000000) * 100. So, it depens on interval. For example, when we make fair-share-scheduler's balancing interval to 1sec, we never want interaval smaller than 1 sec. IIUC, virt-top users can specify 'interval'. So, virt-top needs to use absolute cpuTime delta even if libvirt provides 'util'. Because to show what users want, virt-top needs to use interval users want.
struct _virDomainCPUTime { char field[VIR_DOMAIN_CPU_TIME_FIELD_LENGTH]; unsigned long long value; };
typedef enum { VIR_DOMAIN_CPU_TIME_VIRTUAL = 0, VIR_DOMAIN_CPU_TIME_PHYSICAL = 1, } virDomainCPUTimeFlags;
int virDomainGetCPUTime(virDomainPtr dom, virDomainCPUTimePtr stats, int *nstats, unsigned int flags);
When querying per-virtual CPU time, nstats would be the number of virtual CPUs in the guest. eg
Why we take care of vcpus ?
virDomainInfo info; virDomainGetInfo(dom, &info); virDomainCPUTimePtr stats;
stats = malloc(sizeof(*stats)*info.nrVirtCPU);
virDomainGetCPUTime(dom, stats, info.nrVirtCPU, VIR_DOMAIN_CPU_TIME_VIRTUAL);
Or to get the break down per physical CPU, use the VIR_NODEINFO_MAX_CPUS macro
per vcpu pcpu time is not what I want. Hmm, others needs such information ? And virt-top need to re-calculate per-vm pcpu time by making sum of cputime per vcpu on pcus ? Anyway, cpuacct cgroup/ Linux kernel cannot provide per-vcpu-per-pcpu time and I cannot implement qemu driver. Thanks, -Kame