Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Andi Kleen and committed by
Arnaldo Carvalho de Melo
d66dccdb 8d3db2b9

+14 -1
+14 -1
tools/perf/util/expr.y
··· 181 181 ctx->num_ids = 0; 182 182 } 183 183 184 + static bool already_seen(const char *val, const char *one, const char **other, 185 + int num_other) 186 + { 187 + int i; 188 + 189 + if (one && !strcasecmp(one, val)) 190 + return true; 191 + for (i = 0; i < num_other; i++) 192 + if (!strcasecmp(other[i], val)) 193 + return true; 194 + return false; 195 + } 196 + 184 197 int expr__find_other(const char *p, const char *one, const char ***other, 185 198 int *num_otherp) 186 199 { ··· 213 200 err = 0; 214 201 break; 215 202 } 216 - if (tok == ID && (!one || strcasecmp(one, val.id))) { 203 + if (tok == ID && !already_seen(val.id, one, *other, num_other)) { 217 204 if (num_other >= EXPR_MAX_OTHER - 1) { 218 205 pr_debug("Too many extra events in %s\n", orig); 219 206 break;