From: sashiko-bot@kernel.org
To: "Chun-Tse Shao" <ctshao@google.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH] perf stat: Check aliases in should_skip_zero_counter
Date: Fri, 01 May 2026 18:26:13 +0000 [thread overview]
Message-ID: <20260501182614.8A183C2BCC4@smtp.kernel.org> (raw)
In-Reply-To: <20260501181129.938256-1-ctshao@google.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The alias checking loop introduces an O(M * N^2) time complexity during the display phase, causing unnecessary overhead.
--
commit 1ba80061bda839b47a8c18bdc8aa600c735044d6
Author: Chun-Tse Shao <ctshao@google.com>
perf stat: Check aliases in should_skip_zero_counter
This commit checks aliases directly in should_skip_zero_counter instead of
mutating CPU maps in evsel__merge_aggr_counters. This is done to prevent
zero count aggregation IDs from being hidden in aggregated modes like
--per-socket.
> diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
> index 993f4c4b8f442..c12a3405118a5 100644
> --- a/tools/perf/util/stat-display.c
> +++ b/tools/perf/util/stat-display.c
> @@ -945,6 +945,27 @@ static bool should_skip_zero_counter(struct perf_stat_config *config,
> if (aggr_cpu_id__equal(id, &own_id))
> return false;
> }
> +
> + /*
> + * If the counter is a leader in alias merging, check if the aggr id
> + * matches any of its aliases.
> + */
> + if (config->aggr_mode != AGGR_NONE && counter->first_wildcard_match == NULL) {
> + struct evsel *alias;
> +
> + evlist__for_each_entry(counter->evlist, alias) {
Does this introduce an O(M * N^2) time complexity during the display phase?
Since should_skip_zero_counter() is called for each aggregation unit (M) and
each event (N), the function is called O(M * N) times.
If the event is a standalone event or an alias leader, this block iterates
over the entire evlist (N events) to find its aliases.
Could this scale poorly for very large event lists by introducing unnecessary
iterations, leading to an overall O(M * N^2) complexity?
> + if (alias->first_wildcard_match == counter) {
> + perf_cpu_map__for_each_cpu(cpu, idx, alias->core.cpus) {
> + struct aggr_cpu_id own_id =
> + config->aggr_get_id(config, cpu);
> +
> + if (aggr_cpu_id__equal(id, &own_id))
> + return false;
> + }
> + }
> + }
> + }
> +
> return true;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260501181129.938256-1-ctshao@google.com?part=1
next prev parent reply other threads:[~2026-05-01 18:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-01 18:11 [PATCH] perf stat: Check aliases in should_skip_zero_counter Chun-Tse Shao
2026-05-01 18:26 ` sashiko-bot [this message]
2026-05-01 19:12 ` Ian Rogers
2026-05-01 21:41 ` Chun-Tse Shao
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=20260501182614.8A183C2BCC4@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=ctshao@google.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko@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