linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ian Rogers <irogers@google.com>
To: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Kajol Jain <kjain@linux.ibm.com>, Andi Kleen <ak@linux.intel.com>,
	Jin Yao <yao.jin@linux.intel.com>,
	Kan Liang <kan.liang@linux.intel.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Leo Yan <leo.yan@linaro.org>, LKML <linux-kernel@vger.kernel.org>,
	Stephane Eranian <eranian@google.com>
Subject: Re: [PATCH 1/2] perf expr: Force encapsulation on expr_id_data
Date: Wed, 26 Aug 2020 08:32:12 -0700	[thread overview]
Message-ID: <CAP-5=fVT6wDwJPJFF30ttBeAcOxgkqiQgUPEKtwZWbPLJPqtBw@mail.gmail.com> (raw)
In-Reply-To: <20200826113354.GB753783@krava>

On Wed, Aug 26, 2020 at 4:34 AM Jiri Olsa <jolsa@redhat.com> wrote:
>
> On Tue, Aug 25, 2020 at 09:29:09PM -0700, Ian Rogers wrote:
> > This patch resolves some undefined behavior where variables in
> > expr_id_data were accessed (for debugging) without being defined. To
> > better enforce the tagged union behavior, the struct is moved into
> > expr.c and accessors provided. Tag values (kinds) are explicitly
> > identified.
> >
> > Signed-off-by: Ian Rogers <irogers@google.com>
> > ---
> >  tools/perf/util/expr.c        | 64 ++++++++++++++++++++++++++++++-----
> >  tools/perf/util/expr.h        | 17 +++-------
> >  tools/perf/util/expr.y        |  2 +-
> >  tools/perf/util/metricgroup.c |  4 +--
> >  4 files changed, 62 insertions(+), 25 deletions(-)
> >
> > diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c
> > index 53482ef53c41..1ca0992db86b 100644
> > --- a/tools/perf/util/expr.c
> > +++ b/tools/perf/util/expr.c
> > @@ -17,6 +17,25 @@
> >  extern int expr_debug;
> >  #endif
> >
> > +struct expr_id_data {
> > +     union {
> > +             double val;
> > +             struct {
> > +                     double val;
> > +                     const char *metric_name;
> > +                     const char *metric_expr;
> > +             } ref;
> > +             struct expr_id  *parent;
> > +     };
> > +
> > +     enum {
> > +             EXPR_ID_DATA__VALUE,
> > +             EXPR_ID_DATA__REF,
> > +             EXPR_ID_DATA__REF_VALUE,
> > +             EXPR_ID_DATA__PARENT,
> > +     } kind;
>
> I like that, it's more clear than current state ;-)
>
> could you still put a small comment for each enum above,
> as a hint what it's used for?

Thanks, I had a go at this in v2:
https://lore.kernel.org/lkml/20200826153055.2067780-1-irogers@google.com/T/#u

Ian

> thanks,
> jirka
>

      reply	other threads:[~2020-08-26 15:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-26  4:29 [PATCH 1/2] perf expr: Force encapsulation on expr_id_data Ian Rogers
2020-08-26  4:29 ` [PATCH 2/2] perf parse-events: Avoid an uninitialized read Ian Rogers
2020-08-26 11:34   ` Jiri Olsa
2020-08-26 13:20     ` Arnaldo Carvalho de Melo
2020-08-26 11:33 ` [PATCH 1/2] perf expr: Force encapsulation on expr_id_data Jiri Olsa
2020-08-26 15:32   ` Ian Rogers [this message]

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='CAP-5=fVT6wDwJPJFF30ttBeAcOxgkqiQgUPEKtwZWbPLJPqtBw@mail.gmail.com' \
    --to=irogers@google.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=eranian@google.com \
    --cc=jolsa@redhat.com \
    --cc=kan.liang@linux.intel.com \
    --cc=kjain@linux.ibm.com \
    --cc=leo.yan@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=yao.jin@linux.intel.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).