From edfe7f554ab8f083556c718ecbcefda509c46851 Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Thu, 23 Sep 2021 00:46:05 -0700 Subject: [PATCH] perf metric: Use NAN for missing event IDs. If during computing a metric an event (id) is missing the parsing aborts. A later patch will make it so that events that aren't used in the output are deliberately omitted, in which case we don't want the abort. Modify the missing ID case to report NAN for these cases. Reviewed-by: Andi Kleen Signed-off-by: Ian Rogers Tested-by: John Garry Acked-by: Jiri Olsa Cc: Alexander Shishkin Cc: Ingo Molnar Cc: Jin Yao Cc: Kajol Jain Cc: Mark Rutland Cc: Namhyung Kim Cc: Paul Clarke Cc: Peter Zijlstra Cc: Sandeep Dasgupta Cc: Stephane Eranian Link: https://lore.kernel.org/r/20210923074616.674826-3-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/expr.y | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/expr.y b/tools/perf/util/expr.y index b2ada8f8..41c9cd4 100644 --- a/tools/perf/util/expr.y +++ b/tools/perf/util/expr.y @@ -1,6 +1,7 @@ /* Simple expression parser */ %{ #define YYDEBUG 1 +#include #include #include "util.h" #include "util/debug.h" @@ -88,12 +89,10 @@ expr: NUMBER | ID { struct expr_id_data *data; - if (expr__resolve_id(ctx, $1, &data)) { - free($1); - YYABORT; - } + $$ = NAN; + if (expr__resolve_id(ctx, $1, &data) == 0) + $$ = expr_id_data__value(data); - $$ = expr_id_data__value(data); free($1); } | expr '|' expr { $$ = (long)$1 | (long)$3; } -- 2.7.4