From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756055AbcECOwN (ORCPT ); Tue, 3 May 2016 10:52:13 -0400 Received: from mga03.intel.com ([134.134.136.65]:6320 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755482AbcECOwM (ORCPT ); Tue, 3 May 2016 10:52:12 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,572,1455004800"; d="scan'208";a="957919978" From: kan.liang@intel.com To: peterz@infradead.org Cc: mingo@redhat.com, acme@kernel.org, alexander.shishkin@linux.intel.com, ak@linux.intel.com, linux-kernel@vger.kernel.org, Kan Liang Subject: [PATCH 1/1] perf/core: fix implicitly enable dynamic interrupt throttle Date: Tue, 3 May 2016 00:26:06 -0700 Message-Id: <1462260366-3160-1-git-send-email-kan.liang@intel.com> X-Mailer: git-send-email 2.5.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kan Liang This patch fixes an issue which was introduced from 'commit 91a612eea9a3 ("perf/core: Fix dynamic interrupt throttle")' The old patch unconditionally sets the perf_sample_allowed_ns value to !0. But that could trigger an issue 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 changes perf_event_max_sample_rate. For this case, the mechanism will be enabled implicitly, because perf_sample_allowed_ns becomes !0. This patch only updates the perf_sample_allowed_ns when the dynamic interrupt throttle mechanism is enabled. Signed-off-by: Kan Liang --- kernel/events/core.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kernel/events/core.c b/kernel/events/core.c index 4e2ebf6..4042a3d 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -375,6 +375,14 @@ static void update_perf_cpu_limits(void) { u64 tmp = perf_sample_period_ns; + /* + * Don't update the perf_sample_allowed_ns, + * if the dynamic interrupt throttle mechanism is disabled. + */ + if (sysctl_perf_cpu_time_max_percent == 100 || + sysctl_perf_cpu_time_max_percent == 0) + return; + tmp *= sysctl_perf_cpu_time_max_percent; tmp = div_u64(tmp, 100); if (!tmp) -- 2.5.0