[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1405540969-18975-12-git-send-email-jolsa@kernel.org>
Date: Wed, 16 Jul 2014 22:02:47 +0200
From: Jiri Olsa <jolsa@...nel.org>
To: Ingo Molnar <mingo@...nel.org>
Cc: linux-kernel@...r.kernel.org,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Andi Kleen <ak@...ux.intel.com>, Jiri Olsa <jolsa@...nel.org>
Subject: [PATCH 11/13] perf tools: Add a new pmu interface to iterate over all events
From: Andi Kleen <ak@...ux.intel.com>
With calling a callback. To be used in test code added in the next
patch.
Signed-off-by: Andi Kleen <ak@...ux.intel.com>
Link: http://lkml.kernel.org/n/1405123165-22666-10-git-send-email-andi@firstfloor.org
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
---
tools/perf/util/pmu.c | 18 ++++++++++++++++++
tools/perf/util/pmu.h | 2 ++
2 files changed, 20 insertions(+)
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 8714f9a11abe..397e4004fcdf 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -869,3 +869,21 @@ bool pmu_have_event(const char *pname, const char *name)
}
return false;
}
+
+int pmu_iterate_events(int (*func)(const char *pmu, const char *name))
+{
+ int ret = 0;
+ struct perf_pmu *pmu;
+ struct perf_pmu_alias *alias;
+
+ perf_pmu__find("cpu"); /* Load PMUs */
+ pmu = NULL;
+ while ((pmu = perf_pmu__scan(pmu)) != NULL) {
+ list_for_each_entry(alias, &pmu->aliases, list) {
+ ret = func(pmu->name, alias->name);
+ if (ret != 0)
+ break;
+ }
+ }
+ return ret;
+}
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
index 583d21e4cefb..87a1da471686 100644
--- a/tools/perf/util/pmu.h
+++ b/tools/perf/util/pmu.h
@@ -47,5 +47,7 @@ bool pmu_have_event(const char *pname, const char *name);
int perf_pmu__test(void);
+int pmu_iterate_events(int (*func)(const char *, const char *name));
+
extern const char *json_file;
#endif /* __PMU_H */
--
1.8.3.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists