aboutsummaryrefslogtreecommitdiffstats
path: root/tools/misc/xenperf.c
diff options
context:
space:
mode:
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>2006-08-07 15:53:06 +0100
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>2006-08-07 15:53:06 +0100
commita6e8b7effa20241c47ecd5c5fad549ac64d903a5 (patch)
tree9f06f22bd190243500fa6a9a1fdc6bcd158ebebf /tools/misc/xenperf.c
parented79bfa130dbc949ec2d23cf7d6d538d9222691e (diff)
downloadxen-a6e8b7effa20241c47ecd5c5fad549ac64d903a5.tar.gz
xen-a6e8b7effa20241c47ecd5c5fad549ac64d903a5.tar.bz2
xen-a6e8b7effa20241c47ecd5c5fad549ac64d903a5.zip
Change DOM0_PERFCCONTROL: remove array limit.
Descriptors and values are passed by two distinct buffers. Signed-off-by: Tristan Gingold <tristan.gingold@bull.net>
Diffstat (limited to 'tools/misc/xenperf.c')
-rw-r--r--tools/misc/xenperf.c48
1 files changed, 29 insertions, 19 deletions
diff --git a/tools/misc/xenperf.c b/tools/misc/xenperf.c
index 1572780c3d..1054d022f7 100644
--- a/tools/misc/xenperf.c
+++ b/tools/misc/xenperf.c
@@ -22,7 +22,10 @@ int main(int argc, char *argv[])
{
int i, j, xc_handle;
xc_perfc_desc_t *pcd;
- unsigned int num, sum, reset = 0, full = 0;
+ xc_perfc_val_t *pcv;
+ xc_perfc_val_t *val;
+ int num_desc, num_val;
+ unsigned int sum, reset = 0, full = 0;
if ( argc > 1 )
{
@@ -62,7 +65,7 @@ int main(int argc, char *argv[])
if ( reset )
{
if ( xc_perfc_control(xc_handle, DOM0_PERFCCONTROL_OP_RESET,
- NULL) < 0 )
+ NULL, NULL, NULL, NULL) != 0 )
{
fprintf(stderr, "Error reseting performance counters: %d (%s)\n",
errno, strerror(errno));
@@ -72,47 +75,54 @@ int main(int argc, char *argv[])
return 0;
}
+ if ( xc_perfc_control(xc_handle, DOM0_PERFCCONTROL_OP_QUERY,
+ NULL, NULL, &num_desc, &num_val) != 0 )
+ {
+ fprintf(stderr, "Error getting number of perf counters: %d (%s)\n",
+ errno, strerror(errno));
+ return 1;
+ }
- if ( (num = xc_perfc_control(xc_handle, DOM0_PERFCCONTROL_OP_QUERY,
- NULL)) < 0 )
- {
- fprintf(stderr, "Error getting number of perf counters: %d (%s)\n",
- errno, strerror(errno));
- return 1;
- }
-
- pcd = malloc(sizeof(*pcd) * num);
+ pcd = malloc(sizeof(*pcd) * num_desc);
+ pcv = malloc(sizeof(*pcv) * num_val);
- if ( mlock(pcd, sizeof(*pcd) * num) != 0 )
+ if ( pcd == NULL
+ || mlock(pcd, sizeof(*pcd) * num_desc) != 0
+ || pcv == NULL
+ || mlock(pcd, sizeof(*pcv) * num_val) != 0)
{
- fprintf(stderr, "Could not mlock descriptor buffer: %d (%s)\n",
+ fprintf(stderr, "Could not alloc or mlock buffers: %d (%s)\n",
errno, strerror(errno));
exit(-1);
}
- if ( xc_perfc_control(xc_handle, DOM0_PERFCCONTROL_OP_QUERY, pcd) <= 0 )
+ if ( xc_perfc_control(xc_handle, DOM0_PERFCCONTROL_OP_QUERY,
+ pcd, pcv, NULL, NULL) != 0 )
{
- fprintf(stderr, "Error getting perf counter description: %d (%s)\n",
+ fprintf(stderr, "Error getting perf counter: %d (%s)\n",
errno, strerror(errno));
return 1;
}
- munlock(pcd, sizeof(*pcd) * num);
+ munlock(pcd, sizeof(*pcd) * num_desc);
+ munlock(pcv, sizeof(*pcv) * num_val);
- for ( i = 0; i < num; i++ )
+ val = pcv;
+ for ( i = 0; i < num_desc; i++ )
{
printf ("%-35s ", pcd[i].name);
sum = 0;
for ( j = 0; j < pcd[i].nr_vals; j++ )
- sum += pcd[i].vals[j];
+ sum += val[j];
printf ("T=%10u ", (unsigned int)sum);
if ( full || (pcd[i].nr_vals <= 4) )
for ( j = 0; j < pcd[i].nr_vals; j++ )
- printf(" %10u", (unsigned int)pcd[i].vals[j]);
+ printf(" %10u", (unsigned int)val[j]);
printf("\n");
+ val += pcd[i].nr_vals;
}
return 0;