Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp453528ybk; Wed, 13 May 2020 04:36:44 -0700 (PDT) X-Google-Smtp-Source: APiQypLQUeM/TbUMqGxpJw6E5WqPR7+qLxslfhAO9j4winjzSwx9kgYcqhUz9KAfBbEF6ng3VSQ7 X-Received: by 2002:a17:906:7ac8:: with SMTP id k8mr22408530ejo.235.1589369803956; Wed, 13 May 2020 04:36:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589369803; cv=none; d=google.com; s=arc-20160816; b=cYsnhYtXXIdySSCcgjsETFJnI4quXbuhOE7xmFe7ayEikvEbRhYWzr+VC4mFGOI/Ge IV01h/5DDvsB5PzCGJ7f82U8KZBbVeUYb7JfWPlhqeuscaq3pYk2KXT5UNE1/l63TK49 j2fcAdGv8ui+SYAoeqfptOc1tR1ipe96BzQ2TG4Jl71YleZG2XYSEvHcXAHzhvS8DiSI BRKRvfbtXsmmodYOzxMIQvlipD7GJND3quzvviWUMR6oFMNnzHdrAUkkYwMY/WbDdm3w dmJd2zFk2yNMoag8Dr5zUMeOgNJEqPHLLSJhBEt39wNzC/PAs/9p8mVySjHfZxnyNfyK ATGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=iMcnKpcK4+A9xC5bYEcrshADP6iDpNNfbFlVi1KcwVc=; b=moyDAJ/TYf1g0Wa7geZABKcYe5IQmxjugqO5WFwDNj8lUSW0HlcrfNOiWGW451OoDU g6ywVC9UEzP3TYn/XzhqNWl5KCuT0CfaL5ucPexnMaICsQy0Sd+CVGDy17ntVLzB65RQ xQ6DGpf9c8Kyz8w619nSmP4tVq8PnvOldRIqMYrvMmHhDiH5iKCq25OIKYHHed/vUzuH ty2FNHPPx/IgACEU36XsGad/W46ftzfk/YPHpog3/yGfHTBEzLMIYaweDa9ZpeChFknz yAfHjfnvNsj/O6McBeDHVhsli5ed+smyc5zD7YlW/MNiZurqPJe+P7GAmfvOWrn+3iVy +KeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=M+5AO0jI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 4si257074edw.72.2020.05.13.04.36.21; Wed, 13 May 2020 04:36:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=M+5AO0jI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729376AbgEMLZj (ORCPT + 99 others); Wed, 13 May 2020 07:25:39 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:39457 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726020AbgEMLZi (ORCPT ); Wed, 13 May 2020 07:25:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589369137; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=iMcnKpcK4+A9xC5bYEcrshADP6iDpNNfbFlVi1KcwVc=; b=M+5AO0jIzW2XnHuAaXjavWX5yzyx9XqVXe74q8bMLzBn4lCDtjTkBBHXFaLWpMBkRo/nxf n+lsfJflha6N+Njr7hYKSHltSMkhZ2T+ST+PfQIJ30XQwFeKP+WZawiY2vopPPF3vmyWpZ SFLYFc58fxXmlgM1j2e/38CquTY+BCQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-44-lZ2InMozNMSB-UA6yhsLLQ-1; Wed, 13 May 2020 07:25:33 -0400 X-MC-Unique: lZ2InMozNMSB-UA6yhsLLQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C56BBEC1AC; Wed, 13 May 2020 11:25:31 +0000 (UTC) Received: from krava (unknown [10.40.195.109]) by smtp.corp.redhat.com (Postfix) with SMTP id 17B587D945; Wed, 13 May 2020 11:25:28 +0000 (UTC) Date: Wed, 13 May 2020 13:25:28 +0200 From: Jiri Olsa To: Ian Rogers Cc: Jiri Olsa , Arnaldo Carvalho de Melo , lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan , Joe Mario , Andi Kleen , Kajol Jain , John Garry Subject: Re: [PATCH 1/4] perf expr: Add parsing support for multiple expressions Message-ID: <20200513112528.GH3158213@krava> References: <20200511205307.3107775-1-jolsa@kernel.org> <20200511205307.3107775-2-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 12, 2020 at 11:50:18PM -0700, Ian Rogers wrote: > On Mon, May 11, 2020 at 1:54 PM Jiri Olsa wrote: > > > > Adding support to parse metric difinitions in following form: > > Typo on definitions. right SNIP > > +int expr__parse_custom(struct expr_parse_ctx *ctx, const char *expr) > > +{ > > + return __expr__parse(NULL, ctx, expr, EXPR_CUSTOM, 0); > > +} > > + > > static bool > > already_seen(const char *val, const char *one, const char **other, > > int num_other) > > diff --git a/tools/perf/util/expr.h b/tools/perf/util/expr.h > > index 40fc452b0f2b..ef116b58a5d4 100644 > > --- a/tools/perf/util/expr.h > > +++ b/tools/perf/util/expr.h > > @@ -4,15 +4,29 @@ > > > > #define EXPR_MAX_OTHER 64 > > #define MAX_PARSE_ID EXPR_MAX_OTHER > > +#define EXPR_MAX 20 > > Currently deduplication of ids is done after rather than during > expression pasing, meaning hitting these limits is quite easy. This is > fixed in: > https://lore.kernel.org/lkml/20200508053629.210324-8-irogers@google.com/ > But not for custom expressions being added here. I plan to rebase that > work and clone hashmap from libbpf into libapi to workaround the > dependency issue. > That patch also adds expr__ctx_clear as a convenience for cleaning up > the context, and passes the context around inside of metricgroup > rather than ids. ok SNIP > > symbol ({spec}|{sym})+ > > +all [^;]+ > > > > %% > > struct expr_scanner_ctx *sctx = expr_get_extra(yyscanner); > > @@ -100,6 +103,12 @@ symbol ({spec}|{sym})+ > > } > > } > > > > +{ > > + > > +{all} { BEGIN(INITIAL); return str(yyscanner, ALL, sctx->runtime); } > > + > > +} > > + > > max { return MAX; } > > min { return MIN; } > > if { return IF; } > > @@ -118,6 +127,9 @@ else { return ELSE; } > > "(" { return '('; } > > ")" { return ')'; } > > "," { return ','; } > > +";" { return ';'; } > > +"=" { BEGIN(custom); return '='; } > > Will this interfere with the \\= encoded in MetricExpr? Could you test with: > https://lore.kernel.org/lkml/20200513062752.3681-2-irogers@google.com/ it shouldn't, the escape is matched first.. but I'll put it on top of the new tests to be sure > > > +\n { } > > . { } > > %% > > > > diff --git a/tools/perf/util/expr.y b/tools/perf/util/expr.y > > index 21e82a1e11a2..0521e48fa5e3 100644 > > --- a/tools/perf/util/expr.y > > +++ b/tools/perf/util/expr.y > > @@ -24,9 +24,10 @@ > > char *str; > > } > > > > -%token EXPR_PARSE EXPR_OTHER EXPR_ERROR > > +%token EXPR_PARSE EXPR_OTHER EXPR_CUSTOM EXPR_ERROR > > %token NUMBER > > %token ID > > +%token ALL > > Missing %destructor, fix is here: > https://lore.kernel.org/lkml/20200513000318.15166-1-irogers@google.com/ oops, right.. thanks jirka