mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
This patch is to make xentop able to print vcpu usage for out of order
enabled vcpus in a domain. This really isn't an issue anymore with the changes made to dom0 ops and xm/xend. But, I provide it because: - Josh noticed my previous patch called getvcpuinfo twice for each vpcu, which was completely silly. - this patch would be useful in the remote chance that domain vpcus are enabled out of order. Signed-off-by: Daniel Stekloff <dsteklof@us.ibm.com>
This commit is contained in:
1 parent
44d95809c5
commit
db65a8e335
5 files changed
+36
-20
No files matched your search
@@ -173,9 +173,9 @@ int xi_get_domaininfolist(xi_handle *handle, dom0_getdomaininfo_t *info,
|
||||
return op.u.getdomaininfolist.num_domains;
|
||||
}
|
||||
|
||||
/* Returns cpu usage data from dom0 */
|
||||
long long xi_get_vcpu_usage(xi_handle *handle, unsigned int domain,
|
||||
unsigned int vcpu)
|
||||
/* Get vcpu info from a domain */
|
||||
int xi_get_domain_vcpu_info(xi_handle *handle, unsigned int domain,
|
||||
unsigned int vcpu, dom0_getvcpuinfo_t *info)
|
||||
{
|
||||
dom0_op_t op;
|
||||
op.u.getvcpuinfo.domain = domain;
|
||||
@@ -186,7 +186,9 @@ long long xi_get_vcpu_usage(xi_handle *handle, unsigned int domain,
|
||||
return -1;
|
||||
}
|
||||
|
||||
return op.u.getvcpuinfo.cpu_time;
|
||||
memcpy(info, &op.u.getvcpuinfo, sizeof(dom0_getvcpuinfo_t));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* gets xen version information from hypervisor */
|
||||
|
||||
@@ -41,5 +41,6 @@ int xi_get_physinfo(xi_handle *, dom0_physinfo_t *);
|
||||
int xi_get_domaininfolist(xi_handle *, dom0_getdomaininfo_t *, unsigned int,
|
||||
unsigned int);
|
||||
|
||||
/* Returns cpu usage data from dom0 */
|
||||
long long xi_get_vcpu_usage(xi_handle *, unsigned int, unsigned int);
|
||||
/* Get vcpu info from a domain */
|
||||
int xi_get_domain_vcpu_info(xi_handle *, unsigned int, unsigned int,
|
||||
dom0_getvcpuinfo_t *);
|
||||
@@ -51,7 +51,7 @@ struct xenstat_domain {
|
||||
unsigned int id;
|
||||
unsigned int state;
|
||||
unsigned long long cpu_ns;
|
||||
unsigned int num_vcpus;
|
||||
unsigned int num_vcpus; /* No. vcpus configured for domain */
|
||||
xenstat_vcpu *vcpus; /* Array of length num_vcpus */
|
||||
unsigned long long cur_mem; /* Current memory reservation */
|
||||
unsigned long long max_mem; /* Total memory allowed */
|
||||
@@ -61,6 +61,7 @@ struct xenstat_domain {
|
||||
};
|
||||
|
||||
struct xenstat_vcpu {
|
||||
unsigned int online;
|
||||
unsigned long long ns;
|
||||
};
|
||||
|
||||
@@ -229,7 +230,7 @@ xenstat_node *xenstat_get_node(xenstat_handle * handle, unsigned int flags)
|
||||
domain->id = domaininfo[i].domain;
|
||||
domain->state = domaininfo[i].flags;
|
||||
domain->cpu_ns = domaininfo[i].cpu_time;
|
||||
domain->num_vcpus = domaininfo[i].nr_online_vcpus;
|
||||
domain->num_vcpus = (domaininfo[i].max_vcpu_id+1);
|
||||
domain->vcpus = NULL;
|
||||
domain->cur_mem =
|
||||
((unsigned long long)domaininfo[i].tot_pages)
|
||||
@@ -344,7 +345,7 @@ unsigned long long xenstat_domain_cpu_ns(xenstat_domain * domain)
|
||||
return domain->cpu_ns;
|
||||
}
|
||||
|
||||
/* Find the number of VCPUs allocated to a domain */
|
||||
/* Find the number of VCPUs for a domain */
|
||||
unsigned int xenstat_domain_num_vcpus(xenstat_domain * domain)
|
||||
{
|
||||
return domain->num_vcpus;
|
||||
@@ -432,22 +433,24 @@ xenstat_network *xenstat_domain_network(xenstat_domain * domain,
|
||||
static int xenstat_collect_vcpus(xenstat_node * node)
|
||||
{
|
||||
unsigned int i, vcpu;
|
||||
|
||||
/* Fill in VCPU information */
|
||||
for (i = 0; i < node->num_domains; i++) {
|
||||
node->domains[i].vcpus = malloc(node->domains[i].num_vcpus
|
||||
* sizeof(xenstat_vcpu));
|
||||
if (node->domains[i].vcpus == NULL)
|
||||
return 0;
|
||||
|
||||
|
||||
for (vcpu = 0; vcpu < node->domains[i].num_vcpus; vcpu++) {
|
||||
/* FIXME: need to be using a more efficient mechanism*/
|
||||
long long vcpu_time;
|
||||
vcpu_time = xi_get_vcpu_usage(node->handle->xihandle,
|
||||
node->domains[i].id,
|
||||
vcpu);
|
||||
if (vcpu_time < 0)
|
||||
dom0_getvcpuinfo_t info;
|
||||
|
||||
if (xi_get_domain_vcpu_info(node->handle->xihandle,
|
||||
node->domains[i].id, vcpu, &info) != 0)
|
||||
return 0;
|
||||
node->domains[i].vcpus[vcpu].ns = vcpu_time;
|
||||
|
||||
node->domains[i].vcpus[vcpu].online = info.online;
|
||||
node->domains[i].vcpus[vcpu].ns = info.cpu_time;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
@@ -466,6 +469,12 @@ static void xenstat_uninit_vcpus(xenstat_handle * handle)
|
||||
{
|
||||
}
|
||||
|
||||
/* Get VCPU online status */
|
||||
unsigned int xenstat_vcpu_online(xenstat_vcpu * vcpu)
|
||||
{
|
||||
return vcpu->online;
|
||||
}
|
||||
|
||||
/* Get VCPU usage */
|
||||
unsigned long long xenstat_vcpu_ns(xenstat_vcpu * vcpu)
|
||||
{
|
||||
|
||||
@@ -119,6 +119,7 @@ xenstat_network *xenstat_domain_network(xenstat_domain * domain,
|
||||
*/
|
||||
|
||||
/* Get VCPU usage */
|
||||
unsigned int xenstat_vcpu_online(xenstat_vcpu * vcpu);
|
||||
unsigned long long xenstat_vcpu_ns(xenstat_vcpu * vcpu);
|
||||
|
||||
|
||||
|
||||
@@ -713,13 +713,16 @@ void do_vcpu(xenstat_domain *domain)
|
||||
|
||||
num_vcpus = xenstat_domain_num_vcpus(domain);
|
||||
|
||||
/* for all vcpus dump out values */
|
||||
/* for all online vcpus dump out values */
|
||||
for (i=0; i< num_vcpus; i++) {
|
||||
vcpu = xenstat_domain_vcpu(domain,i);
|
||||
|
||||
if (i != 0 && (i%5)==0)
|
||||
print("\n ");
|
||||
print(" %2u: %10llus", i, xenstat_vcpu_ns(vcpu)/1000000000);
|
||||
if (xenstat_vcpu_online(vcpu) > 0) {
|
||||
if (i != 0 && (i%5)==0)
|
||||
print("\n ");
|
||||
print(" %2u: %10llus", i,
|
||||
xenstat_vcpu_ns(vcpu)/1000000000);
|
||||
}
|
||||
}
|
||||
print("\n");
|
||||
}
|
||||
|
||||