Linux Perf Users
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Tengda Wu <wutengda@huaweicloud.com>,
	Namhyung Kim <namhyung@kernel.org>, <james.clark@linaro.org>,
	<xueshuai@linux.alibaba.com>
Cc: Peter Zijlstra <peterz@infradead.org>, <leo.yan@linux.dev>,
	Li Huafei <lihuafei1@huawei.com>, Ian Rogers <irogers@google.com>,
	Kim Phillips <kim.phillips@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	"Arnaldo Carvalho de Melo" <acme@kernel.org>,
	Ingo Molnar <mingo@redhat.com>, Bill Wendling <morbo@google.com>,
	Nick Desaulniers <nick.desaulniers+lkml@gmail.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Zecheng Li <zli94@ncsu.edu>, <linux-perf-users@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <llvm@lists.linux.dev>
Subject: Re: [PATCH v5 10/26] perf annotate: Default to --itrace=i1i for data type profiling
Date: Wed, 9 Sep 2026 18:38:26 +0300	[thread overview]
Message-ID: <e16c65fb-f020-4417-a7a4-bd34da79214d@intel.com> (raw)
In-Reply-To: <a30bf174539765875129c06381932702934fd0c9.1788872630.git.wutengda@huaweicloud.com>

On 08/09/2026 16:05, Tengda Wu wrote:
> ARM SPE-based sampling can synthesize multiple events on a single
> instruction, as shown below. This would affect data type profiling
> statistics:
> 
>   Available samples
>   0 arm_spe_0/ts_enable=1,pa_enable=1,load_filter=1,store_filter=1,min_latency=30/
>   0 dummy:u
>   84K l1d-miss
>   95K l1d-access
>   77K llc-miss
>   58K llc-access
>   9K tlb-miss
>   108K tlb-access
>   0 branch
>   13K remote-access
>   108K memory
>   108K instructions
> 
> While 'perf report' provides an interactive menu for users to select a
> specific event to prevent duplicate counting, 'perf annotate' lacks such
> a mechanism. Consequently, it counts all instructions across these
> overlapping events, which inflates the profile and distorts the data
> type statistics.
> 
> Although using the '--itrace' option can work around this issue (e.g.:
> perf annotate --data-type --stdio --itrace=i1i), it is inconvenient for
> users to specify this explicitly every time.
> 
> To address this, introduce itrace_synth_opts.default_single_event_per_ip.
> Set this field to true when data type profiling is enabled and the user
> has not explicitly specified an itrace option. In itrace_synth_opts__set_default(),
> use this flag to default to synthesizing at most one event per IP (equivalent
> to --itrace=i1i) to prevent duplicate sample counts.
> 
> Signed-off-by: Tengda Wu <wutengda@huaweicloud.com>

Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
>  tools/perf/builtin-annotate.c |  8 ++++++++
>  tools/perf/util/arm-spe.c     |  5 ++++-
>  tools/perf/util/auxtrace.c    | 12 ++++++++++--
>  tools/perf/util/auxtrace.h    |  7 ++++++-
>  tools/perf/util/cs-etm.c      |  2 +-
>  tools/perf/util/intel-bts.c   |  2 +-
>  tools/perf/util/intel-pt.c    |  3 ++-
>  7 files changed, 32 insertions(+), 7 deletions(-)
> 
> diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
> index 69cb72b2082a..d5b66893c47c 100644
> --- a/tools/perf/builtin-annotate.c
> +++ b/tools/perf/builtin-annotate.c
> @@ -873,6 +873,14 @@ int cmd_annotate(int argc, const char **argv)
>  	annotate.session = perf_session__new(&data, &annotate.tool);
>  	if (IS_ERR(annotate.session))
>  		return PTR_ERR(annotate.session);
> +	/*
> +	 * Hardware tracing (e.g., ARM SPE) may synthesize multiple events per
> +	 * instruction. When data type profiling is enabled, default to synthesizing
> +	 * at most one event (equivalent to --itrace=i1i) to prevent skewed
> +	 * statistics.
> +	 */
> +	if (annotate.data_type && !itrace_synth_opts.set)
> +		itrace_synth_opts.default_single_event_per_ip = true;
>  
>  	annotate.session->itrace_synth_opts = &itrace_synth_opts;
>  
> diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c
> index 401aab529309..ae7a5e9c3892 100644
> --- a/tools/perf/util/arm-spe.c
> +++ b/tools/perf/util/arm-spe.c
> @@ -2029,7 +2029,10 @@ int arm_spe_process_auxtrace_info(union perf_event *event,
>  	if (session->itrace_synth_opts && session->itrace_synth_opts->set) {
>  		spe->synth_opts = *session->itrace_synth_opts;
>  	} else {
> -		itrace_synth_opts__set_default(&spe->synth_opts, false);
> +		struct itrace_synth_opts *opts = session->itrace_synth_opts;
> +		bool single_event_per_ip = opts ? opts->default_single_event_per_ip : false;
> +
> +		itrace_synth_opts__set_default(&spe->synth_opts, false, single_event_per_ip);
>  		/* Default nanoseconds period not supported */
>  		spe->synth_opts.period_type = PERF_ITRACE_PERIOD_INSTRUCTIONS;
>  		spe->synth_opts.period = 1;
> diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
> index aa749e1c3036..ed2113190785 100644
> --- a/tools/perf/util/auxtrace.c
> +++ b/tools/perf/util/auxtrace.c
> @@ -1478,8 +1478,15 @@ s64 perf_event__process_auxtrace(const struct perf_tool *tool __maybe_unused,
>  #define PERF_ITRACE_MAX_LAST_BRANCH_SZ		1024
>  
>  void itrace_synth_opts__set_default(struct itrace_synth_opts *synth_opts,
> -				    bool no_sample)
> +				    bool no_sample, bool single_event_per_ip)
>  {
> +	if (single_event_per_ip) {
> +		synth_opts->instructions = true;
> +		synth_opts->period_type = PERF_ITRACE_PERIOD_INSTRUCTIONS;
> +		synth_opts->period = 1;
> +		return;
> +	}
> +
>  	synth_opts->branches = true;
>  	synth_opts->transactions = true;
>  	synth_opts->ptwrites = true;
> @@ -1582,7 +1589,8 @@ int itrace_do_parse_synth_opts(struct itrace_synth_opts *synth_opts,
>  
>  	if (!str) {
>  		itrace_synth_opts__set_default(synth_opts,
> -					       synth_opts->default_no_sample);
> +					       synth_opts->default_no_sample,
> +					       synth_opts->default_single_event_per_ip);
>  		return 0;
>  	}
>  
> diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h
> index 6947f3f284c0..5012bead1b92 100644
> --- a/tools/perf/util/auxtrace.h
> +++ b/tools/perf/util/auxtrace.h
> @@ -65,6 +65,10 @@ enum itrace_period_type {
>   * struct itrace_synth_opts - AUX area tracing synthesis options.
>   * @set: indicates whether or not options have been set
>   * @default_no_sample: Default to no sampling.
> + * @default_single_event_per_ip: Default to synthesizing at most 1 event per IP
> + *                               (equivalent to --itrace=i1i). Used by commands
> + *                               like 'perf annotate --data-type' to avoid duplicate
> + *                               sample counts for a single instruction.
>   * @inject: indicates the event (not just the sample) must be fully synthesized
>   *          because 'perf inject' will write it out
>   * @instructions: whether to synthesize 'instructions' events
> @@ -117,6 +121,7 @@ enum itrace_period_type {
>  struct itrace_synth_opts {
>  	bool			set;
>  	bool			default_no_sample;
> +	bool			default_single_event_per_ip;
>  	bool			inject;
>  	bool			instructions;
>  	bool			cycles;
> @@ -622,7 +627,7 @@ int itrace_do_parse_synth_opts(struct itrace_synth_opts *synth_opts,
>  int itrace_parse_synth_opts(const struct option *opt, const char *str,
>  			    int unset);
>  void itrace_synth_opts__set_default(struct itrace_synth_opts *synth_opts,
> -				    bool no_sample);
> +				    bool no_sample, bool single_event_per_ip);
>  
>  size_t perf_event__fprintf_auxtrace_error(union perf_event *event, FILE *fp);
>  void perf_session__auxtrace_error_inc(struct perf_session *session,
> diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
> index 114b3cd2da49..2d1ab34f7b6b 100644
> --- a/tools/perf/util/cs-etm.c
> +++ b/tools/perf/util/cs-etm.c
> @@ -3626,7 +3626,7 @@ int cs_etm__process_auxtrace_info_full(union perf_event *event,
>  		etm->synth_opts = *session->itrace_synth_opts;
>  	} else {
>  		itrace_synth_opts__set_default(&etm->synth_opts,
> -				session->itrace_synth_opts->default_no_sample);
> +				session->itrace_synth_opts->default_no_sample, false);
>  		etm->synth_opts.callchain = false;
>  		etm->synth_opts.thread_stack = session->itrace_synth_opts->thread_stack;
>  	}
> diff --git a/tools/perf/util/intel-bts.c b/tools/perf/util/intel-bts.c
> index 02df3e460489..4c9cca3acb6c 100644
> --- a/tools/perf/util/intel-bts.c
> +++ b/tools/perf/util/intel-bts.c
> @@ -877,7 +877,7 @@ int intel_bts_process_auxtrace_info(union perf_event *event,
>  		bts->synth_opts = *session->itrace_synth_opts;
>  	} else {
>  		itrace_synth_opts__set_default(&bts->synth_opts,
> -				session->itrace_synth_opts->default_no_sample);
> +				session->itrace_synth_opts->default_no_sample, false);
>  		bts->synth_opts.thread_stack =
>  				session->itrace_synth_opts->thread_stack;
>  	}
> diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
> index 9d6628169fd9..8c21c9f52d57 100644
> --- a/tools/perf/util/intel-pt.c
> +++ b/tools/perf/util/intel-pt.c
> @@ -4463,7 +4463,8 @@ int intel_pt_process_auxtrace_info(union perf_event *event,
>  	} else {
>  		struct itrace_synth_opts *opts = session->itrace_synth_opts;
>  
> -		itrace_synth_opts__set_default(&pt->synth_opts, opts->default_no_sample);
> +		itrace_synth_opts__set_default(&pt->synth_opts,
> +					opts->default_no_sample, false);
>  		if (!opts->default_no_sample && !opts->inject) {
>  			pt->synth_opts.branches = false;
>  			pt->synth_opts.callchain = true;


  parent reply	other threads:[~2026-09-09 15:38 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08 13:05 [PATCH v5 00/26] perf arm64: Support data type profiling Tengda Wu
2026-09-08 13:05 ` [PATCH v5 01/26] perf capstone: Symbolize address operands to match objdump on arm64 Tengda Wu
2026-09-08 13:18   ` sashiko-bot
2026-09-09 14:49     ` Namhyung Kim
2026-09-10  7:38       ` Tengda Wu
2026-09-08 13:05 ` [PATCH v5 02/26] perf llvm: Fix arm64 adrp instruction disassembly mismatch with objdump Tengda Wu
2026-09-08 13:16   ` sashiko-bot
2026-09-09 14:50   ` Namhyung Kim
2026-09-08 13:05 ` [PATCH v5 03/26] perf annotate-arm64: Generalize arm64_mov__parse to support more instructions Tengda Wu
2026-09-08 13:15   ` sashiko-bot
2026-09-09 14:52   ` Namhyung Kim
2026-09-08 13:05 ` [PATCH v5 04/26] perf annotate-arm64: Handle load and store instructions Tengda Wu
2026-09-08 13:15   ` sashiko-bot
2026-09-09 14:58   ` Namhyung Kim
2026-09-08 13:05 ` [PATCH v5 05/26] perf annotate: Normalize arch__dwarf_regnum() error return values Tengda Wu
2026-09-08 13:24   ` sashiko-bot
2026-09-08 17:57   ` Ian Rogers
2026-09-09 15:00     ` Namhyung Kim
2026-09-08 13:05 ` [PATCH v5 06/26] perf annotate: Introduce extract_op_location callback for arch-specific parsing Tengda Wu
2026-09-08 13:20   ` sashiko-bot
2026-09-09 15:01   ` Namhyung Kim
2026-09-08 13:05 ` [PATCH v5 07/26] perf dwarf-regs: Adapt get_dwarf_regnum() for arm64 Tengda Wu
2026-09-08 13:21   ` sashiko-bot
2026-09-09 15:03     ` Namhyung Kim
2026-09-08 13:05 ` [PATCH v5 08/26] perf annotate: Adapt arch__dwarf_regnum() " Tengda Wu
2026-09-08 13:15   ` sashiko-bot
2026-09-09 15:04   ` Namhyung Kim
2026-09-08 13:05 ` [PATCH v5 09/26] perf annotate-arm64: Implement extract_op_location() callback Tengda Wu
2026-09-08 13:18   ` sashiko-bot
2026-09-10  8:49     ` Tengda Wu
2026-09-08 13:05 ` [PATCH v5 10/26] perf annotate: Default to --itrace=i1i for data type profiling Tengda Wu
2026-09-08 13:15   ` sashiko-bot
2026-09-09 15:38   ` Adrian Hunter [this message]
2026-09-08 13:05 ` [PATCH v5 11/26] perf arm-spe: Set default synthesized event period to 1 Tengda Wu
2026-09-08 13:12   ` sashiko-bot
2026-09-08 13:05 ` [PATCH v5 12/26] perf annotate-data: Extract invalidate_reg_state() as a common helper Tengda Wu
2026-09-08 13:11   ` sashiko-bot
2026-09-08 13:05 ` [PATCH v5 13/26] perf annotate-arm64: Enable instruction tracking support Tengda Wu
2026-09-08 13:18   ` sashiko-bot
2026-09-10  9:20     ` Tengda Wu
2026-09-08 13:05 ` [PATCH v5 14/26] perf annotate-data: Add arch_get_reg_offset helper Tengda Wu
2026-09-08 13:22   ` sashiko-bot
2026-09-10 12:13     ` Tengda Wu
2026-09-08 13:05 ` [PATCH v5 15/26] perf annotate-arm64: Track return type after call instructions Tengda Wu
2026-09-08 13:14   ` sashiko-bot
2026-09-08 13:05 ` [PATCH v5 16/26] perf annotate-arm64: Support load instruction tracking Tengda Wu
2026-09-08 13:23   ` sashiko-bot
2026-09-10 13:19     ` Tengda Wu
2026-09-10 13:28   ` Tengda Wu
2026-09-08 13:05 ` [PATCH v5 17/26] perf annotate-arm64: Support store " Tengda Wu
2026-09-08 13:22   ` sashiko-bot
2026-09-08 13:05 ` [PATCH v5 18/26] perf annotate-data: Expand type_state_reg imm_value to u64 Tengda Wu
2026-09-08 13:26   ` sashiko-bot
2026-09-08 13:05 ` [PATCH v5 19/26] perf annotate-data: Track imm_value for stack variables Tengda Wu
2026-09-08 13:29   ` sashiko-bot
2026-09-08 13:05 ` [PATCH v5 20/26] perf annotate-x86: Delete stale stack state on store of untracked register Tengda Wu
2026-09-08 13:20   ` sashiko-bot
2026-09-08 13:05 ` [PATCH v5 21/26] perf annotate-arm64: Support stack variable tracking Tengda Wu
2026-09-08 13:36   ` sashiko-bot
2026-09-11  1:41     ` Tengda Wu
2026-09-08 13:05 ` [PATCH v5 22/26] perf annotate-arm64: Support 'mov' instruction tracking Tengda Wu
2026-09-08 13:27   ` sashiko-bot
2026-09-11  2:22     ` Tengda Wu
2026-09-08 13:05 ` [PATCH v5 23/26] perf annotate-arm64: Support 'add' " Tengda Wu
2026-09-08 13:27   ` sashiko-bot
2026-09-11  2:29     ` Tengda Wu
2026-09-08 13:06 ` [PATCH v5 24/26] perf annotate-arm64: Support 'adrp' instruction to track global variables Tengda Wu
2026-09-08 13:26   ` sashiko-bot
2026-09-08 13:06 ` [PATCH v5 25/26] perf annotate-arm64: Support per-cpu variable access tracking Tengda Wu
2026-09-08 13:30   ` sashiko-bot
2026-09-11 10:15     ` Tengda Wu
2026-09-08 13:06 ` [PATCH v5 26/26] perf annotate-arm64: Support 'mrs' instruction to track 'current' pointer Tengda Wu
2026-09-08 13:31   ` sashiko-bot
  -- strict thread matches above, loose matches on Subject: below --
2026-09-08 13:00 [PATCH v5 00/26] perf arm64: Support data type profiling Tengda Wu
2026-09-08 13:01 ` [PATCH v5 10/26] perf annotate: Default to --itrace=i1i for " Tengda Wu

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=e16c65fb-f020-4417-a7a4-bd34da79214d@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=kim.phillips@arm.com \
    --cc=leo.yan@linux.dev \
    --cc=lihuafei1@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=morbo@google.com \
    --cc=namhyung@kernel.org \
    --cc=nick.desaulniers+lkml@gmail.com \
    --cc=peterz@infradead.org \
    --cc=wutengda@huaweicloud.com \
    --cc=xueshuai@linux.alibaba.com \
    --cc=zli94@ncsu.edu \
    /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