From: sashiko-bot@kernel.org
To: "Arnaldo Carvalho de Melo" <acme@kernel.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v10 15/16] perf scripts: Add a coverage harness for perf
Date: Sat, 21 Nov 2026 03:36:57 +0000 [thread overview]
Message-ID: <sashiko-outbox-226592@kernel.org> (raw)
In-Reply-To: <20261121032052.1392234-16-acme@kernel.org>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] perf scripts: clang check in coverage.sh runs before
SKIP_BUILD=1 is set
- [Medium] perf scripts: stale dlfilters in existing BUILD_DIR fail
render_report()
- [Low] perf scripts: unused PERF_SOURCES array in coverage.sh
--
commit 54b8c85c84ec187dba6b344cdcebe3e4a53cc9a6
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
perf scripts: Add a coverage harness for perf
This commit adds scripts/coverage.sh and the coverage and coverage-prep make
targets to build perf with clang source-based coverage, run the perf test
suite, and report line coverage.
> diff --git a/tools/perf/scripts/coverage.sh b/tools/perf/scripts/coverage.sh
> new file mode 100755
> index 0000000000000..1d49b09258818
> --- /dev/null
> +++ b/tools/perf/scripts/coverage.sh
> @@ -0,0 +1,434 @@
[ ... ]
> +# perf links objects from these directories, so a change in any of them
> +# makes the build stale.
> +PERF_SOURCES=("$PERF_DIR" "$TOOLS_DIR/lib/perf" "$TOOLS_DIR/lib/api"
> + "$TOOLS_DIR/lib/subcmd" "$TOOLS_DIR/lib/bpf"
> + "$TOOLS_DIR/lib/symbol" "$TOOLS_DIR/include"
> + "$TOOLS_DIR/arch")
[Severity: Low]
PERF_SOURCES is declared here, but nothing in the script references it.
[ ... ]
> + say "Building perf in $BUILD_DIR"
> + [ "$BUILD_DIR" = "$PERF_DIR" ] || make_args+=(O="$BUILD_DIR")
> + if ! make -C "$PERF_DIR" "${make_args[@]+"${make_args[@]}"}" \
> + CC=clang DEBUG=1 \
> + EXTRA_CFLAGS="-fprofile-instr-generate -fcoverage-mapping -gdwarf-$DWARF_VERSION" \
> + -j"$JOBS" > "$BUILD_LOG" 2>&1; then
> + tail -20 "$BUILD_LOG" >&2
> + die "build failed, full log in $BUILD_LOG"
> + fi
> + tail -1 "$BUILD_LOG"
> +}
[ ... ]
> +llvm_cov_objects()
> +{
> + echo "$BUILD_DIR/perf"
> + local so
> +
> + # These are dlopened by perf and have to be profiled separately;
> + # libperf is linked into perf as a static library.
> + for so in libperf-gtk.so libperf-jvmti.so; do
> + [ -f "$BUILD_DIR/$so" ] && echo "--object=$BUILD_DIR/$so"
> + done
> + for so in "$BUILD_DIR"/dlfilters/*.so; do
> + [ -f "$so" ] && echo "--object=$so"
> + done
> + for so in "$BUILD_DIR"/python/perf*.so; do
> + [ -f "$so" ] && echo "--object=$so"
> + done
> +}
> +
> +render_report()
> +{
> + local objects
> +
> + mapfile -t objects < <(llvm_cov_objects)
> + say "Generating report"
> + "$LLVM_COV" report "${objects[@]}" --instr-profile="$PROFDATA" \
> + > "$REPORT" || die "llvm-cov report failed"
> +}
[Severity: Medium]
Can stale shared objects in an existing BUILD_DIR cause render_report() to
fail?
Unlike objects built via tools/build/Makefile.build, the dlfilters pattern
rules in tools/perf/Makefile.perf do not track compiler flag changes:
tools/perf/Makefile.perf:
$(OUTPUT)dlfilters/%.o: dlfilters/%.c include/perf/perf_dlfilter.h
$(Q)$(MKDIR) -p $(OUTPUT)dlfilters
$(QUIET_CC)$(CC) -c -Iinclude $(EXTRA_CFLAGS) -o $@ -fpic $<
.SECONDARY: $(DLFILTERS:.so=.o)
$(OUTPUT)dlfilters/%.so: $(OUTPUT)dlfilters/%.o
$(QUIET_LINK)$(CC) $(filter-out -static,$(LDFLAGS)) $(EXTRA_CFLAGS) -shared -o $@ $<
When coverage.sh runs in a build directory that already had a standard
non-coverage build (or a prior GTK4=1 build leaving libperf-gtk.so behind),
build_perf() does not rebuild dlfilters/*.so or libperf-gtk.so.
llvm_cov_objects() then passes those uninstrumented binaries via --object=
to llvm-cov report, which exits with a "No coverage data found" error.
[ ... ]
> +if [ "$SKIP_BUILD" = 0 ]; then
> + command -v clang > /dev/null ||
> + die "clang not found, it is the only compiler with -fcoverage-mapping"
> +fi
> +
> +# Root does not rebuild a prepared build: use the perf already in
> +# BUILD_DIR, or build when there is none.
> +if [ "$ROOT" = 1 ] && [ "$PREP" = 0 ]; then
> + if [ -x "$BUILD_DIR/perf" ]; then
> + SKIP_BUILD=1
> + say "Running as root, using the coverage build in $BUILD_DIR"
> + else
> + say "Running as root, building perf in $BUILD_DIR"
> + fi
> +fi
[Severity: Medium]
Should the clang check run after the root block that sets SKIP_BUILD=1?
Because SKIP_BUILD is still 0 when the clang check runs, executing
coverage.sh as root against a prepared build fails whenever clang is not
installed on the test host or not in root's PATH.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261121032052.1392234-1-acme@kernel.org?part=15
next prev parent reply other threads:[~2026-11-21 3:36 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-21 3:20 [PATCH v10 00/16] perf coverage: A harness for perf, and the fixes it found Arnaldo Carvalho de Melo
2026-11-21 3:20 ` [PATCH v10 01/16] perf build: Link the GTK UI with EXTRA_CFLAGS Arnaldo Carvalho de Melo
2026-11-21 3:20 ` [PATCH v10 02/16] perf annotate: Handle absolute addressing in data type profiling Arnaldo Carvalho de Melo
2026-11-21 3:20 ` [PATCH v10 03/16] perf annotate: Print the stats after the annotations Arnaldo Carvalho de Melo
2026-11-21 3:20 ` [PATCH v10 04/16] perf build: Record the features checked outside FEATURE_TESTS Arnaldo Carvalho de Melo
2026-11-21 3:20 ` [PATCH v10 05/16] perf annotate-x86: Parse movabs like a mov Arnaldo Carvalho de Melo
2026-11-21 3:20 ` [PATCH v10 06/16] perf annotate-data: Count flexible array accesses for the whole struct Arnaldo Carvalho de Melo
2026-11-21 3:20 ` [PATCH v10 07/16] perf tests: Exercise the x86 operand parser Arnaldo Carvalho de Melo
2026-11-21 3:29 ` sashiko-bot
2026-11-21 3:20 ` [PATCH v10 08/16] perf tests: Exercise DW_OP_addrx global variables Arnaldo Carvalho de Melo
2026-11-21 3:20 ` [PATCH v10 09/16] perf tests: Exercise the flexible array member path Arnaldo Carvalho de Melo
2026-11-21 3:20 ` [PATCH v10 10/16] perf tests: Exercise data type resolution from a register Arnaldo Carvalho de Melo
2026-11-21 3:20 ` [PATCH v10 11/16] perf tests: Exercise the annotate stats output Arnaldo Carvalho de Melo
2026-11-21 3:30 ` sashiko-bot
2026-11-21 3:20 ` [PATCH v10 12/16] perf tests: Fix the Intel PT virtual LBR check Arnaldo Carvalho de Melo
2026-11-21 3:20 ` [PATCH v10 13/16] perf test: Drop samples without an IP in the dlfilter test Arnaldo Carvalho de Melo
2026-11-21 3:20 ` [PATCH v10 14/16] perf test: Skip the LBR inline unwinding check when unsupported Arnaldo Carvalho de Melo
2026-11-21 3:20 ` [PATCH v10 15/16] perf scripts: Add a coverage harness for perf Arnaldo Carvalho de Melo
2026-11-21 3:36 ` sashiko-bot [this message]
2026-11-21 3:20 ` [PATCH v10 16/16] perf scripts: Add a coverage table Arnaldo Carvalho de Melo
2026-11-21 3:34 ` sashiko-bot
2026-11-21 3:36 ` [PATCH v10 00/16] 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-226592@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