public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Thomas Gleixner <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: torvalds@linux-foundation.org, vincent.weaver@maine.edu,
	tglx@linutronix.de, alexander.shishkin@linux.intel.com,
	kan.liang@intel.com, bp@suse.de, mingo@kernel.org,
	linux-kernel@vger.kernel.org, eranian@google.com,
	jolsa@redhat.com, peterz@infradead.org, acme@redhat.com,
	hpa@zytor.com
Subject: [tip:perf/core] x86/perf/intel/cstate: Modularize driver
Date: Thu, 31 Mar 2016 02:21:48 -0700	[thread overview]
Message-ID: <tip-c7afba320e91cca46fdf078798002b9ec84be8d3@git.kernel.org> (raw)
In-Reply-To: <20160320185623.658869675@linutronix.de>

Commit-ID:  c7afba320e91cca46fdf078798002b9ec84be8d3
Gitweb:     http://git.kernel.org/tip/c7afba320e91cca46fdf078798002b9ec84be8d3
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 20 Mar 2016 18:59:04 +0000
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 31 Mar 2016 10:30:38 +0200

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 <tglx@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Link: http://lkml.kernel.org/r/20160320185623.658869675@linutronix.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/Kconfig.perf          |  8 ++++++++
 arch/x86/events/intel/Makefile |  4 +++-
 arch/x86/events/intel/cstate.c | 22 +++++++++++++++++++---
 3 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/arch/x86/Kconfig.perf b/arch/x86/Kconfig.perf
index b239ad5..7d29dd7 100644
--- a/arch/x86/Kconfig.perf
+++ b/arch/x86/Kconfig.perf
@@ -16,4 +16,12 @@ config PERF_EVENTS_INTEL_RAPL
 	Include support for Intel rapl performance events for power
 	monitoring on modern processors.
 
+config PERF_EVENTS_INTEL_CSTATE
+	tristate "Intel cstate performance events"
+	depends on PERF_EVENTS && CPU_SUP_INTEL && PCI
+	default y
+	---help---
+	Include support for Intel cstate performance events for power
+	monitoring on modern processors.
+
 endmenu
diff --git a/arch/x86/events/intel/Makefile b/arch/x86/events/intel/Makefile
index 27adbba..3660b2c 100644
--- a/arch/x86/events/intel/Makefile
+++ b/arch/x86/events/intel/Makefile
@@ -1,7 +1,9 @@
 obj-$(CONFIG_CPU_SUP_INTEL)		+= core.o bts.o cqm.o
-obj-$(CONFIG_CPU_SUP_INTEL)		+= cstate.o ds.o knc.o
+obj-$(CONFIG_CPU_SUP_INTEL)		+= ds.o knc.o
 obj-$(CONFIG_CPU_SUP_INTEL)		+= lbr.o p4.o p6.o pt.o
 obj-$(CONFIG_PERF_EVENTS_INTEL_RAPL)	+= intel-rapl.o
 intel-rapl-objs				:= rapl.o
 obj-$(CONFIG_PERF_EVENTS_INTEL_UNCORE)	+= intel-uncore.o
 intel-uncore-objs			:= uncore.o uncore_nhmex.o uncore_snb.o uncore_snbep.o
+obj-$(CONFIG_PERF_EVENTS_INTEL_CSTATE)	+= intel-cstate.o
+intel-cstate-objs			:= cstate.o
diff --git a/arch/x86/events/intel/cstate.c b/arch/x86/events/intel/cstate.c
index e90ec9e..9ba4e41 100644
--- a/arch/x86/events/intel/cstate.c
+++ b/arch/x86/events/intel/cstate.c
@@ -91,6 +91,8 @@
 #include <asm/cpu_device_id.h>
 #include "../perf_event.h"
 
+MODULE_LICENSE("GPL");
+
 #define DEFINE_CSTATE_FORMAT_ATTR(_var, _name, _format)		\
 static ssize_t __cstate_##_var##_show(struct kobject *kobj,	\
 				struct kobj_attribute *attr,	\
@@ -432,6 +434,11 @@ static int cstate_cpu_notifier(struct notifier_block *self,
 	return NOTIFY_OK;
 }
 
+static struct notifier_block cstate_cpu_nb = {
+	.notifier_call	= cstate_cpu_notifier,
+	.priority       = CPU_PRI_PERF + 1,
+};
+
 static struct pmu cstate_core_pmu = {
 	.attr_groups	= core_attr_groups,
 	.name		= "cstate_core",
@@ -581,7 +588,7 @@ static int __init cstate_probe(const struct cstate_model *cm)
 	return (has_cstate_core || has_cstate_pkg) ? 0 : -ENODEV;
 }
 
-static void __init cstate_cleanup(void)
+static inline void cstate_cleanup(void)
 {
 	if (has_cstate_core)
 		perf_pmu_unregister(&cstate_core_pmu);
@@ -616,7 +623,7 @@ static int __init cstate_init(void)
 			goto out;
 		}
 	}
-	__perf_cpu_notifier(cstate_cpu_notifier);
+	__register_cpu_notifier(&cstate_cpu_nb);
 out:
 	cpu_notifier_register_done();
 	return err;
@@ -640,4 +647,13 @@ static int __init cstate_pmu_init(void)
 
 	return cstate_init();
 }
-device_initcall(cstate_pmu_init);
+module_init(cstate_pmu_init);
+
+static void __exit cstate_pmu_exit(void)
+{
+	cpu_notifier_register_begin();
+	__unregister_cpu_notifier(&cstate_cpu_nb);
+	cstate_cleanup();
+	cpu_notifier_register_done();
+}
+module_exit(cstate_pmu_exit);

  reply	other threads:[~2016-03-31  9:22 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-20 18:59 [patch 0/4] x86/perf/intel/cstate: Fix cpu hotplug handling and make it modular Thomas Gleixner
2016-03-20 18:59 ` [patch 1/4] x86/perf/intel/cstate: Make hotplug handling actually work Thomas Gleixner
2016-03-31  9:20   ` [tip:perf/core] x86/perf/intel/cstate: Make cstate " tip-bot for Thomas Gleixner
2016-03-20 18:59 ` [patch 2/4] x86/perf/intel/cstate: Sanitize probing Thomas Gleixner
2016-03-21 14:19   ` Liang, Kan
2016-03-21 14:42     ` Peter Zijlstra
2016-03-21 15:03       ` Thomas Gleixner
2016-03-21 15:04         ` Thomas Gleixner
2016-03-31  9:21   ` [tip:perf/core] " tip-bot for Thomas Gleixner
2016-03-20 18:59 ` [patch 3/4] x86/perf/intel/cstate: Sanitize error handling Thomas Gleixner
2016-03-31  9:21   ` [tip:perf/core] " tip-bot for Thomas Gleixner
2016-03-20 18:59 ` [patch 4/4] x86/perf/intel/cstate: Modularize driver Thomas Gleixner
2016-03-31  9:21   ` tip-bot for Thomas Gleixner [this message]
2016-03-21 15:01 ` [patch 0/4] x86/perf/intel/cstate: Fix cpu hotplug handling and make it modular Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-c7afba320e91cca46fdf078798002b9ec84be8d3@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=acme@redhat.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=bp@suse.de \
    --cc=eranian@google.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@redhat.com \
    --cc=kan.liang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=vincent.weaver@maine.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox