[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201121031119.3554769-3-irogers@google.com>
Date: Fri, 20 Nov 2020 19:11:16 -0800
From: Ian Rogers <irogers@...gle.com>
To: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...hat.com>,
Namhyung Kim <namhyung@...nel.org>,
linux-kernel@...r.kernel.org, Andi Kleen <ak@...ux.intel.com>,
Jin Yao <yao.jin@...ux.intel.com>,
John Garry <john.garry@...wei.com>,
Paul Clarke <pc@...ibm.com>, kajoljain <kjain@...ux.ibm.com>
Cc: Stephane Eranian <eranian@...gle.com>,
Sandeep Dasgupta <sdasgup@...gle.com>,
linux-perf-users@...r.kernel.org, Ian Rogers <irogers@...gle.com>
Subject: [PATCH v3 2/5] 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.
Signed-off-by: Ian Rogers <irogers@...gle.com>
---
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 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; }
--
2.29.2.454.gaff20da3a2-goog
Powered by blists - more mailing lists