direct-io.hg
changeset 7471:37050ba0e35c
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>
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>
author | kaf24@firebug.cl.cam.ac.uk |
---|---|
date | Sat Oct 22 07:37:15 2005 +0100 (2005-10-22) |
parents | 3951b5b01cfd |
children | 6b8a91dcdc2e |
files | tools/xenstat/libxenstat/src/xen-interface.c tools/xenstat/libxenstat/src/xen-interface.h tools/xenstat/libxenstat/src/xenstat.c tools/xenstat/libxenstat/src/xenstat.h tools/xenstat/xentop/xentop.c |
line diff
1.1 --- a/tools/xenstat/libxenstat/src/xen-interface.c Sat Oct 22 07:35:36 2005 +0100 1.2 +++ b/tools/xenstat/libxenstat/src/xen-interface.c Sat Oct 22 07:37:15 2005 +0100 1.3 @@ -173,9 +173,9 @@ int xi_get_domaininfolist(xi_handle *han 1.4 return op.u.getdomaininfolist.num_domains; 1.5 } 1.6 1.7 -/* Returns cpu usage data from dom0 */ 1.8 -long long xi_get_vcpu_usage(xi_handle *handle, unsigned int domain, 1.9 - unsigned int vcpu) 1.10 +/* Get vcpu info from a domain */ 1.11 +int xi_get_domain_vcpu_info(xi_handle *handle, unsigned int domain, 1.12 + unsigned int vcpu, dom0_getvcpuinfo_t *info) 1.13 { 1.14 dom0_op_t op; 1.15 op.u.getvcpuinfo.domain = domain; 1.16 @@ -186,7 +186,9 @@ long long xi_get_vcpu_usage(xi_handle *h 1.17 return -1; 1.18 } 1.19 1.20 - return op.u.getvcpuinfo.cpu_time; 1.21 + memcpy(info, &op.u.getvcpuinfo, sizeof(dom0_getvcpuinfo_t)); 1.22 + 1.23 + return 0; 1.24 } 1.25 1.26 /* gets xen version information from hypervisor */
2.1 --- a/tools/xenstat/libxenstat/src/xen-interface.h Sat Oct 22 07:35:36 2005 +0100 2.2 +++ b/tools/xenstat/libxenstat/src/xen-interface.h Sat Oct 22 07:37:15 2005 +0100 2.3 @@ -41,5 +41,6 @@ int xi_get_physinfo(xi_handle *, dom0_ph 2.4 int xi_get_domaininfolist(xi_handle *, dom0_getdomaininfo_t *, unsigned int, 2.5 unsigned int); 2.6 2.7 -/* Returns cpu usage data from dom0 */ 2.8 -long long xi_get_vcpu_usage(xi_handle *, unsigned int, unsigned int); 2.9 +/* Get vcpu info from a domain */ 2.10 +int xi_get_domain_vcpu_info(xi_handle *, unsigned int, unsigned int, 2.11 + dom0_getvcpuinfo_t *);
3.1 --- a/tools/xenstat/libxenstat/src/xenstat.c Sat Oct 22 07:35:36 2005 +0100 3.2 +++ b/tools/xenstat/libxenstat/src/xenstat.c Sat Oct 22 07:37:15 2005 +0100 3.3 @@ -51,7 +51,7 @@ struct xenstat_domain { 3.4 unsigned int id; 3.5 unsigned int state; 3.6 unsigned long long cpu_ns; 3.7 - unsigned int num_vcpus; 3.8 + unsigned int num_vcpus; /* No. vcpus configured for domain */ 3.9 xenstat_vcpu *vcpus; /* Array of length num_vcpus */ 3.10 unsigned long long cur_mem; /* Current memory reservation */ 3.11 unsigned long long max_mem; /* Total memory allowed */ 3.12 @@ -61,6 +61,7 @@ struct xenstat_domain { 3.13 }; 3.14 3.15 struct xenstat_vcpu { 3.16 + unsigned int online; 3.17 unsigned long long ns; 3.18 }; 3.19 3.20 @@ -229,7 +230,7 @@ xenstat_node *xenstat_get_node(xenstat_h 3.21 domain->id = domaininfo[i].domain; 3.22 domain->state = domaininfo[i].flags; 3.23 domain->cpu_ns = domaininfo[i].cpu_time; 3.24 - domain->num_vcpus = domaininfo[i].nr_online_vcpus; 3.25 + domain->num_vcpus = (domaininfo[i].max_vcpu_id+1); 3.26 domain->vcpus = NULL; 3.27 domain->cur_mem = 3.28 ((unsigned long long)domaininfo[i].tot_pages) 3.29 @@ -344,7 +345,7 @@ unsigned long long xenstat_domain_cpu_ns 3.30 return domain->cpu_ns; 3.31 } 3.32 3.33 -/* Find the number of VCPUs allocated to a domain */ 3.34 +/* Find the number of VCPUs for a domain */ 3.35 unsigned int xenstat_domain_num_vcpus(xenstat_domain * domain) 3.36 { 3.37 return domain->num_vcpus; 3.38 @@ -432,22 +433,24 @@ xenstat_network *xenstat_domain_network( 3.39 static int xenstat_collect_vcpus(xenstat_node * node) 3.40 { 3.41 unsigned int i, vcpu; 3.42 + 3.43 /* Fill in VCPU information */ 3.44 for (i = 0; i < node->num_domains; i++) { 3.45 node->domains[i].vcpus = malloc(node->domains[i].num_vcpus 3.46 * sizeof(xenstat_vcpu)); 3.47 if (node->domains[i].vcpus == NULL) 3.48 return 0; 3.49 - 3.50 + 3.51 for (vcpu = 0; vcpu < node->domains[i].num_vcpus; vcpu++) { 3.52 /* FIXME: need to be using a more efficient mechanism*/ 3.53 - long long vcpu_time; 3.54 - vcpu_time = xi_get_vcpu_usage(node->handle->xihandle, 3.55 - node->domains[i].id, 3.56 - vcpu); 3.57 - if (vcpu_time < 0) 3.58 + dom0_getvcpuinfo_t info; 3.59 + 3.60 + if (xi_get_domain_vcpu_info(node->handle->xihandle, 3.61 + node->domains[i].id, vcpu, &info) != 0) 3.62 return 0; 3.63 - node->domains[i].vcpus[vcpu].ns = vcpu_time; 3.64 + 3.65 + node->domains[i].vcpus[vcpu].online = info.online; 3.66 + node->domains[i].vcpus[vcpu].ns = info.cpu_time; 3.67 } 3.68 } 3.69 return 1; 3.70 @@ -466,6 +469,12 @@ static void xenstat_uninit_vcpus(xenstat 3.71 { 3.72 } 3.73 3.74 +/* Get VCPU online status */ 3.75 +unsigned int xenstat_vcpu_online(xenstat_vcpu * vcpu) 3.76 +{ 3.77 + return vcpu->online; 3.78 +} 3.79 + 3.80 /* Get VCPU usage */ 3.81 unsigned long long xenstat_vcpu_ns(xenstat_vcpu * vcpu) 3.82 {
4.1 --- a/tools/xenstat/libxenstat/src/xenstat.h Sat Oct 22 07:35:36 2005 +0100 4.2 +++ b/tools/xenstat/libxenstat/src/xenstat.h Sat Oct 22 07:37:15 2005 +0100 4.3 @@ -119,6 +119,7 @@ xenstat_network *xenstat_domain_network( 4.4 */ 4.5 4.6 /* Get VCPU usage */ 4.7 +unsigned int xenstat_vcpu_online(xenstat_vcpu * vcpu); 4.8 unsigned long long xenstat_vcpu_ns(xenstat_vcpu * vcpu); 4.9 4.10
5.1 --- a/tools/xenstat/xentop/xentop.c Sat Oct 22 07:35:36 2005 +0100 5.2 +++ b/tools/xenstat/xentop/xentop.c Sat Oct 22 07:37:15 2005 +0100 5.3 @@ -713,13 +713,16 @@ void do_vcpu(xenstat_domain *domain) 5.4 5.5 num_vcpus = xenstat_domain_num_vcpus(domain); 5.6 5.7 - /* for all vcpus dump out values */ 5.8 + /* for all online vcpus dump out values */ 5.9 for (i=0; i< num_vcpus; i++) { 5.10 vcpu = xenstat_domain_vcpu(domain,i); 5.11 5.12 - if (i != 0 && (i%5)==0) 5.13 - print("\n "); 5.14 - print(" %2u: %10llus", i, xenstat_vcpu_ns(vcpu)/1000000000); 5.15 + if (xenstat_vcpu_online(vcpu) > 0) { 5.16 + if (i != 0 && (i%5)==0) 5.17 + print("\n "); 5.18 + print(" %2u: %10llus", i, 5.19 + xenstat_vcpu_ns(vcpu)/1000000000); 5.20 + } 5.21 } 5.22 print("\n"); 5.23 }