From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756232AbbLDLu7 (ORCPT ); Fri, 4 Dec 2015 06:50:59 -0500 Received: from terminus.zytor.com ([198.137.202.10]:59916 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752612AbbLDLu4 (ORCPT ); Fri, 4 Dec 2015 06:50:56 -0500 Date: Fri, 4 Dec 2015 03:50:10 -0800 From: tip-bot for Peter Zijlstra Message-ID: Cc: dvyukov@google.com, stable@vger.kernel.org, linux-kernel@vger.kernel.org, sasha.levin@oracle.com, hpa@zytor.com, acme@kernel.org, acme@redhat.com, glider@google.com, edumazet@google.com, tglx@linutronix.de, vincent.weaver@maine.edu, jolsa@redhat.com, mingo@kernel.org, torvalds@linux-foundation.org, kcc@google.com, peterz@infradead.org, eranian@google.com Reply-To: sasha.levin@oracle.com, hpa@zytor.com, dvyukov@google.com, stable@vger.kernel.org, linux-kernel@vger.kernel.org, jolsa@redhat.com, tglx@linutronix.de, vincent.weaver@maine.edu, mingo@kernel.org, torvalds@linux-foundation.org, kcc@google.com, eranian@google.com, peterz@infradead.org, acme@kernel.org, acme@redhat.com, glider@google.com, edumazet@google.com In-Reply-To: <20151130115615.GJ17308@twins.programming.kicks-ass.net> References: <20151130115615.GJ17308@twins.programming.kicks-ass.net> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf: Fix PERF_EVENT_IOC_PERIOD deadlock Git-Commit-ID: 642c2d671ceff40e9453203ea0c66e991e11e249 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 Commit-ID: 642c2d671ceff40e9453203ea0c66e991e11e249 Gitweb: http://git.kernel.org/tip/642c2d671ceff40e9453203ea0c66e991e11e249 Author: Peter Zijlstra AuthorDate: Mon, 30 Nov 2015 12:56:15 +0100 Committer: Ingo Molnar CommitDate: Fri, 4 Dec 2015 10:08:03 +0100 perf: Fix PERF_EVENT_IOC_PERIOD deadlock Dmitry reported a fairly silly recursive lock deadlock for PERF_EVENT_IOC_PERIOD, fix this by explicitly doing the inactive part of __perf_event_period() instead of calling that function. Reported-by: Dmitry Vyukov Signed-off-by: Peter Zijlstra (Intel) Cc: Cc: Alexander Potapenko Cc: Arnaldo Carvalho de Melo Cc: Arnaldo Carvalho de Melo Cc: Eric Dumazet Cc: Jiri Olsa Cc: Kostya Serebryany Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Sasha Levin Cc: Stephane Eranian Cc: Thomas Gleixner Cc: Vince Weaver Fixes: c7999c6f3fed ("perf: Fix PERF_EVENT_IOC_PERIOD migration race") Link: http://lkml.kernel.org/r/20151130115615.GJ17308@twins.programming.kicks-ass.net Signed-off-by: Ingo Molnar --- kernel/events/core.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index 5854fcf..49a5118 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -4225,7 +4225,14 @@ retry: goto retry; } - __perf_event_period(&pe); + if (event->attr.freq) { + event->attr.sample_freq = value; + } else { + event->attr.sample_period = value; + event->hw.sample_period = value; + } + + local64_set(&event->hw.period_left, 0); raw_spin_unlock_irq(&ctx->lock); return 0;