From: Ian Rogers <irogers@google.com>
To: irogers@google.com, acme@kernel.org, namhyung@kernel.org
Cc: ak@kernel.org, ak@linux.intel.com, andi@firstfloor.org,
linux-perf-users@vger.kernel.org
Subject: [PATCH v3 5/9] perf evlist: Toggle merged_hybrid_group properly in enable/disable
Date: Wed, 16 Sep 2026 16:46:48 -0700 [thread overview]
Message-ID: <20260916234652.439778-6-irogers@google.com> (raw)
In-Reply-To: <20260916234652.439778-1-irogers@google.com>
Merging makes the merged event the leader of the events of the other
core PMUs so their histograms can be linked, but the result isn't a
real event group. Each event keeps its own file descriptor and has to
be enabled and disabled in its own right.
__evlist__enable(), __evlist__disable() and evlist__is_enabled() skip
anything that isn't a group leader, and the first two then walk the
group members of the events they do act on. For a merged set that is
backwards: the members are skipped by the leader test, so their file
descriptors are never touched, and the walk over the leader's members
only updates the bookkeeping in evsel->disabled.
Treat an evsel with merged_hybrid_group set as a leader so that it is
enabled and disabled in its own right via its own file descriptors.
perf top enables and disables by event name. A merged member carries
the name of its own PMU rather than the name that was asked for, so
also match it against its leader's name, otherwise naming the event
toggles only part of the merged set.
Signed-off-by: Ian Rogers <irogers@google.com>
Assisted-by: Antigravity:gemini-3.1-pro
---
tools/perf/util/evlist.c | 35 ++++++++++++++++++++++++++---------
1 file changed, 26 insertions(+), 9 deletions(-)
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 930efbb66bc8..22eb01116992 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -753,7 +753,9 @@ static bool evlist__is_enabled(struct evlist *evlist)
struct evsel *pos;
evlist__for_each_entry(evlist, pos) {
- if (!evsel__is_group_leader(pos) || !pos->core.fd)
+ if (!pos->core.fd)
+ continue;
+ if (!evsel__is_group_leader(pos) && !pos->merged_hybrid_group)
continue;
/* If at least one event is enabled, evlist is enabled. */
if (!pos->disabled)
@@ -767,14 +769,19 @@ static void __evlist__disable(struct evlist *evlist, char *evsel_name, bool excl
struct evsel *pos, *member;
struct evlist_cpu_iterator evlist_cpu_itr;
bool has_imm = false;
+ bool match;
/* Disable 'immediate' events last */
for (int imm = 0; imm <= 1; imm++) {
evlist__for_each_cpu(evlist_cpu_itr, evlist) {
pos = evlist_cpu_itr.evsel;
- if (evsel__strcmp(pos, evsel_name))
+ match = !evsel__strcmp(pos, evsel_name);
+ if (!match && pos->merged_hybrid_group && evsel__leader(pos))
+ match = !evsel__strcmp(evsel__leader(pos), evsel_name);
+ if (!match)
continue;
- if (pos->disabled || !evsel__is_group_leader(pos) || !pos->core.fd)
+ if (pos->disabled || (!evsel__is_group_leader(pos) &&
+ !pos->merged_hybrid_group) || !pos->core.fd)
continue;
if (excl_dummy && evsel__is_dummy_event(pos))
continue;
@@ -789,9 +796,12 @@ static void __evlist__disable(struct evlist *evlist, char *evsel_name, bool excl
}
evlist__for_each_entry(evlist, pos) {
- if (evsel__strcmp(pos, evsel_name))
+ match = !evsel__strcmp(pos, evsel_name);
+ if (!match && pos->merged_hybrid_group && evsel__leader(pos))
+ match = !evsel__strcmp(evsel__leader(pos), evsel_name);
+ if (!match)
continue;
- if (!evsel__is_group_leader(pos) || !pos->core.fd)
+ if ((!evsel__is_group_leader(pos) && !pos->merged_hybrid_group) || !pos->core.fd)
continue;
if (excl_dummy && evsel__is_dummy_event(pos))
continue;
@@ -827,21 +837,28 @@ static void __evlist__enable(struct evlist *evlist, char *evsel_name, bool excl_
{
struct evsel *pos, *member;
struct evlist_cpu_iterator evlist_cpu_itr;
+ bool match;
evlist__for_each_cpu(evlist_cpu_itr, evlist) {
pos = evlist_cpu_itr.evsel;
- if (evsel__strcmp(pos, evsel_name))
+ match = !evsel__strcmp(pos, evsel_name);
+ if (!match && pos->merged_hybrid_group && evsel__leader(pos))
+ match = !evsel__strcmp(evsel__leader(pos), evsel_name);
+ if (!match)
continue;
- if (!evsel__is_group_leader(pos) || !pos->core.fd)
+ if ((!evsel__is_group_leader(pos) && !pos->merged_hybrid_group) || !pos->core.fd)
continue;
if (excl_dummy && evsel__is_dummy_event(pos))
continue;
evsel__enable_cpu(pos, evlist_cpu_itr.cpu_map_idx);
}
evlist__for_each_entry(evlist, pos) {
- if (evsel__strcmp(pos, evsel_name))
+ match = !evsel__strcmp(pos, evsel_name);
+ if (!match && pos->merged_hybrid_group && evsel__leader(pos))
+ match = !evsel__strcmp(evsel__leader(pos), evsel_name);
+ if (!match)
continue;
- if (!evsel__is_group_leader(pos) || !pos->core.fd)
+ if ((!evsel__is_group_leader(pos) && !pos->merged_hybrid_group) || !pos->core.fd)
continue;
if (excl_dummy && evsel__is_dummy_event(pos))
continue;
--
2.55.0.1082.g2b9226bbc0-goog
next prev parent reply other threads:[~2026-09-16 23:47 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 ` Ian Rogers [this message]
2026-09-16 23:53 ` [PATCH v3 5/9] perf evlist: Toggle merged_hybrid_group properly in enable/disable 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
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=20260916234652.439778-6-irogers@google.com \
--to=irogers@google.com \
--cc=acme@kernel.org \
--cc=ak@kernel.org \
--cc=ak@linux.intel.com \
--cc=andi@firstfloor.org \
--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