perf pmu-events: Fix testing with JEVENTS_ARCH=all

The #slots literal will return NAN when not on ARM64 which causes a
perf test failure when not on an ARM64 for a JEVENTS_ARCH=all build:
..
 10.4: Parsing of PMU event table metrics with fake PMUs             : FAILED!
..
Add an is_test boolean so that the failure can be avoided when running
as a test.

Fixes: acef233b7c ("perf pmu: Add #slots literal support for arm64")
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-13-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Ian Rogers 2023-01-26 15:36:42 -08:00 committed by Arnaldo Carvalho de Melo
parent 5a09b1fd1b
commit 3340a08354
3 changed files with 7 additions and 3 deletions

View File

@ -950,6 +950,7 @@ static int metric_parse_fake(const char *metric_name, const char *str)
pr_debug("expr__ctx_new failed"); pr_debug("expr__ctx_new failed");
return TEST_FAIL; return TEST_FAIL;
} }
ctx->sctx.is_test = true;
if (expr__find_ids(str, NULL, ctx) < 0) { if (expr__find_ids(str, NULL, ctx) < 0) {
pr_err("expr__find_ids failed\n"); pr_err("expr__find_ids failed\n");
return -1; return -1;

View File

@ -9,6 +9,7 @@ struct expr_scanner_ctx {
char *user_requested_cpu_list; char *user_requested_cpu_list;
int runtime; int runtime;
bool system_wide; bool system_wide;
bool is_test;
}; };
struct expr_parse_ctx { struct expr_parse_ctx {

View File

@ -87,9 +87,11 @@ static int literal(yyscan_t scanner, const struct expr_scanner_ctx *sctx)
YYSTYPE *yylval = expr_get_lval(scanner); YYSTYPE *yylval = expr_get_lval(scanner);
yylval->num = expr__get_literal(expr_get_text(scanner), sctx); yylval->num = expr__get_literal(expr_get_text(scanner), sctx);
if (isnan(yylval->num)) if (isnan(yylval->num)) {
return EXPR_ERROR; if (!sctx->is_test)
return EXPR_ERROR;
yylval->num = 1;
}
return LITERAL; return LITERAL;
} }
%} %}