From: sashiko-bot@kernel.org
To: "Arnaldo Carvalho de Melo" <acme@kernel.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v11 12/19] perf test: Exercise the annotate stats output
Date: Sun, 22 Nov 2026 21:53:03 +0000 [thread overview]
Message-ID: <sashiko-outbox-228396@kernel.org> (raw)
In-Reply-To: <20261122214025.16769-13-acme@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] perf test: annotate_stats.sh fails on archs without operand
extraction
- [Low] perf test: annotate_stats.sh awk check fails when bad type count
is 0
--
commit 88aa12c83c2352997344ef608d4e215c23a1b93b
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
perf test: Exercise the annotate stats output
This commit adds a shell test verifying the --insn-stat and --type-stat
output of perf annotate as well as the warning when --type-stat is used
without --data-type.
> diff --git a/tools/perf/tests/shell/annotate_stats.sh b/tools/perf/tests/shell/annotate_stats.sh
> new file mode 100755
> index 0000000000000..5d8a687e85ecb
> --- /dev/null
> +++ b/tools/perf/tests/shell/annotate_stats.sh
> @@ -0,0 +1,172 @@
[ ... ]
> +# Each event annotates the same instructions, so the two-event total is
> +# twice the one-event total.
> +one_total=$(awk '/^total / { t = $2; sub(/,/, "", t); print t; exit }' \
> + "$perfout")
> +two_total=$(awk '/^total / { t = $2; sub(/,/, "", t); print t; exit }' \
> + "$perfout2")
> +if [ -z "$one_total" ] || [ -z "$two_total" ] ||
> + [ "$two_total" -le 0 ] || [ "$two_total" -ne $((2 * one_total)) ]; then
> + echo "FAIL: instruction stats do not count every event" \
> + "(one event: ${one_total:-none}, two events: ${two_total:-none})"
> + tail -n 30 "$perfout2"
> + cleanup
> + exit 1
> +fi
[Severity: Medium]
Will this fail with exit code 1 instead of skipping on architectures that do
not implement instruction operand extraction for data-type profiling?
Unlike the perf mem record step later in the script, the cpu-clock and
task-clock recordings run on all architectures with DWARF support. However,
arch->extract_op_location and memory operand parsing are only implemented on
x86, arm64, and powerpc. On other architectures (such as s390x or riscv64),
__hist_entry__get_data_type() skips every operand because op_loc->mem_ref is
false and op_loc->segment is INSN_SEG_NONE, returning before incrementing
istat->good or istat->bad. As a result, one_total and two_total are both 0,
and [ "$two_total" -le 0 ] fails the test.
[ ... ]
> +# The total is the sum of the bad counters and of the good ones.
> +if ! awk '
> + /^Annotate data type stats:/ { stats = 1; next }
> + !stats { next }
> + /^total / {
> + t = $2; o = $4; b = $7
> + sub(/,/, "", t); sub(/,/, "", o); sub(/,/, "", b)
> + total = t; ok = o; bad = b; next
> + }
> + /^[[:space:]]*[0-9]+ : / && $3 != "insn_track" { fields += $1 }
> + END { exit !(total > 0 && total == ok + bad && bad == fields) }
> +' "$perfout"; then
> + echo "FAIL: data type stats do not add up"
> + tail -n 30 "$perfout"
> + cleanup
> + exit 1
> +fi
[Severity: Low]
Can the bad == fields check in awk fail when all sampled memory events
resolve their data types (bad == 0)?
In print_annotate_data_stat(), PRINT_STAT() only prints non-zero counters, so
when bad is 0 no bad counter lines are emitted and fields remains
uninitialized (""). Because sub(/,/, "", b) turns b into the string "0",
bad == fields compares "0" against "" as strings and exits with a failure.
Comparing bad + 0 == fields + 0 (or initializing fields = 0 in a BEGIN block)
would force numeric comparison.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261122214025.16769-1-acme@kernel.org?part=12
next prev parent reply other threads:[~2026-11-22 21:53 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 21:40 [PATCH v11 00/19] perf coverage: A harness for perf, and the fixes it found Arnaldo Carvalho de Melo
2026-11-22 21:40 ` [PATCH v11 01/19] perf build: Link the GTK UI with EXTRA_CFLAGS Arnaldo Carvalho de Melo
2026-11-22 21:40 ` [PATCH v11 02/19] perf annotate: Handle absolute addressing in data type profiling Arnaldo Carvalho de Melo
2026-11-22 21:40 ` [PATCH v11 03/19] perf annotate: Print the stats after the annotations Arnaldo Carvalho de Melo
2026-11-22 21:40 ` [PATCH v11 04/19] perf build: Record the features checked outside FEATURE_TESTS Arnaldo Carvalho de Melo
2026-11-22 21:40 ` [PATCH v11 05/19] perf annotate-x86: Record immediates in a 64-bit field Arnaldo Carvalho de Melo
2026-11-22 21:40 ` [PATCH v11 06/19] perf annotate-x86: Parse movabs like a mov Arnaldo Carvalho de Melo
2026-11-22 21:40 ` [PATCH v11 07/19] perf annotate-data: Count flexible array accesses for the whole struct Arnaldo Carvalho de Melo
2026-11-22 21:40 ` [PATCH v11 08/19] perf test: Exercise the x86 operand parser Arnaldo Carvalho de Melo
2026-11-22 21:40 ` [PATCH v11 09/19] perf test: Exercise DW_OP_addrx global variables Arnaldo Carvalho de Melo
2026-11-22 21:40 ` [PATCH v11 10/19] perf test: Exercise the flexible array member path Arnaldo Carvalho de Melo
2026-11-22 21:40 ` [PATCH v11 11/19] perf test: Exercise data type resolution from a register Arnaldo Carvalho de Melo
2026-11-22 21:40 ` [PATCH v11 12/19] perf test: Exercise the annotate stats output Arnaldo Carvalho de Melo
2026-11-22 21:53 ` sashiko-bot [this message]
2026-11-22 21:40 ` [PATCH v11 13/19] perf test: Fix the Intel PT virtual LBR check Arnaldo Carvalho de Melo
2026-11-22 21:40 ` [PATCH v11 14/19] perf test: Drop samples without an IP in the dlfilter test Arnaldo Carvalho de Melo
2026-11-22 21:40 ` [PATCH v11 15/19] perf test: Skip the LBR inline unwinding check when unsupported Arnaldo Carvalho de Melo
2026-11-22 21:40 ` [PATCH v11 16/19] perf test: Skip the trace summary BPF tests without kernel BTF Arnaldo Carvalho de Melo
2026-11-22 21:40 ` [PATCH v11 17/19] perf test: Avoid online CPUs in the offline stat test Arnaldo Carvalho de Melo
2026-11-22 21:40 ` [PATCH v11 18/19] perf scripts: Add a coverage harness for perf Arnaldo Carvalho de Melo
2026-11-22 21:54 ` sashiko-bot
2026-11-22 21:40 ` [PATCH v11 19/19] perf scripts: Add a coverage table Arnaldo Carvalho de Melo
2026-11-22 21:54 ` [PATCH v11 00/19] perf coverage: A harness for perf, and the fixes it found sashiko-bot
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-228396@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=acme@kernel.org \
--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