From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932359AbdHVIqT (ORCPT ); Tue, 22 Aug 2017 04:46:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59918 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932132AbdHVIqR (ORCPT ); Tue, 22 Aug 2017 04:46:17 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4E37580F6C Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jolsa@redhat.com Date: Tue, 22 Aug 2017 10:46:15 +0200 From: Jiri Olsa To: Andi Kleen Cc: acme@kernel.org, jolsa@kernel.org, linux-kernel@vger.kernel.org, Andi Kleen Subject: Re: [PATCH v2 10/19] perf, tools: Dedup events in expression parsing Message-ID: <20170822084615.GI23985@krava> References: <20170811232634.30465-1-andi@firstfloor.org> <20170811232634.30465-10-andi@firstfloor.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170811232634.30465-10-andi@firstfloor.org> User-Agent: Mutt/1.8.3 (2017-05-23) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 22 Aug 2017 08:46:17 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 11, 2017 at 04:26:25PM -0700, Andi Kleen wrote: > From: Andi Kleen > > 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 thanks, jirka > --- > 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 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; > -- > 2.9.4 >