diff options
author | Ian Campbell <ian.campbell@citrix.com> | 2010-10-22 15:14:51 +0100 |
---|---|---|
committer | Ian Campbell <ian.campbell@citrix.com> | 2010-10-22 15:14:51 +0100 |
commit | 4513025a87902aa4469b15e8097beb7590da7b78 (patch) | |
tree | 6639b374163076d128b6a5e54a124404b45e8b04 /tools/misc/xenperf.c | |
parent | 231c3160913a957cb9aeb693a7966ac3f8ecc780 (diff) | |
download | xen-4513025a87902aa4469b15e8097beb7590da7b78.tar.gz xen-4513025a87902aa4469b15e8097beb7590da7b78.tar.bz2 xen-4513025a87902aa4469b15e8097beb7590da7b78.zip |
libxc: convert sysctl interfaces over to hypercall buffers
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson.citrix.com>
Diffstat (limited to 'tools/misc/xenperf.c')
-rw-r--r-- | tools/misc/xenperf.c | 38 |
1 files changed, 9 insertions, 29 deletions
diff --git a/tools/misc/xenperf.c b/tools/misc/xenperf.c index 583abc1f82..07e584a5eb 100644 --- a/tools/misc/xenperf.c +++ b/tools/misc/xenperf.c @@ -68,28 +68,12 @@ const char *hypercall_name_table[64] = }; #undef X -static int lock_pages(void *addr, size_t len) -{ - int e = 0; -#ifndef __sun__ - e = mlock(addr, len); -#endif - return (e); -} - -static void unlock_pages(void *addr, size_t len) -{ -#ifndef __sun__ - munlock(addr, len); -#endif -} - int main(int argc, char *argv[]) { int i, j; xc_interface *xc_handle; - xc_perfc_desc_t *pcd; - xc_perfc_val_t *pcv; + DECLARE_HYPERCALL_BUFFER(xc_perfc_desc_t, pcd); + DECLARE_HYPERCALL_BUFFER(xc_perfc_val_t, pcv); xc_perfc_val_t *val; int num_desc, num_val; unsigned int sum, reset = 0, full = 0, pretty = 0; @@ -154,29 +138,23 @@ int main(int argc, char *argv[]) return 1; } - pcd = malloc(sizeof(*pcd) * num_desc); - pcv = malloc(sizeof(*pcv) * num_val); + pcd = xc_hypercall_buffer_alloc(xc_handle, pcd, sizeof(*pcd) * num_desc); + pcv = xc_hypercall_buffer_alloc(xc_handle, pcv, sizeof(*pcv) * num_val); - if ( pcd == NULL - || lock_pages(pcd, sizeof(*pcd) * num_desc) != 0 - || pcv == NULL - || lock_pages(pcv, sizeof(*pcv) * num_val) != 0) + if ( pcd == NULL || pcv == NULL) { - fprintf(stderr, "Could not alloc or lock buffers: %d (%s)\n", + fprintf(stderr, "Could not allocate buffers: %d (%s)\n", errno, strerror(errno)); exit(-1); } - if ( xc_perfc_query(xc_handle, pcd, pcv) != 0 ) + if ( xc_perfc_query(xc_handle, HYPERCALL_BUFFER(pcd), HYPERCALL_BUFFER(pcv)) != 0 ) { fprintf(stderr, "Error getting perf counter: %d (%s)\n", errno, strerror(errno)); return 1; } - unlock_pages(pcd, sizeof(*pcd) * num_desc); - unlock_pages(pcv, sizeof(*pcv) * num_val); - val = pcv; for ( i = 0; i < num_desc; i++ ) { @@ -221,5 +199,7 @@ int main(int argc, char *argv[]) val += pcd[i].nr_vals; } + xc_hypercall_buffer_free(xc_handle, pcd); + xc_hypercall_buffer_free(xc_handle, pcv); return 0; } |