Commit d66dccdb authored by Andi Kleen's avatar Andi Kleen Committed by Arnaldo Carvalho de Melo

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: default avatarAndi Kleen <ak@linux.intel.com>
Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/20170811232634.30465-10-andi@firstfloor.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 8d3db2b9
...@@ -181,6 +181,19 @@ void expr__ctx_init(struct parse_ctx *ctx) ...@@ -181,6 +181,19 @@ void expr__ctx_init(struct parse_ctx *ctx)
ctx->num_ids = 0; 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 expr__find_other(const char *p, const char *one, const char ***other,
int *num_otherp) int *num_otherp)
{ {
...@@ -200,7 +213,7 @@ int expr__find_other(const char *p, const char *one, const char ***other, ...@@ -200,7 +213,7 @@ int expr__find_other(const char *p, const char *one, const char ***other,
err = 0; err = 0;
break; 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) { if (num_other >= EXPR_MAX_OTHER - 1) {
pr_debug("Too many extra events in %s\n", orig); pr_debug("Too many extra events in %s\n", orig);
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment