|
|
32cd9f |
commit 7a6ae407b62615d3ffa9b0d2ac17771b7fc63056
|
|
|
32cd9f |
Author: Vince Weaver <vince@deater.net>
|
|
|
32cd9f |
Date: Thu Sep 27 23:47:58 2018 -0400
|
|
|
32cd9f |
|
|
|
32cd9f |
perf_event: avoid floating point exception if running is 0
|
|
|
32cd9f |
|
|
|
32cd9f |
The perf_event interface isn't supposed to return 0 for running, but
|
|
|
32cd9f |
it happens occasionally. So be sure not to divide by zero if this
|
|
|
32cd9f |
happens. This makes the rdpmc code match the generic perf code in this
|
|
|
32cd9f |
case.
|
|
|
32cd9f |
|
|
|
32cd9f |
This is in response to bitbucket issue #52
|
|
|
32cd9f |
|
|
|
32cd9f |
diff --git a/src/components/perf_event/perf_event.c b/src/components/perf_event/perf_event.c
|
|
|
32cd9f |
index 7fd753ed..82b7d398 100644
|
|
|
32cd9f |
--- a/src/components/perf_event/perf_event.c
|
|
|
32cd9f |
+++ b/src/components/perf_event/perf_event.c
|
|
|
32cd9f |
@@ -1099,14 +1099,23 @@ _pe_rdpmc_read( hwd_context_t *ctx, hwd_control_state_t *ctl,
|
|
|
32cd9f |
count = mmap_read_self(pe_ctl->events[i].mmap_buf,
|
|
|
32cd9f |
&enabled,&running);
|
|
|
32cd9f |
|
|
|
32cd9f |
- /* TODO: error checking? */
|
|
|
32cd9f |
+ /* TODO: more error checking? */
|
|
|
32cd9f |
|
|
|
32cd9f |
/* Handle multiplexing case */
|
|
|
32cd9f |
- if (enabled!=running) {
|
|
|
32cd9f |
+ if (enabled == running) {
|
|
|
32cd9f |
+ /* no adjustment needed */
|
|
|
32cd9f |
+ }
|
|
|
32cd9f |
+ else if (enabled && running) {
|
|
|
32cd9f |
adjusted = (enabled * 128LL) / running;
|
|
|
32cd9f |
adjusted = adjusted * count;
|
|
|
32cd9f |
adjusted = adjusted / 128LL;
|
|
|
32cd9f |
count = adjusted;
|
|
|
32cd9f |
+ } else {
|
|
|
32cd9f |
+ /* This should not happen, but we have had it reported */
|
|
|
32cd9f |
+ SUBDBG("perf_event kernel bug(?) count, enabled, "
|
|
|
32cd9f |
+ "running: %lld, %lld, %lld\n",
|
|
|
32cd9f |
+ papi_pe_buffer[0],enabled,running);
|
|
|
32cd9f |
+
|
|
|
32cd9f |
}
|
|
|
32cd9f |
|
|
|
32cd9f |
pe_ctl->counts[i] = count;
|