From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Jiri Olsa <jolsa@redhat.com>
Cc: Ian Rogers <irogers@google.com>, Andi Kleen <ak@linux.intel.com>,
Namhyung Kim <namhyung@kernel.org>,
John Garry <john.garry@huawei.com>,
Kajol Jain <kjain@linux.ibm.com>,
"Paul A . Clarke" <pc@us.ibm.com>,
Riccardo Mancini <rickyman7@gmail.com>,
Kan Liang <kan.liang@linux.intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Madhavan Srinivasan <maddy@linux.ibm.com>,
Song Liu <song@kernel.org>, Wan Jiabing <wanjiabing@vivo.com>,
Yury Norov <yury.norov@gmail.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 7/8] perf expr: Move ID handling to its own function
Date: Thu, 11 Nov 2021 10:42:30 -0300 [thread overview]
Message-ID: <YY0dxuHTPTuQH+4B@kernel.org> (raw)
In-Reply-To: <YYzSgNNWDkymfYi5@krava>
Em Thu, Nov 11, 2021 at 09:21:20AM +0100, Jiri Olsa escreveu:
> On Wed, Nov 10, 2021 at 04:21:08PM -0800, Ian Rogers wrote:
> > This will facilitate sharing in a follow-on change.
> >
> > Signed-off-by: Ian Rogers <irogers@google.com>
> > ---
> > tools/perf/util/expr.y | 60 ++++++++++++++++++++++++------------------
> > 1 file changed, 34 insertions(+), 26 deletions(-)
> >
> > diff --git a/tools/perf/util/expr.y b/tools/perf/util/expr.y
> > index ba6c6dbf30c8..d90addf9b937 100644
> > --- a/tools/perf/util/expr.y
> > +++ b/tools/perf/util/expr.y
> > @@ -3,6 +3,7 @@
> > #define YYDEBUG 1
> > #include <assert.h>
> > #include <math.h>
> > +#include <stdlib.h>
> > #include "util/debug.h"
> > #define IN_EXPR_Y 1
> > #include "expr.h"
> > @@ -82,6 +83,38 @@ static struct ids union_expr(struct ids ids1, struct ids ids2)
> > return result;
> > }
> >
> > +static struct ids handle_id(struct expr_parse_ctx *ctx, char *id,
> > + bool compute_ids)
> > +{
> > + struct ids result;
>
> nit, missing extra line in here
>
> other than that for the whole patchset:
>
> Acked-by: Jiri Olsa <jolsa@redhat.com>
I'll fix that
> thanks,
> jirka
>
> > + if (!compute_ids) {
> > + /*
> > + * Compute the event's value from ID. If the ID isn't known then
> > + * it isn't used to compute the formula so set to NAN.
> > + */
> > + struct expr_id_data *data;
> > +
> > + result.val = NAN;
> > + if (expr__resolve_id(ctx, id, &data) == 0)
> > + result.val = expr_id_data__value(data);
> > +
> > + result.ids = NULL;
> > + free(id);
> > + } else {
> > + /*
> > + * Set the value to BOTTOM to show that any value is possible
> > + * when the event is computed. Create a set of just the ID.
> > + */
> > + result.val = BOTTOM;
> > + result.ids = ids__new();
> > + if (!result.ids || ids__insert(result.ids, id)) {
> > + pr_err("Error creating IDs for '%s'", id);
> > + free(id);
> > + }
> > + }
> > + return result;
> > +}
> > +
> > /*
> > * If we're not computing ids or $1 and $3 are constants, compute the new
> > * constant value using OP. Its invariant that there are no ids. If computing
> > @@ -167,32 +200,7 @@ expr: NUMBER
> > $$.val = $1;
> > $$.ids = NULL;
> > }
> > -| ID
> > -{
> > - if (!compute_ids) {
> > - /*
> > - * Compute the event's value from ID. If the ID isn't known then
> > - * it isn't used to compute the formula so set to NAN.
> > - */
> > - struct expr_id_data *data;
> > -
> > - $$.val = NAN;
> > - if (expr__resolve_id(ctx, $1, &data) == 0)
> > - $$.val = expr_id_data__value(data);
> > -
> > - $$.ids = NULL;
> > - free($1);
> > - } else {
> > - /*
> > - * Set the value to BOTTOM to show that any value is possible
> > - * when the event is computed. Create a set of just the ID.
> > - */
> > - $$.val = BOTTOM;
> > - $$.ids = ids__new();
> > - if (!$$.ids || ids__insert($$.ids, $1))
> > - YYABORT;
> > - }
> > -}
> > +| ID { $$ = handle_id(ctx, $1, compute_ids); }
> > | expr '|' expr { BINARY_LONG_OP($$, |, $1, $3); }
> > | expr '&' expr { BINARY_LONG_OP($$, &, $1, $3); }
> > | expr '^' expr { BINARY_LONG_OP($$, ^, $1, $3); }
> > --
> > 2.34.0.rc1.387.gb447b232ab-goog
> >
--
- Arnaldo
next prev parent reply other threads:[~2021-11-11 13:42 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-11 0:21 [PATCH v2 0/8] New function and literals for metrics Ian Rogers
2021-11-11 0:21 ` [PATCH v2 1/8] perf test: Add expr test for events with hyphens Ian Rogers
2021-11-11 0:21 ` [PATCH v2 2/8] perf cputopo: Update to use pakage_cpus Ian Rogers
2021-11-11 0:21 ` [PATCH v2 3/8] perf cputopo: Match die_siblings to topology ABI name Ian Rogers
2021-11-11 0:21 ` [PATCH v2 4/8] perf cputopo: Match thread_siblings " Ian Rogers
2021-11-11 0:21 ` [PATCH v2 5/8] perf expr: Add literal values starting with # Ian Rogers
2021-11-11 0:21 ` [PATCH v2 6/8] perf expr: Add metric literals for topology Ian Rogers
2021-11-11 0:21 ` [PATCH v2 7/8] perf expr: Move ID handling to its own function Ian Rogers
2021-11-11 8:21 ` Jiri Olsa
2021-11-11 13:42 ` Arnaldo Carvalho de Melo [this message]
2021-11-11 0:21 ` [PATCH v2 8/8] perf expr: Add source_count for aggregating events Ian Rogers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YY0dxuHTPTuQH+4B@kernel.org \
--to=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=john.garry@huawei.com \
--cc=jolsa@redhat.com \
--cc=kan.liang@linux.intel.com \
--cc=kjain@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=maddy@linux.ibm.com \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=pc@us.ibm.com \
--cc=peterz@infradead.org \
--cc=rickyman7@gmail.com \
--cc=song@kernel.org \
--cc=wanjiabing@vivo.com \
--cc=yury.norov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).