lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAP-5=fU6eUUJeoKTsO0nv=yFvG=Wu_z_1VVpyyWNx42h+BpSKQ@mail.gmail.com>
Date: Fri, 28 Jun 2024 11:34:51 -0700
From: Ian Rogers <irogers@...gle.com>
To: Adrian Hunter <adrian.hunter@...el.com>
Cc: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>, 
	Arnaldo Carvalho de Melo <acme@...nel.org>, Namhyung Kim <namhyung@...nel.org>, 
	Mark Rutland <mark.rutland@....com>, 
	Alexander Shishkin <alexander.shishkin@...ux.intel.com>, Jiri Olsa <jolsa@...nel.org>, 
	Kan Liang <kan.liang@...ux.intel.com>, John Garry <john.g.garry@...cle.com>, 
	Will Deacon <will@...nel.org>, James Clark <james.clark@....com>, 
	Mike Leach <mike.leach@...aro.org>, Leo Yan <leo.yan@...ux.dev>, 
	Suzuki K Poulose <suzuki.poulose@....com>, Yicong Yang <yangyicong@...ilicon.com>, 
	Jonathan Cameron <jonathan.cameron@...wei.com>, Nick Terrell <terrelln@...com>, 
	Nick Desaulniers <ndesaulniers@...gle.com>, Oliver Upton <oliver.upton@...ux.dev>, 
	Anshuman Khandual <anshuman.khandual@....com>, Song Liu <song@...nel.org>, 
	Ilkka Koskinen <ilkka@...amperecomputing.com>, Huacai Chen <chenhuacai@...nel.org>, 
	Yanteng Si <siyanteng@...ngson.cn>, Sun Haiyong <sunhaiyong@...ngson.cn>, 
	linux-kernel@...r.kernel.org, linux-perf-users@...r.kernel.org, 
	linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH v2 01/27] perf auxevent: Zero size dummy tool

On Fri, Jun 28, 2024 at 10:45 AM Adrian Hunter <adrian.hunter@...el.com> wrote:
>
> In subject: "auxevent" -> "auxtrace"

Ack.

> On 26/06/24 23:36, Ian Rogers wrote:
> > The dummy tool is passed as a placeholder to allow a container_of to
> > get additional parameters. As the tool isn't used, make it a zero
> > sized array saving 320 bytes on an x86_64 build.
> >
> > s390-cpumsf's dummy tool struct was unused, so remove.
> >
> > Signed-off-by: Ian Rogers <irogers@...gle.com>
> > ---
> >  tools/perf/util/arm-spe.c     | 6 +++---
> >  tools/perf/util/cs-etm.c      | 6 +++---
> >  tools/perf/util/intel-bts.c   | 6 +++---
> >  tools/perf/util/intel-pt.c    | 7 +++----
> >  tools/perf/util/s390-cpumsf.c | 5 -----
> >  5 files changed, 12 insertions(+), 18 deletions(-)
> >
> > diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c
> > index afbd5869f6bf..ee0d5064ddd4 100644
> > --- a/tools/perf/util/arm-spe.c
> > +++ b/tools/perf/util/arm-spe.c
> > @@ -1074,8 +1074,8 @@ static void arm_spe_print_info(__u64 *arr)
> >  }
> >
> >  struct arm_spe_synth {
> > -     struct perf_tool dummy_tool;
> >       struct perf_session *session;
> > +     struct perf_tool dummy_tool[0];
>
> [] is preferred to [0]
>
> >  };
> >
> >  static int arm_spe_event_synth(struct perf_tool *tool,
> > @@ -1084,7 +1084,7 @@ static int arm_spe_event_synth(struct perf_tool *tool,
> >                              struct machine *machine __maybe_unused)
> >  {
> >       struct arm_spe_synth *arm_spe_synth =
> > -                   container_of(tool, struct arm_spe_synth, dummy_tool);
> > +                   container_of(tool, struct arm_spe_synth, dummy_tool[0]);
> >
> >       return perf_session__deliver_synth_event(arm_spe_synth->session,
> >                                                event, NULL);
> > @@ -1098,7 +1098,7 @@ static int arm_spe_synth_event(struct perf_session *session,
> >       memset(&arm_spe_synth, 0, sizeof(struct arm_spe_synth));
> >       arm_spe_synth.session = session;
> >
> > -     return perf_event__synthesize_attr(&arm_spe_synth.dummy_tool, attr, 1,
> > +     return perf_event__synthesize_attr(arm_spe_synth.dummy_tool, attr, 1,
>
> Passing a pointer to an object that doesn't exist there is NAK IMO

Not disagreeing but I think it is at least more intention revealing
and efficient than passing a struct that isn't initialized because we
know the tool won't be used.

> It would be better to just write another version of
> perf_event__synthesize_attr().

I think we've gotten ourselves into this mess because we're doing poor
man's OO and we're trying to pass values via a tools/container_of
rather than just pass a value. I'm not keen on making this change
larger but I'll see if this can be done and we just explicitly pass
some "void* data" like value.

Thanks,
Ian

> >                                          &id, arm_spe_event_synth);
> >  }
> >
> > diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
> > index 32818bd7cd17..9fd2967d4e3f 100644
> > --- a/tools/perf/util/cs-etm.c
> > +++ b/tools/perf/util/cs-etm.c
> > @@ -1596,8 +1596,8 @@ static int cs_etm__synth_branch_sample(struct cs_etm_queue *etmq,
> >  }
> >
> >  struct cs_etm_synth {
> > -     struct perf_tool dummy_tool;
> >       struct perf_session *session;
> > +     struct perf_tool dummy_tool[0];
> >  };
> >
> >  static int cs_etm__event_synth(struct perf_tool *tool,
> > @@ -1606,7 +1606,7 @@ static int cs_etm__event_synth(struct perf_tool *tool,
> >                              struct machine *machine __maybe_unused)
> >  {
> >       struct cs_etm_synth *cs_etm_synth =
> > -                   container_of(tool, struct cs_etm_synth, dummy_tool);
> > +                   container_of(tool, struct cs_etm_synth, dummy_tool[0]);
> >
> >       return perf_session__deliver_synth_event(cs_etm_synth->session,
> >                                                event, NULL);
> > @@ -1620,7 +1620,7 @@ static int cs_etm__synth_event(struct perf_session *session,
> >       memset(&cs_etm_synth, 0, sizeof(struct cs_etm_synth));
> >       cs_etm_synth.session = session;
> >
> > -     return perf_event__synthesize_attr(&cs_etm_synth.dummy_tool, attr, 1,
> > +     return perf_event__synthesize_attr(cs_etm_synth.dummy_tool, attr, 1,
> >                                          &id, cs_etm__event_synth);
> >  }
> >
> > diff --git a/tools/perf/util/intel-bts.c b/tools/perf/util/intel-bts.c
> > index ec1b3bd9f530..fb8fec3a3c36 100644
> > --- a/tools/perf/util/intel-bts.c
> > +++ b/tools/perf/util/intel-bts.c
> > @@ -738,8 +738,8 @@ static bool intel_bts_evsel_is_auxtrace(struct perf_session *session,
> >  }
> >
> >  struct intel_bts_synth {
> > -     struct perf_tool dummy_tool;
> >       struct perf_session *session;
> > +     struct perf_tool dummy_tool[0];
> >  };
> >
> >  static int intel_bts_event_synth(struct perf_tool *tool,
> > @@ -748,7 +748,7 @@ static int intel_bts_event_synth(struct perf_tool *tool,
> >                                struct machine *machine __maybe_unused)
> >  {
> >       struct intel_bts_synth *intel_bts_synth =
> > -                     container_of(tool, struct intel_bts_synth, dummy_tool);
> > +                     container_of(tool, struct intel_bts_synth, dummy_tool[0]);
> >
> >       return perf_session__deliver_synth_event(intel_bts_synth->session,
> >                                                event, NULL);
> > @@ -762,7 +762,7 @@ static int intel_bts_synth_event(struct perf_session *session,
> >       memset(&intel_bts_synth, 0, sizeof(struct intel_bts_synth));
> >       intel_bts_synth.session = session;
> >
> > -     return perf_event__synthesize_attr(&intel_bts_synth.dummy_tool, attr, 1,
> > +     return perf_event__synthesize_attr(intel_bts_synth.dummy_tool, attr, 1,
> >                                          &id, intel_bts_event_synth);
> >  }
> >
> > diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
> > index d6d7b7512505..b8b90773baa2 100644
> > --- a/tools/perf/util/intel-pt.c
> > +++ b/tools/perf/util/intel-pt.c
> > @@ -3660,8 +3660,8 @@ static int intel_pt_queue_data(struct perf_session *session,
> >  }
> >
> >  struct intel_pt_synth {
> > -     struct perf_tool dummy_tool;
> >       struct perf_session *session;
> > +     struct perf_tool dummy_tool[0];
> >  };
> >
> >  static int intel_pt_event_synth(struct perf_tool *tool,
> > @@ -3670,7 +3670,7 @@ static int intel_pt_event_synth(struct perf_tool *tool,
> >                               struct machine *machine __maybe_unused)
> >  {
> >       struct intel_pt_synth *intel_pt_synth =
> > -                     container_of(tool, struct intel_pt_synth, dummy_tool);
> > +                     container_of(tool, struct intel_pt_synth, dummy_tool[0]);
> >
> >       return perf_session__deliver_synth_event(intel_pt_synth->session, event,
> >                                                NULL);
> > @@ -3687,8 +3687,7 @@ static int intel_pt_synth_event(struct perf_session *session, const char *name,
> >
> >       memset(&intel_pt_synth, 0, sizeof(struct intel_pt_synth));
> >       intel_pt_synth.session = session;
> > -
> > -     err = perf_event__synthesize_attr(&intel_pt_synth.dummy_tool, attr, 1,
> > +     err = perf_event__synthesize_attr(intel_pt_synth.dummy_tool, attr, 1,
> >                                         &id, intel_pt_event_synth);
> >       if (err)
> >               pr_err("%s: failed to synthesize '%s' event type\n",
> > diff --git a/tools/perf/util/s390-cpumsf.c b/tools/perf/util/s390-cpumsf.c
> > index 6fe478b0b61b..4ec583e511af 100644
> > --- a/tools/perf/util/s390-cpumsf.c
> > +++ b/tools/perf/util/s390-cpumsf.c
> > @@ -952,11 +952,6 @@ s390_cpumsf_process_event(struct perf_session *session,
> >       return err;
> >  }
> >
> > -struct s390_cpumsf_synth {
> > -     struct perf_tool cpumsf_tool;
> > -     struct perf_session *session;
> > -};
>
> Should really be a separate patch
>
> > -
> >  static int
> >  s390_cpumsf_process_auxtrace_event(struct perf_session *session,
> >                                  union perf_event *event __maybe_unused,
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ