The following commit has been merged into the perf/core branch of tip:

Commit-ID:     3a50dc76058d7cd8315f9c712b793d81a7ff4541
Gitweb:        
https://git.kernel.org/tip/3a50dc76058d7cd8315f9c712b793d81a7ff4541
Author:        Stephane Eranian <eran...@google.com>
AuthorDate:    Wed, 29 Apr 2020 16:14:42 -07:00
Committer:     Arnaldo Carvalho de Melo <a...@redhat.com>
CommitterDate: Tue, 05 May 2020 16:35:31 -03:00

perf pmu: Add perf_pmu__find_by_type helper

This is used by libpfm4 during event parsing to locate the pmu for an
event.

Signed-off-by: Stephane Eranian <eran...@google.com>
Reviewed-by: Ian Rogers <irog...@google.com>
Acked-by: Jiri Olsa <jo...@redhat.com>
Cc: Adrian Hunter <adrian.hun...@intel.com>
Cc: Alexander Shishkin <alexander.shish...@linux.intel.com>
Cc: Alexei Starovoitov <a...@kernel.org>
Cc: Alexey Budankov <alexey.budan...@linux.intel.com>
Cc: Andi Kleen <a...@linux.intel.com>
Cc: Andrii Nakryiko <andr...@fb.com>
Cc: Daniel Borkmann <dan...@iogearbox.net>
Cc: Florian Fainelli <f.faine...@gmail.com>
Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org>
Cc: Igor Lubashev <iluba...@akamai.com>
Cc: Jin Yao <yao....@linux.intel.com>
Cc: Jiwei Sun <jiwei....@windriver.com>
Cc: John Garry <john.ga...@huawei.com>
Cc: Kan Liang <kan.li...@linux.intel.com>
Cc: Leo Yan <leo....@linaro.org>
Cc: Mark Rutland <mark.rutl...@arm.com>
Cc: Martin KaFai Lau <ka...@fb.com>
Cc: Namhyung Kim <namhy...@kernel.org>
Cc: Peter Zijlstra <pet...@infradead.org>
Cc: Thomas Gleixner <t...@linutronix.de>
Cc: Yonghong Song <y...@fb.com>
Cc: b...@vger.kernel.org
Cc: net...@vger.kernel.org
Cc: yuzhoujian <yuzhouj...@didichuxing.com>
Link: http://lore.kernel.org/lkml/20200429231443.207201-4-irog...@google.com
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 tools/perf/util/pmu.c | 11 +++++++++++
 tools/perf/util/pmu.h |  1 +
 2 files changed, 12 insertions(+)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 5642de7..92bd7fa 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -871,6 +871,17 @@ static struct perf_pmu *pmu_find(const char *name)
        return NULL;
 }
 
+struct perf_pmu *perf_pmu__find_by_type(unsigned int type)
+{
+       struct perf_pmu *pmu;
+
+       list_for_each_entry(pmu, &pmus, list)
+               if (pmu->type == type)
+                       return pmu;
+
+       return NULL;
+}
+
 struct perf_pmu *perf_pmu__scan(struct perf_pmu *pmu)
 {
        /*
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
index 1edd214..cb6fbec 100644
--- a/tools/perf/util/pmu.h
+++ b/tools/perf/util/pmu.h
@@ -72,6 +72,7 @@ struct perf_pmu_alias {
 };
 
 struct perf_pmu *perf_pmu__find(const char *name);
+struct perf_pmu *perf_pmu__find_by_type(unsigned int type);
 int perf_pmu__config(struct perf_pmu *pmu, struct perf_event_attr *attr,
                     struct list_head *head_terms,
                     struct parse_events_error *error);

Reply via email to