Skip to contentSkip to conversation

perf coverage: A harness for perf, and the fixes it found

PATCH Superseded Arnaldo Carvalho de Melo 3 participants 33 messages Nov 17 – Nov 18 perf events

v6 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Arnaldo Carvalho de Melo

author maintainer
#0 lore raw

v6 cover perf coverage: A harness for perf, and the fixes it found

From: Arnaldo Carvalho de Melo <[email protected]>

Hi,

Nothing measured how much of perf the test suite reaches. Patch 1 links the jvmti agent with EXTRA_CFLAGS, without which the coverage build never saw its counters; patch 2 adds tools/perf/scripts/coverage.sh: it builds perf with clang source based coverage, runs the complete perf test suite and reports line and function coverage, optionally against a baseline, with --table and --html like pahole's coverage_table.py. Also as 'make -C tools/perf coverage', 'coverage-prep' and 'coverage-table'.

The useful output is the list of files with the most uncovered lines, computed over the whole tree and not only the files the tests already
touch: that is where new tests should try to get more coverage.

The rest is what the first runs found, in the code, the build and the tests:

- The data type resolver missed 32-bit absolute addressing (patch 3); the DW_OP_addrx globals it also missed are fixed upstream by c3991e42f58a3650, so patch 4 only adds the test. A struct pointer kept in a register at -O2 had no test (patch 7).
- The flexible array member had no test; one showed the struct row at

    0.00% while the member said 100.00% (patches 5-6).

- --insn-stat was printed before the loop that accounts the samples, so --code-with-type showed zeros (patch 8).
- The libbfd probe printed a missing bfd.h error five times per build-test run (patch 9).
- FEATURE-DUMP didn't record llvm-perf and rust, disabling both in the build-test builds (patch 10).
- The Intel PT virtual LBR check lost every aux sample with a single data page (patch 11).
- The dlfilter test kept samples whose IP the kernel now zeroes on a userspace-to-kernel skid (patch 12).
- The LBR inline unwinding check failed instead of reporting Skip when the AMD PMU rejects branch sampling (patch 13).

With coverage-prep by the developer (clang DWARF 5) and the full suite as root on this AMD host, 105,466 of 205,823 lines were covered (51.24%; v5: 50.67% of 205,810), 86,344 of 173,257 in tools/perf/ (49.84%). 168 tests passed, 28 skipped and one failed (20.2, the POLL_HUP regression, outside this series). The global variable and instruction-stats tests passed; the Intel PT hardware tests skipped, so patch 11's 64-page AUX buffer has not yet been tested on Intel. Patch 2's changelog excerpt shows an earlier root run.

The harness and the tests were developed with an AI coding assistant (OpenCode), which drafted the script and the tests and helped debug the failures; an independent local model reviewed the script and I verified its findings before folding them in. I reviewed every change and reproduced each failure before fixing it.

What changed from v5:

- Patch 1 is new (jvmti link); the harness is 2, 3-13 renumber, and 2 folds the sashiko-bot and local review fixes; 3-8 and 11 carry the data type, stats and per-thread fixes; 13 skips only EOPNOTSUPP now, reversing v3. Ian's tags: 05-07, 09 and 12 (05-07 test-only, object if unwanted); 02-04, 08 and 13 unreviewed.

What changed from v4:

- Rebased onto perf-tools-next b7ff10b9 (52 commits).
- Patch 3: the DW_OP_addrx fix is upstream as c3991e42f58a3650 ("perf
dwarf-aux: Support DW_OP_addrx locations for global variables"), by James Clark, so the patch is now test-only.
- Patch 12: also match "doesn't support branch stack sampling", how evsel__open_strerror() formats EOPNOTSUPP, so the test skips on AMD BRS (sashiko-bot).
- Ian Rogers' Reviewed-by on v3 is carried on patches 4-6, 8 and 10-11; patches 1, 3 and 12 changed after that review and need a new look.

What changed from v3:

- Patch 1: a .profraw left half written used to make llvm-profdata drop the whole merge, and with it the run's measurement; the bad files are now skipped and counted (found running the harness on the arm64 boards).
- Patch 2: only set mem_ref for bare number operands when the offset is

    non-zero, and guard find_data_type against reg1 == -1 (sashiko-bot).

- Patch 3: move DW_OP_addrx fallback to dwarf-aux.h so annotate-data.c builds with older elfutils, and fix typo in Fixes SHA (sashiko-bot).
- Patch 12: only "Invalid argument"/"not supported" skips (exit 2); stderr goes to a file, any other record failure prints it and fails.
- Ian Rogers' Reviewed-by on v3 is carried on patches 4-6, 8 and 10-11; patches 1 and 12 changed after that review and need a new look.

What changed from v2:

- Patch 2 is new: absolute addressing is resolved, so the new data type tests pass on 32-bit non-PIE builds and skip on 32-bit PIE.
- Patches 3, 4 and 6: the C programs became 'perf test -w' workloads (global_data, flex_array, regptr), the shell tests no longer compile anything (Ian Rogers).
- Patch 6: regptr uses long long members, so the offsets are the same

    on ILP32 and LP64.

- Patch 5: add the missing annotated_member__extent() stub, so a build with slang but without libdw works (sashiko-bot); it is now a method of struct annotated_member.

What changed from v1:

- Patch 9 (cs-etm) is gone: Leo Yan's series replaces it.
- Patch 1: O= is accepted by all targets, the Python extension is in the report, -f is normalized and the delta matches its baseline.
- Patch 5: the TUI browser counts flexible array accesses too.
- Patch 7: the stats test skips without libdw.
- Patches 10 and 12: Fixes tags corrected.

Best regards,

- Arnaldo

Arnaldo Carvalho de Melo (13):
perf jvmti: Link the agent with EXTRA_CFLAGS
perf scripts: Add a coverage harness for perf
perf annotate: Handle absolute addressing in data type profiling perf tests: Exercise DW_OP_addrx global variables
perf tests: Exercise the flexible array member path
perf annotate-data: Count flexible array accesses for the whole struct perf tests: Exercise data type resolution from a register perf annotate: Print the stats after the annotations
perf tests: Silence the libbfd probe in build-test
perf build: Record the display-only features in FEATURE-DUMP perf tests: Fix the Intel PT virtual LBR check
perf test: Drop samples without an IP in the dlfilter test perf test: Skip the LBR inline unwinding check when unsupported

 tools/perf/.gitignore                         |   1 +
 tools/perf/Makefile                           |  11 +-
 tools/perf/Makefile.config                    |   4 +
 tools/perf/Makefile.perf                      |   6 +-
 tools/perf/builtin-annotate.c                 |  19 +-
 tools/perf/scripts/coverage.sh                | 984 ++++++++++++++++++
 tools/perf/tests/builtin-test.c               |   3 +
 tools/perf/tests/make                         |   2 +-
 tools/perf/tests/shell/addr2line_inlines.sh   |  23 +-
 tools/perf/tests/shell/annotate_stats.sh      |  69 ++
 .../perf/tests/shell/data_type_flex_array.sh  | 108 ++
 tools/perf/tests/shell/data_type_global.sh    |  68 ++
 tools/perf/tests/shell/data_type_register.sh  |  60 ++
 tools/perf/tests/shell/script_dlfilter.sh     |   2 +-
 tools/perf/tests/shell/test_intel_pt.sh       |   9 +-
 tools/perf/tests/tests.h                      |   3 +
 tools/perf/tests/workloads/Build              |   6 +
 tools/perf/tests/workloads/flex_array.c       |  55 +
 tools/perf/tests/workloads/global_data.c      |  55 +
 tools/perf/tests/workloads/regptr.c           |  61 ++
 tools/perf/ui/browsers/annotate-data.c        |   7 +-
 tools/perf/util/annotate-arch/annotate-x86.c  |  52 +-
 tools/perf/util/annotate-data.c               |  25 +-
 tools/perf/util/annotate-data.h               |   8 +
 tools/perf/util/annotate.c                    |  25 +-
 tools/perf/util/annotate.h                    |   7 +
 26 files changed, 1648 insertions(+), 25 deletions(-)
 create mode 100755 tools/perf/scripts/coverage.sh
 create mode 100755 tools/perf/tests/shell/annotate_stats.sh
 create mode 100755 tools/perf/tests/shell/data_type_flex_array.sh
 create mode 100755 tools/perf/tests/shell/data_type_global.sh
 create mode 100755 tools/perf/tests/shell/data_type_register.sh
 create mode 100644 tools/perf/tests/workloads/flex_array.c
 create mode 100644 tools/perf/tests/workloads/global_data.c
 create mode 100644 tools/perf/tests/workloads/regptr.c

base-commit: b7ff10b9ddec8da75304c40fe4abf1ee4f9f0a43
v1-head: 3f5465bea8f5a97a
v2-head: 9706c488afffeb6d
v3-head: f2daf1586528671a
v4-head: b9e240a1b80ecd2a
v5-head: a21454e3d055c93b
v6-head: e1315408a335617d

Signature · 1 line
2.56.0
author maintainer
#1 lore raw

PATCH v6 1/13 perf jvmti: Link the agent with EXTRA_CFLAGS

From: Arnaldo Carvalho de Melo <[email protected]>

The jvmti objects are compiled with EXTRA_CFLAGS but the agent is linked with LDFLAGS only, so flags with link-time parts never reach the shared object. With -fprofile-instr-generate the agent's __profc counters had no __llvm_profile runtime to write them, and its files showed 0.00% in the coverage report.

Pass EXTRA_CFLAGS at link time, as the dlfilter rule already does.

---
 tools/perf/Makefile.perf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/Makefile.perf +1 -1
index b74b534e1153ffcb..9f3e248d5c4efff8 100644
@@ -791,7 +791,7 @@ $(LIBJVMTI_IN): prepare FORCE
 	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=jvmti obj=jvmti
 
 $(OUTPUT)$(LIBJVMTI): $(LIBJVMTI_IN)
-	$(QUIET_LINK)$(CC) $(LDFLAGS) -shared -Wl,-soname -Wl,$(LIBJVMTI) -o $@ $<
+	$(QUIET_LINK)$(CC) $(LDFLAGS) $(EXTRA_CFLAGS) -shared -Wl,-soname -Wl,$(LIBJVMTI) -o $@ $<
 endif
 
 $(patsubst perf-%,%.o,$(PROGRAMS)): $(wildcard */*.h)
Signature · 1 line
2.56.0
#2 lore raw

Re: [PATCH v6 01/13] perf jvmti: Link the agent with EXTRA_CFLAGS

Sashiko has reviewed this patch and found no issues.
Quoted 11 lines

From: Arnaldo Carvalho de Melo <[email protected]>

The jvmti objects are compiled with EXTRA_CFLAGS but the agent is linked with LDFLAGS only, so flags with link-time parts never reach the shared object. With -fprofile-instr-generate the agent's __profc counters had no __llvm_profile runtime to write them, and its files showed 0.00% in the coverage report.

Pass EXTRA_CFLAGS at link time, as the dlfilter rule already does.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
author maintainer
#3 lore raw

PATCH v6 2/13 perf scripts: Add a coverage harness for perf

In reply to Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

Build perf with clang source based coverage, run the complete perf test suite, merge the raw profiles and report line and function coverage, optionally against a baseline. This is pahole's coverage/coverage.sh + coverage-diff.sh merged into one script, wired as
'make -C tools/perf coverage' and listed in 'make help'.

Without -f the report lists the files with the most uncovered lines, which is where new tests should try to get more coverage; -t narrows the tests, -f focuses on specific files, --html writes a browsable report and --table/-T, also available as 'make -C tools/perf coverage-table', prints the last run as an ASCII table with the per-file line and function coverage, like pahole's coverage_table.py.

The build can be split from the test run: 'make -C tools/perf coverage-prep' builds the instrumented perf and records the build directory, and a later run as root, which needs no make, checks that build, runs the tests and renders the report, or prints the table with --table. This is for running the tests that need root on the bare metal host while the instrumented perf is built in the development container.

The report covers the whole tree, not only the paths the tests walk, so the per-file table is a map of what the suite does not reach in a given run. The uncovered line list and the failures the runs exposed are what drove the rest of this series.

  $ make -C tools/perf coverage-prep O=~/coverage-build
  ...
  $ sudo scripts/coverage.sh
  ...
  Total: 104787 of 205810 lines covered (50.91%)
    perf: 85674 of 173247 lines covered (49.45%)
    largest uncovered files (>= 100 lines)
    file                                            lines     cover    missed  fn-cover
    util/intel-pt.c                                  3237     0.00%      3237     0.00%
    util/intel-pt-decoder/intel-pt-decoder.c         3208     0.00%      3208     0.00%
    ui/browsers/hists.c                              2730     0.00%      2730     0.00%
    builtin-sched.c                                  3737    41.26%      2195    43.97%
    builtin-script.c                                 3212    33.50%      2136    37.90%
    util/auxtrace.c                                  2013     4.47%      1923    11.11%
    util/session.c                                   2686    41.14%      1581    48.80%
    ...

Report: /home/acme/coverage-build/cov/report.txt

The total also counts the tools/ libraries and headers linked into perf, the perf line is the tools/perf/ files alone. The numbers above are from the split run: coverage-prep built the instrumented perf as the developer, the tests and the report ran as root. This machine has no Intel PT, so the PT tests skip and leave intel-pt.c and intel-pt-decoder.c at 0.00%; the TUI browser is in the list because the suite does not drive it.

'perf test' exits 0 even when tests fail or time out, so the script takes its status from the "Failed tests :" and "Timed out tests :" lines that perf test prints since commit 33f20342ba525ef7 ("perf test: Add summary reporting").

168 tests passed, 28 skipped, one failure (20.2: Tracepoint event), in code this series does not change.

---
 tools/perf/.gitignore          |   1 +
 tools/perf/Makefile            |  11 +-
 tools/perf/Makefile.perf       |   4 +
 tools/perf/scripts/coverage.sh | 984 +++++++++++++++++++++++++++++++++
 4 files changed, 999 insertions(+), 1 deletion(-)
 create mode 100755 tools/perf/scripts/coverage.sh
tools/perf/.gitignore +1 -0
index 3b968c5158b822ce..9052f25597ac9489 100644
@@ -27,6 +27,7 @@ stats-*.csv
 cscope*
 config.mak
 config.mak.autogen
+.coverage-build-dir
 *-bison.*
 *-flex.*
 *.pyc
tools/perf/Makefile +10 -1
index 00baf90e5bda7123..8df8e9ed37f0a8f5 100644
@@ -140,6 +140,15 @@ check-headers:
 sync-headers:
 	@./scripts/sync-headers.sh $(SYNC_HEADERS_ARGS)
 
+coverage-prep:
+	@./scripts/coverage.sh --prep $(if $(FULL_O),--build-dir=$(FULL_O)) $(COVERAGE_ARGS)
+
+coverage:
+	@./scripts/coverage.sh $(if $(FULL_O),--build-dir=$(FULL_O)) $(COVERAGE_ARGS)
+
+coverage-table:
+	@./scripts/coverage.sh --table $(if $(FULL_O),--build-dir=$(FULL_O)) $(COVERAGE_ARGS)
+
 #
 # All other targets get passed through:
 #
@@ -147,4 +156,4 @@ sync-headers:
 	$(print_msg)
 	$(make)
 
-.PHONY: all clean tags TAGS FORCE Makefile build-test build-test-tarball check-headers sync-headers
+.PHONY: all clean tags TAGS FORCE Makefile build-test build-test-tarball check-headers sync-headers coverage coverage-prep coverage-table
tools/perf/Makefile.perf +4 -0
index 9f3e248d5c4efff8..6ca39ac86599bcad 100644
@@ -873,6 +873,10 @@ help:
 	@echo '  check-headers		- check which header copies are out of sync with the kernel'
 	@echo '  sync-headers		- sync those header copies with the kernel, creating commits'
 	@echo '			  (SYNC_HEADERS_ARGS="..." passes options to the script)'
+	@echo '  coverage-prep		- build perf with clang coverage, ready for a root test run'
+	@echo '  coverage		- build perf with clang coverage, run the tests and report'
+	@echo '  coverage-table	- print an ASCII table of the last coverage run'
+	@echo '			  (COVERAGE_ARGS="..." passes options to the script)'
 
 
 DOC_TARGETS := doc man html info pdf
tools/perf/scripts/coverage.sh new file +984 -0

984 lines not on this page · raw message

Signature · 1 line
2.56.0
#4 lore raw

Re: [PATCH v6 02/13] perf scripts: Add a coverage harness for perf

Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] perf scripts: sticky-bit and root-shell bypass in check_root_path() - [Low] perf scripts: symlink…

Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Medium] perf scripts: sticky-bit and root-shell bypass in check_root_path()
- [Low] perf scripts: symlink following via chown without -h in fix_ownership()
--

commit a0647612ea142c35ebab221e54c45ab482f8b7ad
Author: Arnaldo Carvalho de Melo <[email protected]>

perf scripts: Add a coverage harness for perf

This commit adds tools/perf/scripts/coverage.sh and corresponding make targets to build perf with clang source-based coverage, run the perf test suite, and report coverage statistics.

Quoted 6 lines
tools/perf/scripts/coverage.sh new file +0 -0
new file mode 100755
index 0000000000000..073d665229697
@@ -0,0 +1,984 @@

[ ... ]

Quoted 1 line

+DEFAULT_BUILD_DIR=/tmp/build/perf-coverage

[ ... ]

Quoted 43 lines
tools/perf/scripts/coverage.sh new file +43 -0
+if [ "$ROOT" = 1 ] && [ "$PREP" = 0 ] && [ "$TABLE" = 0 ]; then
+	if [ "$REPORT_ONLY" = 0 ] && [ "$SKIP_BUILD" = 0 ] &&
+	   { [ "$FORCE_BUILD" = 1 ] ||
+	     { [ ! -f "$PERF_DIR/.coverage-build-dir" ] &&
+	       [ ! -x "$BUILD_DIR/perf" ]; }; }; then
+		say "Running as root, building perf in $BUILD_DIR"
+	else
+		SKIP_BUILD=1
+		say "Running as root, using the coverage build in $BUILD_DIR"
+	fi
+fi
+
+#
+# Under sudo the build directory comes from a file the invoking user wrote;
+# root would execute the perf found there and delete and rewrite its cov/
+# directory, so refuse one owned by somebody else or writable by another
+# group or by others.  Every parent is checked too: a directory another
+# user can write lets them swap an entry between this check and the run.
+#
+check_root_path()
+{
+	local path=$1 uid gid mode
+	[ "$ROOT" = 1 ] && [ -n "${SUDO_UID:-}" ] || return 0
+	# abspath() resolves links such as /home -> /var/home on Silverblue
+	# and CoreOS, so the walk below checks their targets.  A path not
+	# resolved that way, like $BUILD_DIR/perf, must not be a link.
+	[ -L "$path" ] && die "$path is a symbolic link, use its target"
+	while :; do
+		if [ -e "$path" ]; then
+			if ! read -r uid gid mode < \
+				<(stat -c '%u %g %a' "$path" 2>/dev/null); then
+				die "could not stat $path"
+			fi
+			# A sticky directory (/tmp) lets anybody create entries
+			# but not replace one that belongs to somebody else.
+			if [ $(( 8#$mode & 8#1000 )) = 0 ]; then
+				[ "$uid" = 0 ] || [ "$uid" = "$SUDO_UID" ] ||
+					die "$path is owned by uid $uid, not by root or $SUDO_UID"
+				# A user private group with umask 002
+				# gives 775, so only the developer's
+				# own group may write here.
+				[ $(( 8#$mode & 8#002 )) = 0 ] ||
+					die "$path is writable by others"

tools/perf/scripts/coverage.sh line 256

Quoted 10 lines
tools/perf/scripts/coverage.sh new file +10 -0
+				if [ $(( 8#$mode & 8#020 )) != 0 ] &&
+				   [ "$gid" != "${SUDO_GID:-}" ]; then
+					die "$path is writable by group $gid"
+				fi
+			fi
+		fi
+		[ "$path" = / ] && return 0
+		path=$(dirname "$path")
+	done
+}

[Severity: Medium]
Can an unprivileged local user bypass check_root_path() by setting the sticky bit on /tmp/build/perf-coverage?

Any user can chmod +t directories and files they own, and the sticky bit check skips all uid, gid and permission checks when $(( 8#$mode & 8#1000 )) is non-zero instead of only allowing root-owned sticky directories. Because DEFAULT_BUILD_DIR is /tmp/build/perf-coverage and running as root automatically sets SKIP_BUILD=1 whenever $BUILD_DIR/perf is executable, a local user can pre-create /tmp/build/perf-coverage/perf with mode 1755 (and a dummy __llvm_profile symbol) so that root executes their binary. In addition, an owner of a sticky /tmp/build directory can still unlink and replace subdirectories inside it, and check_root_path() returns early when SUDO_UID is unset in a direct root shell.

[ ... ]

Quoted 36 lines
tools/perf/scripts/coverage.sh new file +36 -0
+fix_ownership()
+{
+	local uid gid path
+	[ "$ROOT" = 1 ] || return 0
+	if [ -n "${SUDO_UID:-}" ]; then
+		uid=$SUDO_UID
+		gid=${SUDO_GID:-$SUDO_UID}
+	else
+		read -r uid gid < <(stat -c '%u %g' "$PERF_DIR" 2>/dev/null) || return 0
+	fi
+	[ "$uid" != 0 ] || return 0
+
+	for path in "${COV_WRITES[@]}"; do
+		[ -e "$COV_DIR/$path" ] || continue
+		chown -R "$uid:$gid" "$COV_DIR/$path" ||
+			warn "could not give $COV_DIR/$path back to uid $uid"
+	done
+	if [ "$COV_CREATED" = 1 ]; then
+		chown "$uid:$gid" "$COV_DIR" ||
+			warn "could not give $COV_DIR back to uid $uid"
+	fi
+	if [ "$BUILD_CREATED" = 1 ]; then
+		chown -R "$uid:$gid" "$BUILD_DIR" ||
+			warn "could not give $BUILD_DIR back to uid $uid"
+	fi
+	if [ -n "$BUILD_STAMP" ] && [ -f "$BUILD_STAMP" ]; then
+		# -h: find matches a symlink by its own owner, but chown would
+		# otherwise follow it and change a file outside the build tree.
+		find "$BUILD_DIR" -user 0 -newer "$BUILD_STAMP" \
+			-exec chown -h "$uid:$gid" {} + ||
+			warn "could not give the files root built in $BUILD_DIR back to uid $uid"
+		rm -f "$BUILD_STAMP" || true
+	fi
+	if [ "$STATE_DIR_CREATED" = 1 ] && [ -d "$STATE_DIR" ]; then
+		chown "$uid:$gid" "$STATE_DIR" ||
+			warn "could not give $STATE_DIR back to uid $uid"

tools/perf/scripts/coverage.sh line 318

Quoted 10 lines
tools/perf/scripts/coverage.sh new file +10 -0
+	fi
+	if [ -f "$STATE_FILE" ]; then
+		chown "$uid:$gid" "$STATE_FILE" ||
+			warn "could not give $STATE_FILE back to uid $uid"
+	fi
+	if [ -f "$POINTER" ]; then
+		chown "$uid:$gid" "$POINTER" ||
+			warn "could not give $POINTER back to uid $uid"
+	fi
+}

[Severity: Low]
Should the other chown calls in fix_ownership() also pass -h (and -RP when recursive)?

Unlike the find ... -exec chown -h call on $BUILD_DIR, the chown calls on $COV_DIR/$path, $STATE_FILE and $POINTER do not pass -h, and [ -e ] / [ -f ] succeed on symlinks to existing files. If any of those paths is a symlink (for example during --report-only, a subset -t run where baseline.txt is not overwritten, or an early exit after the EXIT trap is armed), root will dereference the symlink and hand ownership of its target to $uid:$gid.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
maintainer
#5 lore raw

Re: [PATCH v6 02/13] perf scripts: Add a coverage harness for perf

In reply to Arnaldo Carvalho de Melo

Hi Arnaldo,

Quoted 8 lines · Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

Build perf with clang source based coverage, run the complete perf test suite, merge the raw profiles and report line and function coverage, optionally against a baseline. This is pahole's coverage/coverage.sh + coverage-diff.sh merged into one script, wired as
'make -C tools/perf coverage' and listed in 'make help'.

Quoted 6 lines

Without -f the report lists the files with the most uncovered lines, which is where new tests should try to get more coverage; -t narrows the tests, -f focuses on specific files, --html writes a browsable report and --table/-T, also available as 'make -C tools/perf coverage-table', prints the last run as an ASCII table with the per-file line and function coverage, like pahole's coverage_table.py.

It'd be nice if you could list all options.

Quoted 4 lines

The build can be split from the test run: 'make -C tools/perf coverage-prep' builds the instrumented perf and records the build directory, and a later run as root, which needs no make, checks that

Ok, so IIUC it's optional and just running 'make coverage' would all necessary jobs one stop, right?

Quoted 4 lines

build, runs the tests and renders the report, or prints the table with --table. This is for running the tests that need root on the bare metal host while the instrumented perf is built in the development container.

What is the table?

Quoted 8 lines

The report covers the whole tree, not only the paths the tests walk, so the per-file table is a map of what the suite does not reach in a given run. The uncovered line list and the failures the runs exposed are what drove the rest of this series.

  $ make -C tools/perf coverage-prep O=~/coverage-build
  ...

What is the actual command line here? I guess it's..

    $ sudo ~/coverage-build/perf test
Quoted 25 lines
  $ sudo scripts/coverage.sh
  ...
  Total: 104787 of 205810 lines covered (50.91%)
    perf: 85674 of 173247 lines covered (49.45%)
    largest uncovered files (>= 100 lines)
    file                                            lines     cover    missed  fn-cover
    util/intel-pt.c                                  3237     0.00%      3237     0.00%
    util/intel-pt-decoder/intel-pt-decoder.c         3208     0.00%      3208     0.00%
    ui/browsers/hists.c                              2730     0.00%      2730     0.00%
    builtin-sched.c                                  3737    41.26%      2195    43.97%
    builtin-script.c                                 3212    33.50%      2136    37.90%
    util/auxtrace.c                                  2013     4.47%      1923    11.11%
    util/session.c                                   2686    41.14%      1581    48.80%
    ...

Report: /home/acme/coverage-build/cov/report.txt

The total also counts the tools/ libraries and headers linked into perf, the perf line is the tools/perf/ files alone. The numbers above are from the split run: coverage-prep built the instrumented perf as the developer, the tests and the report ran as root. This machine has no Intel PT, so the PT tests skip and leave intel-pt.c and intel-pt-decoder.c at 0.00%; the TUI browser is in the list because the suite does not drive it.

Quoted 7 lines

'perf test' exits 0 even when tests fail or time out, so the script takes its status from the "Failed tests :" and "Timed out tests :" lines that perf test prints since commit 33f20342ba525ef7 ("perf test: Add summary reporting").

168 tests passed, 28 skipped, one failure (20.2: Tracepoint event), in code this series does not change.

Looks useful, thanks!

Namhyung

Quoted 3 lines

---

author maintainer
#6 lore raw

Re: [PATCH v6 02/13] perf scripts: Add a coverage harness for perf

Quoted 23 lines · Namhyung Kim
Quoted 6 lines · Arnaldo Carvalho de Melo

Build perf with clang source based coverage, run the complete perf test suite, merge the raw profiles and report line and function coverage, optionally against a baseline. This is pahole's coverage/coverage.sh + coverage-diff.sh merged into one script, wired as
'make -C tools/perf coverage' and listed in 'make help'.

Quoted 6 lines

Without -f the report lists the files with the most uncovered lines, which is where new tests should try to get more coverage; -t narrows the tests, -f focuses on specific files, --html writes a browsable report and --table/-T, also available as 'make -C tools/perf coverage-table', prints the last run as an ASCII table with the per-file line and function coverage, like pahole's coverage_table.py.

It'd be nice if you could list all options.

Quoted 3 lines

The build can be split from the test run: 'make -C tools/perf coverage-prep' builds the instrumented perf and records the build directory, and a later run as root, which needs no make, checks that

Ok, so IIUC it's optional and just running 'make coverage' would all necessary jobs one stop, right?

Quoted 6 lines
Quoted 4 lines

build, runs the tests and renders the report, or prints the table with --table. This is for running the tests that need root on the bare metal host while the instrumented perf is built in the development container.

What is the table?

In v7, as I changed the default:

⬢ [acme@toolbx perf-tools-next]$ make -C tools/perf coverage-table
make: Entering directory '/home/acme/git/perf-tools-next/tools/perf' tools/perf (no tests/ or bench/), 100+ executable lines:
the 20 biggest uncovered gaps, start here when adding coverage tests. --all for every file: make -C tools/perf coverage-table COVERAGE_ARGS="--all"

┌──────────────────────────────────────────┬────────┬────────┬────────┬─────────────────────────────┬─────────────┬──────────┐
│ File                                     │  Lines │    Hit │   Miss │        Line Coverage        │       Funcs │  FuncCov │
├──────────────────────────────────────────┼────────┼────────┼────────┼─────────────────────────────┼─────────────┼──────────┤
│ ui/browsers/hists.c                      │   2730 │      0 │   2730 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/124   │    0.00% │
│ builtin-sched.c                          │   3737 │   1542 │   2195 │ ████████░░░░░░░░░░░░  41.3% │    62/141   │   43.97% │
│ builtin-script.c                         │   3212 │   1118 │   2094 │ ██████░░░░░░░░░░░░░░  34.8% │    51/124   │   41.13% │
│ util/intel-pt-decoder/intel-pt-decoder.c │   3208 │   1201 │   2007 │ ███████░░░░░░░░░░░░░  37.4% │    70/119   │   58.82% │
│ util/intel-pt.c                          │   3237 │   1426 │   1811 │ ████████░░░░░░░░░░░░  44.0% │    79/142   │   55.63% │
│ util/python.c                            │   2984 │   1301 │   1683 │ ████████░░░░░░░░░░░░  43.6% │   128/224   │   57.14% │
│ util/sort.c                              │   2421 │    861 │   1560 │ ███████░░░░░░░░░░░░░  35.6% │    83/246   │   33.74% │
│ util/session.c                           │   2686 │   1204 │   1482 │ ████████░░░░░░░░░░░░  44.8% │    65/125   │   52.00% │
│ util/annotate.c                          │   2245 │    866 │   1379 │ ███████░░░░░░░░░░░░░  38.6% │    60/118   │   50.85% │
│ builtin-kmem.c                           │   1337 │      0 │   1337 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/70    │    0.00% │
│ util/arm-spe.c                           │   1330 │      0 │   1330 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/50    │    0.00% │
│ builtin-kvm.c                            │   1316 │      0 │   1316 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/90    │    0.00% │
│ util/header.c                            │   3941 │   2662 │   1279 │ █████████████░░░░░░░  67.6% │   159/180   │   88.33% │
│ util/evsel.c                             │   3326 │   2067 │   1259 │ ████████████░░░░░░░░  62.2% │   128/155   │   82.58% │
│ builtin-record.c                         │   2737 │   1501 │   1236 │ ██████████░░░░░░░░░░  54.8% │    84/120   │   70.00% │
│ util/probe-event.c                       │   2765 │   1554 │   1211 │ ███████████░░░░░░░░░  56.2% │    81/103   │   78.64% │
│ builtin-trace.c                          │   3657 │   2451 │   1206 │ █████████████░░░░░░░  67.0% │   154/198   │   77.78% │
│ builtin-inject.c                         │   2023 │    890 │   1133 │ ████████░░░░░░░░░░░░  44.0% │    37/94    │   39.36% │
│ builtin-c2c.c                            │   2027 │   1018 │   1009 │ ██████████░░░░░░░░░░  50.2% │    58/156   │   37.18% │
│ util/auxtrace.c                          │   2013 │   1009 │   1004 │ ██████████░░░░░░░░░░  50.1% │    81/126   │   64.29% │
├──────────────────────────────────────────┼────────┼────────┼────────┼─────────────────────────────┼─────────────┼──────────┤
│ TOTAL (perf)                             │ 173244 │  91059 │  82185 │ ██████████░░░░░░░░░░  52.6% │  5868/9306  │   63.06% │
└──────────────────────────────────────────┴────────┴────────┴────────┴─────────────────────────────┴─────────────┴──────────┘

make: Leaving directory '/home/acme/git/perf-tools-next/tools/perf' ⬢ [acme@toolbx perf-tools-next]$

The idea with the default is to point to where to work on writing tests to make sure that we test as much as possible of the codebase.

Instead of doing it unconditionally and showing _all_ of perf, as below.

In my still unpublished local test setup this is run in a lot of distro containers and in several architectures that then gets combined to have a more comprehensive view of what is being tested in perf.

- Arnaldo

⬢ [acme@toolbx perf-tools-next]$ make -C tools/perf coverage-table COVERAGE_ARGS="--all"
make: Entering directory '/home/acme/git/perf-tools-next/tools/perf'
every tools/perf file, tests and benches included, most covered first.

┌───────────────────────────────────────────────┬────────┬────────┬────────┬─────────────────────────────┬─────────────┬──────────┐
│ File                                          │  Lines │    Hit │   Miss │        Line Coverage        │       Funcs │  FuncCov │
├───────────────────────────────────────────────┼────────┼────────┼────────┼─────────────────────────────┼─────────────┼──────────┤
│ arch/x86/util/cpuid.h                         │      9 │      9 │      0 │ ████████████████████ 100.0% │     1/1     │  100.00% │
│ builtin-version.c                             │     12 │     12 │      0 │ ████████████████████ 100.0% │     2/2     │  100.00% │
│ tests/bitmap.c                                │     33 │     33 │      0 │ ████████████████████ 100.0% │     3/3     │  100.00% │
│ tests/event_update.c                          │     63 │     63 │      0 │ ████████████████████ 100.0% │     5/5     │  100.00% │
│ tests/kmod-path.c                             │    112 │    112 │      0 │ ████████████████████ 100.0% │     3/3     │  100.00% │
│ tests/mem.c                                   │     34 │     34 │      0 │ ████████████████████ 100.0% │     2/2     │  100.00% │
│ tests/pe-file-parsing.c                       │      4 │      4 │      0 │ ████████████████████ 100.0% │     1/1     │  100.00% │
│ tests/subcmd-help.c                           │     79 │     79 │      0 │ ████████████████████ 100.0% │     4/4     │  100.00% │
│ tests/thread-map.c                            │     86 │     86 │      0 │ ████████████████████ 100.0% │     4/4     │  100.00% │
│ tests/thread-maps-share.c                     │     47 │     47 │      0 │ ████████████████████ 100.0% │     1/1     │  100.00% │
│ tests/util.c                                  │     49 │     49 │      0 │ ████████████████████ 100.0% │     4/4     │  100.00% │
│ tests/workloads/datasym.c                     │     19 │     19 │      0 │ ████████████████████ 100.0% │     2/2     │  100.00% │
│ tests/workloads/global_data.c                 │     21 │     21 │      0 │ ████████████████████ 100.0% │     2/2     │  100.00% │
│ tests/workloads/inlineloop.c                  │     26 │     26 │      0 │ ████████████████████ 100.0% │     5/5     │  100.00% │
│ tests/workloads/landlock.c                    │     16 │     16 │      0 │ ████████████████████ 100.0% │     1/1     │  100.00% │
│ tests/workloads/regptr.c                      │     24 │     24 │      0 │ ████████████████████ 100.0% │     3/3     │  100.00% │
│ trace/beauty/arch_prctl.c                     │      7 │      7 │      0 │ ████████████████████ 100.0% │     2/2     │  100.00% │
│ trace/beauty/renameat.c                       │      9 │      9 │      0 │ ████████████████████ 100.0% │     2/2     │  100.00% │
│ util/blake2s.c                                │    102 │    102 │      0 │ ████████████████████ 100.0% │     8/8     │  100.00% │
│ util/build-id.h                               │      3 │      3 │      0 │ ████████████████████ 100.0% │     1/1     │  100.00% │
│ util/c2c.c                                    │      9 │      9 │      0 │ ████████████████████ 100.0% │     2/2     │  100.00% │
│ util/cacheline.c                              │      6 │      6 │      0 │ ████████████████████ 100.0% │     1/1     │  100.00% │
│ util/counts.h                                 │      9 │      9 │      0 │ ████████████████████ 100.0% │     3/3     │  100.00% │
│ util/cpumap.h                                 │      3 │      3 │      0 │ ████████████████████ 100.0% │     1/1     │  100.00% │
│ util/data.h                                   │     21 │     21 │      0 │ ████████████████████ 100.0% │     7/7     │  100.00% │
│ util/dlfilter.h                               │     10 │     10 │      0 │ ████████████████████ 100.0% │     2/2     │  100.00% │
│ util/dwarf-aux.h                              │      3 │      3 │      0 │ ████████████████████ 100.0% │     1/1     │  100.00% │
│ util/event.h                                  │     16 │     16 │      0 │ ████████████████████ 100.0% │     5/5     │  100.00% │
│ util/fncache.c                                │     34 │     34 │      0 │ ████████████████████ 100.0% │     7/7     │  100.00% │
│ util/perf-hooks.h                             │      4 │      4 │      0 │ ████████████████████ 100.0% │     1/1     │  100.00% │
│ util/rblist.h                                 │      6 │      6 │      0 │ ████████████████████ 100.0% │     2/2     │  100.00% │
│ util/record.h                                 │      3 │      3 │      0 │ ████████████████████ 100.0% │     1/1     │  100.00% │
│ util/rwsem.c                                  │     23 │     23 │      0 │ ████████████████████ 100.0% │     6/6     │  100.00% │
│ util/session.h                                │      9 │      9 │      0 │ ████████████████████ 100.0% │     3/3     │  100.00% │
│ util/stat.h                                   │      7 │      7 │      0 │ ████████████████████ 100.0% │     1/1     │  100.00% │
│ util/trace-event.h                            │      3 │      3 │      0 │ ████████████████████ 100.0% │     1/1     │  100.00% │
│ util/vdso.h                                   │      3 │      3 │      0 │ ████████████████████ 100.0% │     1/1     │  100.00% │
│ tests/pfm.c                                   │    142 │    140 │      2 │ ███████████████████░  98.6% │     3/3     │  100.00% │
│ tests/stat.c                                  │     69 │     68 │      1 │ ███████████████████░  98.6% │     7/7     │  100.00% │
│ trace/beauty/mode_t.c                         │     42 │     41 │      1 │ ███████████████████░  97.6% │     1/1     │  100.00% │
│ util/print_binary.c                           │     39 │     38 │      1 │ ███████████████████░  97.4% │     2/2     │  100.00% │
│ arch/x86/util/topdown.c                       │     38 │     37 │      1 │ ███████████████████░  97.4% │     4/4     │  100.00% │
│ util/demangle-ocaml.c                         │     33 │     32 │      1 │ ███████████████████░  97.0% │     2/2     │  100.00% │
│ util/mem2node.c                               │     87 │     84 │      3 │ ███████████████████░  96.6% │     5/5     │  100.00% │
│ tests/parse-metric.c                          │    193 │    186 │      7 │ ███████████████████░  96.4% │    14/14    │  100.00% │
│ tests/hybrid-merge.c                          │    120 │    115 │      5 │ ███████████████████░  95.8% │     8/8     │  100.00% │
│ tests/unit_number__scnprintf.c                │     24 │     23 │      1 │ ███████████████████░  95.8% │     1/1     │  100.00% │
│ tests/workloads/brstack.c                     │     23 │     22 │      1 │ ███████████████████░  95.7% │     4/4     │  100.00% │
│ tests/workloads/flex_array.c                  │     23 │     22 │      1 │ ███████████████████░  95.7% │     2/2     │  100.00% │
│ tests/dso-data.c                              │    202 │    193 │      9 │ ███████████████████░  95.5% │    10/10    │  100.00% │
│ tests/mem2node.c                              │     44 │     42 │      2 │ ███████████████████░  95.4% │     2/2     │  100.00% │
│ trace/beauty/clone.c                          │     22 │     21 │      1 │ ███████████████████░  95.4% │     2/2     │  100.00% │
│ tests/expr.c                                  │    218 │    208 │     10 │ ███████████████████░  95.4% │     3/3     │  100.00% │
│ arch/x86/util/header.c                        │     42 │     40 │      2 │ ███████████████████░  95.2% │     3/3     │  100.00% │
│ util/map.h                                    │    123 │    117 │      6 │ ███████████████████░  95.1% │    33/34    │   97.06% │
│ util/machine.h                                │     40 │     38 │      2 │ ███████████████████░  95.0% │    10/10    │  100.00% │
│ util/mem-info.h                               │     19 │     18 │      1 │ ██████████████████░░  94.7% │     6/6     │  100.00% │
│ util/call-path.c                              │     71 │     67 │      4 │ ██████████████████░░  94.4% │     5/5     │  100.00% │
│ trace/beauty/waitid_options.c                 │     17 │     16 │      1 │ ██████████████████░░  94.1% │     1/1     │  100.00% │
│ util/strbuf.h                                 │     17 │     16 │      1 │ ██████████████████░░  94.1% │     3/3     │  100.00% │
│ tests/hists_cumulate.c                        │    387 │    364 │     23 │ ██████████████████░░  94.1% │     9/9     │  100.00% │
│ util/print-events.c                           │    218 │    205 │     13 │ ██████████████████░░  94.0% │     9/9     │  100.00% │
│ tests/cpumap.c                                │    183 │    172 │     11 │ ██████████████████░░  94.0% │    11/11    │  100.00% │
│ trace/beauty/open_flags.c                     │     49 │     46 │      3 │ ██████████████████░░  93.9% │     2/2     │  100.00% │
│ tests/event_groups.c                          │     80 │     75 │      5 │ ██████████████████░░  93.8% │     4/4     │  100.00% │
│ util/comm.c                                   │    151 │    141 │     10 │ ██████████████████░░  93.4% │    15/15    │  100.00% │
│ util/color.c                                  │     91 │     84 │      7 │ ██████████████████░░  92.3% │    11/11    │  100.00% │
│ util/perf-hooks.c                             │     38 │     35 │      3 │ ██████████████████░░  92.1% │     4/4     │  100.00% │
│ tests/parse-events.c                          │   1733 │   1596 │    137 │ ██████████████████░░  92.1% │    93/97    │   95.88% │
│ tests/hists_output.c                          │    399 │    367 │     32 │ ██████████████████░░  92.0% │     9/9     │  100.00% │
│ util/dsos.c                                   │    306 │    281 │     25 │ ██████████████████░░  91.8% │    28/30    │   93.33% │
│ tests/topology.c                              │    142 │    130 │     12 │ ██████████████████░░  91.6% │     4/4     │  100.00% │
│ util/parse-events.h                           │     11 │     10 │      1 │ ██████████████████░░  90.9% │     2/2     │  100.00% │
│ util/namespaces.c                             │    237 │    214 │     23 │ ██████████████████░░  90.3% │    24/25    │   96.00% │
│ util/tsc.c                                    │     91 │     82 │      9 │ ██████████████████░░  90.1% │     6/6     │  100.00% │
│ util/stat-shadow.c                            │    223 │    200 │     23 │ █████████████████░░░  89.7% │     8/8     │  100.00% │
│ util/pfm.c                                    │    221 │    198 │     23 │ █████████████████░░░  89.6% │     6/6     │  100.00% │
│ tests/thread-stack.c                          │     67 │     60 │      7 │ █████████████████░░░  89.6% │     3/3     │  100.00% │
│ util/intel-pt-decoder/intel-pt-pkt-decoder.c  │    583 │    522 │     61 │ █████████████████░░░  89.5% │    37/37    │  100.00% │
│ tests/workloads/code_with_type.c              │     19 │     17 │      2 │ █████████████████░░░  89.5% │     2/2     │  100.00% │
│ tests/maps.c                                  │    181 │    161 │     20 │ █████████████████░░░  88.9% │     4/5     │   80.00% │
│ tests/is_printable_array.c                    │     27 │     24 │      3 │ █████████████████░░░  88.9% │     1/1     │  100.00% │
│ util/ordered-events.c                         │    267 │    237 │     30 │ █████████████████░░░  88.8% │    18/18    │  100.00% │
│ util/evlist.h                                 │    151 │    134 │     17 │ █████████████████░░░  88.7% │    45/49    │   91.84% │
│ trace/beauty/syscalltbl.c                     │     71 │     63 │      8 │ █████████████████░░░  88.7% │     8/8     │  100.00% │
│ util/threads.c                                │    149 │    132 │     17 │ █████████████████░░░  88.6% │    13/14    │   92.86% │
│ util/affinity.c                               │     52 │     46 │      6 │ █████████████████░░░  88.5% │     6/6     │  100.00% │
│ tests/keep-tracking.c                         │     86 │     76 │     10 │ █████████████████░░░  88.4% │     2/2     │  100.00% │
│ tests/mmap-thread-lookup.c                    │    119 │    105 │     14 │ █████████████████░░░  88.2% │     9/9     │  100.00% │
│ util/pmus.c                                   │    604 │    532 │     72 │ █████████████████░░░  88.1% │    31/34    │   91.18% │
│ util/tp_pmu.c                                 │    149 │    131 │     18 │ █████████████████░░░  87.9% │    11/11    │  100.00% │
│ util/callchain.h                              │     41 │     36 │      5 │ █████████████████░░░  87.8% │     8/8     │  100.00% │
│ arch/x86/tests/hybrid.c                       │    180 │    158 │     22 │ █████████████████░░░  87.8% │    16/17    │   94.12% │
│ util/bpf-trace-summary.c                      │    290 │    254 │     36 │ █████████████████░░░  87.6% │    19/19    │  100.00% │
│ util/expr.c                                   │    314 │    275 │     39 │ █████████████████░░░  87.6% │    27/27    │  100.00% │
│ tests/parse-no-sample-id-all.c                │     70 │     61 │      9 │ █████████████████░░░  87.1% │     3/3     │  100.00% │
│ tests/workloads/noploop.c                     │     23 │     20 │      3 │ █████████████████░░░  87.0% │     2/2     │  100.00% │
│ util/rblist.c                                 │     92 │     80 │     12 │ █████████████████░░░  87.0% │     8/9     │   88.89% │
│ trace/beauty/pid.c                            │     15 │     13 │      2 │ █████████████████░░░  86.7% │     1/1     │  100.00% │
│ tests/genelf.c                                │     22 │     19 │      3 │ █████████████████░░░  86.4% │     1/1     │  100.00% │
│ trace/beauty/signum.c                         │     43 │     37 │      6 │ █████████████████░░░  86.1% │     1/1     │  100.00% │
│ builtin-kallsyms.c                            │     50 │     43 │      7 │ █████████████████░░░  86.0% │     2/2     │  100.00% │
│ util/bpf-event.c                              │    681 │    584 │     97 │ █████████████████░░░  85.8% │    25/25    │  100.00% │
│ util/strlist.c                                │    132 │    113 │     19 │ █████████████████░░░  85.6% │    12/13    │   92.31% │
│ util/unwind-libdw.c                           │    309 │    264 │     45 │ █████████████████░░░  85.4% │    12/13    │   92.31% │
│ tests/demangle-rust-v0-test.c                 │     61 │     52 │      9 │ █████████████████░░░  85.2% │     1/1     │  100.00% │
│ util/metricgroup.c                            │   1033 │    873 │    160 │ ████████████████░░░░  84.5% │    40/44    │   90.91% │
│ util/maps.c                                   │    926 │    782 │    144 │ ████████████████░░░░  84.4% │    55/60    │   91.67% │
│ tests/hists_filter.c                          │    205 │    173 │     32 │ ████████████████░░░░  84.4% │     3/3     │  100.00% │
│ tests/workloads/false_sharing.c               │    132 │    111 │     21 │ ████████████████░░░░  84.1% │     4/4     │  100.00% │
│ tests/perf-time-to-tsc.c                      │    119 │    100 │     19 │ ████████████████░░░░  84.0% │     2/2     │  100.00% │
│ tests/bp_account.c                            │    123 │    103 │     20 │ ████████████████░░░░  83.7% │     8/9     │   88.89% │
│ tests/api-io.c                                │    236 │    197 │     39 │ ████████████████░░░░  83.5% │    11/11    │  100.00% │
│ tests/demangle-ocaml-test.c                   │     30 │     25 │      5 │ ████████████████░░░░  83.3% │     1/1     │  100.00% │
│ util/find-map.c                               │     24 │     20 │      4 │ ████████████████░░░░  83.3% │     1/1     │  100.00% │
│ util/kwork.h                                  │      6 │      5 │      1 │ ████████████████░░░░  83.3% │     1/1     │  100.00% │
│ util/namespaces.h                             │      6 │      5 │      1 │ ████████████████░░░░  83.3% │     1/1     │  100.00% │
│ util/units.c                                  │     48 │     40 │      8 │ ████████████████░░░░  83.3% │     4/4     │  100.00% │
│ arch/x86/tests/topdown.c                      │    166 │    138 │     28 │ ████████████████░░░░  83.1% │     6/6     │  100.00% │
│ util/c2c-function.c                           │    907 │    754 │    153 │ ████████████████░░░░  83.1% │    47/52    │   90.38% │
│ tests/perf-hooks.c                            │     23 │     19 │      4 │ ████████████████░░░░  82.6% │     3/3     │  100.00% │
│ util/copyfile.c                               │    103 │     85 │     18 │ ████████████████░░░░  82.5% │     5/6     │   83.33% │
│ util/bpf-utils.c                              │    165 │    136 │     29 │ ████████████████░░░░  82.4% │     7/7     │  100.00% │
│ tests/sample-parsing.c                        │    449 │    369 │     80 │ ████████████████░░░░  82.2% │     5/5     │  100.00% │
│ util/branch.h                                 │     11 │      9 │      2 │ ████████████████░░░░  81.8% │     1/1     │  100.00% │
│ util/map_symbol.c                             │     33 │     27 │      6 │ ████████████████░░░░  81.8% │     6/7     │   85.71% │
│ util/bpf_trace_augment.c                      │    137 │    112 │     25 │ ████████████████░░░░  81.8% │    12/12    │  100.00% │
│ ui/progress.c                                 │     27 │     22 │      5 │ ████████████████░░░░  81.5% │     4/5     │   80.00% │
│ builtin-list.c                                │    609 │    496 │    113 │ ████████████████░░░░  81.4% │    14/15    │   93.33% │
│ tests/dlfilter-test.c                         │    284 │    231 │     53 │ ████████████████░░░░  81.3% │    19/20    │   95.00% │
│ util/evsel_fprintf.c                          │    182 │    148 │     34 │ ████████████████░░░░  81.3% │     5/5     │  100.00% │
│ util/thread.c                                 │    422 │    343 │     79 │ ████████████████░░░░  81.3% │    29/32    │   90.62% │
│ util/bpf_counter_cgroup.c                     │    200 │    162 │     38 │ ████████████████░░░░  81.0% │    10/10    │  100.00% │
│ tests/uncore-event-sorting.c                  │    110 │     89 │     21 │ ████████████████░░░░  80.9% │     3/3     │  100.00% │
│ util/hwmon_pmu.c                              │    572 │    462 │    110 │ ████████████████░░░░  80.8% │    20/20    │  100.00% │
│ util/parse-branch-options.c                   │     52 │     42 │     10 │ ████████████████░░░░  80.8% │     2/2     │  100.00% │
│ util/mem-info.c                               │     31 │     25 │      6 │ ████████████████░░░░  80.7% │     3/4     │   75.00% │
│ tests/time-utils-test.c                       │    191 │    154 │     37 │ ████████████████░░░░  80.6% │     4/4     │  100.00% │
│ util/stat-display.c                           │   1073 │    864 │    209 │ ████████████████░░░░  80.5% │    60/67    │   89.55% │
│ util/dso.h                                    │    332 │    267 │     65 │ ████████████████░░░░  80.4% │    84/96    │   87.50% │
│ util/cpumap.c                                 │    550 │    442 │    108 │ ████████████████░░░░  80.4% │    38/39    │   97.44% │
│ bench/futex-hash.c                            │    137 │    110 │     27 │ ████████████████░░░░  80.3% │     4/4     │  100.00% │
│ util/pmu.c                                    │   1837 │   1470 │    367 │ ████████████████░░░░  80.0% │    98/104   │   94.23% │
│ util/env.h                                    │      5 │      4 │      1 │ ████████████████░░░░  80.0% │     1/1     │  100.00% │
│ util/sample-raw.c                             │     10 │      8 │      2 │ ████████████████░░░░  80.0% │     1/1     │  100.00% │
│ util/strlist.h                                │     20 │     16 │      4 │ ████████████████░░░░  80.0% │     4/5     │   80.00% │
│ tests/dwarf-unwind.c                          │    119 │     95 │     24 │ ███████████████░░░░░  79.8% │     7/7     │  100.00% │
│ tests/wp.c                                    │    104 │     83 │     21 │ ███████████████░░░░░  79.8% │     7/7     │  100.00% │
│ util/evsel.h                                  │     89 │     71 │     18 │ ███████████████░░░░░  79.8% │    23/24    │   95.83% │
│ util/unwind.c                                 │     68 │     54 │     14 │ ███████████████░░░░░  79.4% │     3/3     │  100.00% │
│ util/annotate-arch/annotate-x86.c             │    654 │    518 │    136 │ ███████████████░░░░░  79.2% │     7/9     │   77.78% │
│ builtin-evlist.c                              │     62 │     49 │     13 │ ███████████████░░░░░  79.0% │     2/3     │   66.67% │
│ util/dso.c                                    │   1431 │   1127 │    304 │ ███████████████░░░░░  78.8% │    91/97    │   93.81% │
│ tests/event_refresh.c                         │     88 │     69 │     19 │ ███████████████░░░░░  78.4% │     6/6     │  100.00% │
│ builtin-check.c                               │     69 │     54 │     15 │ ███████████████░░░░░  78.3% │     5/5     │  100.00% │
│ util/symbol.h                                 │     46 │     36 │     10 │ ███████████████░░░░░  78.3% │     9/11    │   81.82% │
│ util/intlist.c                                │     91 │     71 │     20 │ ███████████████░░░░░  78.0% │    10/13    │   76.92% │
│ util/synthetic-events.c                       │   2009 │   1560 │    449 │ ███████████████░░░░░  77.7% │    61/65    │   93.85% │
│ util/thread.h                                 │    160 │    124 │     36 │ ███████████████░░░░░  77.5% │    40/48    │   83.33% │
│ util/drm_pmu.c                                │    479 │    371 │    108 │ ███████████████░░░░░  77.4% │    21/23    │   91.30% │
│ util/annotate-data.c                          │   1494 │   1155 │    339 │ ███████████████░░░░░  77.3% │    58/61    │   95.08% │
│ tests/bp_signal.c                             │    114 │     88 │     26 │ ███████████████░░░░░  77.2% │     8/8     │  100.00% │
│ bench/sched-messaging.c                       │    197 │    152 │     45 │ ███████████████░░░░░  77.2% │     9/11    │   81.82% │
│ util/demangle-java.c                          │    130 │    100 │     30 │ ███████████████░░░░░  76.9% │     2/2     │  100.00% │
│ tests/workloads/thloop.c                      │     56 │     43 │     13 │ ███████████████░░░░░  76.8% │     4/4     │  100.00% │
│ util/counts.c                                 │     43 │     33 │     10 │ ███████████████░░░░░  76.7% │     5/6     │   83.33% │
│ tests/hists_link.c                            │    219 │    168 │     51 │ ███████████████░░░░░  76.7% │     8/8     │  100.00% │
│ util/perf_api_probe.c                         │    132 │    101 │     31 │ ███████████████░░░░░  76.5% │    16/16    │  100.00% │
│ util/record.c                                 │    187 │    143 │     44 │ ███████████████░░░░░  76.5% │     9/9     │  100.00% │
│ arch/x86/util/auxtrace.c                      │     25 │     19 │      6 │ ███████████████░░░░░  76.0% │     1/1     │  100.00% │
│ tests/hwmon_pmu.c                             │    257 │    195 │     62 │ ███████████████░░░░░  75.9% │     7/7     │  100.00% │
│ util/trace-event-parse.c                      │    135 │    102 │     33 │ ███████████████░░░░░  75.6% │    10/13    │   76.92% │
│ builtin-timechart.c                           │   1518 │   1140 │    378 │ ███████████████░░░░░  75.1% │    43/62    │   69.35% │
│ perf-sys.h                                    │      4 │      3 │      1 │ ███████████████░░░░░  75.0% │     1/1     │  100.00% │
│ tests/fdarray.c                               │    140 │    105 │     35 │ ███████████████░░░░░  75.0% │     4/4     │  100.00% │
│ util/intlist.h                                │     20 │     15 │      5 │ ███████████████░░░░░  75.0% │     4/5     │   80.00% │
│ util/maps.h                                   │      4 │      3 │      1 │ ███████████████░░░░░  75.0% │     1/1     │  100.00% │
│ util/probe-finder.h                           │      4 │      3 │      1 │ ███████████████░░░░░  75.0% │     1/1     │  100.00% │
│ util/srccode.h                                │      4 │      3 │      1 │ ███████████████░░░░░  75.0% │     1/1     │  100.00% │
│ util/trace-event.c                            │     88 │     66 │     22 │ ███████████████░░░░░  75.0% │     7/8     │   87.50% │
│ util/build-id.c                               │    664 │    497 │    167 │ ██████████████░░░░░░  74.8% │    39/42    │   92.86% │
│ util/annotate.h                               │     75 │     56 │     19 │ ██████████████░░░░░░  74.7% │    12/15    │   80.00% │
│ util/parse-events.c                           │   2027 │   1510 │    517 │ ██████████████░░░░░░  74.5% │    76/85    │   89.41% │
│ tests/demangle-java-test.c                    │     35 │     26 │      9 │ ██████████████░░░░░░  74.3% │     1/1     │  100.00% │
│ arch/x86/tests/dwarf-unwind.c                 │     38 │     28 │     10 │ ██████████████░░░░░░  73.7% │     2/2     │  100.00% │
│ util/target.h                                 │     34 │     25 │      9 │ ██████████████░░░░░░  73.5% │     6/6     │  100.00% │
│ tests/tests-scripts.c                         │    256 │    188 │     68 │ ██████████████░░░░░░  73.4% │    10/10    │  100.00% │
│ tests/event-times.c                           │    154 │    113 │     41 │ ██████████████░░░░░░  73.4% │     9/9     │  100.00% │
│ util/stat.c                                   │    448 │    328 │    120 │ ██████████████░░░░░░  73.2% │    36/42    │   85.71% │
│ util/data-convert-json.c                      │    313 │    229 │     84 │ ██████████████░░░░░░  73.2% │     9/9     │  100.00% │
│ util/sideband_evlist.c                        │     93 │     68 │     25 │ ██████████████░░░░░░  73.1% │     4/5     │   80.00% │
│ tests/bp_signal_overflow.c                    │     74 │     54 │     20 │ ██████████████░░░░░░  73.0% │     4/4     │  100.00% │
│ util/tool.c                                   │    291 │    212 │     79 │ ██████████████░░░░░░  72.8% │    25/65    │   38.46% │
│ tests/backward-ring-buffer.c                  │    114 │     83 │     31 │ ██████████████░░░░░░  72.8% │     4/4     │  100.00% │
│ tests/pmu.c                                   │    425 │    309 │    116 │ ██████████████░░░░░░  72.7% │    10/10    │  100.00% │
│ tests/workloads/jitdump.c                     │    106 │     77 │     29 │ ██████████████░░░░░░  72.6% │     5/5     │  100.00% │
│ util/cputopo.c                                │    356 │    258 │     98 │ ██████████████░░░░░░  72.5% │    11/13    │   84.62% │
│ util/parse-sublevel-options.c                 │     47 │     34 │     13 │ ██████████████░░░░░░  72.3% │     2/2     │  100.00% │
│ util/util.c                                   │    315 │    227 │     88 │ ██████████████░░░░░░  72.1% │    23/26    │   88.46% │
│ util/libdw.c                                  │    161 │    116 │     45 │ ██████████████░░░░░░  72.1% │     4/4     │  100.00% │
│ util/map.c                                    │    404 │    291 │    113 │ ██████████████░░░░░░  72.0% │    34/37    │   91.89% │
│ util/debuginfo.c                              │    121 │     87 │     34 │ ██████████████░░░░░░  71.9% │     7/7     │  100.00% │
│ util/symbol.c                                 │   1775 │   1275 │    500 │ ██████████████░░░░░░  71.8% │    82/94    │   87.23% │
│ tests/expand-cgroup.c                         │    159 │    114 │     45 │ ██████████████░░░░░░  71.7% │     6/6     │  100.00% │
│ trace/beauty/beauty.h                         │     14 │     10 │      4 │ ██████████████░░░░░░  71.4% │     1/1     │  100.00% │
│ util/rlimit.c                                 │     35 │     25 │     10 │ ██████████████░░░░░░  71.4% │     2/2     │  100.00% │
│ builtin-daemon.c                              │   1011 │    721 │    290 │ ██████████████░░░░░░  71.3% │    45/47    │   95.74% │
│ util/dwarf-aux.c                              │   1454 │   1037 │    417 │ ██████████████░░░░░░  71.3% │    76/90    │   84.44% │
│ util/hist.c                                   │   2089 │   1486 │    603 │ ██████████████░░░░░░  71.1% │   112/132   │   84.85% │
│ util/dwarf-regs-arch/dwarf-regs-x86.c         │    151 │    107 │     44 │ ██████████████░░░░░░  70.9% │     3/5     │   60.00% │
│ tests/sdt.c                                   │     65 │     46 │     19 │ ██████████████░░░░░░  70.8% │     5/5     │  100.00% │
│ ui/stdio/hist.c                               │    626 │    442 │    184 │ ██████████████░░░░░░  70.6% │    19/25    │   76.00% │
│ util/genelf.c                                 │    281 │    198 │     83 │ ██████████████░░░░░░  70.5% │     3/3     │  100.00% │
│ util/blake2s.h                                │     27 │     19 │      8 │ ██████████████░░░░░░  70.4% │     2/3     │   66.67% │
│ ui/hist.c                                     │    906 │    635 │    271 │ ██████████████░░░░░░  70.1% │    49/61    │   80.33% │
│ builtin-probe.c                               │    524 │    366 │    158 │ █████████████░░░░░░░  69.8% │    16/19    │   84.21% │
│ util/addr_location.c                          │     23 │     16 │      7 │ █████████████░░░░░░░  69.6% │     2/3     │   66.67% │
│ util/sample.h                                 │     13 │      9 │      4 │ █████████████░░░░░░░  69.2% │     2/3     │   66.67% │
│ util/zstd.c                                   │    103 │     71 │     32 │ █████████████░░░░░░░  68.9% │     4/4     │  100.00% │
│ arch/x86/tests/intel-pt-test.c                │    196 │    135 │     61 │ █████████████░░░░░░░  68.9% │     9/11    │   81.82% │
│ util/intel-tpebs.c                            │    492 │    338 │    154 │ █████████████░░░░░░░  68.7% │    17/17    │  100.00% │
│ tests/symbols.c                               │    304 │    208 │     96 │ █████████████░░░░░░░  68.4% │    11/15    │   73.33% │
│ tests/task-exit.c                             │     95 │     65 │     30 │ █████████████░░░░░░░  68.4% │     2/3     │   66.67% │
│ util/smt.c                                    │     19 │     13 │      6 │ █████████████░░░░░░░  68.4% │     2/2     │  100.00% │
│ util/svghelper.c                              │    557 │    381 │    176 │ █████████████░░░░░░░  68.4% │    27/33    │   81.82% │
│ tests/sw-clock.c                              │     98 │     67 │     31 │ █████████████░░░░░░░  68.4% │     2/2     │  100.00% │
│ util/bpf_lock_contention.c                    │    610 │    415 │    195 │ █████████████░░░░░░░  68.0% │    15/16    │   93.75% │
│ util/cap.c                                    │     25 │     17 │      8 │ █████████████░░░░░░░  68.0% │     1/1     │  100.00% │
│ builtin-kwork.c                               │   1749 │   1188 │    561 │ █████████████░░░░░░░  67.9% │    78/101   │   77.23% │
│ tests/pmu-events.c                            │    621 │    421 │    200 │ █████████████░░░░░░░  67.8% │    25/25    │  100.00% │
│ tests/switch-tracking.c                       │    431 │    292 │    139 │ █████████████░░░░░░░  67.8% │    10/10    │  100.00% │
│ util/header.c                                 │   3941 │   2662 │   1279 │ █████████████░░░░░░░  67.6% │   159/180   │   88.33% │
│ util/sample.c                                 │     89 │     60 │     29 │ █████████████░░░░░░░  67.4% │     6/6     │  100.00% │
│ builtin-trace.c                               │   3657 │   2451 │   1206 │ █████████████░░░░░░░  67.0% │   154/198   │   77.78% │
│ util/time-utils.c                             │    347 │    232 │    115 │ █████████████░░░░░░░  66.9% │    16/20    │   80.00% │
│ util/evlist.c                                 │   1933 │   1292 │    641 │ █████████████░░░░░░░  66.8% │   102/131   │   77.86% │
│ util/print_binary.h                           │      3 │      2 │      1 │ █████████████░░░░░░░  66.7% │     1/1     │  100.00% │
│ util/time-utils.h                             │      6 │      4 │      2 │ █████████████░░░░░░░  66.7% │     1/1     │  100.00% │
│ util/dlfilter.c                               │    449 │    298 │    151 │ █████████████░░░░░░░  66.4% │    24/28    │   85.71% │
│ tests/evsel-roundtrip-name.c                  │     77 │     51 │     26 │ █████████████░░░░░░░  66.2% │     3/3     │  100.00% │
│ trace/beauty/fcntl.c                          │     65 │     43 │     22 │ █████████████░░░░░░░  66.2% │     4/6     │   66.67% │
│ util/llvm.c                                   │    195 │    129 │     66 │ █████████████░░░░░░░  66.2% │     4/5     │   80.00% │
│ util/tool_pmu.c                               │    510 │    336 │    174 │ █████████████░░░░░░░  65.9% │    20/24    │   83.33% │
│ util/symbol_fprintf.c                         │     41 │     27 │     14 │ █████████████░░░░░░░  65.8% │     4/6     │   66.67% │
│ util/lzma.c                                   │     89 │     58 │     31 │ █████████████░░░░░░░  65.2% │     3/4     │   75.00% │
│ tests/kallsyms-split.c                        │     86 │     56 │     30 │ █████████████░░░░░░░  65.1% │     3/3     │  100.00% │
│ ui/util.c                                     │     40 │     26 │     14 │ █████████████░░░░░░░  65.0% │     4/6     │   66.67% │
│ util/trace-event-read.c                       │    350 │    226 │    124 │ ████████████░░░░░░░░  64.6% │    14/15    │   93.33% │
│ util/top.c                                    │     84 │     54 │     30 │ ████████████░░░░░░░░  64.3% │     2/2     │  100.00% │
│ builtin-ftrace.c                              │   1430 │    912 │    518 │ ████████████░░░░░░░░  63.8% │    60/66    │   90.91% │
│ util/hist.h                                   │     88 │     56 │     32 │ ████████████░░░░░░░░  63.6% │    13/18    │   72.22% │
│ util/perf_event_attr_fprintf.c                │    291 │    185 │    106 │ ████████████░░░░░░░░  63.6% │    13/19    │   68.42% │
│ builtin-stat.c                                │   2002 │   1272 │    730 │ ████████████░░░░░░░░  63.5% │    70/98    │   71.43% │
│ util/event.c                                  │    571 │    362 │    209 │ ████████████░░░░░░░░  63.4% │    41/54    │   75.93% │
│ tests/tool_pmu.c                              │    128 │     81 │     47 │ ████████████░░░░░░░░  63.3% │     4/4     │  100.00% │
│ util/strbuf.c                                 │    117 │     74 │     43 │ ████████████░░░░░░░░  63.2% │     8/9     │   88.89% │
│ builtin-buildid-list.c                        │    111 │     70 │     41 │ ████████████░░░░░░░░  63.1% │     4/7     │   57.14% │
│ util/term.c                                   │     27 │     17 │     10 │ ████████████░░░░░░░░  63.0% │     2/2     │  100.00% │
│ util/data.c                                   │    394 │    248 │    146 │ ████████████░░░░░░░░  62.9% │    24/28    │   85.71% │
│ trace/beauty/prctl.c                          │     48 │     30 │     18 │ ████████████░░░░░░░░  62.5% │     2/5     │   40.00% │
│ tests/builtin-test.c                          │   1627 │   1012 │    615 │ ████████████░░░░░░░░  62.2% │    50/63    │   79.37% │
│ trace/beauty/futex_op.c                       │     37 │     23 │     14 │ ████████████░░░░░░░░  62.2% │     1/1     │  100.00% │
│ util/evsel.c                                  │   3326 │   2067 │   1259 │ ████████████░░░░░░░░  62.2% │   128/155   │   82.58% │
│ tests/openat-syscall-tp-fields.c              │     98 │     60 │     38 │ ████████████░░░░░░░░  61.2% │     1/1     │  100.00% │
│ util/perf-regs-arch/perf_regs_x86.c           │    462 │    282 │    180 │ ████████████░░░░░░░░  61.0% │    15/19    │   78.95% │
│ tests/mmap-basic.c                            │    312 │    190 │    122 │ ████████████░░░░░░░░  60.9% │     8/8     │  100.00% │
│ util/machine.c                                │   2246 │   1367 │    879 │ ████████████░░░░░░░░  60.9% │   103/131   │   78.63% │
│ builtin-annotate.c                            │    630 │    383 │    247 │ ████████████░░░░░░░░  60.8% │    10/15    │   66.67% │
│ util/srcline.c                                │    370 │    224 │    146 │ ████████████░░░░░░░░  60.5% │    16/21    │   76.19% │
│ util/strfilter.c                              │    225 │    136 │     89 │ ████████████░░░░░░░░  60.4% │    12/14    │   85.71% │
│ util/trace-event-info.c                       │    498 │    301 │    197 │ ████████████░░░░░░░░  60.4% │    18/20    │   90.00% │
│ tests/sigtrap.c                               │    141 │     85 │     56 │ ████████████░░░░░░░░  60.3% │     7/10    │   70.00% │
│ util/probe-file.c                             │    839 │    505 │    334 │ ████████████░░░░░░░░  60.2% │    36/48    │   75.00% │
│ builtin-report.c                              │   1352 │    812 │    540 │ ████████████░░░░░░░░  60.1% │    28/38    │   73.68% │
│ util/cgroup.c                                 │    420 │    251 │    169 │ ███████████░░░░░░░░░  59.8% │    20/27    │   74.07% │
│ builtin-data.c                                │     42 │     25 │     17 │ ███████████░░░░░░░░░  59.5% │     2/2     │  100.00% │
│ util/auxtrace.h                               │     37 │     22 │     15 │ ███████████░░░░░░░░░  59.5% │     5/5     │  100.00% │
│ util/config.c                                 │    739 │    438 │    301 │ ███████████░░░░░░░░░  59.3% │    44/60    │   73.33% │
│ tests/code-reading.c                          │    608 │    360 │    248 │ ███████████░░░░░░░░░  59.2% │    18/20    │   90.00% │
│ util/env.c                                    │    721 │    426 │    295 │ ███████████░░░░░░░░░  59.1% │    32/43    │   74.42% │
│ tests/perf-record.c                           │    259 │    153 │    106 │ ███████████░░░░░░░░░  59.1% │     2/2     │  100.00% │
│ tests/openat-syscall-all-cpus.c               │     83 │     49 │     34 │ ███████████░░░░░░░░░  59.0% │     1/1     │  100.00% │
│ util/aslr.c                                   │   1026 │    603 │    423 │ ███████████░░░░░░░░░  58.8% │    25/32    │   78.12% │
│ util/mutex.c                                  │    116 │     68 │     48 │ ███████████░░░░░░░░░  58.6% │    13/18    │   72.22% │
│ util/thread_map.c                             │    281 │    164 │    117 │ ███████████░░░░░░░░░  58.4% │    15/17    │   88.24% │
│ ui/setup.c                                    │     55 │     32 │     23 │ ███████████░░░░░░░░░  58.2% │     4/7     │   57.14% │
│ util/vdso.c                                   │    227 │    132 │     95 │ ███████████░░░░░░░░░  58.2% │    10/15    │   66.67% │
│ util/bpf_off_cpu.c                            │    293 │    170 │    123 │ ███████████░░░░░░░░░  58.0% │     6/6     │  100.00% │
│ util/cloexec.c                                │     57 │     33 │     24 │ ███████████░░░░░░░░░  57.9% │     2/2     │  100.00% │
│ util/tracepoint.c                             │     26 │     15 │     11 │ ███████████░░░░░░░░░  57.7% │     1/2     │   50.00% │
│ util/jitdump.c                                │    655 │    374 │    281 │ ███████████░░░░░░░░░  57.1% │    17/19    │   89.47% │
│ util/disasm.c                                 │    993 │    564 │    429 │ ███████████░░░░░░░░░  56.8% │    37/57    │   64.91% │
│ util/probe-finder.c                           │   1404 │    797 │    607 │ ███████████░░░░░░░░░  56.8% │    36/45    │   80.00% │
│ util/probe-event.c                            │   2765 │   1554 │   1211 │ ███████████░░░░░░░░░  56.2% │    81/103   │   78.64% │
│ util/thread-stack.c                           │    742 │    417 │    325 │ ███████████░░░░░░░░░  56.2% │    26/39    │   66.67% │
│ util/demangle-rust-v0.c                       │   1613 │    906 │    707 │ ███████████░░░░░░░░░  56.2% │    52/68    │   76.47% │
│ util/debug.c                                  │    212 │    119 │     93 │ ███████████░░░░░░░░░  56.1% │    12/20    │   60.00% │
│ util/cacheline.h                              │     18 │     10 │      8 │ ███████████░░░░░░░░░  55.6% │     2/2     │  100.00% │
│ util/unwind.h                                 │      9 │      5 │      4 │ ███████████░░░░░░░░░  55.6% │     3/4     │   75.00% │
│ tests/openat-syscall.c                        │     47 │     26 │     21 │ ███████████░░░░░░░░░  55.3% │     1/1     │  100.00% │
│ arch/x86/tests/bp-modify.c                    │    123 │     68 │     55 │ ███████████░░░░░░░░░  55.3% │     5/6     │   83.33% │
│ builtin-record.c                              │   2737 │   1501 │   1236 │ ██████████░░░░░░░░░░  54.8% │    84/120   │   70.00% │
│ util/symbol-elf.c                             │   1930 │   1041 │    889 │ ██████████░░░░░░░░░░  53.9% │    55/93    │   59.14% │
│ trace/beauty/pkey_alloc.c                     │     30 │     16 │     14 │ ██████████░░░░░░░░░░  53.3% │     1/3     │   33.33% │
│ arch/x86/util/intel-pt.c                      │    820 │    431 │    389 │ ██████████░░░░░░░░░░  52.6% │    23/38    │   60.53% │
│ tests/evsel-tp-sched.c                        │     59 │     31 │     28 │ ██████████░░░░░░░░░░  52.5% │     2/2     │  100.00% │
│ bench/mem-functions.c                         │    300 │    154 │    146 │ ██████████░░░░░░░░░░  51.3% │    12/21    │   57.14% │
│ builtin-lock.c                                │   1950 │    983 │    967 │ ██████████░░░░░░░░░░  50.4% │    55/80    │   68.75% │
│ builtin-c2c.c                                 │   2027 │   1018 │   1009 │ ██████████░░░░░░░░░░  50.2% │    58/156   │   37.18% │
│ util/auxtrace.c                               │   2013 │   1009 │   1004 │ ██████████░░░░░░░░░░  50.1% │    81/126   │   64.29% │
│ util/intel-pt-decoder/intel-pt-log.h          │      6 │      3 │      3 │ ██████████░░░░░░░░░░  50.0% │     1/2     │   50.00% │
│ util/callchain.c                              │   1302 │    639 │    663 │ █████████░░░░░░░░░░░  49.1% │    38/69    │   55.07% │
│ util/path.c                                   │     45 │     22 │     23 │ █████████░░░░░░░░░░░  48.9% │     4/7     │   57.14% │
│ util/intel-pt-decoder/intel-pt-insn-decoder.c │    229 │    110 │    119 │ █████████░░░░░░░░░░░  48.0% │     3/7     │   42.86% │
│ util/parse-regs-options.c                     │    199 │     95 │    104 │ █████████░░░░░░░░░░░  47.7% │     6/8     │   75.00% │
│ bench/futex.c                                 │     42 │     20 │     22 │ █████████░░░░░░░░░░░  47.6% │     2/2     │  100.00% │
│ tests/vmlinux-kallsyms.c                      │    208 │     99 │    109 │ █████████░░░░░░░░░░░  47.6% │     4/5     │   80.00% │
│ builtin-top.c                                 │   1353 │    629 │    724 │ █████████░░░░░░░░░░░  46.5% │    23/44    │   52.27% │
│ trace/beauty/ioctl.c                          │    121 │     56 │     65 │ █████████░░░░░░░░░░░  46.3% │     3/10    │   30.00% │
│ util/string.c                                 │    294 │    136 │    158 │ █████████░░░░░░░░░░░  46.3% │    11/15    │   73.33% │
│ util/lock-contention.c                        │     78 │     36 │     42 │ █████████░░░░░░░░░░░  46.2% │     4/5     │   80.00% │
│ trace/beauty/mmap.c                           │     37 │     17 │     20 │ █████████░░░░░░░░░░░  46.0% │     4/8     │   50.00% │
│ builtin-mem.c                                 │    371 │    169 │    202 │ █████████░░░░░░░░░░░  45.5% │     5/9     │   55.56% │
│ tests/hists_common.c                          │    104 │     47 │     57 │ █████████░░░░░░░░░░░  45.2% │     1/3     │   33.33% │
│ util/session.c                                │   2686 │   1204 │   1482 │ ████████░░░░░░░░░░░░  44.8% │    65/125   │   52.00% │
│ trace/beauty/timespec.c                       │      9 │      4 │      5 │ ████████░░░░░░░░░░░░  44.4% │     1/2     │   50.00% │
│ util/intel-pt.c                               │   3237 │   1426 │   1811 │ ████████░░░░░░░░░░░░  44.0% │    79/142   │   55.63% │
│ builtin-inject.c                              │   2023 │    890 │   1133 │ ████████░░░░░░░░░░░░  44.0% │    37/94    │   39.36% │
│ util/bpf_counter.c                            │    573 │    250 │    323 │ ████████░░░░░░░░░░░░  43.6% │    23/34    │   67.65% │
│ util/python.c                                 │   2984 │   1301 │   1683 │ ████████░░░░░░░░░░░░  43.6% │   128/224   │   57.14% │
│ util/data-convert-bt.c                        │   1128 │    483 │    645 │ ████████░░░░░░░░░░░░  42.8% │    27/49    │   55.10% │
│ perf.c                                        │    320 │    135 │    185 │ ████████░░░░░░░░░░░░  42.2% │    10/15    │   66.67% │
│ builtin-sched.c                               │   3737 │   1542 │   2195 │ ████████░░░░░░░░░░░░  41.3% │    62/141   │   43.97% │
│ util/libbfd.h                                 │     20 │      8 │     12 │ ████████░░░░░░░░░░░░  40.0% │     3/7     │   42.86% │
│ util/mem-events.c                             │    760 │    302 │    458 │ ███████░░░░░░░░░░░░░  39.7% │    15/24    │   62.50% │
│ bench/syscall.c                               │    115 │     45 │     70 │ ███████░░░░░░░░░░░░░  39.1% │     2/7     │   28.57% │
│ builtin-buildid-cache.c                       │    414 │    162 │    252 │ ███████░░░░░░░░░░░░░  39.1% │     5/15    │   33.33% │
│ builtin-config.c                              │    149 │     58 │     91 │ ███████░░░░░░░░░░░░░  38.9% │     3/5     │   60.00% │
│ util/annotate.c                               │   2245 │    866 │   1379 │ ███████░░░░░░░░░░░░░  38.6% │    60/118   │   50.85% │
│ builtin-bench.c                               │    121 │     46 │     75 │ ███████░░░░░░░░░░░░░  38.0% │     3/7     │   42.86% │
│ util/clockid.c                                │     45 │     17 │     28 │ ███████░░░░░░░░░░░░░  37.8% │     2/3     │   66.67% │
│ util/intel-pt-decoder/intel-pt-decoder.c      │   3208 │   1201 │   2007 │ ███████░░░░░░░░░░░░░  37.4% │    70/119   │   58.82% │
│ builtin-diff.c                                │   1214 │    434 │    780 │ ███████░░░░░░░░░░░░░  35.8% │    34/79    │   43.04% │
│ util/sort.c                                   │   2421 │    861 │   1560 │ ███████░░░░░░░░░░░░░  35.6% │    83/246   │   33.74% │
│ util/pmu.h                                    │     17 │      6 │     11 │ ███████░░░░░░░░░░░░░  35.3% │     1/1     │  100.00% │
│ util/trigger.h                                │     34 │     12 │     22 │ ███████░░░░░░░░░░░░░  35.3% │     4/9     │   44.44% │
│ builtin-script.c                              │   3212 │   1118 │   2094 │ ██████░░░░░░░░░░░░░░  34.8% │    51/124   │   41.13% │
│ util/hashmap.h                                │     23 │      8 │     15 │ ██████░░░░░░░░░░░░░░  34.8% │     1/2     │   50.00% │
│ util/target.c                                 │     75 │     26 │     49 │ ██████░░░░░░░░░░░░░░  34.7% │     2/3     │   66.67% │
│ util/mmap.c                                   │    212 │     71 │    141 │ ██████░░░░░░░░░░░░░░  33.5% │     7/17    │   41.18% │
│ util/ordered-events.h                         │      9 │      3 │      6 │ ██████░░░░░░░░░░░░░░  33.3% │     1/3     │   33.33% │
│ util/string2.h                                │      9 │      3 │      6 │ ██████░░░░░░░░░░░░░░  33.3% │     1/3     │   33.33% │
│ arch/x86/util/tsc.c                           │     51 │     16 │     35 │ ██████░░░░░░░░░░░░░░  31.4% │     1/2     │   50.00% │
│ util/branch.c                                 │    158 │     49 │    109 │ ██████░░░░░░░░░░░░░░  31.0% │     4/9     │   44.44% │
│ util/util.h                                   │     17 │      5 │     12 │ █████░░░░░░░░░░░░░░░  29.4% │     1/1     │  100.00% │
│ util/perf_regs.c                              │    276 │     78 │    198 │ █████░░░░░░░░░░░░░░░  28.3% │     9/12    │   75.00% │
│ util/bpf-filter.c                             │    496 │    140 │    356 │ █████░░░░░░░░░░░░░░░  28.2% │     9/16    │   56.25% │
│ util/kvm-stat.h                               │     22 │      6 │     16 │ █████░░░░░░░░░░░░░░░  27.3% │     2/4     │   50.00% │
│ arch/x86/util/event.c                         │     27 │      7 │     20 │ █████░░░░░░░░░░░░░░░  25.9% │     1/1     │  100.00% │
│ util/dwarf-regs.c                             │    184 │     47 │    137 │ █████░░░░░░░░░░░░░░░  25.5% │     4/5     │   80.00% │
│ util/evswitch.c                               │     40 │     10 │     30 │ █████░░░░░░░░░░░░░░░  25.0% │     2/3     │   66.67% │
│ arch/x86/tests/amd-ibs-via-core-pmu.c         │     35 │      8 │     27 │ ████░░░░░░░░░░░░░░░░  22.9% │     1/2     │   50.00% │
│ arch/x86/util/machine.c                       │     31 │      7 │     24 │ ████░░░░░░░░░░░░░░░░  22.6% │     1/2     │   50.00% │
│ arch/common.c                                 │    137 │     25 │    112 │ ███░░░░░░░░░░░░░░░░░  18.2% │     4/6     │   66.67% │
│ bench/futex.h                                 │     30 │      5 │     25 │ ███░░░░░░░░░░░░░░░░░  16.7% │     2/9     │   22.22% │
│ arch/x86/util/evsel.c                         │     61 │      6 │     55 │ █░░░░░░░░░░░░░░░░░░░   9.8% │     1/4     │   25.00% │
│ util/addr2line.c                              │    317 │     28 │    289 │ █░░░░░░░░░░░░░░░░░░░   8.8% │     2/8     │   25.00% │
│ arch/x86/util/pmu.c                           │    198 │     17 │    181 │ █░░░░░░░░░░░░░░░░░░░   8.6% │     2/12    │   16.67% │
│ util/block-range.c                            │    225 │     19 │    206 │ █░░░░░░░░░░░░░░░░░░░   8.4% │     3/7     │   42.86% │
│ util/capstone.c                               │    453 │     21 │    432 │ ░░░░░░░░░░░░░░░░░░░░   4.6% │     1/19    │    5.26% │
│ util/intel-pt-decoder/intel-pt-log.c          │    160 │      7 │    153 │ ░░░░░░░░░░░░░░░░░░░░   4.4% │     2/18    │   11.11% │
│ arch/x86/tests/amd-ibs-period.c               │    497 │     21 │    476 │ ░░░░░░░░░░░░░░░░░░░░   4.2% │     2/24    │    8.33% │
│ util/block-info.c                             │    333 │      4 │    329 │ ░░░░░░░░░░░░░░░░░░░░   1.2% │     1/27    │    3.70% │
│ arch/x86/util/intel-bts.c                     │    288 │      0 │    288 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/13    │    0.00% │
│ arch/x86/util/iostat.c                        │    219 │      0 │    219 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/13    │    0.00% │
│ bench/atomic.c                                │    144 │      0 │    144 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/8     │    0.00% │
│ bench/breakpoint.c                            │    165 │      0 │    165 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/6     │    0.00% │
│ bench/epoll-ctl.c                             │    251 │      0 │    251 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/9     │    0.00% │
│ bench/epoll-wait.c                            │    292 │      0 │    292 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/9     │    0.00% │
│ bench/evlist-open-close.c                     │    182 │      0 │    182 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/7     │    0.00% │
│ bench/find-bit-bench.c                        │     83 │      0 │     83 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/4     │    0.00% │
│ bench/futex-lock-pi.c                         │    144 │      0 │    144 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/5     │    0.00% │
│ bench/futex-requeue.c                         │    182 │      0 │    182 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/5     │    0.00% │
│ bench/futex-wake-parallel.c                   │    188 │      0 │    188 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/9     │    0.00% │
│ bench/futex-wake.c                            │    127 │      0 │    127 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/5     │    0.00% │
│ bench/inject-buildid.c                        │    285 │      0 │    285 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/15    │    0.00% │
│ bench/kallsyms-parse.c                        │     36 │      0 │     36 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/3     │    0.00% │
│ bench/maps.c                                  │    128 │      0 │    128 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/2     │    0.00% │
│ bench/numa.c                                  │   1101 │      0 │   1101 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/43    │    0.00% │
│ bench/pmu-scan.c                              │    114 │      0 │    114 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/5     │    0.00% │
│ bench/sched-pipe.c                            │    261 │      0 │    261 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/9     │    0.00% │
│ bench/sched-seccomp-notify.c                  │    102 │      0 │    102 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/4     │    0.00% │
│ bench/symbols.c                               │    175 │      0 │    175 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/4     │    0.00% │
│ bench/synthesize.c                            │    174 │      0 │    174 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/6     │    0.00% │
│ bench/uprobe.c                                │    102 │      0 │    102 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/9     │    0.00% │
│ builtin-help.c                                │    366 │      0 │    366 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/26    │    0.00% │
│ builtin-kmem.c                                │   1337 │      0 │   1337 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/70    │    0.00% │
│ builtin-kvm.c                                 │   1316 │      0 │   1316 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/90    │    0.00% │
│ jvmti/jvmti_agent.c                           │    280 │      0 │    280 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/12    │    0.00% │
│ jvmti/libjvmti.c                              │    280 │      0 │    280 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/10    │    0.00% │
│ tests/workloads/branch_not_taken_loop.c       │      5 │      0 │      5 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/2     │    0.00% │
│ tests/workloads/callchain.c                   │      9 │      0 │      9 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/3     │    0.00% │
│ tests/workloads/context_switch_loop.c         │     61 │      0 │     61 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/3     │    0.00% │
│ tests/workloads/deterministic.c               │     21 │      0 │     21 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/3     │    0.00% │
│ tests/workloads/leafloop.c                    │     20 │      0 │     20 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/4     │    0.00% │
│ tests/workloads/named_threads.c               │     29 │      0 │     29 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/2     │    0.00% │
│ tests/workloads/page_fault_loop.c             │     24 │      0 │     24 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/1     │    0.00% │
│ tests/workloads/sqrtloop.c                    │     24 │      0 │     24 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/3     │    0.00% │
│ tests/workloads/traploop.c                    │      9 │      0 │      9 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/2     │    0.00% │
│ trace/beauty/eventfd.c                        │     19 │      0 │     19 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/1     │    0.00% │
│ trace/beauty/flock.c                          │     24 │      0 │     24 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/1     │    0.00% │
│ trace/beauty/fs_at_flags.c                    │     22 │      0 │     22 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/4     │    0.00% │
│ trace/beauty/fsmount.c                        │     25 │      0 │     25 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/4     │    0.00% │
│ trace/beauty/fspick.c                         │      9 │      0 │      9 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/2     │    0.00% │
│ trace/beauty/futex_val3.c                     │      7 │      0 │      7 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/1     │    0.00% │
│ trace/beauty/kcmp.c                           │     19 │      0 │     19 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/3     │    0.00% │
│ trace/beauty/mount_flags.c                    │     14 │      0 │     14 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/3     │    0.00% │
│ trace/beauty/move_mount.c                     │      9 │      0 │      9 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/2     │    0.00% │
│ trace/beauty/msg_flags.c                      │     39 │      0 │     39 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/1     │    0.00% │
│ trace/beauty/perf_event_open.c                │     53 │      0 │     53 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/5     │    0.00% │
│ trace/beauty/sched_policy.c                   │     25 │      0 │     25 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/1     │    0.00% │
│ trace/beauty/seccomp.c                        │     29 │      0 │     29 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/2     │    0.00% │
│ trace/beauty/sockaddr.c                       │     51 │      0 │     51 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/5     │    0.00% │
│ trace/beauty/socket.c                         │     20 │      0 │     20 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/4     │    0.00% │
│ trace/beauty/socket_type.c                    │     32 │      0 │     32 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/1     │    0.00% │
│ trace/beauty/statx.c                          │     10 │      0 │     10 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/2     │    0.00% │
│ trace/beauty/sync_file_range.c                │     14 │      0 │     14 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/2     │    0.00% │
│ trace/beauty/tracepoints/x86_irq_vectors.c    │     10 │      0 │     10 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/3     │    0.00% │
│ trace/beauty/tracepoints/x86_msr.c            │     10 │      0 │     10 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/3     │    0.00% │
│ ui/browser.c                                  │    559 │      0 │    559 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/41    │    0.00% │
│ ui/browsers/annotate-data.c                   │    428 │      0 │    428 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/23    │    0.00% │
│ ui/browsers/annotate.c                        │    896 │      0 │    896 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/48    │    0.00% │
│ ui/browsers/c2c-function.c                    │    118 │      0 │    118 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/8     │    0.00% │
│ ui/browsers/header.c                          │     93 │      0 │     93 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/4     │    0.00% │
│ ui/browsers/hists.c                           │   2730 │      0 │   2730 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/124   │    0.00% │
│ ui/browsers/map.c                             │     87 │      0 │     87 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/4     │    0.00% │
│ ui/browsers/res_sample.c                      │     64 │      0 │     64 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/3     │    0.00% │
│ ui/browsers/scripts.c                         │    179 │      0 │    179 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/7     │    0.00% │
│ ui/helpline.c                                 │     40 │      0 │     40 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/10    │    0.00% │
│ ui/keysyms.c                                  │     34 │      0 │     34 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/1     │    0.00% │
│ ui/stdio/progress.c                           │     79 │      0 │     79 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/5     │    0.00% │
│ ui/tui/helpline.c                             │     30 │      0 │     30 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/4     │    0.00% │
│ ui/tui/progress.c                             │     52 │      0 │     52 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/5     │    0.00% │
│ ui/tui/setup.c                                │    125 │      0 │    125 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/9     │    0.00% │
│ ui/tui/util.c                                 │    201 │      0 │    201 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/12    │    0.00% │
│ util/amd-sample-raw.c                         │    322 │      0 │    322 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/16    │    0.00% │
│ util/annotate-arch/annotate-alpha.c           │     81 │      0 │     81 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/4     │    0.00% │
│ util/annotate-arch/annotate-arc.c             │      9 │      0 │      9 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/1     │    0.00% │
│ util/annotate-arch/annotate-arm.c             │     40 │      0 │     40 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/2     │    0.00% │
│ util/annotate-arch/annotate-arm64.c           │    778 │      0 │    778 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/30    │    0.00% │
│ util/annotate-arch/annotate-csky.c            │     35 │      0 │     35 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/2     │    0.00% │
│ util/annotate-arch/annotate-loongarch.c       │     94 │      0 │     94 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/4     │    0.00% │
│ util/annotate-arch/annotate-mips.c            │     37 │      0 │     37 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/2     │    0.00% │
│ util/annotate-arch/annotate-powerpc.c         │    144 │      0 │    144 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/10    │    0.00% │
│ util/annotate-arch/annotate-riscv64.c         │     25 │      0 │     25 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/2     │    0.00% │
│ util/annotate-arch/annotate-s390.c            │    119 │      0 │    119 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/5     │    0.00% │
│ util/annotate-arch/annotate-sparc.c           │    136 │      0 │    136 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/5     │    0.00% │
│ util/arm-spe-decoder/arm-spe-decoder.c        │    214 │      0 │    214 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/7     │    0.00% │
│ util/arm-spe-decoder/arm-spe-pkt-decoder.c    │    364 │      0 │    364 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/22    │    0.00% │
│ util/arm-spe.c                                │   1330 │      0 │   1330 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/50    │    0.00% │
│ util/arm64-frame-pointer-unwind-support.c     │     37 │      0 │     37 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/4     │    0.00% │
│ util/block-range.h                            │     21 │      0 │     21 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/4     │    0.00% │
│ util/bpf_ftrace.c                             │    150 │      0 │    150 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/5     │    0.00% │
│ util/bpf_kwork.c                              │    213 │      0 │    213 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/12    │    0.00% │
│ util/bpf_kwork_top.c                          │    169 │      0 │    169 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/12    │    0.00% │
│ util/btf.c                                    │     11 │      0 │     11 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/1     │    0.00% │
│ util/color_config.c                           │     21 │      0 │     21 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/1     │    0.00% │
│ util/cs-etm-base.c                            │     94 │      0 │     94 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/4     │    0.00% │
│ util/cs-etm.h                                 │      4 │      0 │      4 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/1     │    0.00% │
│ util/db-export.c                              │    432 │      0 │    432 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/24    │    0.00% │
│ util/dwarf-regs-arch/dwarf-regs-arm.c         │      5 │      0 │      5 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/1     │    0.00% │
│ util/dwarf-regs-arch/dwarf-regs-arm64.c       │     22 │      0 │     22 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/2     │    0.00% │
│ util/dwarf-regs-arch/dwarf-regs-csky.c        │     61 │      0 │     61 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/4     │    0.00% │
│ util/dwarf-regs-arch/dwarf-regs-loongarch.c   │      5 │      0 │      5 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/1     │    0.00% │
│ util/dwarf-regs-arch/dwarf-regs-mips.c        │      7 │      0 │      7 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/1     │    0.00% │
│ util/dwarf-regs-arch/dwarf-regs-powerpc.c     │     69 │      0 │     69 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/5     │    0.00% │
│ util/dwarf-regs-arch/dwarf-regs-riscv.c       │      5 │      0 │      5 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/1     │    0.00% │
│ util/dwarf-regs-arch/dwarf-regs-s390.c        │     44 │      0 │     44 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/1     │    0.00% │
│ util/genelf_debug.c                           │    318 │      0 │    318 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/27    │    0.00% │
│ util/help-unknown-cmd.c                       │     87 │      0 │     87 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/4     │    0.00% │
│ util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.c  │     67 │      0 │     67 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/5     │    0.00% │
│ util/hisi-ptt.c                               │    107 │      0 │    107 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/11    │    0.00% │
│ util/intel-bts.c                              │    623 │      0 │    623 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/29    │    0.00% │
│ util/intel-pt-decoder/intel-pt-decoder.h      │     15 │      0 │     15 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/1     │    0.00% │
│ util/iostat.c                                 │     19 │      0 │     19 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/8     │    0.00% │
│ util/jitdump.h                                │      9 │      0 │      9 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/2     │    0.00% │
│ util/kvm-stat-arch/kvm-stat-arm64.c           │     31 │      0 │     31 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/7     │    0.00% │
│ util/kvm-stat-arch/kvm-stat-loongarch.c       │     44 │      0 │     44 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/7     │    0.00% │
│ util/kvm-stat-arch/kvm-stat-powerpc.c         │     91 │      0 │     91 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/14    │    0.00% │
│ util/kvm-stat-arch/kvm-stat-riscv.c           │     28 │      0 │     28 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/7     │    0.00% │
│ util/kvm-stat-arch/kvm-stat-s390.c            │     35 │      0 │     35 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/8     │    0.00% │
│ util/kvm-stat-arch/kvm-stat-x86.c             │     94 │      0 │     94 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/17    │    0.00% │
│ util/kvm-stat.c                               │    241 │      0 │    241 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/18    │    0.00% │
│ util/levenshtein.c                            │     33 │      0 │     33 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/1     │    0.00% │
│ util/memswap.c                                │     14 │      0 │     14 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/2     │    0.00% │
│ util/perf-regs-arch/perf_regs_aarch64.c       │    161 │      0 │    161 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/6     │    0.00% │
│ util/perf-regs-arch/perf_regs_arm.c           │     48 │      0 │     48 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/4     │    0.00% │
│ util/perf-regs-arch/perf_regs_csky.c          │     86 │      0 │     86 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/4     │    0.00% │
│ util/perf-regs-arch/perf_regs_loongarch.c     │     80 │      0 │     80 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/4     │    0.00% │
│ util/perf-regs-arch/perf_regs_mips.c          │     76 │      0 │     76 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/4     │    0.00% │
│ util/perf-regs-arch/perf_regs_powerpc.c       │    189 │      0 │    189 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/6     │    0.00% │
│ util/perf-regs-arch/perf_regs_riscv.c         │    137 │      0 │    137 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/6     │    0.00% │
│ util/perf-regs-arch/perf_regs_s390.c          │    127 │      0 │    127 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/6     │    0.00% │
│ util/perf_regs.h                              │      3 │      0 │      3 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/1     │    0.00% │
│ util/powerpc-vpadtl.c                         │    418 │      0 │    418 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/23    │    0.00% │
│ util/print_insn.c                             │     31 │      0 │     31 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/4     │    0.00% │
│ util/pstack.c                                 │     39 │      0 │     39 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/6     │    0.00% │
│ util/s390-cpumsf.c                            │    673 │      0 │    673 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/31    │    0.00% │
│ util/s390-sample-raw.c                        │    227 │      0 │    227 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/13    │    0.00% │
│ util/sharded_mutex.c                          │     20 │      0 │     20 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/2     │    0.00% │
│ util/sharded_mutex.h                          │      3 │      0 │      3 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/1     │    0.00% │
│ util/spark.c                                  │     21 │      0 │     21 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/1     │    0.00% │
│ util/srccode.c                                │    110 │      0 │    110 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/5     │    0.00% │
│ util/stream.c                                 │    222 │      0 │    222 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/17    │    0.00% │
│ util/topdown.c                                │      2 │      0 │      2 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/1     │    0.00% │
│ util/values.c                                 │    216 │      0 │    216 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/10    │    0.00% │
│ util/zlib.c                                   │     65 │      0 │     65 │ ░░░░░░░░░░░░░░░░░░░░   0.0% │     0/2     │    0.00% │
├───────────────────────────────────────────────┼────────┼────────┼────────┼─────────────────────────────┼─────────────┼──────────┤
│ TOTAL (perf)                                  │ 173244 │  91059 │  82185 │ ██████████░░░░░░░░░░  52.6% │  5868/9306  │   63.06% │
└───────────────────────────────────────────────┴────────┴────────┴────────┴─────────────────────────────┴─────────────┴──────────┘

make: Leaving directory '/home/acme/git/perf-tools-next/tools/perf' ⬢ [acme@toolbx perf-tools-next]$

author maintainer
#7 lore raw

PATCH v6 3/13 perf annotate: Handle absolute addressing in data type profiling

In reply to Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

32-bit x86 accesses globals with absolute addresses, like "movl %eax,0x8c73448", but the operand parser only recognized the offset(reg) forms, so the operand had no memory reference, the resolver saw a zero data address and resolved nothing.

Parse a bare "0x" number as an absolute memory operand, leaving jumps, calls, loop* and the 64-bit movabs* out, use the address in the resolver, and let the instruction tracking record the type of an absolute global load in the destination register. The displacement is sign extended for 64-bit objects, as the CPU does, and zero extended for 32-bit ones. Values that do not fit the int offset, zero, and the operands of relocatable objects, which are unrelocated addends, are skipped.

With bare numbers being memory operands, a frame base register of -1, "none", would also compare equal to the -1 "no register" of an absolute operand and take it for a stack access, so guard those comparisons. Operands left with no register, like a user space "%gs:imm", are no longer looked up as variables, which can change the data type stats of those samples.

---
 tools/perf/util/annotate-arch/annotate-x86.c | 52 ++++++++++++++++++--
 tools/perf/util/annotate.c                   | 25 +++++++++-
 tools/perf/util/annotate.h                   |  7 +++
 3 files changed, 79 insertions(+), 5 deletions(-)
tools/perf/util/annotate-arch/annotate-x86.c +48 -4
index e38a4e7a54d5585c..adb52d148cba6001 100644
@@ -230,6 +230,11 @@ static bool vtable_get_rettype(Dwarf_Die *class_die, int offset,
 	return die_get_real_type(&func_die, type_die) != NULL;
 }
 
+static bool is_stack_or_fb_reg(struct type_state *state, int fbreg, int reg)
+{
+	return (fbreg != -1 && reg == fbreg) || reg == state->stack_reg;
+}
+
 static void update_insn_state_x86(struct type_state *state,
 				  struct data_loc_info *dloc, Dwarf_Die *cu_die,
 				  struct disasm_line *dl)
@@ -437,7 +442,7 @@ static void update_insn_state_x86(struct type_state *state,
 		invalidate_reg_state(tsr);
 
 		/* Case 1: Based on stack pointer or frame pointer */
-		if (sreg == fbreg || sreg == state->stack_reg) {
+		if (is_stack_or_fb_reg(state, fbreg, sreg)) {
 			struct type_state_stack *stack;
 			int offset = src->offset - fboff;
 
@@ -626,7 +631,7 @@ static void update_insn_state_x86(struct type_state *state,
 
 retry:
 		/* Check stack variables with offset */
-		if (sreg == fbreg || sreg == state->stack_reg) {
+		if (is_stack_or_fb_reg(state, fbreg, sreg)) {
 			struct type_state_stack *stack;
 			int offset = src->offset - fboff;
 
@@ -741,6 +746,29 @@ static void update_insn_state_x86(struct type_state *state,
 				     insn_offset, addr, dst->reg1);
 			pr_debug_type_name(&type_die, tsr->kind);
 		}
+		/* Or an absolute address, as used by 32-bit code */
+		else if (annotated_op_loc__is_abs(src, map__dso(dloc->ms->map))) {
+			struct map_symbol *ms = dloc->ms;
+			u64 ip = ms->sym->start + dl->al.offset;
+			u64 addr = annotated_op_loc__abs_addr(src, map__dso(ms->map));
+			int offset;
+
+			if (!get_global_var_type(cu_die, dloc, ip, addr, &offset,
+						 &type_die) ||
+			    !die_get_member_type(&type_die, offset, &type_die)) {
+				invalidate_reg_state(tsr);
+				return;
+			}
+
+			tsr->type = type_die;
+			tsr->kind = TSR_KIND_TYPE;
+			tsr->offset = 0;
+			tsr->ok = true;
+
+			pr_debug_dtp("mov [%x] global addr=%#"PRIx64" -> reg%d",
+				     insn_offset, addr, dst->reg1);
+			pr_debug_type_name(&type_die, tsr->kind);
+		}
 		/* And check percpu access with base register */
 		else if (has_reg_type(state, sreg) &&
 			 state->regs[sreg].kind == TSR_KIND_PERCPU_BASE) {
@@ -827,7 +855,7 @@ static void update_insn_state_x86(struct type_state *state,
 	/* Case 3. register to memory transfers */
 	if (!src->mem_ref && dst->mem_ref) {
 		/* Check stack variables with offset */
-		if (dst->reg1 == fbreg || dst->reg1 == state->stack_reg) {
+		if (is_stack_or_fb_reg(state, fbreg, dst->reg1)) {
 			struct type_state_stack *stack;
 			int offset = dst->offset - fboff;
 
@@ -931,7 +959,7 @@ static int extract_reg_offset(const struct arch *arch, const char *str,
 }
 
 static void extract_op_location_x86(const struct arch *arch,
-				    struct disasm_line *dl __maybe_unused,
+				    struct disasm_line *dl,
 				    const char *op_str, int op_idx __maybe_unused,
 				    struct annotated_op_loc *op_loc)
 {
@@ -960,6 +988,22 @@ static void extract_op_location_x86(const struct arch *arch,
 			op_loc->offset = strtol(s + 1, &p, 0);
 			if (p && p != s + 1)
 				op_loc->imm = true;
+		} else if (!strncmp(s, "0x", 2) && !ins__is_jump(&dl->ins) &&
+			   !ins__is_call(&dl->ins) &&
+			   strncmp(dl->ins.name, "loop", 4) &&
+			   strncmp(dl->ins.name, "movabs", 6)) {
+			u64 offset = strtoull(s, NULL, 0);
+
+			/*
+			 * Keep only what fits the int, as disp32 or as a u32;
+			 * movabs*, the 64-bit form, is left out.
+			 */
+			if (offset != 0 && (offset <= UINT_MAX ||
+					    (s64)(int)offset == (s64)offset)) {
+				/* Absolute address, as used by 32-bit code */
+				op_loc->mem_ref = true;
+				op_loc->offset = offset;
+			}
 		}
 	}
 }
tools/perf/util/annotate.c +24 -1
index 86a4beec6528e9bd..f33e22c20656a4f3 100644
@@ -2605,6 +2605,21 @@ int arch__dwarf_regnum(const struct arch *arch, const char *str)
 	return reg < 0 ? -1 : reg;
 }
 
+/* A relocatable object's operand is an unrelocated addend, not an address */
+bool annotated_op_loc__is_abs(const struct annotated_op_loc *op_loc,
+			      const struct dso *dso)
+{
+	return !dso__rel(dso) && op_loc->mem_ref && op_loc->reg1 == -1 && op_loc->reg2 == -1 &&
+	       op_loc->segment == INSN_SEG_NONE && op_loc->offset != 0;
+}
+
+/* The disp32 of a 64-bit object is sign extended, a 32-bit one is not */
+u64 annotated_op_loc__abs_addr(const struct annotated_op_loc *op_loc,
+			       const struct dso *dso)
+{
+	return dso__is_64_bit(dso) ? (u64)(s64)op_loc->offset : (u32)op_loc->offset;
+}
+
 /**
  * annotate_get_insn_location - Get location of instruction
  * @arch: the architecture info
@@ -2622,7 +2637,7 @@ int arch__dwarf_regnum(const struct arch *arch, const char *str)
  *   mov  (%rax), %rcx   # src_reg1 = rax, src_mem = 1, src_offset = 0
  *                       # dst_reg1 = rcx, dst_mem = 0
  *
- *   mov  0x18, %r8      # src_reg1 = -1, src_mem = 0
+ *   mov  0x18, %r8      # src_reg1 = -1, src_mem = 1, src_offset = 0x18
  *                       # dst_reg1 = r8, dst_mem = 0
  *
  *   mov  %rsi, 8(%rbx,%rcx,4)  # src_reg1 = rsi, src_mem = 0, src_multi_regs = 0
@@ -2894,6 +2909,11 @@ __hist_entry__get_data_type(struct hist_entry *he, const struct arch *arch,
 			dloc.var_addr = annotate_calc_pcrel(ms, dloc.ip,
 							    op_loc->offset, dl);
 		}
+		/* Absolute addressing, as used by 32-bit code */
+		else if (annotated_op_loc__is_abs(op_loc, map__dso(ms->map))) {
+			dloc.var_addr = annotated_op_loc__abs_addr(op_loc, map__dso(ms->map));
+			op_loc->reg1 = DWARF_REG_PC;
+		}
 
 		/* This CPU access in kernel - pretend PC-relative addressing */
 		if (dso__kernel(map__dso(ms->map)) && arch__is_x86(arch) &&
@@ -2902,6 +2922,9 @@ __hist_entry__get_data_type(struct hist_entry *he, const struct arch *arch,
 			op_loc->reg1 = DWARF_REG_PC;
 		}
 
+		if (op_loc->reg1 == -1)
+			continue;
+
 		mem_type = find_data_type(&dloc);
 
 		if (mem_type == NULL && is_stack_canary(arch, op_loc)) {
tools/perf/util/annotate.h +7 -0
index 1b47c1156b9a72e1..1b0991d4e98c911e 100644
@@ -18,6 +18,7 @@
 #include "branch.h"
 #include "evsel.h"
 
+struct dso;
 struct hist_browser_timer;
 struct hist_entry;
 struct map;
@@ -638,6 +639,12 @@ struct annotated_insn_loc {
 	     i < INSN_OP_MAX;						\
 	     i++, op_loc++)
 
+/* Bare number operand, as used by 32-bit code to access globals */
+bool annotated_op_loc__is_abs(const struct annotated_op_loc *op_loc,
+			      const struct dso *dso);
+u64 annotated_op_loc__abs_addr(const struct annotated_op_loc *op_loc,
+			       const struct dso *dso);
+
 /* Get detailed location info in the instruction */
 int annotate_get_insn_location(const struct arch *arch, struct disasm_line *dl,
 			       struct annotated_insn_loc *loc);
Signature · 1 line
2.56.0
#8 lore raw

Re: [PATCH v6 03/13] perf annotate: Handle absolute addressing in data type profiling

Sashiko has reviewed this patch and found no issues.
Quoted 15 lines

From: Arnaldo Carvalho de Melo <[email protected]>

32-bit x86 accesses globals with absolute addresses, like "movl %eax,0x8c73448", but the operand parser only recognized the offset(reg) forms, so the operand had no memory reference, the resolver saw a zero data address and resolved nothing.

Parse a bare "0x" number as an absolute memory operand, leaving jumps, calls, loop* and the 64-bit movabs* out, use the address in the resolver, and let the instruction tracking record the type of an absolute global load in the destination register. The displacement is sign extended for 64-bit objects, as the CPU does, and zero extended for 32-bit ones. Values that do not fit the int offset, zero, and the operands of relocatable objects, which are unrelocated addends, are skipped.

Quoted 8 lines

With bare numbers being memory operands, a frame base register of -1, "none", would also compare equal to the -1 "no register" of an absolute operand and take it for a stack access, so guard those comparisons. Operands left with no register, like a user space "%gs:imm", are no longer looked up as variables, which can change the data type stats of those samples.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
maintainer
#9 lore raw

Re: [PATCH v6 03/13] perf annotate: Handle absolute addressing in data type profiling

In reply to Arnaldo Carvalho de Melo
Quoted 64 lines · Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

32-bit x86 accesses globals with absolute addresses, like "movl %eax,0x8c73448", but the operand parser only recognized the offset(reg) forms, so the operand had no memory reference, the resolver saw a zero data address and resolved nothing.

Parse a bare "0x" number as an absolute memory operand, leaving jumps, calls, loop* and the 64-bit movabs* out, use the address in the resolver, and let the instruction tracking record the type of an absolute global load in the destination register. The displacement is sign extended for 64-bit objects, as the CPU does, and zero extended for 32-bit ones. Values that do not fit the int offset, zero, and the operands of relocatable objects, which are unrelocated addends, are skipped.

With bare numbers being memory operands, a frame base register of -1, "none", would also compare equal to the -1 "no register" of an absolute operand and take it for a stack access, so guard those comparisons. Operands left with no register, like a user space "%gs:imm", are no longer looked up as variables, which can change the data type stats of those samples.

---
 tools/perf/util/annotate-arch/annotate-x86.c | 52 ++++++++++++++++++--
 tools/perf/util/annotate.c                   | 25 +++++++++-
 tools/perf/util/annotate.h                   |  7 +++
 3 files changed, 79 insertions(+), 5 deletions(-)
tools/perf/util/annotate-arch/annotate-x86.c +7 -2
index e38a4e7a54d5585c..adb52d148cba6001 100644
@@ -230,6 +230,11 @@ static bool vtable_get_rettype(Dwarf_Die *class_die, int offset,
 	return die_get_real_type(&func_die, type_die) != NULL;
 }
 
+static bool is_stack_or_fb_reg(struct type_state *state, int fbreg, int reg)
+{
+	return (fbreg != -1 && reg == fbreg) || reg == state->stack_reg;
+}
+
 static void update_insn_state_x86(struct type_state *state,
 				  struct data_loc_info *dloc, Dwarf_Die *cu_die,
 				  struct disasm_line *dl)
@@ -437,7 +442,7 @@ static void update_insn_state_x86(struct type_state *state,
 		invalidate_reg_state(tsr);
 
 		/* Case 1: Based on stack pointer or frame pointer */
-		if (sreg == fbreg || sreg == state->stack_reg) {
+		if (is_stack_or_fb_reg(state, fbreg, sreg)) {
 			struct type_state_stack *stack;
 			int offset = src->offset - fboff;
 
@@ -626,7 +631,7 @@ static void update_insn_state_x86(struct type_state *state,
 
 retry:
 		/* Check stack variables with offset */
-		if (sreg == fbreg || sreg == state->stack_reg) {
+		if (is_stack_or_fb_reg(state, fbreg, sreg)) {
 			struct type_state_stack *stack;
 			int offset = src->offset - fboff;
 

tools/perf/util/annotate-arch/annotate-x86.c static void update_insn_state_x86(struct type_state *state, · line 750

Quoted 5 lines
tools/perf/util/annotate-arch/annotate-x86.c +2 -0
@@ -741,6 +746,29 @@ static void update_insn_state_x86(struct type_state *state,
 				     insn_offset, addr, dst->reg1);
 			pr_debug_type_name(&type_die, tsr->kind);
 		}
+		/* Or an absolute address, as used by 32-bit code */
+		else if (annotated_op_loc__is_abs(src, map__dso(dloc->ms->map))) {

Then shouldn't it check if it's actually 32-bit code?

Quoted 4 lines
tools/perf/util/annotate-arch/annotate-x86.c +4 -0
+			struct map_symbol *ms = dloc->ms;
+			u64 ip = ms->sym->start + dl->al.offset;
+			u64 addr = annotated_op_loc__abs_addr(src, map__dso(ms->map));
+			int offset;

tools/perf/util/annotate-arch/annotate-x86.c static void update_insn_state_x86(struct type_state *state, · line 764

Quoted 10 lines
tools/perf/util/annotate-arch/annotate-x86.c +10 -0
+
+			if (!get_global_var_type(cu_die, dloc, ip, addr, &offset,
+						 &type_die) ||
+			    !die_get_member_type(&type_die, offset, &type_die)) {
+				invalidate_reg_state(tsr);
+				return;
+			}
+
+			tsr->type = type_die;
+			tsr->kind = TSR_KIND_TYPE;

I'm not sure if it's _TYPE at this point. Probably _POINTER instead?

Quoted 36 lines
tools/perf/util/annotate-arch/annotate-x86.c +13 -2
+			tsr->offset = 0;
+			tsr->ok = true;
+
+			pr_debug_dtp("mov [%x] global addr=%#"PRIx64" -> reg%d",
+				     insn_offset, addr, dst->reg1);
+			pr_debug_type_name(&type_die, tsr->kind);
+		}
 		/* And check percpu access with base register */
 		else if (has_reg_type(state, sreg) &&
 			 state->regs[sreg].kind == TSR_KIND_PERCPU_BASE) {
@@ -827,7 +855,7 @@ static void update_insn_state_x86(struct type_state *state,
 	/* Case 3. register to memory transfers */
 	if (!src->mem_ref && dst->mem_ref) {
 		/* Check stack variables with offset */
-		if (dst->reg1 == fbreg || dst->reg1 == state->stack_reg) {
+		if (is_stack_or_fb_reg(state, fbreg, dst->reg1)) {
 			struct type_state_stack *stack;
 			int offset = dst->offset - fboff;
 
@@ -931,7 +959,7 @@ static int extract_reg_offset(const struct arch *arch, const char *str,
 }
 
 static void extract_op_location_x86(const struct arch *arch,
-				    struct disasm_line *dl __maybe_unused,
+				    struct disasm_line *dl,
 				    const char *op_str, int op_idx __maybe_unused,
 				    struct annotated_op_loc *op_loc)
 {
@@ -960,6 +988,22 @@ static void extract_op_location_x86(const struct arch *arch,
 			op_loc->offset = strtol(s + 1, &p, 0);
 			if (p && p != s + 1)
 				op_loc->imm = true;
+		} else if (!strncmp(s, "0x", 2) && !ins__is_jump(&dl->ins) &&
+			   !ins__is_call(&dl->ins) &&
+			   strncmp(dl->ins.name, "loop", 4) &&
+			   strncmp(dl->ins.name, "movabs", 6)) {

tools/perf/util/annotate-arch/annotate-x86.c static void extract_op_location_x86(const struct arch *arch, · line 1004

Quoted 10 lines
tools/perf/util/annotate-arch/annotate-x86.c +10 -0
+			u64 offset = strtoull(s, NULL, 0);
+
+			/*
+			 * Keep only what fits the int, as disp32 or as a u32;
+			 * movabs*, the 64-bit form, is left out.
+			 */
+			if (offset != 0 && (offset <= UINT_MAX ||
+					    (s64)(int)offset == (s64)offset)) {
+				/* Absolute address, as used by 32-bit code */
+				op_loc->mem_ref = true;

I don't think it's a mem-ref.

Thanks,
Namhyung

Quoted 90 lines
tools/perf/util/annotate-arch/annotate-x86.c +2 -0
+				op_loc->offset = offset;
+			}
 		}
 	}
 }
tools/perf/util/annotate.c +24 -1
index 86a4beec6528e9bd..f33e22c20656a4f3 100644
@@ -2605,6 +2605,21 @@ int arch__dwarf_regnum(const struct arch *arch, const char *str)
 	return reg < 0 ? -1 : reg;
 }
 
+/* A relocatable object's operand is an unrelocated addend, not an address */
+bool annotated_op_loc__is_abs(const struct annotated_op_loc *op_loc,
+			      const struct dso *dso)
+{
+	return !dso__rel(dso) && op_loc->mem_ref && op_loc->reg1 == -1 && op_loc->reg2 == -1 &&
+	       op_loc->segment == INSN_SEG_NONE && op_loc->offset != 0;
+}
+
+/* The disp32 of a 64-bit object is sign extended, a 32-bit one is not */
+u64 annotated_op_loc__abs_addr(const struct annotated_op_loc *op_loc,
+			       const struct dso *dso)
+{
+	return dso__is_64_bit(dso) ? (u64)(s64)op_loc->offset : (u32)op_loc->offset;
+}
+
 /**
  * annotate_get_insn_location - Get location of instruction
  * @arch: the architecture info
@@ -2622,7 +2637,7 @@ int arch__dwarf_regnum(const struct arch *arch, const char *str)
  *   mov  (%rax), %rcx   # src_reg1 = rax, src_mem = 1, src_offset = 0
  *                       # dst_reg1 = rcx, dst_mem = 0
  *
- *   mov  0x18, %r8      # src_reg1 = -1, src_mem = 0
+ *   mov  0x18, %r8      # src_reg1 = -1, src_mem = 1, src_offset = 0x18
  *                       # dst_reg1 = r8, dst_mem = 0
  *
  *   mov  %rsi, 8(%rbx,%rcx,4)  # src_reg1 = rsi, src_mem = 0, src_multi_regs = 0
@@ -2894,6 +2909,11 @@ __hist_entry__get_data_type(struct hist_entry *he, const struct arch *arch,
 			dloc.var_addr = annotate_calc_pcrel(ms, dloc.ip,
 							    op_loc->offset, dl);
 		}
+		/* Absolute addressing, as used by 32-bit code */
+		else if (annotated_op_loc__is_abs(op_loc, map__dso(ms->map))) {
+			dloc.var_addr = annotated_op_loc__abs_addr(op_loc, map__dso(ms->map));
+			op_loc->reg1 = DWARF_REG_PC;
+		}
 
 		/* This CPU access in kernel - pretend PC-relative addressing */
 		if (dso__kernel(map__dso(ms->map)) && arch__is_x86(arch) &&
@@ -2902,6 +2922,9 @@ __hist_entry__get_data_type(struct hist_entry *he, const struct arch *arch,
 			op_loc->reg1 = DWARF_REG_PC;
 		}
 
+		if (op_loc->reg1 == -1)
+			continue;
+
 		mem_type = find_data_type(&dloc);
 
 		if (mem_type == NULL && is_stack_canary(arch, op_loc)) {
tools/perf/util/annotate.h +7 -0
index 1b47c1156b9a72e1..1b0991d4e98c911e 100644
@@ -18,6 +18,7 @@
 #include "branch.h"
 #include "evsel.h"
 
+struct dso;
 struct hist_browser_timer;
 struct hist_entry;
 struct map;
@@ -638,6 +639,12 @@ struct annotated_insn_loc {
 	     i < INSN_OP_MAX;						\
 	     i++, op_loc++)
 
+/* Bare number operand, as used by 32-bit code to access globals */
+bool annotated_op_loc__is_abs(const struct annotated_op_loc *op_loc,
+			      const struct dso *dso);
+u64 annotated_op_loc__abs_addr(const struct annotated_op_loc *op_loc,
+			       const struct dso *dso);
+
 /* Get detailed location info in the instruction */
 int annotate_get_insn_location(const struct arch *arch, struct disasm_line *dl,
 			       struct annotated_insn_loc *loc);
Signature · 1 line
2.56.0
author maintainer
#10 lore raw

Re: [PATCH v6 03/13] perf annotate: Handle absolute addressing in data type profiling

Quoted 64 lines · Namhyung Kim
Quoted 63 lines · Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

32-bit x86 accesses globals with absolute addresses, like "movl %eax,0x8c73448", but the operand parser only recognized the offset(reg) forms, so the operand had no memory reference, the resolver saw a zero data address and resolved nothing.

Parse a bare "0x" number as an absolute memory operand, leaving jumps, calls, loop* and the 64-bit movabs* out, use the address in the resolver, and let the instruction tracking record the type of an absolute global load in the destination register. The displacement is sign extended for 64-bit objects, as the CPU does, and zero extended for 32-bit ones. Values that do not fit the int offset, zero, and the operands of relocatable objects, which are unrelocated addends, are skipped.

With bare numbers being memory operands, a frame base register of -1, "none", would also compare equal to the -1 "no register" of an absolute operand and take it for a stack access, so guard those comparisons. Operands left with no register, like a user space "%gs:imm", are no longer looked up as variables, which can change the data type stats of those samples.

---
 tools/perf/util/annotate-arch/annotate-x86.c | 52 ++++++++++++++++++--
 tools/perf/util/annotate.c                   | 25 +++++++++-
 tools/perf/util/annotate.h                   |  7 +++
 3 files changed, 79 insertions(+), 5 deletions(-)
tools/perf/util/annotate-arch/annotate-x86.c +7 -2
index e38a4e7a54d5585c..adb52d148cba6001 100644
@@ -230,6 +230,11 @@ static bool vtable_get_rettype(Dwarf_Die *class_die, int offset,
 	return die_get_real_type(&func_die, type_die) != NULL;
 }
 
+static bool is_stack_or_fb_reg(struct type_state *state, int fbreg, int reg)
+{
+	return (fbreg != -1 && reg == fbreg) || reg == state->stack_reg;
+}
+
 static void update_insn_state_x86(struct type_state *state,
 				  struct data_loc_info *dloc, Dwarf_Die *cu_die,
 				  struct disasm_line *dl)
@@ -437,7 +442,7 @@ static void update_insn_state_x86(struct type_state *state,
 		invalidate_reg_state(tsr);
 
 		/* Case 1: Based on stack pointer or frame pointer */
-		if (sreg == fbreg || sreg == state->stack_reg) {
+		if (is_stack_or_fb_reg(state, fbreg, sreg)) {
 			struct type_state_stack *stack;
 			int offset = src->offset - fboff;
 
@@ -626,7 +631,7 @@ static void update_insn_state_x86(struct type_state *state,
 
 retry:
 		/* Check stack variables with offset */
-		if (sreg == fbreg || sreg == state->stack_reg) {
+		if (is_stack_or_fb_reg(state, fbreg, sreg)) {
 			struct type_state_stack *stack;
 			int offset = src->offset - fboff;
 
Quoted 8 lines

tools/perf/util/annotate-arch/annotate-x86.c static void update_insn_state_x86(struct type_state *state, · line 750

Quoted 6 lines
tools/perf/util/annotate-arch/annotate-x86.c +2 -0
@@ -741,6 +746,29 @@ static void update_insn_state_x86(struct type_state *state,
 				     insn_offset, addr, dst->reg1);
 			pr_debug_type_name(&type_die, tsr->kind);
 		}
+		/* Or an absolute address, as used by 32-bit code */
+		else if (annotated_op_loc__is_abs(src, map__dso(dloc->ms->map))) {

Then shouldn't it check if it's actually 32-bit code?

After some more rounds of local reviews and trying to answer your question:
/*
* Keep only what fits the int, as disp32 or as a u32;

-                        * movabs*, the 64-bit form, is left out.
+                        * a 64-bit absolute value is left out.  The LLVM
+                        * disassembler prints a disp32 that does not fit an
+                        * int as a negative number.
                         */
                        if (offset != 0 && (offset <= UINT_MAX ||
                                            (s64)(int)offset == (s64)offset)) {
-                               /* Absolute address, as used by 32-bit code */
+                               /* An absolute address: 32-bit code, or a 64-bit disp32 */
                                op_loc->mem_ref = true;
                                op_loc->offset = offset;
                        }

It is not 32-bit specific, the comment was wrong.

Quoted 8 lines
Quoted 8 lines
tools/perf/util/annotate-arch/annotate-x86.c +8 -0
+			struct map_symbol *ms = dloc->ms;
+			u64 ip = ms->sym->start + dl->al.offset;
+			u64 addr = annotated_op_loc__abs_addr(src, map__dso(ms->map));
+			int offset;
+
+			if (!get_global_var_type(cu_die, dloc, ip, addr, &offset,
+						 &type_die) ||
+			    !die_get_member_type(&type_die, offset, &type_die)) {
Quoted 8 lines

tools/perf/util/annotate-arch/annotate-x86.c static void update_insn_state_x86(struct type_state *state, · line 764

Quoted 6 lines
tools/perf/util/annotate-arch/annotate-x86.c +6 -0
+				invalidate_reg_state(tsr);
+				return;
+			}
+
+			tsr->type = type_die;
+			tsr->kind = TSR_KIND_TYPE;

I'm not sure if it's _TYPE at this point. Probably _POINTER instead?

Why do you think so?

This is just duplicating to some degree what is right before, that uses a TYPE for a global, no? But please check v7, there is a change in this area.

- Arnaldo

author maintainer
#11 lore raw

PATCH v6 4/13 perf tests: Exercise DW_OP_addrx global variables

In reply to Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

clang emits DW_AT_location with DW_OP_addrx for globals in DWARF 5, gcc emits DW_OP_addr. The global_data workload keeps a zero initialized struct in .bss and the test checks that its accesses are annotated, so the DW_OP_addrx path is exercised when perf is built with clang and DWARF 5 (e.g. coverage.sh --dwarf-version 5), and the DW_OP_addr one with gcc. It skips on 32-bit PIE builds, which reach static globals relative to the GOT base register, and the resolver does not track that.

---
 tools/perf/tests/builtin-test.c            |  1 +
 tools/perf/tests/shell/data_type_global.sh | 68 ++++++++++++++++++++++
 tools/perf/tests/tests.h                   |  1 +
 tools/perf/tests/workloads/Build           |  2 +
 tools/perf/tests/workloads/global_data.c   | 55 +++++++++++++++++
 5 files changed, 127 insertions(+)
 create mode 100755 tools/perf/tests/shell/data_type_global.sh
 create mode 100644 tools/perf/tests/workloads/global_data.c
tools/perf/tests/builtin-test.c +1 -0
index 327483f96401b580..e056a3d3594ff8a2 100644
@@ -213,6 +213,7 @@ static struct test_workload *workloads[] = {
 	&workload__deterministic,
 	&workload__callchain,
 	&workload__false_sharing,
+	&workload__global_data,
 
 #ifdef HAVE_RUST_SUPPORT
 	&workload__code_with_type,
tools/perf/tests/shell/data_type_global.sh new file +68 -0

68 lines not on this page · raw message

tools/perf/tests/tests.h +1 -0
index af822885890dda73..049a164503166529 100644
@@ -273,6 +273,7 @@ DECLARE_WORKLOAD(context_switch_loop);
 DECLARE_WORKLOAD(deterministic);
 DECLARE_WORKLOAD(callchain);
 DECLARE_WORKLOAD(false_sharing);
+DECLARE_WORKLOAD(global_data);
 
 #ifdef HAVE_RUST_SUPPORT
 DECLARE_WORKLOAD(code_with_type);
tools/perf/tests/workloads/Build +2 -0
index 43cc4da6fb0786de..03017aaaaa0bec32 100644
@@ -17,6 +17,7 @@ perf-test-y += context_switch_loop.o
 perf-test-y += deterministic.o
 perf-test-y += callchain.o
 perf-test-y += false_sharing.o
+perf-test-y += global_data.o
 
 ifeq ($(CONFIG_RUST_SUPPORT),y)
     perf-test-y += code_with_type.o
@@ -35,3 +36,4 @@ CFLAGS_deterministic.o    = -g -O0 -fno-inline -U_FORTIFY_SOURCE
 CFLAGS_named_threads.o    = -g -O0 -fno-inline -U_FORTIFY_SOURCE
 CFLAGS_callchain.o        = -g -O0 -fno-inline -U_FORTIFY_SOURCE
 CFLAGS_false_sharing.o    = -g -O0 -fno-inline -U_FORTIFY_SOURCE
+CFLAGS_global_data.o      = -g -O0 -fno-inline -U_FORTIFY_SOURCE
tools/perf/tests/workloads/global_data.c new file +55 -0

55 lines not on this page · raw message

Signature · 1 line
2.56.0
#12 lore raw

Re: [PATCH v6 04/13] perf tests: Exercise DW_OP_addrx global variables

Sashiko has reviewed this patch and found no issues.
Quoted 11 lines

From: Arnaldo Carvalho de Melo <[email protected]>

clang emits DW_AT_location with DW_OP_addrx for globals in DWARF 5, gcc emits DW_OP_addr. The global_data workload keeps a zero initialized struct in .bss and the test checks that its accesses are annotated, so the DW_OP_addrx path is exercised when perf is built with clang and DWARF 5 (e.g. coverage.sh --dwarf-version 5), and the DW_OP_addr one with gcc. It skips on 32-bit PIE builds, which reach static globals relative to the GOT base register, and the resolver does not track that.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
author maintainer
#13 lore raw

PATCH v6 5/13 perf tests: Exercise the flexible array member path

In reply to Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

No test covered find_flex_array() and get_flex_array_member(). Add a flex_array workload that keeps a struct with a trailing data[] behind a global pointer, and a test that checks the accesses past the struct size are resolved and named after the flexible array member; find_data_type() folds offsets past the struct modulo the element size back to the member's offset (+0x4 for char data[]). The test skips on 32-bit PIE builds, which reach static globals relative to the GOT base register.

---
 tools/perf/tests/builtin-test.c               |  1 +
 .../perf/tests/shell/data_type_flex_array.sh  | 68 +++++++++++++++++++
 tools/perf/tests/tests.h                      |  1 +
 tools/perf/tests/workloads/Build              |  2 +
 tools/perf/tests/workloads/flex_array.c       | 55 +++++++++++++++
 5 files changed, 127 insertions(+)
 create mode 100755 tools/perf/tests/shell/data_type_flex_array.sh
 create mode 100644 tools/perf/tests/workloads/flex_array.c
tools/perf/tests/builtin-test.c +1 -0
index e056a3d3594ff8a2..8fc425d470c17dbf 100644
@@ -214,6 +214,7 @@ static struct test_workload *workloads[] = {
 	&workload__callchain,
 	&workload__false_sharing,
 	&workload__global_data,
+	&workload__flex_array,
 
 #ifdef HAVE_RUST_SUPPORT
 	&workload__code_with_type,
tools/perf/tests/shell/data_type_flex_array.sh new file +68 -0

68 lines not on this page · raw message

tools/perf/tests/tests.h +1 -0
index 049a164503166529..0cf33d91804f19c4 100644
@@ -274,6 +274,7 @@ DECLARE_WORKLOAD(deterministic);
 DECLARE_WORKLOAD(callchain);
 DECLARE_WORKLOAD(false_sharing);
 DECLARE_WORKLOAD(global_data);
+DECLARE_WORKLOAD(flex_array);
 
 #ifdef HAVE_RUST_SUPPORT
 DECLARE_WORKLOAD(code_with_type);
tools/perf/tests/workloads/Build +2 -0
index 03017aaaaa0bec32..74a0cbe49dc93533 100644
@@ -18,6 +18,7 @@ perf-test-y += deterministic.o
 perf-test-y += callchain.o
 perf-test-y += false_sharing.o
 perf-test-y += global_data.o
+perf-test-y += flex_array.o
 
 ifeq ($(CONFIG_RUST_SUPPORT),y)
     perf-test-y += code_with_type.o
@@ -37,3 +38,4 @@ CFLAGS_named_threads.o    = -g -O0 -fno-inline -U_FORTIFY_SOURCE
 CFLAGS_callchain.o        = -g -O0 -fno-inline -U_FORTIFY_SOURCE
 CFLAGS_false_sharing.o    = -g -O0 -fno-inline -U_FORTIFY_SOURCE
 CFLAGS_global_data.o      = -g -O0 -fno-inline -U_FORTIFY_SOURCE
+CFLAGS_flex_array.o       = -g -O0 -fno-inline -U_FORTIFY_SOURCE
tools/perf/tests/workloads/flex_array.c new file +55 -0

55 lines not on this page · raw message

Signature · 1 line
2.56.0
#14 lore raw

Re: [PATCH v6 05/13] perf tests: Exercise the flexible array member path

Sashiko has reviewed this patch and found no issues.
Quoted 10 lines

From: Arnaldo Carvalho de Melo <[email protected]>

No test covered find_flex_array() and get_flex_array_member(). Add a flex_array workload that keeps a struct with a trailing data[] behind a global pointer, and a test that checks the accesses past the struct size are resolved and named after the flexible array member; find_data_type() folds offsets past the struct modulo the element size back to the member's offset (+0x4 for char data[]). The test skips on 32-bit PIE builds, which reach static globals relative to the GOT base register.

Quoted 2 lines

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
author maintainer
#15 lore raw

PATCH v6 6/13 perf annotate-data: Count flexible array accesses for the whole struct

In reply to Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

The per-member percentage sums the histogram entries in the member's own [offset, offset + size) range. A flexible array member is resolved past the end of its struct, so the struct row only covered its declared size and showed 0.00% while the member row showed 100.00% and the header said N samples.

Take a member's extent as the end of its last child as well, so the struct counts what was resolved past it. Union members all start at offset 0, so a plain union keeps its size; a member that is itself a struct with a flexible array extends the union too. The TUI browser accounts the members the same way, use the extent there as well.

Extend tests/shell/data_type_flex_array.sh to check that the accesses count for the struct in the percent, samples and period columns.

Fixes aaca646915a1bb53 ("perf annotate-data: Adjust type offset for flex-array")
Cc Namhyung Kim <[email protected]>
---
 .../perf/tests/shell/data_type_flex_array.sh  | 42 ++++++++++++++++++-
 tools/perf/ui/browsers/annotate-data.c        |  7 ++--
 tools/perf/util/annotate-data.c               | 25 ++++++++++-
 tools/perf/util/annotate-data.h               |  8 ++++
 4 files changed, 75 insertions(+), 7 deletions(-)
tools/perf/tests/shell/data_type_flex_array.sh +41 -1
index 850997d94baab07d..224380577fc45fc8 100755
@@ -64,5 +64,45 @@ if ! grep -Fq "# data-type: struct flex +0x4 (data)" "$perfout"; then
 	exit 1
 fi
 
-echo "flexible array member resolved"
+# The accesses to the flexible array are resolved past the end of the
+# struct: they must count for the struct, not only for the member.
+if ! perf annotate --data-type -i "$perfdata" --stdio > "$perfout"; then
+	echo "FAIL: perf annotate --data-type"
+	cleanup
+	exit 1
+fi
+
+if ! awk '
+	$1 + 0 == 100.00 && /struct flex/ { struct_ok = 1 }
+	$1 + 0 > 0 && /char\[\]/ && /data;/ { data_ok = 1 }
+	END { exit !(struct_ok && data_ok) }
+' <(sed -n "/^Annotate type: 'struct flex' in/,/^Annotate type: /p" "$perfout"); then
+	echo "FAIL: --data-type does not count the flexible array accesses"
+	tail -n 30 "$perfout"
+	cleanup
+	exit 1
+fi
+
+# Same with the samples and period columns, the other two display modes.
+for mode in --show-nr-samples --show-total-period; do
+	if ! perf annotate --data-type -i "$perfdata" --stdio "$mode" > "$perfout"; then
+		echo "FAIL: perf annotate --data-type $mode"
+		cleanup
+		exit 1
+	fi
+
+	if ! awk '
+		$1 + 0 > 0 && /struct flex/ { total = $1 + 0 }
+		/int/ && /len;/ { len = $1 + 0 }
+		/char\[\]/ && /data;/ { data = $1 + 0 }
+		END { exit !(total > 0 && data > 0 && total == data + len) }
+	' <(sed -n "/^Annotate type: 'struct flex' in/,/^Annotate type: /p" "$perfout"); then
+		echo "FAIL: --data-type $mode does not count the flexible array accesses"
+		tail -n 30 "$perfout"
+		cleanup
+		exit 1
+	fi
+done
+
+echo "flexible array member resolved and counted"
 cleanup
tools/perf/ui/browsers/annotate-data.c +3 -4
index 0f778788df4a934b..e4047e97e8a943a4 100644
@@ -53,12 +53,11 @@ static int get_member_overhead(struct annotated_data_type *adt,
 			       struct evsel *leader)
 {
 	struct annotated_member *member = entry->data;
-	int i, k;
+	int i, k, end = annotated_member__extent(member);
 
-	for (i = 0; i < member->size; i++) {
+	for (i = member->offset; i < end; i++) {
 		struct type_hist *h;
 		struct evsel *evsel;
-		int offset = member->offset + i;
 
 		k = 0;
 		for_each_group_evsel(evsel, leader) {
@@ -69,7 +68,7 @@ static int get_member_overhead(struct annotated_data_type *adt,
 				continue;
 
 			h = &adt->histograms[evsel->core.idx];
-			if (hashmap__find(&h->samples, offset, &hist))
+			if (hashmap__find(&h->samples, i, &hist))
 				update_hist_entry(&entry->hists[k], hist);
 			k++;
 		}
tools/perf/util/annotate-data.c +23 -2
index 2332d465f9751ef3..19c1de5c29853f69 100644
@@ -2208,6 +2208,26 @@ static void print_annotated_data_value(struct type_hist *h, u64 period, int nr_s
 		color_fprintf(stdout, color, " %7.2f", percent);
 }
 
+/*
+ * A flexible array member is resolved past the end of its parent, so the
+ * parent's samples are not bounded by its size.  A GNU extension non-last
+ * member with a flexible array can overlap the next member and double-count.
+ */
+int annotated_member__extent(struct annotated_member *member)
+{
+	struct annotated_member *child;
+	int end = member->offset + member->size;
+
+	list_for_each_entry(child, &member->children, node) {
+		int child_end = annotated_member__extent(child);
+
+		if (child_end > end)
+			end = child_end;
+	}
+
+	return end;
+}
+
 static void print_annotated_data_type(struct annotated_data_type *mem_type,
 				      struct annotated_member *member,
 				      struct evsel *evsel, int indent)
@@ -2215,6 +2235,7 @@ static void print_annotated_data_type(struct annotated_data_type *mem_type,
 	struct annotated_member *child;
 	struct type_hist *h;
 	int i, nr_events = 0, samples = 0;
+	int end = annotated_member__extent(member);
 	u64 period = 0;
 	int width = symbol_conf.show_total_period ? 11 : 7;
 	struct evsel *pos;
@@ -2228,10 +2249,10 @@ static void print_annotated_data_type(struct annotated_data_type *mem_type,
 
 		samples = 0;
 		period = 0;
-		for (i = 0; i < member->size; i++) {
+		for (i = member->offset; i < end; i++) {
 			struct type_hist_entry *entry;
 
-			if (!hashmap__find(&h->samples, member->offset + i, &entry))
+			if (!hashmap__find(&h->samples, i, &entry))
 				continue;
 
 			samples += entry->nr_samples;
tools/perf/util/annotate-data.h +8 -0
index 184262c7356213fa..6e0d410929651426 100644
@@ -260,6 +260,9 @@ void global_var_type__tree_delete(struct rb_root *root);
 /* Print data type annotation (including members) on stdout */
 int hist_entry__annotate_data_tty(struct hist_entry *he, struct evsel *evsel);
 
+/* End offset of a member, including a flexible array's children */
+int annotated_member__extent(struct annotated_member *member);
+
 /* Get name of member field at the given offset in the data type */
 int annotated_data_type__get_member_name(struct annotated_data_type *adt,
 					 char *buf, size_t sz, int member_offset);
@@ -316,6 +319,11 @@ static inline int hist_entry__annotate_data_tty(struct hist_entry *he __maybe_un
 	return -1;
 }
 
+static inline int annotated_member__extent(struct annotated_member *member)
+{
+	return member->offset + member->size;
+}
+
 static inline int annotated_data_type__get_member_name(struct annotated_data_type *adt __maybe_unused,
 						       char *buf __maybe_unused,
 						       size_t sz __maybe_unused,
Signature · 1 line
2.56.0
#16 lore raw

Re: [PATCH v6 06/13] perf annotate-data: Count flexible array accesses for the whole struct

Sashiko has reviewed this patch and found no issues.
Quoted 14 lines

From: Arnaldo Carvalho de Melo <[email protected]>

The per-member percentage sums the histogram entries in the member's own [offset, offset + size) range. A flexible array member is resolved past the end of its struct, so the struct row only covered its declared size and showed 0.00% while the member row showed 100.00% and the header said N samples.

Take a member's extent as the end of its last child as well, so the struct counts what was resolved past it. Union members all start at offset 0, so a plain union keeps its size; a member that is itself a struct with a flexible array extends the union too. The TUI browser accounts the members the same way, use the extent there as well.

Quoted 7 lines

Extend tests/shell/data_type_flex_array.sh to check that the accesses count for the struct in the percent, samples and period columns.

Fixes aaca646915a1bb53 ("perf annotate-data: Adjust type offset for flex-array")
Cc Namhyung Kim <[email protected]>

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
author maintainer
#17 lore raw

PATCH v6 7/13 perf tests: Exercise data type resolution from a register

In reply to Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

At -O2 a struct pointer lives in a register (with DWARF describing it with a register location on register-argument ABIs), while the unoptimized workloads the data type tests profile keep their variables on the stack.

Add a regptr workload with a noinline function that takes the pointer from a volatile global, so the compiler cannot constant-propagate the object address, and check that its three member accesses are resolved from that register.

---
 tools/perf/tests/builtin-test.c              |  1 +
 tools/perf/tests/shell/data_type_register.sh | 60 +++++++++++++++++++
 tools/perf/tests/tests.h                     |  1 +
 tools/perf/tests/workloads/Build             |  2 +
 tools/perf/tests/workloads/regptr.c          | 61 ++++++++++++++++++++
 5 files changed, 125 insertions(+)
 create mode 100755 tools/perf/tests/shell/data_type_register.sh
 create mode 100644 tools/perf/tests/workloads/regptr.c
tools/perf/tests/builtin-test.c +1 -0
index 8fc425d470c17dbf..fe4d4cd54f85d502 100644
@@ -215,6 +215,7 @@ static struct test_workload *workloads[] = {
 	&workload__false_sharing,
 	&workload__global_data,
 	&workload__flex_array,
+	&workload__regptr,
 
 #ifdef HAVE_RUST_SUPPORT
 	&workload__code_with_type,
tools/perf/tests/shell/data_type_register.sh new file +60 -0

60 lines not on this page · raw message

tools/perf/tests/tests.h +1 -0
index 0cf33d91804f19c4..b03c56d5e4c98aaf 100644
@@ -275,6 +275,7 @@ DECLARE_WORKLOAD(callchain);
 DECLARE_WORKLOAD(false_sharing);
 DECLARE_WORKLOAD(global_data);
 DECLARE_WORKLOAD(flex_array);
+DECLARE_WORKLOAD(regptr);
 
 #ifdef HAVE_RUST_SUPPORT
 DECLARE_WORKLOAD(code_with_type);
tools/perf/tests/workloads/Build +2 -0
index 74a0cbe49dc93533..17189458032c0a17 100644
@@ -19,6 +19,7 @@ perf-test-y += callchain.o
 perf-test-y += false_sharing.o
 perf-test-y += global_data.o
 perf-test-y += flex_array.o
+perf-test-y += regptr.o
 
 ifeq ($(CONFIG_RUST_SUPPORT),y)
     perf-test-y += code_with_type.o
@@ -39,3 +40,4 @@ CFLAGS_callchain.o        = -g -O0 -fno-inline -U_FORTIFY_SOURCE
 CFLAGS_false_sharing.o    = -g -O0 -fno-inline -U_FORTIFY_SOURCE
 CFLAGS_global_data.o      = -g -O0 -fno-inline -U_FORTIFY_SOURCE
 CFLAGS_flex_array.o       = -g -O0 -fno-inline -U_FORTIFY_SOURCE
+CFLAGS_regptr.o           = -g -O2
tools/perf/tests/workloads/regptr.c new file +61 -0

61 lines not on this page · raw message

Signature · 1 line
2.56.0
#18 lore raw

Re: [PATCH v6 07/13] perf tests: Exercise data type resolution from a register

Sashiko has reviewed this patch and found no issues.
Quoted 6 lines

From: Arnaldo Carvalho de Melo <[email protected]>

At -O2 a struct pointer lives in a register (with DWARF describing it with a register location on register-argument ABIs), while the unoptimized workloads the data type tests profile keep their variables on the stack.

Quoted 7 lines

Add a regptr workload with a noinline function that takes the pointer from a volatile global, so the compiler cannot constant-propagate the object address, and check that its three member accesses are resolved from that register.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
maintainer
#19 lore raw

Re: [PATCH v6 07/13] perf tests: Exercise data type resolution from a register

In reply to Arnaldo Carvalho de Melo
Quoted 10 lines · Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

At -O2 a struct pointer lives in a register (with DWARF describing it with a register location on register-argument ABIs), while the unoptimized workloads the data type tests profile keep their variables on the stack.

Add a regptr workload with a noinline function that takes the pointer from a volatile global, so the compiler cannot constant-propagate the object address, and check that its three member accesses are resolved from that register.

Thanks for adding the workloads for data type profiling. I was unsure if it's ok to add since it'd requires many test cases to cover various aspect of binary patterns or compiler/language differences. But having a seperate repo for the test programs would be cumbersome too.

Thanks,
Namhyung

Quoted 190 lines
---
 tools/perf/tests/builtin-test.c              |  1 +
 tools/perf/tests/shell/data_type_register.sh | 60 +++++++++++++++++++
 tools/perf/tests/tests.h                     |  1 +
 tools/perf/tests/workloads/Build             |  2 +
 tools/perf/tests/workloads/regptr.c          | 61 ++++++++++++++++++++
 5 files changed, 125 insertions(+)
 create mode 100755 tools/perf/tests/shell/data_type_register.sh
 create mode 100644 tools/perf/tests/workloads/regptr.c
tools/perf/tests/builtin-test.c +1 -0
index 8fc425d470c17dbf..fe4d4cd54f85d502 100644
@@ -215,6 +215,7 @@ static struct test_workload *workloads[] = {
 	&workload__false_sharing,
 	&workload__global_data,
 	&workload__flex_array,
+	&workload__regptr,
 
 #ifdef HAVE_RUST_SUPPORT
 	&workload__code_with_type,
tools/perf/tests/shell/data_type_register.sh new file +60 -0
new file mode 100755
index 0000000000000000..0d4a420cad9475cd
@@ -0,0 +1,60 @@
+#!/bin/bash
+# perf data type profiling tests for register variables
+# SPDX-License-Identifier: GPL-2.0
+
+set -e
+
+perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
+perfout=$(mktemp /tmp/__perf_test.perf.out.XXXXX)
+
+cleanup()
+{
+	rm -f "$perfdata" "$perfout"
+	trap - EXIT TERM INT
+}
+
+trap_cleanup()
+{
+	echo "Unexpected signal in ${FUNCNAME[1]}"
+	cleanup
+	exit 1
+}
+trap trap_cleanup EXIT TERM INT
+
+if ! perf check feature -q dwarf; then
+	echo "Skip: no DWARF (libdw) support"
+	cleanup
+	exit 2
+fi
+
+# No point in recording if the PMU cannot do memory events.
+if ! perf mem record -o /dev/null -- true 2>/dev/null; then
+	echo "Skip: cannot record memory events on this PMU"
+	cleanup
+	exit 2
+fi
+
+if ! perf mem record -o "$perfdata" -- perf test -w regptr 1 > /dev/null 2>&1; then
+	echo "FAIL: perf mem record"
+	cleanup
+	exit 1
+fi
+
+if ! perf annotate --code-with-type -i "$perfdata" --stdio \
+		--percent-limit 1 > "$perfout"; then
+	echo "FAIL: perf annotate"
+	cleanup
+	exit 1
+fi
+
+for member in "+0 (a)" "+0x8 (b)" "+0x10 (c)"; do
+	if ! grep -Fq "# data-type: struct node ${member}" "$perfout"; then
+		echo "FAIL: member ${member} not resolved from the register"
+		tail -n 30 "$perfout"
+		cleanup
+		exit 1
+	fi
+done
+
+echo "register held access resolved"
+cleanup
tools/perf/tests/tests.h +1 -0
index 0cf33d91804f19c4..b03c56d5e4c98aaf 100644
@@ -275,6 +275,7 @@ DECLARE_WORKLOAD(callchain);
 DECLARE_WORKLOAD(false_sharing);
 DECLARE_WORKLOAD(global_data);
 DECLARE_WORKLOAD(flex_array);
+DECLARE_WORKLOAD(regptr);
 
 #ifdef HAVE_RUST_SUPPORT
 DECLARE_WORKLOAD(code_with_type);
tools/perf/tests/workloads/Build +2 -0
index 74a0cbe49dc93533..17189458032c0a17 100644
@@ -19,6 +19,7 @@ perf-test-y += callchain.o
 perf-test-y += false_sharing.o
 perf-test-y += global_data.o
 perf-test-y += flex_array.o
+perf-test-y += regptr.o
 
 ifeq ($(CONFIG_RUST_SUPPORT),y)
     perf-test-y += code_with_type.o
@@ -39,3 +40,4 @@ CFLAGS_callchain.o        = -g -O0 -fno-inline -U_FORTIFY_SOURCE
 CFLAGS_false_sharing.o    = -g -O0 -fno-inline -U_FORTIFY_SOURCE
 CFLAGS_global_data.o      = -g -O0 -fno-inline -U_FORTIFY_SOURCE
 CFLAGS_flex_array.o       = -g -O0 -fno-inline -U_FORTIFY_SOURCE
+CFLAGS_regptr.o           = -g -O2
tools/perf/tests/workloads/regptr.c new file +61 -0
new file mode 100644
index 0000000000000000..441202b61ae7b2e6
@@ -0,0 +1,61 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * A struct pointer that -O2 keeps in a register, so the member accesses
+ * have to be resolved from the register's type state and not from a
+ * stack slot.
+ *
+ * See tests/shell/data_type_register.sh.
+ */
+#include <signal.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <linux/compiler.h>
+#include "../tests.h"
+
+struct node {
+	long long a;
+	long long b;
+	long long c;
+};
+
+static struct node n;
+static struct node *volatile vp;
+static volatile unsigned long long reg_sink;
+static volatile sig_atomic_t done;
+
+static void sighandler(int sig __maybe_unused)
+{
+	done = 1;
+}
+
+static noinline long long touch(struct node *p)
+{
+	long long sum = 0;
+
+	sum += p->a;
+	/* A load too, or a load-only PMU never resolves b. */
+	p->b += sum;
+	sum += p->c;
+	return sum;
+}
+
+static int regptr(int argc, const char **argv)
+{
+	unsigned long long sum = 0;
+	int sec = 1;
+
+	if (argc > 0)
+		sec = atoi(argv[0]);
+
+	vp = &n;
+	signal(SIGINT, sighandler);
+	signal(SIGALRM, sighandler);
+	alarm(sec);
+
+	while (!done)
+		sum += touch(vp);
+	reg_sink = sum;
+	return 0;
+}
+
+DEFINE_WORKLOAD(regptr);
Signature · 1 line
2.56.0
author maintainer
#20 lore raw

Re: [PATCH v6 07/13] perf tests: Exercise data type resolution from a register

Quoted 12 lines · Namhyung Kim
Quoted 10 lines · Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

At -O2 a struct pointer lives in a register (with DWARF describing it with a register location on register-argument ABIs), while the unoptimized workloads the data type tests profile keep their variables on the stack.

Add a regptr workload with a noinline function that takes the pointer from a volatile global, so the compiler cannot constant-propagate the object address, and check that its three member accesses are resolved from that register.

Quoted 4 lines

Thanks for adding the workloads for data type profiling. I was unsure if it's ok to add since it'd requires many test cases to cover various aspect of binary patterns or compiler/language differences. But having a seperate repo for the test programs would be cumbersome too.

I think these are all super small samples that can get into the perf binary, at some point if possible we can have it in dlsym'able .so files. For now this way of including what is needed to fine tune/test important new features such as data-type profiling is worth having it linked in the main binary.

- Arnaldo

author maintainer
#21 lore raw

PATCH v6 8/13 perf annotate: Print the stats after the annotations

In reply to Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

The instruction stats are printed from hists__find_annotations() before that event is annotated: the first event reports zeros and later events can report stale counts. The data type total is only counted in --data-type mode, so --type-stat without it is incomplete too.

Print the stats once after all events have been annotated, warning if --type-stat is used without --data-type. Leave the TUI's alternate screen before printing, so the stats remain on the terminal.

Fixes 58824fa0087e1cb7 ("perf annotate: Add --insn-stat option for debugging")
Fixes 61a9741e9f78c64c ("perf annotate: Add --type-stat option for debugging")
Cc Namhyung Kim <[email protected]>
---
 tools/perf/builtin-annotate.c            | 19 +++++--
 tools/perf/tests/shell/annotate_stats.sh | 69 ++++++++++++++++++++++++
 2 files changed, 83 insertions(+), 5 deletions(-)
 create mode 100755 tools/perf/tests/shell/annotate_stats.sh
tools/perf/builtin-annotate.c +14 -5
index 331adbdbd635917d..8ced8a4aebf07709 100644
@@ -414,11 +414,6 @@ static void hists__find_annotations(struct hists *hists,
 	struct rb_node *nd = rb_first_cached(&hists->entries), *next;
 	int key = K_RIGHT;
 
-	if (ann->type_stat)
-		print_annotate_data_stat(&ann_data_stat);
-	if (ann->insn_stat)
-		print_annotate_item_stat(&ann_insn_stat, "Instruction");
-
 	while (nd) {
 		struct hist_entry *he = rb_entry(nd, struct hist_entry, rb_node);
 		struct annotation *notes;
@@ -660,6 +655,17 @@ static int __cmd_annotate(struct perf_annotate *ann)
 		hists__find_annotations(hists, pos, ann);
 	}
 
+	if (use_browser == 1 && (ann->insn_stat || (ann->data_type && ann->type_stat))) {
+		/* Leave the alternate screen before printing to the terminal. */
+		ui__exit(false);
+		use_browser = 0;
+	}
+
+	if (ann->data_type && ann->type_stat)
+		print_annotate_data_stat(&ann_data_stat);
+	if (ann->insn_stat)
+		print_annotate_item_stat(&ann_insn_stat, "Instruction");
+
 	if (use_browser == 2) {
 		void (*show_annotations)(void);
 
@@ -865,6 +871,9 @@ int cmd_annotate(int argc, const char **argv)
 	if (quiet)
 		perf_quiet_option();
 
+	if (annotate.type_stat && !annotate.data_type)
+		pr_warning("Warning: --type-stat needs --data-type\n");
+
 	data.path = input_name;
 
 	perf_tool__init(&annotate.tool, /*ordered_events=*/true);
tools/perf/tests/shell/annotate_stats.sh new file +69 -0

69 lines not on this page · raw message

Signature · 1 line
2.56.0
#22 lore raw

Re: [PATCH v6 08/13] perf annotate: Print the stats after the annotations

Sashiko has reviewed this patch and found no issues.
Quoted 7 lines

From: Arnaldo Carvalho de Melo <[email protected]>

The instruction stats are printed from hists__find_annotations() before that event is annotated: the first event reports zeros and later events can report stale counts. The data type total is only counted in --data-type mode, so --type-stat without it is incomplete too.

Quoted 8 lines

Print the stats once after all events have been annotated, warning if --type-stat is used without --data-type. Leave the TUI's alternate screen before printing, so the stats remain on the terminal.

Fixes 58824fa0087e1cb7 ("perf annotate: Add --insn-stat option for debugging")
Fixes 61a9741e9f78c64c ("perf annotate: Add --type-stat option for debugging")
Cc Namhyung Kim <[email protected]>

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=8
author maintainer
#23 lore raw

PATCH v6 9/13 perf tests: Silence the libbfd probe in build-test

In reply to Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

build-test evaluates the libbfd probe at parse time and the compiler's stderr isn't captured by $(shell ...), so without binutils-devel it prints "bfd.h: No such file or directory" once per tests/make invocation, five times per run.

Redirect the compiler's stderr; the empty result still skips the nondistro tests as intended.

Fixes 523471c5163659c6 ("perf build: Skip nondistro build test if libbfd is old")
Cc James Clark <[email protected]>
---
 tools/perf/tests/make | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/make +1 -1
index 7524de5228029e7e..e6d7ac49b5b1693d 100644
@@ -128,7 +128,7 @@ make_minimal        += NO_SDT=1 NO_JVMTI=1 NO_LIBZSTD=1
 make_minimal        += NO_CAPSTONE=1
 
 # binutils 2_42 and newer have bfd_thread_init()
-new_libbfd := $(shell echo '#include <bfd.h>' | $(CC) -E -x c - | grep bfd_thread_init)
+new_libbfd := $(shell echo '#include <bfd.h>' | $(CC) -E -x c - 2>/dev/null | grep bfd_thread_init)
 
 # Whether libLLVM can be built, which needs the llvm-devel/llvm-dev headers and
 # libraries of version 13 or newer, not just llvm-config. This mirrors the
Signature · 1 line
2.56.0
#24 lore raw

Re: [PATCH v6 09/13] perf tests: Silence the libbfd probe in build-test

Sashiko has reviewed this patch and found no issues.
Quoted 7 lines

From: Arnaldo Carvalho de Melo <[email protected]>

build-test evaluates the libbfd probe at parse time and the compiler's stderr isn't captured by $(shell ...), so without binutils-devel it prints "bfd.h: No such file or directory" once per tests/make invocation, five times per run.

Quoted 7 lines

Redirect the compiler's stderr; the empty result still skips the nondistro tests as intended.

Fixes 523471c5163659c6 ("perf build: Skip nondistro build test if libbfd is old")
Cc James Clark <[email protected]>

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=9
author maintainer
#25 lore raw

PATCH v6 10/13 perf build: Record the display-only features in FEATURE-DUMP

In reply to Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

llvm-perf and rust are in FEATURE_DISPLAY but not in FEATURE_TESTS: they can't be part of the test-all fast path, which sets every FEATURE_TESTS entry to 1 when test-all.c builds. Since FEATURE-DUMP is written from FEATURE_TESTS only, a FEATURES_DUMP= build, as used by build-test, never sees them and silently builds without libLLVM and the rust workloads.

Append the display features that aren't in FEATURE_TESTS to the dump after the regular feature checks have run.

Fixes 206dcfca1f5cfac3 ("perf build: Autodetect minimum required llvm-dev version")
Fixes 3f5dfa472ea6771c ("tools build: Fix rust feature detection")
Cc James Clark <[email protected]>
---
 tools/perf/Makefile.config | 4 ++++
 1 file changed, 4 insertions(+)
tools/perf/Makefile.config +4 -0
index 78423b0dcc73ac14..baef6b534e8aa8dc 100644
@@ -1313,3 +1313,7 @@ endif
 # tests.
 $(shell rm -f $(FEATURE_DUMP_FILENAME))
 $(foreach feat,$(FEATURE_TESTS),$(shell echo "$(call feature_assign,$(feat))" >> $(FEATURE_DUMP_FILENAME)))
+# Features only in FEATURE_DISPLAY aren't part of the test-all fast path, so
+# they have to be checked explicitly and recorded here too, otherwise a
+# FEATURES_DUMP= build silently disables them (llvm-perf, rust).
+$(foreach feat,$(filter-out $(FEATURE_TESTS),$(FEATURE_DISPLAY)),$(shell echo "$(call feature_assign,$(feat))" >> $(FEATURE_DUMP_FILENAME)))
Signature · 1 line
2.56.0
#26 lore raw

Re: [PATCH v6 10/13] perf build: Record the display-only features in FEATURE-DUMP

Sashiko has reviewed this patch and found no issues.
Quoted 8 lines

From: Arnaldo Carvalho de Melo <[email protected]>

llvm-perf and rust are in FEATURE_DISPLAY but not in FEATURE_TESTS: they can't be part of the test-all fast path, which sets every FEATURE_TESTS entry to 1 when test-all.c builds. Since FEATURE-DUMP is written from FEATURE_TESTS only, a FEATURES_DUMP= build, as used by build-test, never sees them and silently builds without libLLVM and the rust workloads.

Quoted 7 lines

Append the display features that aren't in FEATURE_TESTS to the dump after the regular feature checks have run.

Fixes 206dcfca1f5cfac3 ("perf build: Autodetect minimum required llvm-dev version")
Fixes 3f5dfa472ea6771c ("tools build: Fix rust feature detection")
Cc James Clark <[email protected]>

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=10
author maintainer
#27 lore raw

PATCH v6 11/13 perf tests: Fix the Intel PT virtual LBR check

In reply to Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

With one data page the virtual LBR record loses its AUX samples:

Warning: Processed 29 samples and lost 100.00%

Use --per-thread with 4 data and 64 AUX pages. Its single 276 KiB buffer (including metadata on 4 KiB pages) fits the default 516 KiB mlock allowance, regardless of CPU count. Also require the Python perf module to export session: importing an unrelated perf module used to fail the check instead of skipping it.

Fixes 915d6b14dc0c ("perf test: Migrate Intel PT virtual LBR test to Python API")
---
 tools/perf/tests/shell/test_intel_pt.sh | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
tools/perf/tests/shell/test_intel_pt.sh +5 -4
index c0ecece0a8255124..ba4ed6dc6dd87a5b 100755
@@ -384,13 +384,14 @@ test_virtual_lbr()
 	# shellcheck source=lib/setup_python.sh
 	. "${shelldir}"/lib/setup_python.sh
 
-	if ! "$PYTHON" -c 'import perf' > /dev/null 2>&1; then
-		echo "SKIP: Python perf module not found"
+	if ! "$PYTHON" -c 'import perf; perf.session' > /dev/null 2>&1; then
+		echo "SKIP: Python perf module with session support not found"
 		return 2
 	fi
 
-	# Check if virtual lbr is working
-	perf_record_no_bpf -o "${tmpfile}" --aux-sample \
+	# A single data page overruns aux samples; use one per-thread buffer
+	# with 4 data and 64 aux pages, plus a metadata page (276 KiB).
+	perf_record_no_bpf --per-thread -m 4,64 -o "${tmpfile}" --aux-sample \
 		-e '{intel_pt//,cycles}:u' perf test -w brstack || return 1
 	perf inject --itrace=L -i "${tmpfile}" -o "${perfdatafile}" || return 1
 	output=$("$PYTHON" "${shelldir}/lib/perf_brstack_max.py" -i "${perfdatafile}") || return 1
Signature · 1 line
2.56.0
#28 lore raw

Re: [PATCH v6 11/13] perf tests: Fix the Intel PT virtual LBR check

Sashiko has reviewed this patch and found no issues.
Quoted 6 lines

From: Arnaldo Carvalho de Melo <[email protected]>

With one data page the virtual LBR record loses its AUX samples:

Warning: Processed 29 samples and lost 100.00%

Quoted 8 lines

Use --per-thread with 4 data and 64 AUX pages. Its single 276 KiB buffer (including metadata on 4 KiB pages) fits the default 516 KiB mlock allowance, regardless of CPU count. Also require the Python perf module to export session: importing an unrelated perf module used to fail the check instead of skipping it.

Fixes 915d6b14dc0c ("perf test: Migrate Intel PT virtual LBR test to Python API")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=11
author maintainer
#29 lore raw

PATCH v6 12/13 perf test: Drop samples without an IP in the dlfilter test

In reply to Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

Since v7.3 the kernel zeroes PERF_SAMPLE_IP when a userspace-only event skids into kernel mode, so that kernel register state is not exposed to an unprivileged event (166f10836a653dfa "perf/core: Fix kernel register info leak via hardware skid").

The test dlfilter keeps those samples, and the check that nothing but test_loop survives then trips on their lines: the comm column reads "perf". Drop them, which is what the test wants, everything except test_loop must be filtered out.

Fixes 199d5e872a9ce737 ("perf tests script dlfilter: Add a dlfilter test")
---
 tools/perf/tests/shell/script_dlfilter.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/shell/script_dlfilter.sh +1 -1
index 88222280f6094fd0..797cd9ae84141f64 100755
@@ -46,7 +46,7 @@ int filter_event(void *data, const struct perf_dlfilter_sample *sample, void *ct
 	const struct perf_dlfilter_al *al;
 
 	if (!sample->ip)
-		return 0;
+		return 1;
 
 	al = perf_dlfilter_fns.resolve_ip(ctx);
 	if (!al || !al->sym || strcmp(al->sym, "test_loop"))
Signature · 1 line
2.56.0
#30 lore raw

Re: [PATCH v6 12/13] perf test: Drop samples without an IP in the dlfilter test

Sashiko has reviewed this patch and found no issues.
Quoted 7 lines

From: Arnaldo Carvalho de Melo <[email protected]>

Since v7.3 the kernel zeroes PERF_SAMPLE_IP when a userspace-only event skids into kernel mode, so that kernel register state is not exposed to an unprivileged event (166f10836a653dfa "perf/core: Fix kernel register info leak via hardware skid").

Quoted 8 lines

The test dlfilter keeps those samples, and the check that nothing but test_loop survives then trips on their lines: the comm column reads "perf". Drop them, which is what the test wants, everything except test_loop must be filtered out.

Fixes 199d5e872a9ce737 ("perf tests script dlfilter: Add a dlfilter test")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=12
author maintainer
#31 lore raw

PATCH v6 13/13 perf test: Skip the LBR inline unwinding check when unsupported

In reply to Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

The LBR check considers caps/branches sufficient to record cycles with --call-graph lbr. AMD BRS advertises branches but samples only its own retired branches event, so the test fails instead of skipping.

Skip only when evsel__open_strerror() reports "doesn't support branch stack sampling" (EOPNOTSUPP). Generic EINVAL or "not supported" may indicate a regression; show the error and fail.

Fixes 446c595dc0dd1759 ("perf test addr2line_inlines: Ensure inline information shows on LBR leaves")
Cc Ian Rogers <[email protected]>
---
 tools/perf/tests/shell/addr2line_inlines.sh | 23 ++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
tools/perf/tests/shell/addr2line_inlines.sh +22 -1
index e8754ef2d7f21ac2..ca88a6b886ca1ae3 100755
@@ -8,6 +8,8 @@ err=0
 test_dir=$(mktemp -d /tmp/perf-test-inline-addr2line.XXXXXXXXXX)
 perf_data="${test_dir}/perf.data"
 perf_script_txt="${test_dir}/perf_script.txt"
+perf_record_err="${test_dir}/perf_record.err"
+lbr_skipped=0
 
 cleanup() {
     rm -rf "${test_dir}"
@@ -71,7 +73,22 @@ test_lbr() {
     fi
 
     # Record data. Currently only dwarf callchains support inlined functions.
-    perf record --call-graph lbr -e cycles:u -o "${perf_data}" -- perf test -w inlineloop 1
+    # Some PMUs advertise branches but reject branch sampling for cycles, e.g.
+    # AMD BRS, which only samples its own retired branches event.
+    if ! perf record --call-graph lbr -e cycles:u -o "${perf_data}" -- \
+            perf test -w inlineloop 1 2> "${perf_record_err}"
+    then
+        if grep -Fq "doesn't support branch stack sampling" "${perf_record_err}"
+        then
+            echo "Skip: LBR not supported by the PMU"
+            lbr_skipped=1
+        else
+            cat "${perf_record_err}"
+            echo "Inline unwinding lbr verification test [Failed to record]"
+            err=1
+        fi
+        return
+    fi
 
     # Check output with inline (default) and srcline
     perf script -i "${perf_data}" --fields +srcline > "${perf_script_txt}"
@@ -93,4 +110,8 @@ test_dwarf
 test_lbr
 
 cleanup
+if [ $err -eq 0 ] && [ $lbr_skipped -eq 1 ]
+then
+    exit 2
+fi
 exit $err
Signature · 1 line
2.56.0
#32 lore raw

Re: [PATCH v6 13/13] perf test: Skip the LBR inline unwinding check when unsupported

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] perf test: test_lbr() fails to skip on AMD BRS due to EINVAL vs EOPNOTSUPP --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] perf test: test_lbr() fails to skip on AMD BRS due to EINVAL vs EOPNOTSUPP
--

commit d21ae617447c59168b264906c4d199925c28a698
Author: Arnaldo Carvalho de Melo <[email protected]>

perf test: Skip the LBR inline unwinding check when unsupported

This commit updates test_lbr() in addr2line_inlines.sh to skip the LBR test when perf record reports that the PMU does not support branch stack sampling.

Quoted 4 lines
tools/perf/tests/shell/addr2line_inlines.sh +0 -0
index e8754ef2d7f21..ca88a6b886ca1 100755

[ ... ]

Quoted 11 lines
tools/perf/tests/shell/addr2line_inlines.sh +6 -1
@@ -71,7 +73,22 @@ test_lbr() {
     fi
 
     # Record data. Currently only dwarf callchains support inlined functions.
-    perf record --call-graph lbr -e cycles:u -o "${perf_data}" -- perf test -w inlineloop 1
+    # Some PMUs advertise branches but reject branch sampling for cycles, e.g.
+    # AMD BRS, which only samples its own retired branches event.
+    if ! perf record --call-graph lbr -e cycles:u -o "${perf_data}" -- \
+            perf test -w inlineloop 1 2> "${perf_record_err}"
+    then
+        if grep -Fq "doesn't support branch stack sampling" "${perf_record_err}"

tools/perf/tests/shell/addr2line_inlines.sh test_lbr() { · line 91

Quoted 10 lines
tools/perf/tests/shell/addr2line_inlines.sh +10 -0
+        then
+            echo "Skip: LBR not supported by the PMU"
+            lbr_skipped=1
+        else
+            cat "${perf_record_err}"
+            echo "Inline unwinding lbr verification test [Failed to record]"
+            err=1
+        fi
+        return
+    fi

[Severity: Medium]
Does test_lbr() still fail on AMD BRS instead of skipping?

On AMD BRS, amd_brs_hw_config() rejects non-BRS events such as cycles:u with -EINVAL rather than -EOPNOTSUPP:

arch/x86/events/amd/brs.c:amd_brs_hw_config() {
    ...
	if (!amd_is_brs_event(event))
		return -EINVAL;
    ...
}

In tools/perf/util/evsel.c, evsel__open_strerror() only formats the "doesn't support branch stack sampling" message under case EOPNOTSUPP, and falls through to the generic Invalid argument message for EINVAL. As a result, grep does not match perf_record_err on AMD BRS and test_lbr() still enters the else branch and fails with err=1.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=13