Files
xen/tools/misc/xenperf.c
T
kfraser@localhost.localdomain 1df421476a Replace dom0_ops hypercall with three new hypercalls:
1. platform_op -- used by dom0 kernel to perform actions on the
    hardware platform (e.g., MTRR access, microcode update, platform
    quirks, ...)
 2. domctl -- used by management tools to control a specified domain
 3. sysctl -- used by management tools for system-wide actions

Benefits include more sensible factoring of actions to
hypercalls. Also allows tool compatibility to be tracked separately
from the dom0 kernel. The assumption is that it will be easier to
replace libxenctrl, libxenguest and Xen as a matched set if the
dom0 kernel does not need to be replaced too (e.g., because that
would require vendor revalidation).

From here on we hope to maintain dom0 kernel compatibility. This
promise is not extended to tool compatibility beyond the existing
guarantee that compatibility will not be broken within a three-level
stable release [3.0.2, 3.0.3, etc.].

Signed-off-by: Keir Fraser <keir@xensource.com>
2006-08-25 18:39:10 +01:00

130 lines
3.3 KiB
C

/* -*- Mode:C; c-basic-offset:4; tab-width:4 -*-
****************************************************************************
* (C) 2004 - Rolf Neugebauer - Intel Research Cambridge
****************************************************************************
*
* File: xenperf.c
* Author: Rolf Neugebauer (rolf.neugebauer@intel.com)
* Date: Nov 2004
*
* Description:
*/
#include <xenctrl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <errno.h>
#include <string.h>
int main(int argc, char *argv[])
{
int i, j, xc_handle;
xc_perfc_desc_t *pcd;
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 )
{
char *p = argv[1];
if ( p[0] == '-' )
{
switch ( p[1] )
{
case 'f':
full = 1;
break;
case 'r':
reset = 1;
break;
default:
goto error;
}
}
else
{
error:
printf("%s: [-r]\n", argv[0]);
printf("no args: print digested counters\n");
printf(" -f : print full arrays/histograms\n");
printf(" -r : reset counters\n");
return 0;
}
}
if ( (xc_handle = xc_interface_open()) == -1 )
{
fprintf(stderr, "Error opening xc interface: %d (%s)\n",
errno, strerror(errno));
return 1;
}
if ( reset )
{
if ( xc_perfc_control(xc_handle, XEN_SYSCTL_PERFCOP_reset,
NULL, NULL, NULL, NULL) != 0 )
{
fprintf(stderr, "Error reseting performance counters: %d (%s)\n",
errno, strerror(errno));
return 1;
}
return 0;
}
if ( xc_perfc_control(xc_handle, XEN_SYSCTL_PERFCOP_query,
NULL, NULL, &num_desc, &num_val) != 0 )
{
fprintf(stderr, "Error getting number of perf counters: %d (%s)\n",
errno, strerror(errno));
return 1;
}
pcd = malloc(sizeof(*pcd) * num_desc);
pcv = malloc(sizeof(*pcv) * num_val);
if ( pcd == NULL
|| mlock(pcd, sizeof(*pcd) * num_desc) != 0
|| pcv == NULL
|| mlock(pcd, sizeof(*pcv) * num_val) != 0)
{
fprintf(stderr, "Could not alloc or mlock buffers: %d (%s)\n",
errno, strerror(errno));
exit(-1);
}
if ( xc_perfc_control(xc_handle, XEN_SYSCTL_PERFCOP_query,
pcd, pcv, NULL, NULL) != 0 )
{
fprintf(stderr, "Error getting perf counter: %d (%s)\n",
errno, strerror(errno));
return 1;
}
munlock(pcd, sizeof(*pcd) * num_desc);
munlock(pcv, sizeof(*pcv) * num_val);
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 += 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)val[j]);
printf("\n");
val += pcd[i].nr_vals;
}
return 0;
}