diff options
author | Andi Kleen <ak@linux.intel.com> | 2017-08-11 16:26:25 -0700 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-08-22 12:19:08 -0300 |
commit | d66dccdb13c9748f27d8401b45c027953fc833e8 (patch) | |
tree | 9c0f3ab5246fb5a43f28b96ec4a83d576b37afcf | |
parent | 8d3db2b97f5cb22cc589ba1e8e5232a26bfeb5d6 (diff) | |
download | linux-d66dccdb13c9748f27d8401b45c027953fc833e8.tar.bz2 |
perf tools: Dedup events in expression parsing
Avoid adding redundant events while parsing an expression. When we add
an "other" event check first if it already exists.
v2: Fix perf test failure.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/20170811232634.30465-10-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/util/expr.y | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/tools/perf/util/expr.y b/tools/perf/util/expr.y index 5753c4f21534..432b8560cf51 100644 --- a/tools/perf/util/expr.y +++ b/tools/perf/util/expr.y @@ -181,6 +181,19 @@ void expr__ctx_init(struct parse_ctx *ctx) ctx->num_ids = 0; } +static bool already_seen(const char *val, const char *one, const char **other, + int num_other) +{ + int i; + + if (one && !strcasecmp(one, val)) + return true; + for (i = 0; i < num_other; i++) + if (!strcasecmp(other[i], val)) + return true; + return false; +} + int expr__find_other(const char *p, const char *one, const char ***other, int *num_otherp) { @@ -200,7 +213,7 @@ int expr__find_other(const char *p, const char *one, const char ***other, err = 0; break; } - if (tok == ID && (!one || strcasecmp(one, val.id))) { + if (tok == ID && !already_seen(val.id, one, *other, num_other)) { if (num_other >= EXPR_MAX_OTHER - 1) { pr_debug("Too many extra events in %s\n", orig); break; |