[PATCH] perf/Power: PERF_EVENT_IOC_ENABLE does not reenable event
sukadev at linux.vnet.ibm.com
Sat Jan 12 06:11:17 EST 2013
If we disable a perf event because we exceeded the specified ->event_limit,
power_pmu_stop() sets the PERF_HES_STOPPED flag on the event.
If the application then re-enables the event using PERF_EVENT_IOC_ENABLE
ioctl, we don't seem to ever clear this STOPPED flag. Consequently, the
user space is never notified of the event.
Following message has more background and test case.
The problem reported there does not seem to occur on x86. My unverified theory:
Both x86 and Power clear the event->hw.state flag to 0 in their ->pmu_start()
operations. On X86 x86_pmu_start() is called from x86_pmu_enable(). But on
Power, power_pmu_start() is not called from power_pmu_enable().
Used the following test cases to verify that this patch works on latest PAPI.
$ papi.git/src/ctests/nonthread PAPI_TOT_CYC at 5000000
Signed-off-by: Sukadev Bhattiprolu <sukadev at linux.vnet.ibm.com>
arch/powerpc/perf/core-book3s.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
index aa2465e..a6faada 100644
@@ -880,8 +880,16 @@ static int power_pmu_add(struct perf_event *event, int ef_flags)
cpuhw->events[n0] = event->hw.config;
cpuhw->flags[n0] = event->hw.event_base;
+ * If this event was disabled in record_and_restart() because we
+ * exceeded the ->event_limit, this is probably a good time to
+ * re-enable the event ? If we don't reenable the event, we will
+ * never notify the user again about this event.
if (!(ef_flags & PERF_EF_START))
event->hw.state = PERF_HES_STOPPED | PERF_HES_UPTODATE;
+ event->hw.state &= ~PERF_HES_STOPPED;
* If group events scheduling transaction was started,
More information about the Linuxppc-dev