From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752635AbdHXIXG (ORCPT ); Thu, 24 Aug 2017 04:23:06 -0400 Received: from terminus.zytor.com ([65.50.211.136]:42235 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751845AbdHXIXD (ORCPT ); Thu, 24 Aug 2017 04:23:03 -0400 Date: Thu, 24 Aug 2017 01:21:54 -0700 From: tip-bot for Andi Kleen Message-ID: Cc: hpa@zytor.com, mingo@kernel.org, acme@redhat.com, jolsa@kernel.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, ak@linux.intel.com Reply-To: linux-kernel@vger.kernel.org, tglx@linutronix.de, ak@linux.intel.com, hpa@zytor.com, acme@redhat.com, mingo@kernel.org, jolsa@kernel.org In-Reply-To: <20170811232634.30465-10-andi@firstfloor.org> References: <20170811232634.30465-10-andi@firstfloor.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf tools: Dedup events in expression parsing Git-Commit-ID: d66dccdb13c9748f27d8401b45c027953fc833e8 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: d66dccdb13c9748f27d8401b45c027953fc833e8 Gitweb: http://git.kernel.org/tip/d66dccdb13c9748f27d8401b45c027953fc833e8 Author: Andi Kleen AuthorDate: Fri, 11 Aug 2017 16:26:25 -0700 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 22 Aug 2017 12:19:08 -0300 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 Acked-by: Jiri Olsa Link: http://lkml.kernel.org/r/20170811232634.30465-10-andi@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/expr.y | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/expr.y b/tools/perf/util/expr.y index 5753c4f..432b856 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;