From: sashiko-bot@kernel.org
To: "Ian Rogers" <irogers@google.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v2 01/12] perf parse-events: Restrict core PMU bypass to --cputype option
Date: Tue, 16 Jun 2026 06:31:57 +0000 [thread overview]
Message-ID: <20260616063157.945531F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260616061404.41929-2-irogers@google.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
New issues:
- [High] Hardcoded `false` for `cputype_filter` in `add_default_events()` breaks parsing of default metrics when `--cputype` is used.
Pre-existing issues:
- [High] In `__parse_events()`, an error during group sorting leads to a memory leak and incorrect success return code.
- [High] In `parse_groups()`, `combined_evlist` is leaked on error paths.
--
commit b77824e04893a569eb872e4ec5bd9c15848d74b6
Author: Ian Rogers <irogers@google.com>
perf parse-events: Restrict core PMU bypass to --cputype option
This commit introduces a cputype_filter flag to distinguish PMU filtering
initiated by --cputype from --pmu-filter, restricting the core-only PMU
bypass to the former.
> diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
> index a04466ea3b0a0..2505bc604e532 100644
> --- a/tools/perf/builtin-stat.c
> +++ b/tools/perf/builtin-stat.c
[ ... ]
> @@ -1999,7 +2001,7 @@ static int add_default_events(void)
> ret = -1;
> goto out;
> }
> - ret = metricgroup__parse_groups(evlist, pmu, "transaction",
> + ret = metricgroup__parse_groups(evlist, pmu, false, "transaction",
[Severity: High]
Should parse_events_option_args.cputype_filter be passed here instead of
hardcoding false?
If the --cputype option is active, hardcoding false causes
parse_events__filter_pmu() to filter out software and uncore PMU events
required by default metrics (like duration_time). This causes default metric
parsing to fail and can abort perf stat entirely.
[ ... ]
> @@ -2036,7 +2038,7 @@ static int add_default_events(void)
> if (!force_metric_only)
> stat_config.metric_only = true;
>
> - ret = metricgroup__parse_groups(evlist, pmu, "smi",
> + ret = metricgroup__parse_groups(evlist, pmu, false, "smi",
[Severity: High]
Similarly here, does this hardcoded false break the smi metric when using
the --cputype option?
[ ... ]
> @@ -2073,7 +2075,7 @@ static int add_default_events(void)
> }
> str[8] = stat_config.topdown_level + '0';
> if (metricgroup__parse_groups(evlist,
> - pmu, str,
> + pmu, false, str,
[Severity: High]
Does this hardcoded false break the Topdown metric group parsing when using
the --cputype option?
[ ... ]
> @@ -2112,7 +2114,7 @@ static int add_default_events(void)
> ret = -ENOMEM;
> break;
> }
> - if (metricgroup__parse_groups(metric_evlist, pmu, default_metricgroup_names[i],
> + if (metricgroup__parse_groups(metric_evlist, pmu, false, default_metricgroup_names[i],
[Severity: High]
Does this hardcoded false break the standard default metrics when using
the --cputype option?
> diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
> index c2ce3e53aaee7..9c9b048838411 100644
> --- a/tools/perf/util/metricgroup.c
> +++ b/tools/perf/util/metricgroup.c
[ ... ]
> @@ -1476,7 +1480,8 @@ static int parse_groups(struct evlist *perf_evlist,
> if (!metric_evlist) {
> ret = parse_ids(metric_no_merge, fake_pmu, m->pctx, m->modifier,
> m->group_events, tool_events, &m->evlist,
> - (pmu && strcmp(pmu, "all") == 0) ? NULL : pmu);
> + (pmu && strcmp(pmu, "all") == 0) ? NULL : pmu,
> + cputype_filter);
> if (ret)
> goto out;
[Severity: High]
This is a pre-existing issue, but does this error path leak combined_evlist?
If a subsequent operation in the metric_list loop fails, the function jumps
to the out: label:
tools/perf/util/metricgroup.c:parse_groups() {
...
if (combined_evlist) {
evlist__splice_list_tail(perf_evlist, &combined_evlist->core.entries);
evlist__delete(combined_evlist);
}
...
out:
metricgroup__free_metrics(&metric_list);
return ret;
}
Since the cleanup for combined_evlist is located above the out: label, it gets
completely skipped, leaking the list and its events.
> diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
> index 943569e82b82f..9f64d5197b8a8 100644
> --- a/tools/perf/util/parse-events.c
> +++ b/tools/perf/util/parse-events.c
[ ... ]
> @@ -2288,18 +2291,20 @@ static int parse_events__sort_events_and_fix_groups(struct list_head *list)
> return (idx_changed || num_leaders != orig_num_leaders) ? 1 : 0;
> }
>
> -int __parse_events(struct evlist *evlist, const char *str, const char *pmu_filter,
> +int __parse_events(struct evlist *evlist, const char *str,
> + const char *pmu_filter, bool cputype_filter,
> struct parse_events_error *err, bool fake_pmu,
> bool warn_if_reordered, bool fake_tp)
> {
> struct parse_events_state parse_state = {
[Severity: High]
This is a pre-existing issue, but does __parse_events() leak memory and
falsely report success if group sorting fails?
If parse_events__sort_events_and_fix_groups() returns a negative error code
(e.g., due to ENOMEM), the function returns the successful ret instead of
the error code ret2:
tools/perf/util/parse-events.c:__parse_events() {
...
ret = parse_events__scanner(str, &parse_state);
...
ret2 = parse_events__sort_events_and_fix_groups(&parse_state.list);
if (ret2 < 0)
return ret;
...
}
Returning here also bypasses the call to evlist__splice_list_tail(), which
causes all dynamically allocated evsel elements in parse_state.list to be
lost and leaked when the list goes out of scope.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260616061404.41929-1-irogers@google.com?part=1
next prev parent reply other threads:[~2026-06-16 6:31 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-16 1:27 [PATCH v1 00/12] perf tests: Enhancements, speedups, and flakiness fixes Ian Rogers
2026-06-16 1:27 ` [PATCH v1 01/12] perf parse-events: Restrict core PMU bypass to --cputype option Ian Rogers
2026-06-16 1:44 ` sashiko-bot
2026-06-16 1:27 ` [PATCH v1 02/12] perf test: Truncate test description to fit terminal width Ian Rogers
2026-06-16 1:38 ` sashiko-bot
2026-06-16 1:27 ` [PATCH v1 03/12] perf tests workloads: Support sub-second durations in noploop and thloop Ian Rogers
2026-06-16 1:35 ` sashiko-bot
2026-06-16 1:27 ` [PATCH v1 04/12] perf tests: Add robust record retry helper and use subsecond workloads Ian Rogers
2026-06-16 1:38 ` sashiko-bot
2026-06-16 1:27 ` [PATCH v1 05/12] perf tests: Skip metrics validation if system-wide recording lacks permission Ian Rogers
2026-06-16 1:41 ` sashiko-bot
2026-06-16 1:27 ` [PATCH v1 06/12] perf tests: Fix Python JIT dump profiling test failure Ian Rogers
2026-06-16 1:39 ` sashiko-bot
2026-06-16 1:27 ` [PATCH v1 07/12] perf tests: Fix flakiness in trace record and replay test Ian Rogers
2026-06-16 1:42 ` sashiko-bot
2026-06-16 1:27 ` [PATCH v1 08/12] perf tests: Fix flakiness in BPF counters test on hybrid systems Ian Rogers
2026-06-16 1:35 ` sashiko-bot
2026-06-16 1:27 ` [PATCH v1 09/12] perf tests: Fix flakiness in branch stack sampling tests Ian Rogers
2026-06-16 1:27 ` [PATCH v1 10/12] perf tests: Speed up off-cpu profiling tests Ian Rogers
2026-06-16 1:41 ` sashiko-bot
2026-06-16 1:27 ` [PATCH v1 11/12] perf tests: Speed up lock contention analysis shell test Ian Rogers
2026-06-16 1:27 ` [PATCH v1 12/12] perf tests: Speed up metrics checking shell tests Ian Rogers
2026-06-16 6:13 ` [PATCH v2 00/12] perf tests: Enhance robustness, speed up execution, and fix flakiness Ian Rogers
2026-06-16 6:13 ` [PATCH v2 01/12] perf parse-events: Restrict core PMU bypass to --cputype option Ian Rogers
2026-06-16 6:31 ` sashiko-bot [this message]
2026-06-16 6:13 ` [PATCH v2 02/12] perf test: Truncate test description to fit terminal width Ian Rogers
2026-06-16 6:24 ` sashiko-bot
2026-06-16 6:13 ` [PATCH v2 03/12] perf tests workloads: Support sub-second durations in noploop and thloop Ian Rogers
2026-06-16 6:22 ` sashiko-bot
2026-06-16 6:13 ` [PATCH v2 04/12] perf tests: Add robust record retry helper and use subsecond workloads Ian Rogers
2026-06-16 6:27 ` sashiko-bot
2026-06-16 6:13 ` [PATCH v2 05/12] perf tests: Skip metrics validation if system-wide recording lacks permission Ian Rogers
2026-06-16 6:13 ` [PATCH v2 06/12] perf tests: Fix Python JIT dump profiling test failure Ian Rogers
2026-06-16 6:27 ` sashiko-bot
2026-06-16 6:13 ` [PATCH v2 07/12] perf tests: Fix flakiness in trace record and replay test Ian Rogers
2026-06-16 6:27 ` sashiko-bot
2026-06-16 6:14 ` [PATCH v2 08/12] perf tests: Fix flakiness in BPF counters test on hybrid systems Ian Rogers
2026-06-16 6:14 ` [PATCH v2 09/12] perf tests: Fix flakiness in branch stack sampling tests Ian Rogers
2026-06-16 6:14 ` [PATCH v2 10/12] perf tests: Speed up off-cpu profiling tests Ian Rogers
2026-06-16 6:25 ` sashiko-bot
2026-06-16 6:14 ` [PATCH v2 11/12] perf tests: Speed up lock contention analysis shell test Ian Rogers
2026-06-16 6:14 ` [PATCH v2 12/12] perf tests: Speed up metrics checking shell tests Ian Rogers
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=20260616063157.945531F000E9@smtp.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox