Skip to content

Commit 74545f6

Browse files
David Carrillo-CisnerosIngo Molnar
authored andcommitted
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 <[email protected]> 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]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 4e06d4f commit 74545f6

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

arch/x86/events/intel/cstate.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ static struct pmu cstate_core_pmu = {
434434
.stop = cstate_pmu_event_stop,
435435
.read = cstate_pmu_event_update,
436436
.capabilities = PERF_PMU_CAP_NO_INTERRUPT,
437+
.module = THIS_MODULE,
437438
};
438439

439440
static struct pmu cstate_pkg_pmu = {
@@ -447,6 +448,7 @@ static struct pmu cstate_pkg_pmu = {
447448
.stop = cstate_pmu_event_stop,
448449
.read = cstate_pmu_event_update,
449450
.capabilities = PERF_PMU_CAP_NO_INTERRUPT,
451+
.module = THIS_MODULE,
450452
};
451453

452454
static const struct cstate_model nhm_cstates __initconst = {

arch/x86/events/intel/rapl.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,7 @@ static int __init init_rapl_pmus(void)
697697
rapl_pmus->pmu.start = rapl_pmu_event_start;
698698
rapl_pmus->pmu.stop = rapl_pmu_event_stop;
699699
rapl_pmus->pmu.read = rapl_pmu_event_read;
700+
rapl_pmus->pmu.module = THIS_MODULE;
700701
return 0;
701702
}
702703

arch/x86/events/intel/uncore.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,7 @@ static int uncore_pmu_register(struct intel_uncore_pmu *pmu)
733733
.start = uncore_pmu_event_start,
734734
.stop = uncore_pmu_event_stop,
735735
.read = uncore_pmu_event_read,
736+
.module = THIS_MODULE,
736737
};
737738
} else {
738739
pmu->pmu = *pmu->type->pmu;

0 commit comments

Comments
 (0)