From: sashiko-bot@kernel.org
To: "Ian Rogers" <irogers@google.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH] perf evlist: Reparent first_wildcard_match when evsels are removed
Date: Fri, 04 Dec 2026 01:36:00 +0000 [thread overview]
Message-ID: <sashiko-outbox-248899@kernel.org> (raw)
In-Reply-To: <20261204011846.1959123-1-irogers@google.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] perf: evlist__add() map propagation omits wildcard
reparenting
--
commit 21a926f2d87a03affcb864c9eb166a663484742d
Author: Ian Rogers <irogers@google.com>
perf evlist: Reparent first_wildcard_match when evsels are removed
This patch adds helpers to reparent first_wildcard_match when an evsel is
removed from an evlist, calling them from evlist__remove(),
evlist__create_maps(), and evlist__create_syswide_maps(), along with unit
tests in tools/perf/tests/hybrid-merge.c.
> diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
> index c2402e4791b64..4b8cba6410c45 100644
> --- a/tools/perf/util/evlist.c
> +++ b/tools/perf/util/evlist.c
[ ... ]
> @@ -1383,6 +1421,7 @@ int evlist__create_maps(struct evlist *evlist, struct target *target)
> evlist__core(evlist)->has_user_cpus = !!target->cpu_list;
>
> perf_evlist__set_maps(evlist__core(evlist), cpus, threads);
> + evlist__fix_removed_wildcard_matches(evlist);
>
> /* as evlist now has references, put count here */
> perf_cpu_map__put(cpus);
[Severity: Medium]
Can evlist__add() still leave stale first_wildcard_match pointers before
evlist__create_maps() runs, or when it is never called?
evlist__new() calls perf_evlist__set_maps() with NULL maps, which sets
needs_map_propagation on every new evlist. During __parse_events() ->
evlist__splice_list_tail(), evlist__add() runs
__perf_evlist__propagate_maps() and removes an empty-CPU primary evsel.
For an event with a per-event cpu= term (such as cycles/cpu=0/ when cpu_atom
does not cover CPU 0), the later evsels are added with first_wildcard_match
still pointing to the removed evsel.
In perf stat --for-each-cgroup, evlist__expand_cgroup() runs before
evlist__create_maps() and copies pos->first_wildcard_match->priv. Since the
removed evsel was never in the list, priv is NULL, permanently breaking
wildcard merging among the surviving PMUs.
Callers such as pyrf__parse_events() set maps before parse_events() and never
call evlist__create_maps(), leaving dangling first_wildcard_match pointers.
Would calling evlist__fix_removed_wildcard_matches() in
evlist__splice_list_tail() (or reparenting on removal in evlist__add()) cover
these paths?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204011846.1959123-1-irogers@google.com?part=1
prev parent reply other threads:[~2026-12-04 1:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 1:18 [PATCH] perf evlist: Reparent first_wildcard_match when evsels are removed Ian Rogers
2026-12-04 1:36 ` sashiko-bot [this message]
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=sashiko-outbox-248899@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=irogers@google.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.