Skip to contentSkip to conversation

Patch "perf/x86: Set pmu->module in Intel PMU modules" has been added to the 4.9-stable tree

PATCH [email protected] 1 participant 1 message Aug 4, 2017

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

    perf/x86: Set pmu->module in Intel PMU modules

to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
perf-x86-set-pmu-module-in-intel-pmu-modules.patch
and it can be found in the queue-4.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From foo@baz Fri Aug 4 15:30:10 PDT 2017

From: David Carrillo-Cisneros <[email protected]>
Date: Thu, 22 Dec 2016 17:17:40 -0800
Subject: perf/x86: Set pmu->module in Intel PMU modules

From: David Carrillo-Cisneros <[email protected]>

[ Upstream commit 74545f63890e38520eb4d1dbedcadaa9c0dbc824 ]

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.

Cc Alexander Shishkin <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Dave Hansen <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Kan Liang <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Paul Turner <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Srinivas Pandruvada <[email protected]>
Cc Stephane Eranian <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
 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(+)
arch/x86/events/intel/cstate.c +2 -0
@@ -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 = {
arch/x86/events/intel/rapl.c +1 -0
@@ -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;
 }
 
arch/x86/events/intel/uncore.c +1 -0
@@ -733,6 +733,7 @@ static int uncore_pmu_register(struct in
 			.start		= uncore_pmu_event_start,
 			.stop		= uncore_pmu_event_stop,
 			.read		= uncore_pmu_event_read,
+			.module		= THIS_MODULE,
 		};
 	} else {
 		pmu->pmu = *pmu->type->pmu;

Patches currently in stable-queue which might be from [email protected] are

queue-4.9/perf-x86-set-pmu-module-in-intel-pmu-modules.patch