Commit ed4c1778 authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo

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: default avatarIan Rogers <irogers@google.com>
Acked-by: default avatarKan Liang <kan.liang@linux.intel.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Caleb Biggers <caleb.biggers@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Perry Taylor <perry.taylor@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
Link: http://lore.kernel.org/lkml/20221215064755.1620246-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent ad9ef9eb
...@@ -959,7 +959,7 @@ static struct test_metric metrics[] = { ...@@ -959,7 +959,7 @@ static struct test_metric metrics[] = {
{ "(imx8_ddr0@read\\-cycles@ + imx8_ddr0@write\\-cycles@)", }, { "(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 expr_parse_ctx *ctx;
struct hashmap_entry *cur; struct hashmap_entry *cur;
...@@ -968,7 +968,7 @@ static int metric_parse_fake(const char *str) ...@@ -968,7 +968,7 @@ static int metric_parse_fake(const char *str)
size_t bkt; size_t bkt;
int i; int i;
pr_debug("parsing '%s'\n", str); pr_debug("parsing '%s': '%s'\n", metric_name, str);
ctx = expr__ctx_new(); ctx = expr__ctx_new();
if (!ctx) { if (!ctx) {
...@@ -1006,8 +1006,13 @@ static int metric_parse_fake(const char *str) ...@@ -1006,8 +1006,13 @@ static int metric_parse_fake(const char *str)
hashmap__for_each_entry(ctx->ids, cur, bkt) hashmap__for_each_entry(ctx->ids, cur, bkt)
expr__add_id_val(ctx, strdup(cur->pkey), i--); expr__add_id_val(ctx, strdup(cur->pkey), i--);
if (expr__parse(&result, ctx, str)) { if (expr__parse(&result, ctx, str)) {
pr_err("expr__parse failed\n"); pr_err("expr__parse failed for %s\n", metric_name);
ret = -1; /* 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, ...@@ -1023,7 +1028,7 @@ static int test__parsing_fake_callback(const struct pmu_event *pe,
if (!pe->metric_expr) if (!pe->metric_expr)
return 0; 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, ...@@ -1037,7 +1042,7 @@ static int test__parsing_fake(struct test_suite *test __maybe_unused,
int err = 0; int err = 0;
for (size_t i = 0; i < ARRAY_SIZE(metrics); i++) { 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) if (err)
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment