aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Rogers <[email protected]>2021-09-23 00:46:05 -0700
committerArnaldo Carvalho de Melo <[email protected]>2021-09-29 13:25:56 -0300
commitedfe7f554ab8f083556c718ecbcefda509c46851 (patch)
tree99b78f21bb35e8b373bcdcc8a253275be0b8a8cc
parentcb94a02e7494c001fa8b5a4c5e16693fafd98530 (diff)
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 <[email protected]> Signed-off-by: Ian Rogers <[email protected]> Tested-by: John Garry <[email protected]> Acked-by: Jiri Olsa <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jin Yao <[email protected]> Cc: Kajol Jain <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Paul Clarke <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Sandeep Dasgupta <[email protected]> Cc: Stephane Eranian <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
-rw-r--r--tools/perf/util/expr.y9
1 files changed, 4 insertions, 5 deletions
diff --git a/tools/perf/util/expr.y b/tools/perf/util/expr.y
index b2ada8f8309a..41c9cd4efadd 100644
--- a/tools/perf/util/expr.y
+++ b/tools/perf/util/expr.y
@@ -1,6 +1,7 @@
/* Simple expression parser */
%{
#define YYDEBUG 1
+#include <math.h>
#include <stdio.h>
#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; }