[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20160923112726.5890-4-alexander.shishkin@linux.intel.com>
Date: Fri, 23 Sep 2016 14:27:23 +0300
From: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
To: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc: Ingo Molnar <mingo@...hat.com>, linux-kernel@...r.kernel.org,
vince@...ter.net, eranian@...gle.com,
Arnaldo Carvalho de Melo <acme@...radead.org>,
tglx@...utronix.de, ak@...ux.intel.com,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Subject: [RFC PATCH 3/6] perf: Add a helper for looking up pmus by type
This patch adds a helper for looking up a registered pmu by its type.
Signed-off-by: Alexander Shishkin <alexander.shishkin@...ux.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
Powered by blists - more mailing lists