[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1428993665-2133-9-git-send-email-sukadev@linux.vnet.ibm.com>
Date: Mon, 13 Apr 2015 23:41:01 -0700
From: Sukadev Bhattiprolu <sukadev@...ux.vnet.ibm.com>
To: mingo@...hat.com, ak@...ux.intel.com,
Michael Ellerman <mpe@...erman.id.au>,
Jiri Olsa <jolsa@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: peterz@...radead.org, namhyung@...nel.org,
linuxppc-dev@...ts.ozlabs.org, <linux-kernel@...r.kernel.org>
Subject: [PATCH v9 08/11] 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>
Signed-off-by: Sukadev Bhattiprolu <sukadev@...ux.vnet.ibm.com>
---
Changelog[v9] by Sukadev Bhattiprolu
Rebase to 4.0 and fix conflicts in:
tools/perf/util/pmu.c
tools/perf/util/pmu.h
---
tools/perf/util/pmu.c | 18 ++++++++++++++++++
tools/perf/util/pmu.h | 1 +
2 files changed, 19 insertions(+)
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 2150455..82f7654 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -1068,3 +1068,21 @@ int perf_pmu__scan_file(struct perf_pmu *pmu, const char *name, const char *fmt,
va_end(args);
return ret;
}
+
+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 f8dac0f..889cadf 100644
--- a/tools/perf/util/pmu.h
+++ b/tools/perf/util/pmu.h
@@ -76,6 +76,7 @@ int perf_pmu__scan_file(struct perf_pmu *pmu, const char *name, const char *fmt,
int perf_pmu__test(void);
struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu);
+int pmu_iterate_events(int (*func)(const char *, const char *name));
extern const char *json_file;
#endif /* __PMU_H */
--
1.7.9.5
--
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