From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932563AbcFCKvB (ORCPT ); Fri, 3 Jun 2016 06:51:01 -0400 Received: from terminus.zytor.com ([198.137.202.10]:56156 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932160AbcFCKvA (ORCPT ); Fri, 3 Jun 2016 06:51:00 -0400 Date: Fri, 3 Jun 2016 03:50:17 -0700 From: tip-bot for Kan Liang Message-ID: Cc: vincent.weaver@maine.edu, tglx@linutronix.de, kan.liang@intel.com, alexander.shishkin@linux.intel.com, torvalds@linux-foundation.org, peterz@infradead.org, hpa@zytor.com, mingo@kernel.org, jolsa@redhat.com, linux-kernel@vger.kernel.org, acme@redhat.com, eranian@google.com Reply-To: alexander.shishkin@linux.intel.com, torvalds@linux-foundation.org, kan.liang@intel.com, vincent.weaver@maine.edu, tglx@linutronix.de, hpa@zytor.com, mingo@kernel.org, peterz@infradead.org, linux-kernel@vger.kernel.org, jolsa@redhat.com, eranian@google.com, acme@redhat.com In-Reply-To: <1462260366-3160-1-git-send-email-kan.liang@intel.com> References: <1462260366-3160-1-git-send-email-kan.liang@intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf/core: Fix implicitly enable dynamic interrupt throttle Git-Commit-ID: ab7fdefba68f66c8523571c3b3a940635d781824 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: ab7fdefba68f66c8523571c3b3a940635d781824 Gitweb: http://git.kernel.org/tip/ab7fdefba68f66c8523571c3b3a940635d781824 Author: Kan Liang AuthorDate: Tue, 3 May 2016 00:26:06 -0700 Committer: Ingo Molnar CommitDate: Fri, 3 Jun 2016 09:40:16 +0200 perf/core: Fix implicitly enable dynamic interrupt throttle This patch fixes an issue which was introduced by commit: 91a612eea9a3 ("perf/core: Fix dynamic interrupt throttle") ... which commit unconditionally sets the perf_sample_allowed_ns value to !0. But that could trigger a bug in the following corner case: The user can disable the dynamic interrupt throttle mechanism by setting perf_cpu_time_max_percent to 0. Then they change perf_event_max_sample_rate. For this case, the mechanism will be enabled implicitly, because perf_sample_allowed_ns becomes !0 - which is not what we want. This patch only updates perf_sample_allowed_ns when the dynamic interrupt throttle mechanism is enabled. Signed-off-by: Kan Liang Signed-off-by: Peter Zijlstra (Intel) Cc: Alexander Shishkin Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Stephane Eranian Cc: Thomas Gleixner Cc: Vince Weaver Cc: acme@kernel.org Link: http://lkml.kernel.org/r/1462260366-3160-1-git-send-email-kan.liang@intel.com Signed-off-by: Ingo Molnar --- kernel/events/core.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/events/core.c b/kernel/events/core.c index f54454e..f94f164 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -397,6 +397,13 @@ int perf_proc_update_handler(struct ctl_table *table, int write, if (ret || !write) return ret; + /* + * If throttling is disabled don't allow the write: + */ + if (sysctl_perf_cpu_time_max_percent == 100 || + sysctl_perf_cpu_time_max_percent == 0) + return -EINVAL; + max_samples_per_tick = DIV_ROUND_UP(sysctl_perf_event_sample_rate, HZ); perf_sample_period_ns = NSEC_PER_SEC / sysctl_perf_event_sample_rate; update_perf_cpu_limits();