aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Rogers <[email protected]>2022-12-14 22:47:24 -0800
committerArnaldo Carvalho de Melo <[email protected]>2022-12-21 14:52:40 -0300
commited4c1778cc1abd18d491d0eecb7947c7cac3a598 (patch)
tree7da29050ea867f6ca6820d2293a45f3103da0f1a
parentad9ef9eb64a2230c12fa5c6c98aed176428012e8 (diff)
perf test pmu-events: Fake PMU metric workaround
We test metrics with fake events with fake values. The fake values may yield division by zero and so we count both up and down to try to avoid this. Unfortunately this isn't sufficient for some metrics and so don't fail the test for them. Add the metric name to debug output. Signed-off-by: Ian Rogers <[email protected]> Acked-by: Kan Liang <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Caleb Biggers <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: John Garry <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Perry Taylor <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Xing Zhengjun <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
-rw-r--r--tools/perf/tests/pmu-events.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/tools/perf/tests/pmu-events.c b/tools/perf/tests/pmu-events.c
index e36d8b1610d4..a9f2330f6257 100644
--- a/tools/perf/tests/pmu-events.c
+++ b/tools/perf/tests/pmu-events.c
@@ -959,7 +959,7 @@ static struct test_metric metrics[] = {
{ "(imx8_ddr0@read\\-cycles@ + imx8_ddr0@write\\-cycles@)", },
};
-static int metric_parse_fake(const char *str)
+static int metric_parse_fake(const char *metric_name, const char *str)
{
struct expr_parse_ctx *ctx;
struct hashmap_entry *cur;
@@ -968,7 +968,7 @@ static int metric_parse_fake(const char *str)
size_t bkt;
int i;
- pr_debug("parsing '%s'\n", str);
+ pr_debug("parsing '%s': '%s'\n", metric_name, str);
ctx = expr__ctx_new();
if (!ctx) {
@@ -1006,8 +1006,13 @@ static int metric_parse_fake(const char *str)
hashmap__for_each_entry(ctx->ids, cur, bkt)
expr__add_id_val(ctx, strdup(cur->pkey), i--);
if (expr__parse(&result, ctx, str)) {
- pr_err("expr__parse failed\n");
- ret = -1;
+ pr_err("expr__parse failed for %s\n", metric_name);
+ /* The following have hard to avoid divide by zero. */
+ if (!strcmp(metric_name, "tma_clears_resteers") ||
+ !strcmp(metric_name, "tma_mispredicts_resteers"))
+ ret = 0;
+ else
+ ret = -1;
}
}
@@ -1023,7 +1028,7 @@ static int test__parsing_fake_callback(const struct pmu_event *pe,
if (!pe->metric_expr)
return 0;
- return metric_parse_fake(pe->metric_expr);
+ return metric_parse_fake(pe->metric_name, pe->metric_expr);
}
/*
@@ -1037,7 +1042,7 @@ static int test__parsing_fake(struct test_suite *test __maybe_unused,
int err = 0;
for (size_t i = 0; i < ARRAY_SIZE(metrics); i++) {
- err = metric_parse_fake(metrics[i].str);
+ err = metric_parse_fake("", metrics[i].str);
if (err)
return err;
}