Linux Perf Users
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: namhyung@kernel.org, ak@kernel.org, ak@linux.intel.com,
	andi@firstfloor.org, linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v4 3/9] perf tools: Expose opt-in --hybrid-merge
Date: Fri, 18 Sep 2026 17:31:41 -0300	[thread overview]
Message-ID: <aq2fraVJUKUS2I2z@x2> (raw)
In-Reply-To: <20260917050708.704702-4-irogers@google.com>

On Wed, Sep 16, 2026 at 10:07:02PM -0700, Ian Rogers wrote:
> Add --hybrid-merge to perf report and perf top. It merges the events a
> wildcard expanded to across the core PMUs, and their histograms, so
> that a symbol which ran on more than one kind of core is reported once
> with the total rather than once per PMU.
> 
> evlist__merge_hybrid() links the events and evlist__merge_hists_hybrid()
> links the histograms. There is nothing to merge on a machine with a
> single core PMU, or when the events didn't come from a wildcard, so
> warn in that case rather than quietly producing an unmerged report.
> 
> Merging collapses the per-PMU entries into one set, which doesn't
> combine with the per-level breakdown of --hierarchy, so asking for both
> is an error.

It would be interesting to have a hotkey to switch to this mode on the
fly and back, even if it required to reset everything when doing so, but
probably it should be possible on the -> hybrid-merge way.

- Arnaldo
 
> Signed-off-by: Ian Rogers <irogers@google.com>
> Assisted-by: Antigravity:gemini-3.1-pro
> ---
>  tools/perf/Documentation/perf-report.txt |  5 +++++
>  tools/perf/Documentation/perf-top.txt    |  5 +++++
>  tools/perf/builtin-report.c              | 19 +++++++++++++++++++
>  tools/perf/builtin-top.c                 | 17 +++++++++++++++++
>  tools/perf/util/symbol.c                 |  1 +
>  5 files changed, 47 insertions(+)
> 
> diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
> index 1a4706329c6c..3718ebd297ce 100644
> --- a/tools/perf/Documentation/perf-report.txt
> +++ b/tools/perf/Documentation/perf-report.txt
> @@ -578,6 +578,11 @@ include::itrace.txt[]
>  --raw-trace::
>  	When displaying traceevent output, do not use print fmt or plugins.
>  
> +--hybrid-merge::
> +	Merge matching events from all hybrid core PMUs into one
> +	display. For example, if a wildcard expands to run on both p-cores and
> +	e-cores, this aggregates them into a single view.
> +
>  -H::
>  --hierarchy::
>  	Enable hierarchical output.  In the hierarchy mode, each sort key groups
> diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt
> index 2da2a16bbf26..c5e96da6ed82 100644
> --- a/tools/perf/Documentation/perf-top.txt
> +++ b/tools/perf/Documentation/perf-top.txt
> @@ -49,6 +49,11 @@ Default is to monitor all CPUS.
>  	encoding with the layout of the event control registers as described
>  	by entries in /sys/bus/event_source/devices/cpu/format/*.
>  
> +--hybrid-merge::
> +	Merge matching events from all hybrid core PMUs into one
> +	display. For example, if a wildcard expands to run on both p-cores and
> +	e-cores, this aggregates them into a single view.
> +
>  --filter=<filter>::
>  	Event filter.  This option should follow an event selector (-e). For
>  	syntax see linkperf:perf-record[1].
> diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
> index 279e61c2366c..bda4836fc524 100644
> --- a/tools/perf/builtin-report.c
> +++ b/tools/perf/builtin-report.c
> @@ -1114,6 +1114,17 @@ static int __cmd_report(struct report *rep)
>  	evlist__for_each_entry(session->evlist, pos)
>  		rep->nr_entries += evsel__hists(pos)->nr_entries;
>  
> +	if (symbol_conf.hybrid_merge) {
> +		struct perf_env *env = perf_session__env(session);
> +
> +		if (evlist__can_merge_hybrid(session->evlist, env)) {
> +			evlist__merge_hybrid(session->evlist, env);
> +			evlist__merge_hists_hybrid(session->evlist, false);
> +		} else {
> +			ui__warning("--hybrid-merge: no events to merge across core PMUs\n");
> +		}
> +	}
> +
>  	if (use_browser == 0) {
>  		if (verbose > 3)
>  			perf_session__fprintf(session, stdout);
> @@ -1449,6 +1460,8 @@ int cmd_report(int argc, const char **argv)
>  		    parse_branch_mode),
>  	OPT_BOOLEAN(0, "branch-history", &branch_call_mode,
>  		    "add last branch records to call history"),
> +	OPT_BOOLEAN(0, "hybrid-merge", &symbol_conf.hybrid_merge,
> +		    "merge the same event across hybrid core PMUs"),
>  	OPT_STRING(0, "objdump", &objdump_path, "path",
>  		   "objdump binary to use for disassembly and annotations"),
>  	OPT_STRING(0, "addr2line", &addr2line_path, "path",
> @@ -1548,6 +1561,12 @@ int cmd_report(int argc, const char **argv)
>  		report.symbol_filter_str = argv[0];
>  	}
>  
> +	if (symbol_conf.report_hierarchy && symbol_conf.hybrid_merge) {
> +		pr_err("Error: --hierarchy and --hybrid-merge are mutually exclusive.\n");
> +		ret = -EINVAL;
> +		goto exit;
> +	}
> +
>  	if (disassembler_style) {
>  		annotate_opts.disassembler_style = strdup(disassembler_style);
>  		if (!annotate_opts.disassembler_style)
> diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
> index c2562d49be46..3bb3337f1244 100644
> --- a/tools/perf/builtin-top.c
> +++ b/tools/perf/builtin-top.c
> @@ -1336,6 +1336,15 @@ static int __cmd_top(struct perf_top *top)
>          if (!target__none(&opts->target))
>  		evlist__enable(top->evlist);
>  
> +	if (symbol_conf.hybrid_merge) {
> +		if (evlist__can_merge_hybrid(top->evlist, /*env=*/NULL)) {
> +			evlist__merge_hybrid(top->evlist, /*env=*/NULL);
> +			evlist__merge_hists_hybrid(top->evlist, false);
> +		} else {
> +			ui__warning("--hybrid-merge: no events to merge across core PMUs\n");
> +		}
> +	}
> +
>  	ret = -1;
>  	if (pthread_create(&thread_process, NULL, process_thread, top)) {
>  		ui__error("Could not create process thread.\n");
> @@ -1491,6 +1500,8 @@ int cmd_top(int argc, const char **argv)
>  	OPT_CALLBACK('e', "event", &parse_events_option_args, "event",
>  		     "event selector. use 'perf list' to list available events",
>  		     parse_events_option),
> +	OPT_BOOLEAN(0, "hybrid-merge", &symbol_conf.hybrid_merge,
> +		    "merge the same event across hybrid core PMUs"),
>  	OPT_CALLBACK(0, "filter", &top.evlist, "filter",
>  		     "event filter", parse_filter),
>  	OPT_U64('c', "count", &opts->user_interval, "event period to sample"),
> @@ -1679,6 +1690,12 @@ int cmd_top(int argc, const char **argv)
>  	if (argc)
>  		usage_with_options(top_usage, options);
>  
> +	if (symbol_conf.report_hierarchy && symbol_conf.hybrid_merge) {
> +		pr_err("Error: --hierarchy and --hybrid-merge are mutually exclusive.\n");
> +		status = -EINVAL;
> +		goto out_put_evlist;
> +	}
> +
>  	if (disassembler_style) {
>  		annotate_opts.disassembler_style = strdup(disassembler_style);
>  		if (!annotate_opts.disassembler_style) {
> diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
> index 3206929473a2..163652f071c6 100644
> --- a/tools/perf/util/symbol.c
> +++ b/tools/perf/util/symbol.c
> @@ -74,6 +74,7 @@ struct symbol_conf symbol_conf = {
>  	.symfs			= "",
>  	.symfs_layout_flat	= false,
>  	.event_group		= true,
> +	.hybrid_merge		= false,
>  	.inline_name		= true,
>  	.res_sample		= 0,
>  	.addr2line_timeout_ms	= 5 * 1000,
> -- 
> 2.55.0.1082.g2b9226bbc0-goog

  parent reply	other threads:[~2026-09-18 20:31 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-16  6:52 [PATCH v2 0/9] perf report/top: Add opt-in --hybrid-merge Ian Rogers
2026-09-16  6:52 ` [PATCH v2 1/9] perf evlist: Implement evlist__can_merge_hybrid using first_wildcard_match Ian Rogers
2026-09-16  7:02   ` sashiko-bot
2026-09-16  6:52 ` [PATCH v2 2/9] perf ui hist: Add support for aggregated total_period and merging entries Ian Rogers
2026-09-16  7:04   ` sashiko-bot
2026-09-16  6:52 ` [PATCH v2 3/9] perf tools: Expose opt-in --hybrid-merge Ian Rogers
2026-09-16  7:04   ` sashiko-bot
2026-09-16  6:52 ` [PATCH v2 4/9] perf Documentation: Add tip for hybrid event merging Ian Rogers
2026-09-16  6:59   ` sashiko-bot
2026-09-16  6:52 ` [PATCH v2 5/9] perf evlist: Toggle merged_hybrid_group properly in enable/disable Ian Rogers
2026-09-16  7:06   ` sashiko-bot
2026-09-16  6:52 ` [PATCH v2 6/9] perf tools: Add TUI hints for --hybrid-merge Ian Rogers
2026-09-16  7:01   ` sashiko-bot
2026-09-16  6:52 ` [PATCH v2 7/9] perf config: Add core.hybrid-merge to configure event merging Ian Rogers
2026-09-16  6:59   ` sashiko-bot
2026-09-16  6:52 ` [PATCH v2 8/9] perf test: Expand tests for --hybrid-merge Ian Rogers
2026-09-16  7:04   ` sashiko-bot
2026-09-16  6:52 ` [PATCH v2 9/9] perf test: Isolate test suite from user .perfconfig natively Ian Rogers
2026-09-16  7:08   ` sashiko-bot
2026-09-16 23:46 ` [PATCH v3 0/9] perf report/top: Add opt-in --hybrid-merge Ian Rogers
2026-09-16 23:46   ` [PATCH v3 1/9] perf evlist: Implement evlist__can_merge_hybrid using first_wildcard_match Ian Rogers
2026-09-16 23:58     ` sashiko-bot
2026-09-16 23:46   ` [PATCH v3 2/9] perf ui hist: Add support for aggregated total_period and merging entries Ian Rogers
2026-09-16 23:57     ` sashiko-bot
2026-09-16 23:46   ` [PATCH v3 3/9] perf tools: Expose opt-in --hybrid-merge Ian Rogers
2026-09-16 23:57     ` sashiko-bot
2026-09-16 23:46   ` [PATCH v3 4/9] perf Documentation: Add tip for hybrid event merging Ian Rogers
2026-09-16 23:48     ` sashiko-bot
2026-09-16 23:46   ` [PATCH v3 5/9] perf evlist: Toggle merged_hybrid_group properly in enable/disable Ian Rogers
2026-09-16 23:53     ` sashiko-bot
2026-09-16 23:46   ` [PATCH v3 6/9] perf tools: Add TUI hints for --hybrid-merge Ian Rogers
2026-09-16 23:53     ` sashiko-bot
2026-09-16 23:46   ` [PATCH v3 7/9] perf config: Add core.hybrid-merge to configure event merging Ian Rogers
2026-09-16 23:57     ` sashiko-bot
2026-09-16 23:46   ` [PATCH v3 8/9] perf test: Expand tests for --hybrid-merge Ian Rogers
2026-09-16 23:53     ` sashiko-bot
2026-09-16 23:46   ` [PATCH v3 9/9] perf test: Isolate test suite from user .perfconfig natively Ian Rogers
2026-09-16 23:57     ` sashiko-bot
2026-09-17  5:06   ` [PATCH v4 0/9] perf report/top: Add opt-in --hybrid-merge Ian Rogers
2026-09-17  5:07     ` [PATCH v4 1/9] perf evlist: Implement evlist__can_merge_hybrid using first_wildcard_match Ian Rogers
2026-09-17  5:14       ` sashiko-bot
2026-09-17  5:07     ` [PATCH v4 2/9] perf ui hist: Add support for aggregated total_period and merging entries Ian Rogers
2026-09-17  5:16       ` sashiko-bot
2026-09-17  5:07     ` [PATCH v4 3/9] perf tools: Expose opt-in --hybrid-merge Ian Rogers
2026-09-17  5:16       ` sashiko-bot
2026-09-18 20:31       ` Arnaldo Carvalho de Melo [this message]
2026-09-18 20:51         ` Ian Rogers
2026-09-17  5:07     ` [PATCH v4 4/9] perf Documentation: Add tip for hybrid event merging Ian Rogers
2026-09-17  5:10       ` sashiko-bot
2026-09-17  5:07     ` [PATCH v4 5/9] perf evlist: Toggle merged_hybrid_group properly in enable/disable Ian Rogers
2026-09-17  5:13       ` sashiko-bot
2026-09-17  5:07     ` [PATCH v4 6/9] perf tools: Add TUI hints for --hybrid-merge Ian Rogers
2026-09-17  5:14       ` sashiko-bot
2026-09-17  5:07     ` [PATCH v4 7/9] perf config: Add core.hybrid-merge to configure event merging Ian Rogers
2026-09-17  5:16       ` sashiko-bot
2026-09-17  5:07     ` [PATCH v4 8/9] perf test: Expand tests for --hybrid-merge Ian Rogers
2026-09-17  5:18       ` sashiko-bot
2026-09-17  5:07     ` [PATCH v4 9/9] perf test: Isolate test suite from user .perfconfig natively Ian Rogers
2026-09-17  5:17       ` sashiko-bot
2026-09-18 20:40     ` [PATCH v4 0/9] perf report/top: Add opt-in --hybrid-merge Arnaldo Carvalho de Melo
2026-09-18 21:58       ` Arnaldo Carvalho de Melo
2026-09-18 22:07         ` Ian Rogers
2026-09-18 22:11           ` Ian Rogers
2026-09-18 23:04           ` Arnaldo Melo

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=aq2fraVJUKUS2I2z@x2 \
    --to=acme@kernel.org \
    --cc=ak@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=andi@firstfloor.org \
    --cc=irogers@google.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=namhyung@kernel.org \
    /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