summaryrefslogtreecommitdiff
path: root/tools/perf/tests
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2023-01-27 02:36:34 +0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2023-02-02 23:18:31 +0300
commitdb95818e888a927456686518880ed0145b1f20ce (patch)
tree91a4a5f2e304148114907050c4655a077c8c0e2c /tools/perf/tests
parentdf5499ddb859bb848ddad5939d258da8a781af3a (diff)
downloadlinux-db95818e888a927456686518880ed0145b1f20ce.tar.xz
perf pmu-events: Add separate metric from pmu_event
Create a new pmu_metric for the metric related variables from pmu_event but that is initially just a clone of pmu_event. Add iterators for pmu_metric and use in places that metrics are desired rather than events. Make the event iterator skip metric only events, and the metric iterator skip event only events. Reviewed-by: John Garry <john.g.garry@oracle.com> Reviewed-by: Kajol Jain <kjain@linux.ibm.com> Signed-off-by: Ian Rogers <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Caleb Biggers <caleb.biggers@intel.com> Cc: Florian Fischer <florian.fischer@muhq.space> Cc: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@arm.com> Cc: Jing Zhang <renyu.zj@linux.alibaba.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Kang Minchul <tegongkang@gmail.com> Cc: Kim Phillips <kim.phillips@amd.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: Perry Taylor <perry.taylor@intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ravi Bangoria <ravi.bangoria@amd.com> Cc: Rob Herring <robh@kernel.org> Cc: Sandipan Das <sandipan.das@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 Cc: linuxppc-dev@lists.ozlabs.org Link: https://lore.kernel.org/r/20230126233645.200509-5-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/tests')
-rw-r--r--tools/perf/tests/pmu-events.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/tools/perf/tests/pmu-events.c b/tools/perf/tests/pmu-events.c
index a9f2330f6257..e5fb3d5a06c3 100644
--- a/tools/perf/tests/pmu-events.c
+++ b/tools/perf/tests/pmu-events.c
@@ -840,7 +840,7 @@ struct metric {
struct metric_ref metric_ref;
};
-static int test__parsing_callback(const struct pmu_event *pe, const struct pmu_events_table *table,
+static int test__parsing_callback(const struct pmu_metric *pm, const struct pmu_events_table *table,
void *data)
{
int *failures = data;
@@ -854,10 +854,10 @@ static int test__parsing_callback(const struct pmu_event *pe, const struct pmu_e
};
int err = 0;
- if (!pe->metric_expr)
+ if (!pm->metric_expr)
return 0;
- pr_debug("Found metric '%s'\n", pe->metric_name);
+ pr_debug("Found metric '%s'\n", pm->metric_name);
(*failures)++;
/*
@@ -877,14 +877,14 @@ static int test__parsing_callback(const struct pmu_event *pe, const struct pmu_e
perf_evlist__set_maps(&evlist->core, cpus, NULL);
runtime_stat__init(&st);
- err = metricgroup__parse_groups_test(evlist, table, pe->metric_name,
+ err = metricgroup__parse_groups_test(evlist, table, pm->metric_name,
false, false,
&metric_events);
if (err) {
- if (!strcmp(pe->metric_name, "M1") || !strcmp(pe->metric_name, "M2") ||
- !strcmp(pe->metric_name, "M3")) {
+ if (!strcmp(pm->metric_name, "M1") || !strcmp(pm->metric_name, "M2") ||
+ !strcmp(pm->metric_name, "M3")) {
(*failures)--;
- pr_debug("Expected broken metric %s skipping\n", pe->metric_name);
+ pr_debug("Expected broken metric %s skipping\n", pm->metric_name);
err = 0;
}
goto out_err;
@@ -912,7 +912,7 @@ static int test__parsing_callback(const struct pmu_event *pe, const struct pmu_e
struct metric_expr *mexp;
list_for_each_entry (mexp, &me->head, nd) {
- if (strcmp(mexp->metric_name, pe->metric_name))
+ if (strcmp(mexp->metric_name, pm->metric_name))
continue;
pr_debug("Result %f\n", test_generic_metric(mexp, 0, &st));
err = 0;
@@ -921,11 +921,11 @@ static int test__parsing_callback(const struct pmu_event *pe, const struct pmu_e
}
}
}
- pr_debug("Didn't find parsed metric %s", pe->metric_name);
+ pr_debug("Didn't find parsed metric %s", pm->metric_name);
err = 1;
out_err:
if (err)
- pr_debug("Broken metric %s\n", pe->metric_name);
+ pr_debug("Broken metric %s\n", pm->metric_name);
/* ... cleanup. */
metricgroup__rblist_exit(&metric_events);
@@ -941,8 +941,8 @@ static int test__parsing(struct test_suite *test __maybe_unused,
{
int failures = 0;
- pmu_for_each_core_event(test__parsing_callback, &failures);
- pmu_for_each_sys_event(test__parsing_callback, &failures);
+ pmu_for_each_core_metric(test__parsing_callback, &failures);
+ pmu_for_each_sys_metric(test__parsing_callback, &failures);
return failures == 0 ? TEST_OK : TEST_FAIL;
}
@@ -1021,14 +1021,11 @@ out:
return ret;
}
-static int test__parsing_fake_callback(const struct pmu_event *pe,
+static int test__parsing_fake_callback(const struct pmu_metric *pm,
const struct pmu_events_table *table __maybe_unused,
void *data __maybe_unused)
{
- if (!pe->metric_expr)
- return 0;
-
- return metric_parse_fake(pe->metric_name, pe->metric_expr);
+ return metric_parse_fake(pm->metric_name, pm->metric_expr);
}
/*
@@ -1047,11 +1044,11 @@ static int test__parsing_fake(struct test_suite *test __maybe_unused,
return err;
}
- err = pmu_for_each_core_event(test__parsing_fake_callback, NULL);
+ err = pmu_for_each_core_metric(test__parsing_fake_callback, NULL);
if (err)
return err;
- return pmu_for_each_sys_event(test__parsing_fake_callback, NULL);
+ return pmu_for_each_sys_metric(test__parsing_fake_callback, NULL);
}
static struct test_case pmu_events_tests[] = {