Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1489961

[RFC PATCH 3/6] perf: Add a helper for looking up pmus by type

From Alexander Shishkin <alexander.shishkin@linux.intel.com>
Newsgroups linux.kernel
Subject [RFC PATCH 3/6] perf: Add a helper for looking up pmus by type
Date 2016-09-23 13:40 +0200
Message-ID <skwZH-31N-1@gated-at.bofh.it> (permalink)
References <skwQ1-2Yn-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


This patch adds a helper for looking up a registered pmu by its type.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
---
 kernel/events/core.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 2e8a0e389b..b64a5c611f 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -8780,6 +8780,18 @@ static int perf_try_init_event(struct pmu *pmu, struct perf_event *event)
 	return ret;
 }
 
+/* call under pmus_srcu */
+static struct pmu *__perf_find_pmu(u32 type)
+{
+	struct pmu *pmu;
+
+	rcu_read_lock();
+	pmu = idr_find(&pmu_idr, type);
+	rcu_read_unlock();
+
+	return pmu;
+}
+
 static struct pmu *perf_init_event(struct perf_event *event)
 {
 	struct pmu *pmu = NULL;
@@ -8788,9 +8800,7 @@ static struct pmu *perf_init_event(struct perf_event *event)
 
 	idx = srcu_read_lock(&pmus_srcu);
 
-	rcu_read_lock();
-	pmu = idr_find(&pmu_idr, event->attr.type);
-	rcu_read_unlock();
+	pmu = __perf_find_pmu(event->attr.type);
 	if (pmu) {
 		ret = perf_try_init_event(pmu, event);
 		if (ret)
-- 
2.9.3

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC PATCH 0/6] perf: Add AUX data sampling Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-09-23 13:30 +0200
  [RFC PATCH 1/6] perf: Move mlock accounting to ring buffer allocation Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-09-23 13:30 +0200
    Re: [RFC PATCH 1/6] perf: Move mlock accounting to ring buffer  allocation Peter Zijlstra <peterz@infradead.org> - 2016-09-23 14:20 +0200
      Re: [RFC PATCH 1/6] perf: Move mlock accounting to ring buffer allocation Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-09-23 16:40 +0200
        Re: [RFC PATCH 1/6] perf: Move mlock accounting to ring buffer  allocation Peter Zijlstra <peterz@infradead.org> - 2016-09-23 17:30 +0200
          Re: [RFC PATCH 1/6] perf: Move mlock accounting to ring buffer allocation Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-09-23 18:00 +0200
      Re: [RFC PATCH 1/6] perf: Move mlock accounting to ring buffer  allocation Andi Kleen <ak@linux.intel.com> - 2016-09-23 19:30 +0200
        Re: [RFC PATCH 1/6] perf: Move mlock accounting to ring buffer  allocation Peter Zijlstra <peterz@infradead.org> - 2016-09-23 22:30 +0200
          Re: [RFC PATCH 1/6] perf: Move mlock accounting to ring buffer allocation Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-09-26 10:30 +0200
            Re: [RFC PATCH 1/6] perf: Move mlock accounting to ring buffer  allocation Peter Zijlstra <peterz@infradead.org> - 2016-09-26 11:10 +0200
              Re: [RFC PATCH 1/6] perf: Move mlock accounting to ring buffer allocation Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-09-26 14:50 +0200
              Re: [RFC PATCH 1/6] perf: Move mlock accounting to ring buffer allocation Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-09-26 18:20 +0200
  [RFC PATCH 2/6] perf: Add api to (de-)allocate AUX buffers for kernel counters Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-09-23 13:40 +0200
  [RFC PATCH 3/6] perf: Add a helper for looking up pmus by type Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-09-23 13:40 +0200
  [RFC PATCH 4/6] perf: Add infrastructure for using AUX data in perf samples Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-09-23 13:40 +0200
  [RFC PATCH 5/6] perf: Disable PMU around address filter adjustment Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-09-23 13:40 +0200
  [RFC PATCH 6/6] perf: Disable IRQs in address filter sync path Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-09-23 13:40 +0200
    Re: [RFC PATCH 6/6] perf: Disable IRQs in address filter sync path Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-09-26 18:30 +0200
      Re: [RFC PATCH 6/6] perf: Disable IRQs in address filter sync path Mathieu Poirier <mathieu.poirier@linaro.org> - 2016-10-04 18:50 +0200
  Re: [RFC PATCH 0/6] perf: Add AUX data sampling Peter Zijlstra <peterz@infradead.org> - 2016-09-23 13:50 +0200
    Re: [RFC PATCH 0/6] perf: Add AUX data sampling Andi Kleen <ak@linux.intel.com> - 2016-09-23 19:20 +0200
      Re: [RFC PATCH 0/6] perf: Add AUX data sampling Peter Zijlstra <peterz@infradead.org> - 2016-09-23 22:40 +0200
        Re: [RFC PATCH 0/6] perf: Add AUX data sampling Andi Kleen <ak@linux.intel.com> - 2016-09-24 00:40 +0200

csiph-web