linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Ian Rogers <irogers@google.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>,
	Kan Liang <kan.liang@linux.intel.com>,
	John Garry <john.g.garry@oracle.com>,
	Will Deacon <will@kernel.org>, James Clark <james.clark@arm.com>,
	Mike Leach <mike.leach@linaro.org>, Leo Yan <leo.yan@linux.dev>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Yicong Yang <yangyicong@hisilicon.com>,
	Jonathan Cameron <jonathan.cameron@huawei.com>,
	Nick Terrell <terrelln@fb.com>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Oliver Upton <oliver.upton@linux.dev>,
	Anshuman Khandual <anshuman.khandual@arm.com>,
	Song Liu <song@kernel.org>,
	Ilkka Koskinen <ilkka@os.amperecomputing.com>,
	Huacai Chen <chenhuacai@kernel.org>,
	Yanteng Si <siyanteng@loongson.cn>,
	Sun Haiyong <sunhaiyong@loongson.cn>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 01/27] perf auxevent: Zero size dummy tool
Date: Fri, 28 Jun 2024 20:44:50 +0300	[thread overview]
Message-ID: <d36acf6a-1505-459d-b392-be0fc952ad08@intel.com> (raw)
In-Reply-To: <20240626203630.1194748-2-irogers@google.com>

In subject: "auxevent" -> "auxtrace"

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@google.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

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

>  					   &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,


  reply	other threads:[~2024-06-28 17:45 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-26 20:36 [PATCH v2 00/27] Constify tool pointers Ian Rogers
2024-06-26 20:36 ` [PATCH v2 01/27] perf auxevent: Zero size dummy tool Ian Rogers
2024-06-28 17:44   ` Adrian Hunter [this message]
2024-06-28 18:34     ` Ian Rogers
2024-06-26 20:36 ` [PATCH v2 02/27] perf cs-etm: Fix address sanitizer dso build failure Ian Rogers
2024-06-26 20:36 ` [PATCH v2 03/27] perf tool: Constify tool pointers Ian Rogers
2024-06-26 20:36 ` [PATCH v2 04/27] perf tool: Move fill defaults into tool.c Ian Rogers
2024-06-26 20:36 ` [PATCH v2 05/27] perf tool: Add perf_tool__init Ian Rogers
2024-06-26 20:36 ` [PATCH v2 06/27] perf kmem: Use perf_tool__init Ian Rogers
2024-06-26 20:36 ` [PATCH v2 07/27] perf buildid-list: " Ian Rogers
2024-06-26 20:36 ` [PATCH v2 08/27] perf kvm: " Ian Rogers
2024-06-26 20:36 ` [PATCH v2 09/27] perf lock: " Ian Rogers
2024-06-26 20:36 ` [PATCH v2 10/27] perf evlist: " Ian Rogers
2024-06-26 20:36 ` [PATCH v2 11/27] perf record: " Ian Rogers
2024-06-26 20:36 ` [PATCH v2 12/27] perf c2c: " Ian Rogers
2024-06-26 20:36 ` [PATCH v2 13/27] perf script: " Ian Rogers
2024-06-26 20:36 ` [PATCH v2 14/27] perf inject: " Ian Rogers
2024-06-26 20:36 ` [PATCH v2 15/27] perf report: " Ian Rogers
2024-06-26 20:36 ` [PATCH v2 16/27] perf stat: " Ian Rogers
2024-06-26 20:36 ` [PATCH v2 17/27] perf annotate: " Ian Rogers
2024-06-26 20:36 ` [PATCH v2 18/27] perf sched: " Ian Rogers
2024-06-26 20:36 ` [PATCH v2 19/27] perf mem: " Ian Rogers
2024-06-26 20:36 ` [PATCH v2 20/27] perf timechart: " Ian Rogers
2024-06-26 20:36 ` [PATCH v2 21/27] perf diff: " Ian Rogers
2024-06-26 20:36 ` [PATCH v2 22/27] perf data convert json: " Ian Rogers
2024-06-26 20:36 ` [PATCH v2 23/27] perf data convert ctf: " Ian Rogers
2024-06-26 20:36 ` [PATCH v2 24/27] perf test event_update: Ensure tools is initialized Ian Rogers
2024-06-26 20:36 ` [PATCH v2 25/27] perf kwork: Use perf_tool__init Ian Rogers
2024-06-26 20:36 ` [PATCH v2 26/27] perf tool: Remove perf_tool__fill_defaults Ian Rogers
2024-06-26 20:36 ` [PATCH v2 27/27] perf session: Constify tool Ian Rogers
2024-06-28 17:24 ` [PATCH v2 00/27] Constify tool pointers Namhyung Kim
2024-06-28 17:52   ` Ian Rogers
2024-06-28 22:07     ` Namhyung Kim

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=d36acf6a-1505-459d-b392-be0fc952ad08@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=anshuman.khandual@arm.com \
    --cc=chenhuacai@kernel.org \
    --cc=ilkka@os.amperecomputing.com \
    --cc=irogers@google.com \
    --cc=james.clark@arm.com \
    --cc=john.g.garry@oracle.com \
    --cc=jolsa@kernel.org \
    --cc=jonathan.cameron@huawei.com \
    --cc=kan.liang@linux.intel.com \
    --cc=leo.yan@linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mike.leach@linaro.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=oliver.upton@linux.dev \
    --cc=peterz@infradead.org \
    --cc=siyanteng@loongson.cn \
    --cc=song@kernel.org \
    --cc=sunhaiyong@loongson.cn \
    --cc=suzuki.poulose@arm.com \
    --cc=terrelln@fb.com \
    --cc=will@kernel.org \
    --cc=yangyicong@hisilicon.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).