From: sashiko-bot@kernel.org
To: "Ian Rogers" <irogers@google.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v2 2/2] perf test: Add stat metrics --for-each-cgroup test
Date: Tue, 19 May 2026 02:59:00 +0000 [thread overview]
Message-ID: <20260519025900.D05B3C2BCB7@smtp.kernel.org> (raw)
In-Reply-To: <20260519015108.3094513-3-irogers@google.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] The test will falsely fail on healthy systems if the tested cgroups are idle.
- [Medium] The capability checks verify unrelated events instead of the tested metric, risking false failures on unsupported hardware.
- [Medium] A loose substring match causes the test to falsely pass if metrics for the root cgroup are missing.
--
commit 87b9c1deb7ab23590530747e324c9b8bf5728b9d
Author: Ian Rogers <irogers@google.com>
perf test: Add stat metrics --for-each-cgroup test
This commit adds a new shell test stat_metrics_cgrp.sh to verify metric
reporting with --for-each-cgroup. It checks if system-wide monitoring is
supported and tests both standard mode and BPF counters mode.
> diff --git a/tools/perf/tests/shell/stat_metrics_cgrp.sh b/tools/perf/tests/shell/stat_metrics_cgrp.sh
> new file mode 100755
> index 0000000000000..2f74bd9e3f2ee
> --- /dev/null
> +++ b/tools/perf/tests/shell/stat_metrics_cgrp.sh
[ ... ]
> +# skip if system-wide is not supported
> +check_system_wide()
> +{
> + log_verbose "Checking system-wide..."
> + if ! perf stat -a -e instructions sleep 0.01 > /dev/null 2>&1
> + then
> + log_verbose "Skipping: system-wide monitoring not supported"
> + exit 2
> + fi
> +}
This check verifies the instructions event, but the test measures
insn_per_cycle which also requires cycles. If a test environment supports
instructions but lacks hardware support for cycles (such as in some virtual
environments), will this preliminary check pass but cause the actual test
to fail? Could this capability check use --metrics=insn_per_cycle instead?
[ ... ]
> + # Split test_cgroups by comma
> + IFS=',' read -r -a cgrps <<< "${test_cgroups}"
> +
> + for cgrp in "${cgrps[@]}"; do
> + # Find lines for this cgroup and metric
> + local cgrp_lines
> + cgrp_lines=$(echo "${output}" | grep -F "${cgrp}" | grep "insn_per_cycle" || true)
When cgrp is / (the root cgroup), won't grep -F "/" match any sub-cgroup
containing a slash, like /user.slice? If perf stat fails to output metrics
for the root cgroup, it seems cgrp_lines might still be populated by the
child's metrics, potentially causing the test to pass and hide a failure.
> +
> + if [ -z "${cgrp_lines}" ]
> + then
> + echo "FAIL: No metric lines found for cgroup '${cgrp}'"
> + exit 1
> + fi
> +
> + # Check for nan or nested
> + if echo "${cgrp_lines}" | grep -q -i -E ",nan,|,nested,"
> + then
> + echo "FAIL: Invalid metric value (nan/nested) for cgroup '${cgrp}'"
> + echo "Line: ${cgrp_lines}"
> + exit 1
> + fi
> + # Check for empty metric value
> + if echo "${cgrp_lines}" | grep -q -E ",,[[:space:]]*[^,]*insn_per_cycle"
> + then
> + echo "FAIL: Empty metric value for cgroup '${cgrp}'"
If a tested cgroup like user.slice is completely idle during the 0.1 second
sleep, its cycles and instructions counts will be 0. Would the insn_per_cycle
metric evaluate to NaN and be output as an empty field in CSV mode?
If so, will this check cause the test to falsely fail on healthy systems
where the tested cgroups happen to be idle?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260519015108.3094513-1-irogers@google.com?part=2
next prev parent reply other threads:[~2026-05-19 2:59 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-18 22:22 [PATCH v1 0/2] Fix cgroup metric association with BPF counters Ian Rogers
2026-05-18 22:22 ` [PATCH v1 1/2] perf stat: Propagate supported flag to follower cgroup BPF events Ian Rogers
2026-05-18 22:22 ` [PATCH v1 2/2] perf test: Add stat metrics --for-each-cgroup test Ian Rogers
2026-05-18 22:43 ` sashiko-bot
2026-05-19 1:51 ` [PATCH v2 0/2] Fix cgroup metric association with BPF counters Ian Rogers
2026-05-19 1:51 ` [PATCH v2 1/2] perf stat: Propagate supported flag to follower cgroup BPF events Ian Rogers
2026-05-19 1:51 ` [PATCH v2 2/2] perf test: Add stat metrics --for-each-cgroup test Ian Rogers
2026-05-19 2:59 ` sashiko-bot [this message]
2026-05-19 5:01 ` [PATCH v3 0/2] Fix cgroup metric association with BPF counters Ian Rogers
2026-05-19 5:01 ` [PATCH v3 1/2] perf stat: Propagate supported flag to follower cgroup BPF events Ian Rogers
2026-05-19 5:39 ` sashiko-bot
2026-05-19 5:47 ` Namhyung Kim
2026-05-19 5:01 ` [PATCH v3 2/2] perf test: Add stat metrics --for-each-cgroup test Ian Rogers
2026-05-19 5:47 ` sashiko-bot
2026-05-19 5:54 ` Namhyung Kim
2026-05-19 15:13 ` Ian Rogers
2026-05-19 17:09 ` Namhyung Kim
2026-05-19 15:27 ` [PATCH v4 0/2] Fix cgroup metric association with BPF counters Ian Rogers
2026-05-19 15:27 ` [PATCH v4 1/2] perf stat: Propagate supported flag to follower cgroup BPF events Ian Rogers
2026-05-19 15:27 ` [PATCH v4 2/2] perf test: Add stat metrics --for-each-cgroup test 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=20260519025900.D05B3C2BCB7@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