Skip to content

Commit c7afba3

Browse files
KAGA-KOKOIngo Molnar
authored andcommitted
x86/perf/intel/cstate: Modularize driver
Add the exit function and allow the driver to be built as a module. Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Vince Weaver <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent d29859e commit c7afba3

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

arch/x86/Kconfig.perf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,12 @@ config PERF_EVENTS_INTEL_RAPL
1616
Include support for Intel rapl performance events for power
1717
monitoring on modern processors.
1818

19+
config PERF_EVENTS_INTEL_CSTATE
20+
tristate "Intel cstate performance events"
21+
depends on PERF_EVENTS && CPU_SUP_INTEL && PCI
22+
default y
23+
---help---
24+
Include support for Intel cstate performance events for power
25+
monitoring on modern processors.
26+
1927
endmenu

arch/x86/events/intel/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
obj-$(CONFIG_CPU_SUP_INTEL) += core.o bts.o cqm.o
2-
obj-$(CONFIG_CPU_SUP_INTEL) += cstate.o ds.o knc.o
2+
obj-$(CONFIG_CPU_SUP_INTEL) += ds.o knc.o
33
obj-$(CONFIG_CPU_SUP_INTEL) += lbr.o p4.o p6.o pt.o
44
obj-$(CONFIG_PERF_EVENTS_INTEL_RAPL) += intel-rapl.o
55
intel-rapl-objs := rapl.o
66
obj-$(CONFIG_PERF_EVENTS_INTEL_UNCORE) += intel-uncore.o
77
intel-uncore-objs := uncore.o uncore_nhmex.o uncore_snb.o uncore_snbep.o
8+
obj-$(CONFIG_PERF_EVENTS_INTEL_CSTATE) += intel-cstate.o
9+
intel-cstate-objs := cstate.o

arch/x86/events/intel/cstate.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@
9191
#include <asm/cpu_device_id.h>
9292
#include "../perf_event.h"
9393

94+
MODULE_LICENSE("GPL");
95+
9496
#define DEFINE_CSTATE_FORMAT_ATTR(_var, _name, _format) \
9597
static ssize_t __cstate_##_var##_show(struct kobject *kobj, \
9698
struct kobj_attribute *attr, \
@@ -432,6 +434,11 @@ static int cstate_cpu_notifier(struct notifier_block *self,
432434
return NOTIFY_OK;
433435
}
434436

437+
static struct notifier_block cstate_cpu_nb = {
438+
.notifier_call = cstate_cpu_notifier,
439+
.priority = CPU_PRI_PERF + 1,
440+
};
441+
435442
static struct pmu cstate_core_pmu = {
436443
.attr_groups = core_attr_groups,
437444
.name = "cstate_core",
@@ -581,7 +588,7 @@ static int __init cstate_probe(const struct cstate_model *cm)
581588
return (has_cstate_core || has_cstate_pkg) ? 0 : -ENODEV;
582589
}
583590

584-
static void __init cstate_cleanup(void)
591+
static inline void cstate_cleanup(void)
585592
{
586593
if (has_cstate_core)
587594
perf_pmu_unregister(&cstate_core_pmu);
@@ -616,7 +623,7 @@ static int __init cstate_init(void)
616623
goto out;
617624
}
618625
}
619-
__perf_cpu_notifier(cstate_cpu_notifier);
626+
__register_cpu_notifier(&cstate_cpu_nb);
620627
out:
621628
cpu_notifier_register_done();
622629
return err;
@@ -640,4 +647,13 @@ static int __init cstate_pmu_init(void)
640647

641648
return cstate_init();
642649
}
643-
device_initcall(cstate_pmu_init);
650+
module_init(cstate_pmu_init);
651+
652+
static void __exit cstate_pmu_exit(void)
653+
{
654+
cpu_notifier_register_begin();
655+
__unregister_cpu_notifier(&cstate_cpu_nb);
656+
cstate_cleanup();
657+
cpu_notifier_register_done();
658+
}
659+
module_exit(cstate_pmu_exit);

0 commit comments

Comments
 (0)