Commit-ID:  1e02cd40f15190b78fcc6b3f50c952fb4028e9a5
Gitweb:     http://git.kernel.org/tip/1e02cd40f15190b78fcc6b3f50c952fb4028e9a5
Author:     Peter Zijlstra <pet...@infradead.org>
AuthorDate: Thu, 10 Mar 2016 15:39:24 +0100
Committer:  Ingo Molnar <mi...@kernel.org>
CommitDate: Mon, 21 Mar 2016 09:08:14 +0100

perf/core: Fix the unthrottle logic

Its possible to IOC_PERIOD while the event is throttled, this would
re-start the event and the next tick would then try to unthrottle it,
and find the event wasn't actually stopped anymore.

This would tickle a WARN in the x86-pmu code which isn't expecting to
start a !stopped event.

Signed-off-by: Peter Zijlstra (Intel) <pet...@infradead.org>
Reviewed-by: Alexander Shishkin <alexander.shish...@linux.intel.com>
Cc: Andy Lutomirski <l...@amacapital.net>
Cc: Arnaldo Carvalho de Melo <a...@redhat.com>
Cc: Borislav Petkov <b...@alien8.de>
Cc: Brian Gerst <brge...@gmail.com>
Cc: David Ahern <dsah...@gmail.com>
Cc: Denys Vlasenko <dvlas...@redhat.com>
Cc: H. Peter Anvin <h...@zytor.com>
Cc: Jiri Olsa <jo...@redhat.com>
Cc: Linus Torvalds <torva...@linux-foundation.org>
Cc: Namhyung Kim <namhy...@kernel.org>
Cc: Peter Zijlstra <pet...@infradead.org>
Cc: Stephane Eranian <eran...@google.com>
Cc: Thomas Gleixner <t...@linutronix.de>
Cc: Vince Weaver <vincent.wea...@maine.edu>
Cc: dvyu...@google.com
Cc: o...@redhat.com
Cc: pan...@redhat.com
Cc: sasha.le...@oracle.com
Cc: vi...@deater.net
Link: 
http://lkml.kernel.org/r/20160310143924.gr6...@twins.programming.kicks-ass.net
Signed-off-by: Ingo Molnar <mi...@kernel.org>
---
 kernel/events/core.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 712570d..d394773 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -4210,6 +4210,14 @@ static void __perf_event_period(struct perf_event *event,
        active = (event->state == PERF_EVENT_STATE_ACTIVE);
        if (active) {
                perf_pmu_disable(ctx->pmu);
+               /*
+                * We could be throttled; unthrottle now to avoid the tick
+                * trying to unthrottle while we already re-started the event.
+                */
+               if (event->hw.interrupts == MAX_INTERRUPTS) {
+                       event->hw.interrupts = 0;
+                       perf_log_throttle(event, 1);
+               }
                event->pmu->stop(event, PERF_EF_UPDATE);
        }
 

Reply via email to