mirror of
https://github.com/torvalds/linux.git
synced 2024-12-12 22:23:55 +00:00
3340a08354
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>
139 lines
2.6 KiB
Plaintext
139 lines
2.6 KiB
Plaintext
%option prefix="expr_"
|
|
%option reentrant
|
|
%option bison-bridge
|
|
|
|
%{
|
|
#include <linux/compiler.h>
|
|
#include "expr.h"
|
|
#include "expr-bison.h"
|
|
#include <math.h>
|
|
|
|
char *expr_get_text(yyscan_t yyscanner);
|
|
YYSTYPE *expr_get_lval(yyscan_t yyscanner);
|
|
|
|
static double __value(YYSTYPE *yylval, char *str, int token)
|
|
{
|
|
double num;
|
|
|
|
errno = 0;
|
|
num = strtod(str, NULL);
|
|
if (errno)
|
|
return EXPR_ERROR;
|
|
|
|
yylval->num = num;
|
|
return token;
|
|
}
|
|
|
|
static int value(yyscan_t scanner)
|
|
{
|
|
YYSTYPE *yylval = expr_get_lval(scanner);
|
|
char *text = expr_get_text(scanner);
|
|
|
|
return __value(yylval, text, NUMBER);
|
|
}
|
|
|
|
/*
|
|
* Allow @ instead of / to be able to specify pmu/event/ without
|
|
* conflicts with normal division.
|
|
*/
|
|
static char *normalize(char *str, int runtime)
|
|
{
|
|
char *ret = str;
|
|
char *dst = str;
|
|
|
|
while (*str) {
|
|
if (*str == '\\') {
|
|
*dst++ = *++str;
|
|
if (!*str)
|
|
break;
|
|
}
|
|
else if (*str == '?') {
|
|
char *paramval;
|
|
int i = 0;
|
|
int size = asprintf(¶mval, "%d", runtime);
|
|
|
|
if (size < 0)
|
|
*dst++ = '0';
|
|
else {
|
|
while (i < size)
|
|
*dst++ = paramval[i++];
|
|
free(paramval);
|
|
}
|
|
}
|
|
else
|
|
*dst++ = *str;
|
|
str++;
|
|
}
|
|
|
|
*dst = 0x0;
|
|
return ret;
|
|
}
|
|
|
|
static int str(yyscan_t scanner, int token, int runtime)
|
|
{
|
|
YYSTYPE *yylval = expr_get_lval(scanner);
|
|
char *text = expr_get_text(scanner);
|
|
|
|
yylval->str = normalize(strdup(text), runtime);
|
|
if (!yylval->str)
|
|
return EXPR_ERROR;
|
|
|
|
yylval->str = normalize(yylval->str, runtime);
|
|
return token;
|
|
}
|
|
|
|
static int literal(yyscan_t scanner, const struct expr_scanner_ctx *sctx)
|
|
{
|
|
YYSTYPE *yylval = expr_get_lval(scanner);
|
|
|
|
yylval->num = expr__get_literal(expr_get_text(scanner), sctx);
|
|
if (isnan(yylval->num)) {
|
|
if (!sctx->is_test)
|
|
return EXPR_ERROR;
|
|
yylval->num = 1;
|
|
}
|
|
return LITERAL;
|
|
}
|
|
%}
|
|
|
|
number ([0-9]+\.?[0-9]*|[0-9]*\.?[0-9]+)(e-?[0-9]+)?
|
|
|
|
sch [-,=]
|
|
spec \\{sch}
|
|
sym [0-9a-zA-Z_\.:@?]+
|
|
symbol ({spec}|{sym})+
|
|
literal #[0-9a-zA-Z_\.\-]+
|
|
|
|
%%
|
|
struct expr_scanner_ctx *sctx = expr_get_extra(yyscanner);
|
|
|
|
d_ratio { return D_RATIO; }
|
|
max { return MAX; }
|
|
min { return MIN; }
|
|
if { return IF; }
|
|
else { return ELSE; }
|
|
source_count { return SOURCE_COUNT; }
|
|
{literal} { return literal(yyscanner, sctx); }
|
|
{number} { return value(yyscanner); }
|
|
{symbol} { return str(yyscanner, ID, sctx->runtime); }
|
|
"|" { return '|'; }
|
|
"^" { return '^'; }
|
|
"&" { return '&'; }
|
|
"<" { return '<'; }
|
|
">" { return '>'; }
|
|
"-" { return '-'; }
|
|
"+" { return '+'; }
|
|
"*" { return '*'; }
|
|
"/" { return '/'; }
|
|
"%" { return '%'; }
|
|
"(" { return '('; }
|
|
")" { return ')'; }
|
|
"," { return ','; }
|
|
. { }
|
|
%%
|
|
|
|
int expr_wrap(void *scanner __maybe_unused)
|
|
{
|
|
return 1;
|
|
}
|