From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938646AbdAEPJn (ORCPT ); Thu, 5 Jan 2017 10:09:43 -0500 Received: from terminus.zytor.com ([198.137.202.10]:43894 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S938611AbdAEPIh (ORCPT ); Thu, 5 Jan 2017 10:08:37 -0500 Date: Thu, 5 Jan 2017 07:07:05 -0800 From: tip-bot for David Carrillo-Cisneros Message-ID: Cc: peterz@infradead.org, pjt@google.com, bp@suse.de, mingo@kernel.org, torvalds@linux-foundation.org, eranian@google.com, alexander.shishkin@linux.intel.com, dave.hansen@linux.intel.com, tglx@linutronix.de, jolsa@redhat.com, srinivas.pandruvada@linux.intel.com, acme@redhat.com, hpa@zytor.com, kan.liang@intel.com, linux-kernel@vger.kernel.org, davidcc@google.com Reply-To: srinivas.pandruvada@linux.intel.com, tglx@linutronix.de, jolsa@redhat.com, dave.hansen@linux.intel.com, davidcc@google.com, linux-kernel@vger.kernel.org, kan.liang@intel.com, acme@redhat.com, hpa@zytor.com, peterz@infradead.org, bp@suse.de, pjt@google.com, alexander.shishkin@linux.intel.com, eranian@google.com, mingo@kernel.org, torvalds@linux-foundation.org In-Reply-To: <1482455860-116269-1-git-send-email-davidcc@google.com> References: <1482455860-116269-1-git-send-email-davidcc@google.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf/x86: Set pmu->module in Intel PMU modules Git-Commit-ID: 74545f63890e38520eb4d1dbedcadaa9c0dbc824 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: 74545f63890e38520eb4d1dbedcadaa9c0dbc824 Gitweb: http://git.kernel.org/tip/74545f63890e38520eb4d1dbedcadaa9c0dbc824 Author: David Carrillo-Cisneros AuthorDate: Thu, 22 Dec 2016 17:17:40 -0800 Committer: Ingo Molnar CommitDate: Thu, 5 Jan 2017 09:13:55 +0100 perf/x86: Set pmu->module in Intel PMU modules The conversion of Intel PMU drivers into modules did not include reference counting. The machine will crash when attempting to access deleted code if an event from a module PMU is started and the module removed before the event is destroyed. i.e. this crashes the machine: $ insmod intel-rapl-perf.ko $ perf stat -e power/energy-cores/ -C 0 & $ rmmod intel-rapl-perf.ko Set THIS_MODULE to pmu->module in Intel module PMUs so that generic code can handle reference counting and deny rmmod while an event still exists. Signed-off-by: David Carrillo-Cisneros Cc: Alexander Shishkin Cc: Arnaldo Carvalho de Melo Cc: Borislav Petkov Cc: Dave Hansen Cc: Jiri Olsa Cc: Kan Liang Cc: Linus Torvalds Cc: Paul Turner Cc: Peter Zijlstra Cc: Srinivas Pandruvada Cc: Stephane Eranian Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1482455860-116269-1-git-send-email-davidcc@google.com Signed-off-by: Ingo Molnar --- arch/x86/events/intel/cstate.c | 2 ++ arch/x86/events/intel/rapl.c | 1 + arch/x86/events/intel/uncore.c | 1 + 3 files changed, 4 insertions(+) diff --git a/arch/x86/events/intel/cstate.c b/arch/x86/events/intel/cstate.c index fec8a46..1076c9a 100644 --- a/arch/x86/events/intel/cstate.c +++ b/arch/x86/events/intel/cstate.c @@ -434,6 +434,7 @@ static struct pmu cstate_core_pmu = { .stop = cstate_pmu_event_stop, .read = cstate_pmu_event_update, .capabilities = PERF_PMU_CAP_NO_INTERRUPT, + .module = THIS_MODULE, }; static struct pmu cstate_pkg_pmu = { @@ -447,6 +448,7 @@ static struct pmu cstate_pkg_pmu = { .stop = cstate_pmu_event_stop, .read = cstate_pmu_event_update, .capabilities = PERF_PMU_CAP_NO_INTERRUPT, + .module = THIS_MODULE, }; static const struct cstate_model nhm_cstates __initconst = { diff --git a/arch/x86/events/intel/rapl.c b/arch/x86/events/intel/rapl.c index bd34124..17c3564 100644 --- a/arch/x86/events/intel/rapl.c +++ b/arch/x86/events/intel/rapl.c @@ -697,6 +697,7 @@ static int __init init_rapl_pmus(void) rapl_pmus->pmu.start = rapl_pmu_event_start; rapl_pmus->pmu.stop = rapl_pmu_event_stop; rapl_pmus->pmu.read = rapl_pmu_event_read; + rapl_pmus->pmu.module = THIS_MODULE; return 0; } diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c index 97c246f..8c4ccdc 100644 --- a/arch/x86/events/intel/uncore.c +++ b/arch/x86/events/intel/uncore.c @@ -733,6 +733,7 @@ static int uncore_pmu_register(struct intel_uncore_pmu *pmu) .start = uncore_pmu_event_start, .stop = uncore_pmu_event_stop, .read = uncore_pmu_event_read, + .module = THIS_MODULE, }; } else { pmu->pmu = *pmu->type->pmu;