|
|
a2eaef |
commit a37160c18eb8106a2b61ed181e2479a83381f3dc
|
|
|
a2eaef |
Author: James Ralph <ralph@icl.utk.edu>
|
|
|
a2eaef |
Date: Fri Jul 25 15:59:41 2014 -0400
|
|
|
a2eaef |
|
|
|
a2eaef |
perf_event.c: cleanup error messages
|
|
|
a2eaef |
|
|
|
a2eaef |
Thanks to Gary Mohr
|
|
|
a2eaef |
-------------------
|
|
|
a2eaef |
This patch contains general cleanup code. Calls to PAPIERROR pass a string which does
|
|
|
a2eaef |
not need to end with a new line because this function will always add one. New lines at
|
|
|
a2eaef |
the end of strings passed to this function have been removed. These changes also add
|
|
|
a2eaef |
some additional debug messages.
|
|
|
a2eaef |
|
|
|
a2eaef |
diff --git a/src/components/perf_event/perf_event.c b/src/components/perf_event/perf_event.c
|
|
|
a2eaef |
index 049c810..3eea38d 100644
|
|
|
a2eaef |
--- a/src/components/perf_event/perf_event.c
|
|
|
a2eaef |
+++ b/src/components/perf_event/perf_event.c
|
|
|
a2eaef |
@@ -300,11 +300,10 @@ sys_perf_event_open( struct perf_event_attr *hw_event, pid_t pid, int cpu,
|
|
|
a2eaef |
{
|
|
|
a2eaef |
int ret;
|
|
|
a2eaef |
|
|
|
a2eaef |
- SUBDBG("sys_perf_event_open(%p,%d,%d,%d,%lx\n",hw_event,pid,cpu,group_fd,flags);
|
|
|
a2eaef |
+ SUBDBG("sys_perf_event_open(hw_event: %p, pid: %d, cpu: %d, group_fd: %d, flags: %lx\n", hw_event, pid, cpu, group_fd, flags);
|
|
|
a2eaef |
SUBDBG(" type: %d\n",hw_event->type);
|
|
|
a2eaef |
SUBDBG(" size: %d\n",hw_event->size);
|
|
|
a2eaef |
- SUBDBG(" config: %"PRIx64" (%"PRIu64")\n",hw_event->config,
|
|
|
a2eaef |
- hw_event->config);
|
|
|
a2eaef |
+ SUBDBG(" config: %"PRIx64" (%"PRIu64")\n",hw_event->config, hw_event->config);
|
|
|
a2eaef |
SUBDBG(" sample_period: %"PRIu64"\n",hw_event->sample_period);
|
|
|
a2eaef |
SUBDBG(" sample_type: %"PRIu64"\n",hw_event->sample_type);
|
|
|
a2eaef |
SUBDBG(" read_format: %"PRIu64"\n",hw_event->read_format);
|
|
|
a2eaef |
@@ -323,6 +322,21 @@ sys_perf_event_open( struct perf_event_attr *hw_event, pid_t pid, int cpu,
|
|
|
a2eaef |
SUBDBG(" enable_on_exec: %d\n",hw_event->enable_on_exec);
|
|
|
a2eaef |
SUBDBG(" task: %d\n",hw_event->task);
|
|
|
a2eaef |
SUBDBG(" watermark: %d\n",hw_event->watermark);
|
|
|
a2eaef |
+ SUBDBG(" precise_ip: %d\n",hw_event->precise_ip);
|
|
|
a2eaef |
+ SUBDBG(" mmap_data: %d\n",hw_event->mmap_data);
|
|
|
a2eaef |
+ SUBDBG(" sample_id_all: %d\n",hw_event->sample_id_all);
|
|
|
a2eaef |
+ SUBDBG(" exclude_host: %d\n",hw_event->exclude_host);
|
|
|
a2eaef |
+ SUBDBG(" exclude_guest: %d\n",hw_event->exclude_guest);
|
|
|
a2eaef |
+ SUBDBG(" exclude_callchain_kernel: %d\n",hw_event->exclude_callchain_kernel);
|
|
|
a2eaef |
+ SUBDBG(" exclude_callchain_user: %d\n",hw_event->exclude_callchain_user);
|
|
|
a2eaef |
+ SUBDBG(" wakeup_events: %"PRIx32" (%"PRIu32")\n", hw_event->wakeup_events, hw_event->wakeup_events);
|
|
|
a2eaef |
+ SUBDBG(" bp_type: %"PRIx32" (%"PRIu32")\n", hw_event->bp_type, hw_event->bp_type);
|
|
|
a2eaef |
+ SUBDBG(" config1: %"PRIx64" (%"PRIu64")\n", hw_event->config1, hw_event->config1);
|
|
|
a2eaef |
+ SUBDBG(" config2: %"PRIx64" (%"PRIu64")\n", hw_event->config2, hw_event->config2);
|
|
|
a2eaef |
+ SUBDBG(" branch_sample_type: %"PRIx64" (%"PRIu64")\n", hw_event->branch_sample_type, hw_event->branch_sample_type);
|
|
|
a2eaef |
+ SUBDBG(" sample_regs_user: %"PRIx64" (%"PRIu64")\n", hw_event->sample_regs_user, hw_event->sample_regs_user);
|
|
|
a2eaef |
+ SUBDBG(" sample_stack_user: %"PRIx32" (%"PRIu32")\n", hw_event->sample_stack_user, hw_event->sample_stack_user);
|
|
|
a2eaef |
+
|
|
|
a2eaef |
ret =
|
|
|
a2eaef |
syscall( __NR_perf_event_open, hw_event, pid, cpu, group_fd, flags );
|
|
|
a2eaef |
SUBDBG("Returned %d %d %s\n",ret,
|
|
|
a2eaef |
@@ -470,14 +484,14 @@ check_scheduability( pe_context_t *ctx, pe_control_t *ctl, int idx )
|
|
|
a2eaef |
/* start the event */
|
|
|
a2eaef |
retval = ioctl( group_leader_fd, PERF_EVENT_IOC_ENABLE, NULL );
|
|
|
a2eaef |
if (retval == -1) {
|
|
|
a2eaef |
- PAPIERROR("ioctl(PERF_EVENT_IOC_ENABLE) failed.\n");
|
|
|
a2eaef |
+ PAPIERROR("ioctl(PERF_EVENT_IOC_ENABLE) failed");
|
|
|
a2eaef |
return PAPI_ESYS;
|
|
|
a2eaef |
}
|
|
|
a2eaef |
|
|
|
a2eaef |
/* stop the event */
|
|
|
a2eaef |
retval = ioctl(group_leader_fd, PERF_EVENT_IOC_DISABLE, NULL );
|
|
|
a2eaef |
if (retval == -1) {
|
|
|
a2eaef |
- PAPIERROR( "ioctl(PERF_EVENT_IOC_DISABLE) failed.\n" );
|
|
|
a2eaef |
+ PAPIERROR( "ioctl(PERF_EVENT_IOC_DISABLE) failed" );
|
|
|
a2eaef |
return PAPI_ESYS;
|
|
|
a2eaef |
}
|
|
|
a2eaef |
|
|
|
a2eaef |
@@ -514,7 +528,7 @@ check_scheduability( pe_context_t *ctx, pe_control_t *ctl, int idx )
|
|
|
a2eaef |
retval=ioctl( ctl->events[i].event_fd, PERF_EVENT_IOC_RESET, NULL );
|
|
|
a2eaef |
if (retval == -1) {
|
|
|
a2eaef |
PAPIERROR( "ioctl(PERF_EVENT_IOC_RESET) #%d/%d %d "
|
|
|
a2eaef |
- "(fd %d)failed.\n",
|
|
|
a2eaef |
+ "(fd %d)failed",
|
|
|
a2eaef |
i,ctl->num_events,idx,ctl->events[i].event_fd);
|
|
|
a2eaef |
return PAPI_ESYS;
|
|
|
a2eaef |
}
|
|
|
a2eaef |
@@ -794,7 +808,7 @@ close_pe_events( pe_context_t *ctx, pe_control_t *ctl )
|
|
|
a2eaef |
if (ctl->num_events!=num_closed) {
|
|
|
a2eaef |
if (ctl->num_events!=(num_closed+events_not_opened)) {
|
|
|
a2eaef |
PAPIERROR("Didn't close all events: "
|
|
|
a2eaef |
- "Closed %d Not Opened: %d Expected %d\n",
|
|
|
a2eaef |
+ "Closed %d Not Opened: %d Expected %d",
|
|
|
a2eaef |
num_closed,events_not_opened,ctl->num_events);
|
|
|
a2eaef |
return PAPI_EBUG;
|
|
|
a2eaef |
}
|
|
|
a2eaef |
@@ -824,9 +838,7 @@ _pe_set_domain( hwd_control_state_t *ctl, int domain)
|
|
|
a2eaef |
int i;
|
|
|
a2eaef |
pe_control_t *pe_ctl = ( pe_control_t *) ctl;
|
|
|
a2eaef |
|
|
|
a2eaef |
- SUBDBG("old control domain %d, new domain %d\n",
|
|
|
a2eaef |
- pe_ctl->domain,domain);
|
|
|
a2eaef |
-
|
|
|
a2eaef |
+ SUBDBG("old control domain %d, new domain %d\n", pe_ctl->domain,domain);
|
|
|
a2eaef |
pe_ctl->domain = domain;
|
|
|
a2eaef |
|
|
|
a2eaef |
/* Force the domain on all events */
|
|
|
a2eaef |
@@ -915,6 +927,8 @@ int
|
|
|
a2eaef |
_pe_read( hwd_context_t *ctx, hwd_control_state_t *ctl,
|
|
|
a2eaef |
long long **events, int flags )
|
|
|
a2eaef |
{
|
|
|
a2eaef |
+ SUBDBG("ENTER: ctx: %p, ctl: %p, events: %p, flags: %#x\n", ctx, ctl, events, flags);
|
|
|
a2eaef |
+
|
|
|
a2eaef |
( void ) flags; /*unused */
|
|
|
a2eaef |
int i, ret = -1;
|
|
|
a2eaef |
pe_context_t *pe_ctx = ( pe_context_t *) ctx;
|
|
|
a2eaef |
@@ -964,7 +978,7 @@ _pe_read( hwd_context_t *ctx, hwd_control_state_t *ctl,
|
|
|
a2eaef |
|
|
|
a2eaef |
/* We should read 3 64-bit values from the counter */
|
|
|
a2eaef |
if (ret<(signed)(3*sizeof(long long))) {
|
|
|
a2eaef |
- PAPIERROR("Error! short read!\n");
|
|
|
a2eaef |
+ PAPIERROR("Error! short read");
|
|
|
a2eaef |
return PAPI_ESYS;
|
|
|
a2eaef |
}
|
|
|
a2eaef |
|
|
|
a2eaef |
@@ -1020,8 +1034,8 @@ _pe_read( hwd_context_t *ctx, hwd_control_state_t *ctl,
|
|
|
a2eaef |
|
|
|
a2eaef |
/* we should read one 64-bit value from each counter */
|
|
|
a2eaef |
if (ret!=sizeof(long long)) {
|
|
|
a2eaef |
- PAPIERROR("Error! short read!\n");
|
|
|
a2eaef |
- PAPIERROR("read: fd: %2d, tid: %ld, cpu: %d, ret: %d\n",
|
|
|
a2eaef |
+ PAPIERROR("Error! short read");
|
|
|
a2eaef |
+ PAPIERROR("read: fd: %2d, tid: %ld, cpu: %d, ret: %d",
|
|
|
a2eaef |
pe_ctl->events[i].event_fd,
|
|
|
a2eaef |
(long)pe_ctl->tid, pe_ctl->cpu, ret);
|
|
|
a2eaef |
return PAPI_ESYS;
|
|
|
a2eaef |
@@ -1042,7 +1056,7 @@ _pe_read( hwd_context_t *ctx, hwd_control_state_t *ctl,
|
|
|
a2eaef |
|
|
|
a2eaef |
else {
|
|
|
a2eaef |
if (pe_ctl->events[0].group_leader_fd!=-1) {
|
|
|
a2eaef |
- PAPIERROR("Was expecting group leader!\n");
|
|
|
a2eaef |
+ PAPIERROR("Was expecting group leader");
|
|
|
a2eaef |
}
|
|
|
a2eaef |
|
|
|
a2eaef |
ret = read( pe_ctl->events[0].event_fd, papi_pe_buffer,
|
|
|
a2eaef |
@@ -1056,7 +1070,7 @@ _pe_read( hwd_context_t *ctx, hwd_control_state_t *ctl,
|
|
|
a2eaef |
/* we read 1 64-bit value (number of events) then */
|
|
|
a2eaef |
/* num_events more 64-bit values that hold the counts */
|
|
|
a2eaef |
if (ret<(signed)((1+pe_ctl->num_events)*sizeof(long long))) {
|
|
|
a2eaef |
- PAPIERROR("Error! short read!\n");
|
|
|
a2eaef |
+ PAPIERROR("Error! short read");
|
|
|
a2eaef |
return PAPI_ESYS;
|
|
|
a2eaef |
}
|
|
|
a2eaef |
|
|
|
a2eaef |
@@ -1072,7 +1086,7 @@ _pe_read( hwd_context_t *ctx, hwd_control_state_t *ctl,
|
|
|
a2eaef |
|
|
|
a2eaef |
/* Make sure the kernel agrees with how many events we have */
|
|
|
a2eaef |
if (papi_pe_buffer[0]!=pe_ctl->num_events) {
|
|
|
a2eaef |
- PAPIERROR("Error! Wrong number of events!\n");
|
|
|
a2eaef |
+ PAPIERROR("Error! Wrong number of events");
|
|
|
a2eaef |
return PAPI_ESYS;
|
|
|
a2eaef |
}
|
|
|
a2eaef |
|
|
|
a2eaef |
@@ -1106,6 +1120,7 @@ _pe_read( hwd_context_t *ctx, hwd_control_state_t *ctl,
|
|
|
a2eaef |
/* point PAPI to the values we read */
|
|
|
a2eaef |
*events = pe_ctl->counts;
|
|
|
a2eaef |
|
|
|
a2eaef |
+ SUBDBG("EXIT: *events: %p\n", *events);
|
|
|
a2eaef |
return PAPI_OK;
|
|
|
a2eaef |
}
|
|
|
a2eaef |
|
|
|
a2eaef |
@@ -1134,7 +1149,7 @@ _pe_start( hwd_context_t *ctx, hwd_control_state_t *ctl )
|
|
|
a2eaef |
|
|
|
a2eaef |
/* ioctls always return -1 on failure */
|
|
|
a2eaef |
if (ret == -1) {
|
|
|
a2eaef |
- PAPIERROR("ioctl(PERF_EVENT_IOC_ENABLE) failed.\n");
|
|
|
a2eaef |
+ PAPIERROR("ioctl(PERF_EVENT_IOC_ENABLE) failed");
|
|
|
a2eaef |
return PAPI_ESYS;
|
|
|
a2eaef |
}
|
|
|
a2eaef |
|
|
|
a2eaef |
@@ -1143,7 +1158,7 @@ _pe_start( hwd_context_t *ctx, hwd_control_state_t *ctl )
|
|
|
a2eaef |
}
|
|
|
a2eaef |
|
|
|
a2eaef |
if (!did_something) {
|
|
|
a2eaef |
- PAPIERROR("Did not enable any counters.\n");
|
|
|
a2eaef |
+ PAPIERROR("Did not enable any counters");
|
|
|
a2eaef |
return PAPI_EBUG;
|
|
|
a2eaef |
}
|
|
|
a2eaef |
|
|
|
a2eaef |
@@ -1157,6 +1172,7 @@ _pe_start( hwd_context_t *ctx, hwd_control_state_t *ctl )
|
|
|
a2eaef |
int
|
|
|
a2eaef |
_pe_stop( hwd_context_t *ctx, hwd_control_state_t *ctl )
|
|
|
a2eaef |
{
|
|
|
a2eaef |
+ SUBDBG( "ENTER: ctx: %p, ctl: %p\n", ctx, ctl);
|
|
|
a2eaef |
|
|
|
a2eaef |
int ret;
|
|
|
a2eaef |
int i;
|
|
|
a2eaef |
@@ -1178,6 +1194,7 @@ _pe_stop( hwd_context_t *ctx, hwd_control_state_t *ctl )
|
|
|
a2eaef |
|
|
|
a2eaef |
pe_ctx->state &= ~PERF_EVENTS_RUNNING;
|
|
|
a2eaef |
|
|
|
a2eaef |
+ SUBDBG( "EXIT:\n");
|
|
|
a2eaef |
return PAPI_OK;
|
|
|
a2eaef |
}
|
|
|
a2eaef |
|
|
|
a2eaef |
@@ -1190,6 +1207,7 @@ _pe_update_control_state( hwd_control_state_t *ctl,
|
|
|
a2eaef |
NativeInfo_t *native,
|
|
|
a2eaef |
int count, hwd_context_t *ctx )
|
|
|
a2eaef |
{
|
|
|
a2eaef |
+ SUBDBG( "ENTER: ctl: %p, native: %p, count: %d, ctx: %p\n", ctl, native, count, ctx);
|
|
|
a2eaef |
int i = 0, ret;
|
|
|
a2eaef |
pe_context_t *pe_ctx = ( pe_context_t *) ctx;
|
|
|
a2eaef |
pe_control_t *pe_ctl = ( pe_control_t *) ctl;
|
|
|
a2eaef |
@@ -1202,7 +1220,7 @@ _pe_update_control_state( hwd_control_state_t *ctl,
|
|
|
a2eaef |
/* Calling with count==0 should be OK, it's how things are deallocated */
|
|
|
a2eaef |
/* when an eventset is destroyed. */
|
|
|
a2eaef |
if ( count == 0 ) {
|
|
|
a2eaef |
- SUBDBG( "Called with count == 0\n" );
|
|
|
a2eaef |
+ SUBDBG( "EXIT: Called with count == 0\n" );
|
|
|
a2eaef |
return PAPI_OK;
|
|
|
a2eaef |
}
|
|
|
a2eaef |
|
|
|
a2eaef |
@@ -1236,15 +1254,16 @@ _pe_update_control_state( hwd_control_state_t *ctl,
|
|
|
a2eaef |
pe_ctl->num_events = count;
|
|
|
a2eaef |
_pe_set_domain( ctl, pe_ctl->domain );
|
|
|
a2eaef |
|
|
|
a2eaef |
- /* actuall open the events */
|
|
|
a2eaef |
+ /* actually open the events */
|
|
|
a2eaef |
/* (why is this a separate function?) */
|
|
|
a2eaef |
ret = open_pe_events( pe_ctx, pe_ctl );
|
|
|
a2eaef |
if ( ret != PAPI_OK ) {
|
|
|
a2eaef |
- SUBDBG("open_pe_events failed\n");
|
|
|
a2eaef |
+ SUBDBG("EXIT: open_pe_events returned: %d\n", ret);
|
|
|
a2eaef |
/* Restore values ? */
|
|
|
a2eaef |
return ret;
|
|
|
a2eaef |
}
|
|
|
a2eaef |
|
|
|
a2eaef |
+ SUBDBG( "EXIT:\n" );
|
|
|
a2eaef |
return PAPI_OK;
|
|
|
a2eaef |
}
|
|
|
a2eaef |
|
|
|
a2eaef |
@@ -1914,7 +1933,7 @@ _pe_dispatch_timer( int n, hwd_siginfo_t *info, void *uc)
|
|
|
a2eaef |
}
|
|
|
a2eaef |
|
|
|
a2eaef |
if (ioctl( fd, PERF_EVENT_IOC_DISABLE, NULL ) == -1 ) {
|
|
|
a2eaef |
- PAPIERROR("ioctl(PERF_EVENT_IOC_DISABLE) failed.\n");
|
|
|
a2eaef |
+ PAPIERROR("ioctl(PERF_EVENT_IOC_DISABLE) failed");
|
|
|
a2eaef |
}
|
|
|
a2eaef |
|
|
|
a2eaef |
if ( ( thread->running_eventset[cidx]->state & PAPI_PROFILING ) &&
|