Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753825AbcCUJwg (ORCPT ); Mon, 21 Mar 2016 05:52:36 -0400 Received: from [198.137.202.10] ([198.137.202.10]:45184 "EHLO terminus.zytor.com" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751981AbcCUJw0 (ORCPT ); Mon, 21 Mar 2016 05:52:26 -0400 Date: Mon, 21 Mar 2016 02:48:39 -0700 From: tip-bot for Peter Zijlstra Message-ID: Cc: mingo@kernel.org, dvlasenk@redhat.com, hpa@zytor.com, linux-kernel@vger.kernel.org, eranian@google.com, vincent.weaver@maine.edu, peterz@infradead.org, brgerst@gmail.com, acme@redhat.com, bp@alien8.de, dsahern@gmail.com, tglx@linutronix.de, jolsa@redhat.com, luto@amacapital.net, torvalds@linux-foundation.org, namhyung@kernel.org, alexander.shishkin@linux.intel.com Reply-To: tglx@linutronix.de, dsahern@gmail.com, bp@alien8.de, alexander.shishkin@linux.intel.com, namhyung@kernel.org, torvalds@linux-foundation.org, luto@amacapital.net, jolsa@redhat.com, eranian@google.com, linux-kernel@vger.kernel.org, hpa@zytor.com, dvlasenk@redhat.com, mingo@kernel.org, acme@redhat.com, brgerst@gmail.com, peterz@infradead.org, vincent.weaver@maine.edu In-Reply-To: <20160310143924.GR6356@twins.programming.kicks-ass.net> References: <20160310143924.GR6356@twins.programming.kicks-ass.net> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf/core: Fix the unthrottle logic Git-Commit-ID: 1e02cd40f15190b78fcc6b3f50c952fb4028e9a5 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2279 Lines: 62 Commit-ID: 1e02cd40f15190b78fcc6b3f50c952fb4028e9a5 Gitweb: http://git.kernel.org/tip/1e02cd40f15190b78fcc6b3f50c952fb4028e9a5 Author: Peter Zijlstra AuthorDate: Thu, 10 Mar 2016 15:39:24 +0100 Committer: Ingo Molnar 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) Reviewed-by: Alexander Shishkin Cc: Andy Lutomirski Cc: Arnaldo Carvalho de Melo Cc: Borislav Petkov Cc: Brian Gerst Cc: David Ahern Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Jiri Olsa Cc: Linus Torvalds Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Cc: Thomas Gleixner Cc: Vince Weaver Cc: dvyukov@google.com Cc: oleg@redhat.com Cc: panand@redhat.com Cc: sasha.levin@oracle.com Cc: vince@deater.net Link: http://lkml.kernel.org/r/20160310143924.GR6356@twins.programming.kicks-ass.net Signed-off-by: Ingo Molnar --- 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); }