From 5c9ceee75a90cd5db0d38d9dbfde6659194a9b5b Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Sun, 24 May 2026 10:29:50 -0400 Subject: Revert "perf cgroup: Update metric leader in evlist__expand_cgroup" This reverts commit d26e31446c0fa96feca0b7701243b42447225d33. Signed-off-by: Sasha Levin --- tools/perf/util/cgroup.c | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) --- a/tools/perf/util/cgroup.c +++ b/tools/perf/util/cgroup.c @@ -417,6 +417,7 @@ int evlist__expand_cgroup(struct evlist struct rblist *metric_events, bool open_cgroup) { struct evlist *orig_list, *tmp_list; + struct evsel *pos, *evsel, *leader; struct rblist orig_metric_events; struct cgroup *cgrp = NULL; struct cgroup_name *cn; @@ -455,7 +456,6 @@ int evlist__expand_cgroup(struct evlist goto out_err; list_for_each_entry(cn, &cgroup_list, list) { - struct evsel *pos; char *name; if (!cn->used) @@ -471,37 +471,21 @@ int evlist__expand_cgroup(struct evlist if (cgrp == NULL) continue; - /* copy the list and set to the new cgroup. */ + leader = NULL; evlist__for_each_entry(orig_list, pos) { - struct evsel *evsel = evsel__clone(/*dest=*/NULL, pos); - + evsel = evsel__clone(/*dest=*/NULL, pos); if (evsel == NULL) goto out_err; - /* stash the copy during the copying. */ - pos->priv = evsel; cgroup__put(evsel->cgrp); evsel->cgrp = cgroup__get(cgrp); - evlist__add(tmp_list, evsel); - } - /* update leader information using stashed pointer to copy. */ - evlist__for_each_entry(orig_list, pos) { - struct evsel *evsel = pos->priv; - - if (evsel__leader(pos)) - evsel__set_leader(evsel, evsel__leader(pos)->priv); - - if (pos->metric_leader) - evsel->metric_leader = pos->metric_leader->priv; + if (evsel__is_group_leader(pos)) + leader = evsel; + evsel__set_leader(evsel, leader); - if (pos->first_wildcard_match) - evsel->first_wildcard_match = pos->first_wildcard_match->priv; + evlist__add(tmp_list, evsel); } - /* the stashed copy is no longer used. */ - evlist__for_each_entry(orig_list, pos) - pos->priv = NULL; - /* cgroup__new() has a refcount, release it here */ cgroup__put(cgrp); nr_cgroups++;