All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Arnaldo Carvalho de Melo" <acme@kernel.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v11 18/19] perf scripts: Add a coverage harness for perf
Date: Sun, 22 Nov 2026 21:54:44 +0000	[thread overview]
Message-ID: <sashiko-outbox-228397@kernel.org> (raw)
In-Reply-To: <20261122214025.16769-19-acme@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] perf scripts: coverage.sh deletes python/perf*.so breaking
  root reruns
--

commit 9ed4bdc97ad1f9cf11d58cc735ab649590f18481
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 and function coverage.

> diff --git a/tools/perf/scripts/coverage.sh b/tools/perf/scripts/coverage.sh
> new file mode 100755
> index 0000000000000..90845f94ac930
> --- /dev/null
> +++ b/tools/perf/scripts/coverage.sh

[ ... ]

> +# 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
> +
> +if [ "$SKIP_BUILD" = 0 ]; then
> +	command -v clang > /dev/null ||
> +		die "clang not found, it is the only compiler with -fcoverage-mapping"
> +	command -v clang++ > /dev/null ||
> +		die "clang++ not found, it instruments the C++ sources"
> +fi
> +
> +test_status=0
> +
> +if [ "$PREP" = 1 ]; then
> +	build_perf
> +	say "Coverage build ready: $BUILD_DIR/perf"
> +	make_hint="make -C $PERF_DIR coverage"
> +	[ "$BUILD_DIR" = "$PERF_DIR" ] || make_hint+=" O=$BUILD_DIR"
> +	printf "As root: %s\n" "$make_hint"
> +	exit 0
> +fi
> +
> +build_perf
> +run_tests
> +merge_profiles
> +
> +[ -f "$PROFDATA" ] || die "no $PROFDATA, the merge did not run"
> +
> +export LC_ALL=C
> +render_report
> +print_summary
> +update_baseline
> +
> +printf "\nReport:  %s\n" "$REPORT"
> +# The python extension rule can't see the compiler flags change, so drop
> +# what this run built for the next build.
> +rm -f "$BUILD_DIR"/python/perf*.so
> +rm -rf "$BUILD_DIR"/python_ext_build

[Severity: Medium]
Does deleting $BUILD_DIR/python/perf*.so at the end of the run break a
subsequent root coverage run in the same $BUILD_DIR?

Because $BUILD_DIR/perf is left in place, a later root run (for example after
an unprivileged coverage run, or a second root run after coverage-prep) sees
-x "$BUILD_DIR/perf" and sets SKIP_BUILD=1 without rebuilding
python/perf*.so.  Python tests such as tests/shell/python-use.sh then fail to
import the perf module, and llvm_cov_objects() silently omits python/perf*.so
from the coverage report.

Also, because rm -rf "$BUILD_DIR"/python_ext_build sits after the PREP=1
early exit, running coverage-prep without a subsequent coverage run leaves
the instrumented python_ext_build cache behind; removing python_ext_build in
build_perf() right after make (while keeping python/perf*.so, which already
depends on $(PERFLIBS_PY) in Makefile.perf) would avoid both problems.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261122214025.16769-1-acme@kernel.org?part=18

  reply	other threads:[~2026-11-22 21:54 UTC|newest]

Thread overview: 24+ 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
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 [this message]
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
2026-11-23  0:17   ` Arnaldo Carvalho de Melo

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-228397@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.