linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
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, bp@suse.de,
	pjt@google.com, alexander.shishkin@linux.intel.com,
	eranian@google.com, mingo@kernel.org,
	torvalds@linux-foundation.org
Cc: linux-tip-commits@vger.kernel.org
Subject: Re: [tip:perf/urgent] perf/x86: Set pmu->module in Intel PMU modules
Date: Thu, 5 Jan 2017 16:52:21 +0100	[thread overview]
Message-ID: <20170105155221.GA3107@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <tip-74545f63890e38520eb4d1dbedcadaa9c0dbc824@git.kernel.org>

On Thu, Jan 05, 2017 at 07:07:05AM -0800, tip-bot for David Carrillo-Cisneros wrote:
> --- 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;


Ah, forgot about this, thanks for picking it up.

The first time I saw this I thought about doing something like the
below, but never got around to testing if that works and subsequently
forgot about things again.

Does this make sense and or work?

---

diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 4741ecdb9817..70f8a5a2e224 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -852,7 +852,14 @@ extern int perf_aux_output_skip(struct perf_output_handle *handle,
 				unsigned long size);
 extern void *perf_get_aux(struct perf_output_handle *handle);
 
-extern int perf_pmu_register(struct pmu *pmu, const char *name, int type);
+extern int __perf_pmu_register(struct pmu *pmu, const char *name, int type);
+
+#define perf_pmu_register(_pmu, _name, _type)			\
+({								\
+ 	(_pmu)->module = THIS_MODULE;				\
+ 	__perf_pmu_register((_pmu), (_name), (_type));		\
+})
+
 extern void perf_pmu_unregister(struct pmu *pmu);
 
 extern int perf_num_counters(void);
diff --git a/kernel/events/core.c b/kernel/events/core.c
index faf073d0287f..cde2004d932d 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -8752,7 +8767,7 @@ static int pmu_dev_alloc(struct pmu *pmu)
 static struct lock_class_key cpuctx_mutex;
 static struct lock_class_key cpuctx_lock;
 
-int perf_pmu_register(struct pmu *pmu, const char *name, int type)
+int __perf_pmu_register(struct pmu *pmu, const char *name, int type)
 {
 	int cpu, ret;
 

  reply	other threads:[~2017-01-05 15:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-23  1:17 [PATCH] perf/x86: set pmu->module in Intel PMU modules David Carrillo-Cisneros
2017-01-05 15:07 ` [tip:perf/urgent] perf/x86: Set " tip-bot for David Carrillo-Cisneros
2017-01-05 15:52   ` Peter Zijlstra [this message]
2017-01-05 18:46     ` Linus Torvalds
2017-01-05 20:24       ` 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=20170105155221.GA3107@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=acme@redhat.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=bp@suse.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=davidcc@google.com \
    --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=pjt@google.com \
    --cc=srinivas.pandruvada@linux.intel.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /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;
as well as URLs for NNTP newsgroup(s).