aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/perf/pmu-events/pmu-events.h
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2022-08-12 16:09:45 -0700
committerArnaldo Carvalho de Melo <acme@redhat.com>2022-08-13 15:01:31 -0300
commit660842e468dcefb5d1d4fb40ed3abe4d1388dff7 (patch)
tree1f440d77fef497cee8c1a71bc8cf3d4f1bec69af /tools/perf/pmu-events/pmu-events.h
parentperf pmu-events: Move test events/metrics to JSON (diff)
downloadwireguard-linux-660842e468dcefb5d1d4fb40ed3abe4d1388dff7.tar.xz
wireguard-linux-660842e468dcefb5d1d4fb40ed3abe4d1388dff7.zip
perf pmu-events: Don't assume pmu_event is an array
The current code assumes that a struct pmu_event can be iterated over forward until a NULL pmu_event is encountered. This makes it difficult to refactor pmu_event. Add a loop function taking a callback function that's passed the struct pmu_event. This way the pmu_event is only needed for one element and not an entire array. Switch existing code iterating over the pmu_event arrays to use the new loop function pmu_events_table_for_each_event. Signed-off-by: Ian Rogers <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@arm.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: John Garry <john.garry@huawei.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Leo Yan <leo.yan@linaro.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mike Leach <mike.leach@linaro.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ravi Bangoria <ravi.bangoria@amd.com> Cc: Stephane Eranian <eranian@google.com> Cc: Will Deacon <will@kernel.org> Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com> Cc: linux-arm-kernel@lists.infradead.org Link: https://lore.kernel.org/r/20220812230949.683239-11-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/pmu-events/pmu-events.h')
-rw-r--r--tools/perf/pmu-events/pmu-events.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/tools/perf/pmu-events/pmu-events.h b/tools/perf/pmu-events/pmu-events.h
index 485e730f9922..70672842f77f 100644
--- a/tools/perf/pmu-events/pmu-events.h
+++ b/tools/perf/pmu-events/pmu-events.h
@@ -34,6 +34,9 @@ typedef int (*pmu_event_iter_fn)(const struct pmu_event *pe,
const struct pmu_event *table,
void *data);
+int pmu_events_table_for_each_event(const struct pmu_event *table, pmu_event_iter_fn fn,
+ void *data);
+
const struct pmu_event *perf_pmu__find_table(struct perf_pmu *pmu);
const struct pmu_event *find_core_events_table(const char *arch, const char *cpuid);
int pmu_for_each_core_event(pmu_event_iter_fn fn, void *data);