diff options
Diffstat (limited to 'tools/misc/xenlockprof.c')
-rw-r--r-- | tools/misc/xenlockprof.c | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/tools/misc/xenlockprof.c b/tools/misc/xenlockprof.c index 0235ab0150..41fcb792cc 100644 --- a/tools/misc/xenlockprof.c +++ b/tools/misc/xenlockprof.c @@ -18,22 +18,6 @@ #include <string.h> #include <inttypes.h> -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[]) { xc_interface *xc_handle; @@ -41,7 +25,7 @@ int main(int argc, char *argv[]) uint64_t time; double l, b, sl, sb; char name[60]; - xc_lockprof_data_t *data; + DECLARE_HYPERCALL_BUFFER(xc_lockprof_data_t, data); if ( (argc > 2) || ((argc == 2) && (strcmp(argv[1], "-r") != 0)) ) { @@ -78,24 +62,22 @@ int main(int argc, char *argv[]) } n += 32; /* just to be sure */ - data = malloc(sizeof(*data) * n); - if ( (data == NULL) || (lock_pages(data, sizeof(*data) * n) != 0) ) + data = xc_hypercall_buffer_alloc(xc_handle, data, sizeof(*data) * n); + if ( data == NULL ) { - fprintf(stderr, "Could not alloc or lock buffers: %d (%s)\n", + fprintf(stderr, "Could not allocate buffers: %d (%s)\n", errno, strerror(errno)); return 1; } i = n; - if ( xc_lockprof_query(xc_handle, &i, &time, data) != 0 ) + if ( xc_lockprof_query(xc_handle, &i, &time, HYPERCALL_BUFFER(data)) != 0 ) { fprintf(stderr, "Error getting profile records: %d (%s)\n", errno, strerror(errno)); return 1; } - unlock_pages(data, sizeof(*data) * n); - if ( i > n ) { printf("data incomplete, %d records are missing!\n\n", i - n); @@ -132,5 +114,7 @@ int main(int argc, char *argv[]) printf("total locked time: %20.9fs\n", sl); printf("total blocked time: %20.9fs\n", sb); + xc_hypercall_buffer_free(xc_handle, data); + return 0; } |