* [PATCH v1 00/17] perf tests: Add coverage for the untested perf subcommands
@ 2026-11-24 18:45 Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 01/17] perf tests top: Pin the ring buffer size Arnaldo Carvalho de Melo
` (17 more replies)
0 siblings, 18 replies; 30+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-24 18:45 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
Arnaldo Carvalho de Melo
Hi,
The v12 "perf coverage: A harness for perf, and the fixes it found"
series is still unmerged. The coverage analysis done for it showed
that several perf subcommands had no shell test coverage at all, and it
also caught two issues in the existing tests. This series is that
result, made independent of the harness: everything here applies to
perf-tools-next with nothing from v12, so it can be considered on its
own while that series is still being reviewed.
Patches 1-2 fix existing tests, patches 3-17 add or extend tests for
the subcommands the analysis found untested. All changes are in
tools/perf/tests/shell/, no production code is touched.
- perf top pins its ring buffer to the default data size, so the
result does not depend on the host's perf_event_mlock_kb (1).
- perf sched captures the workload output before grepping it, so a
saturating grep cannot kill the producer with SIGPIPE;
--no-inherit was dropped, it is already cleared for CPU-wide
recording (2).
- help (3) and config (4) get their first tests; help -a works in
build trees via a dummy exec path.
- script list, fields and dump (5), report and diff sort keys (6).
- diff options (7) are checked by what each changes: the compute
formulas by their column, --time by a window that shows nothing,
-o by the entry order, -b on a file whose entries have no baseline
match.
- annotate (8) and report (9) options the same way; the ones with
nothing to observe in stdio output run as parse checks.
- record (10), trace (11) and timechart (12) options.
- kmem (13) and bench (14) get their first tests; the bench ones
skip cleanly when root or the hardware is missing, including
benchmarks that skip themselves with a zero exit status.
- lock (15) report and info, probe (16) variable and line listing.
- report TUI (17): the six browsers are driven from a pty.
Running as non-root on this host, 13 of the 17 scripts exit 0; perf
sched, kmem, lock and trace need root and exit 2 with their skip
message, as designed. All option names and expectations were checked
against the built perf -h output and the sources.
The tests, the two fixes and the review fixes were developed with an AI
coding assistant (OpenCode): it drafted the tests, found the two issues
above and processed three rounds of review findings. Every commit was
reviewed, amended and run here before posting.
Arnaldo Carvalho de Melo (17):
perf tests top: Pin the ring buffer size
perf tests sched: Exercise the sched views and options
perf tests help: Add a basic perf help test
perf tests config: Exercise the config file and list options
perf tests script: Exercise the list, fields and dump options
perf tests sort: Exercise the report and diff sort keys
perf tests diff: Exercise the output options
perf tests annotate: Exercise the output and filter options
perf tests report: Exercise the output and format options
perf tests record: Exercise more record options
perf tests trace: Exercise the tracing options
perf tests timechart: Exercise the report options
perf tests kmem: Add a basic perf kmem test
perf tests bench: Add smoke tests for perf bench
perf tests lock: Exercise perf lock report and info
perf tests probe: Exercise the variable and line listing
perf tests report: Exercise the TUI browsers
tools/perf/tests/shell/annotate.sh | 64 +++++++
tools/perf/tests/shell/bench.sh | 130 +++++++++++++
tools/perf/tests/shell/config.sh | 134 ++++++++++++++
tools/perf/tests/shell/diff.sh | 191 ++++++++++++++++++-
tools/perf/tests/shell/help.sh | 80 ++++++++
tools/perf/tests/shell/kmem.sh | 215 ++++++++++++++++++++++
tools/perf/tests/shell/lock_contention.sh | 40 ++++
tools/perf/tests/shell/probe_vars.sh | 80 ++++++++
tools/perf/tests/shell/record_options.sh | 173 +++++++++++++++++
tools/perf/tests/shell/report_options.sh | 122 ++++++++++++
tools/perf/tests/shell/report_tui.sh | 112 +++++++++++
tools/perf/tests/shell/sched.sh | 154 +++++++++++-----
tools/perf/tests/shell/script.sh | 131 ++++++++++++-
tools/perf/tests/shell/sort.sh | 72 ++++++++
tools/perf/tests/shell/timechart.sh | 46 +++++
tools/perf/tests/shell/top.sh | 7 +-
tools/perf/tests/shell/trace_options.sh | 97 ++++++++++
17 files changed, 1794 insertions(+), 54 deletions(-)
create mode 100755 tools/perf/tests/shell/bench.sh
create mode 100755 tools/perf/tests/shell/config.sh
create mode 100755 tools/perf/tests/shell/help.sh
create mode 100755 tools/perf/tests/shell/kmem.sh
create mode 100755 tools/perf/tests/shell/probe_vars.sh
create mode 100755 tools/perf/tests/shell/record_options.sh
create mode 100755 tools/perf/tests/shell/report_options.sh
create mode 100755 tools/perf/tests/shell/report_tui.sh
create mode 100755 tools/perf/tests/shell/sort.sh
create mode 100755 tools/perf/tests/shell/trace_options.sh
--
2.56.0
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH v1 01/17] perf tests top: Pin the ring buffer size
2026-11-24 18:45 [PATCH v1 00/17] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
@ 2026-11-24 18:45 ` Arnaldo Carvalho de Melo
2026-11-24 19:01 ` sashiko-bot
2026-11-24 18:45 ` [PATCH v1 02/17] perf tests sched: Exercise the sched views and options Arnaldo Carvalho de Melo
` (16 subsequent siblings)
17 siblings, 1 reply; 30+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-24 18:45 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <acme@redhat.com>
perf top sizes its default ring buffer from kernel.perf_event_mlock_kb, so
a test host tuned with a large value makes the default mapping huge and
perf top fails with ENOMEM.
Pass -m 128, the upstream default of 516 KiB, so the test behaves the same
whatever the host setting is.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/shell/top.sh | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/tools/perf/tests/shell/top.sh b/tools/perf/tests/shell/top.sh
index 3d52677ccb5fd309..4808d79275178b40 100755
--- a/tools/perf/tests/shell/top.sh
+++ b/tools/perf/tests/shell/top.sh
@@ -19,6 +19,9 @@ trap_cleanup() {
}
trap trap_cleanup EXIT TERM INT
+# perf top sizes its default ring buffer from kernel.perf_event_mlock_kb,
+# which a test host may have tuned large, pin it to the upstream default
+# of 128 pages (516 KiB) so the test does not depend on the host setting.
test_basic_perf_top() {
echo "Basic perf top test"
@@ -36,7 +39,7 @@ test_basic_perf_top() {
# Use -e cpu-clock to ensure we get samples
# Use sleep to keep stdin open but silent, preventing EOF loop or interactive spam
retval=0
- sleep 10 | timeout 5s perf top --stdio -d 1 -e cpu-clock \
+ sleep 10 | timeout 5s perf top --stdio -d 1 -m 128 -e cpu-clock \
-p $PID > "${log_file}" 2>&1 || retval=$?
if [ "${retval:-0}" -ne 124 ] && [ "${retval:-0}" -ne 0 ]; then
echo "Basic perf top test [Failed: perf top failed to start or run (ret=$retval)]"
@@ -83,7 +86,7 @@ test_hybrid_merge_perf_top() {
# environments can seamlessly fall back to cpu-clock while real
# hybrid hardware will naturally cover the merge logic.
retval=0
- sleep 10 | timeout 5s perf top \
+ sleep 10 | timeout 5s perf top -m 128 \
--stdio --hybrid-merge -d 1 -p $PID > "${log_file}" 2>&1 || retval=$?
if [ "${retval:-0}" -ne 124 ] && [ "${retval:-0}" -ne 0 ]; then
echo "Perf top hybrid merge test [Failed: run err=$retval]"
--
2.56.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v1 02/17] perf tests sched: Exercise the sched views and options
2026-11-24 18:45 [PATCH v1 00/17] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 01/17] perf tests top: Pin the ring buffer size Arnaldo Carvalho de Melo
@ 2026-11-24 18:45 ` Arnaldo Carvalho de Melo
2026-11-24 18:58 ` sashiko-bot
2026-11-24 18:45 ` [PATCH v1 03/17] perf tests help: Add a basic perf help test Arnaldo Carvalho de Melo
` (15 subsequent siblings)
17 siblings, 1 reply; 30+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-24 18:45 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <acme@redhat.com>
The test pipes the map, latency and timehist output to grep, which
stops reading at the first match, so the command is killed by
SIGPIPE before it produces the rest of its output. It also passes
--no-inherit, a no-op since perf sched record always records CPU
wide and inherit is cleared for CPU wide targets.
Capture the output first, drop --no-inherit and add the map,
latency and timehist options along with schedstat record, report and
diff coverage.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/shell/sched.sh | 154 +++++++++++++++++++++++---------
1 file changed, 111 insertions(+), 43 deletions(-)
diff --git a/tools/perf/tests/shell/sched.sh b/tools/perf/tests/shell/sched.sh
index 113df962a51c878f..e1aa8570b21f4ad9 100755
--- a/tools/perf/tests/shell/sched.sh
+++ b/tools/perf/tests/shell/sched.sh
@@ -11,12 +11,17 @@ fi
err=0
perfdata=$(mktemp /tmp/__perf_test_sched.perf.data.XXXXX)
+statsdata=$(mktemp /tmp/__perf_test_sched.stats.XXXXX)
+schedout=$(mktemp /tmp/__perf_test_sched.out.XXXXX)
PID1=0
PID2=0
cleanup() {
rm -f "${perfdata}"
rm -f "${perfdata}".old
+ rm -f "${statsdata}"
+ rm -f "${statsdata}".old
+ rm -f "${schedout}"
trap - EXIT TERM INT
}
@@ -56,90 +61,153 @@ cleanup_noploops() {
kill "$PID1" "$PID2" || true
}
+run_sched() {
+ local desc="$1" expect="$2"
+
+ shift 2
+ echo "Sched ${desc}"
+ if ! perf sched "$@" > "${schedout}" 2>&1
+ then
+ echo "Sched ${desc} [Failed: perf sched failed]"
+ cat "${schedout}"
+ err=1
+ return
+ fi
+ if [ -n "${expect}" ] && ! grep -q "${expect}" "${schedout}"
+ then
+ echo "Sched ${desc} [Failed: missing '${expect}']"
+ cat "${schedout}"
+ err=1
+ return
+ fi
+ echo "Sched ${desc} [Success]"
+}
+
test_sched_record() {
echo "Sched record"
start_noploops
- perf sched record --no-inherit -o "${perfdata}" sleep 1
+ if ! perf sched record -o "${perfdata}" sleep 1
+ then
+ echo "Sched record [Failed: perf sched record failed]"
+ err=1
+ fi
cleanup_noploops
}
test_sched_latency() {
- echo "Sched latency"
-
- if ! perf sched latency -i "${perfdata}" | grep -q perf-noploop
- then
- echo "Sched latency [Failed missing output]"
- err=1
- fi
+ run_sched "latency" "perf-noploop" latency -i "${perfdata}"
}
test_sched_latency_histogram() {
- echo "Sched latency histogram"
+ run_sched "latency histogram" "Latency Distribution Histogram" \
+ latency -H -i "${perfdata}"
+ run_sched "latency linear histogram" "Latency Distribution Histogram" \
+ latency --histogram --hist-mode linear -i "${perfdata}"
+}
- if ! perf sched latency -H -i "${perfdata}" | grep -q "Latency Distribution Histogram"
- then
- echo "Sched latency histogram [Failed missing log histogram]"
- err=1
- fi
+test_sched_latency_options() {
+ run_sched "latency sort" "perf-noploop" latency -s max -i "${perfdata}"
+ run_sched "latency per pid" "perf-noploop" latency -p -i "${perfdata}"
+ run_sched "latency cpu filter" "" latency -C 0 -i "${perfdata}"
+ run_sched "latency time filter" "perf-noploop" latency --time 0, -i "${perfdata}"
+}
- if ! perf sched latency --histogram --hist-mode linear -i "${perfdata}" | grep -q "Latency Distribution Histogram"
- then
- echo "Sched latency histogram [Failed missing linear histogram]"
- err=1
- fi
+test_sched_script() {
+ run_sched "script" "perf-noploop" script -i "${perfdata}"
}
-test_sched_latency_time() {
- echo "Sched latency time filter"
+test_sched_map() {
+ run_sched "map" "perf-noploop" map -i "${perfdata}"
+}
- if ! perf sched latency --time 0, -i "${perfdata}" | grep -q perf-noploop
- then
- echo "Sched latency time filter [Failed missing output]"
- err=1
- fi
+test_sched_map_options() {
+ run_sched "map compact" "" map --compact -i "${perfdata}"
+ run_sched "map color" "" map --color-pids "${PID1}" --color-cpus 0 \
+ --cpus 0 -i "${perfdata}"
+ run_sched "map task name" "" map --task-name perf-noploop -i "${perfdata}"
+ run_sched "map fuzzy name" "" map --task-name noploop --fuzzy-name \
+ -i "${perfdata}"
}
-test_sched_script() {
- echo "Sched script"
+test_sched_timehist() {
+ run_sched "timehist" "perf-noploop" timehist -i "${perfdata}"
+}
+
+test_sched_timehist_options() {
+ run_sched "timehist summary" "Runtime summary" timehist --summary -i "${perfdata}"
+ run_sched "timehist wakeups" "awakened:" timehist -w -i "${perfdata}"
+ run_sched "timehist migrations" "migrated:" timehist -M -i "${perfdata}"
+ run_sched "timehist idle" "Idle-time summary" timehist -I --summary -i "${perfdata}"
+ run_sched "timehist state" "sch delay" \
+ timehist --state --show-prio -V -P -i "${perfdata}"
+ run_sched "timehist call graph" "" timehist -g --max-stack 3 -i "${perfdata}"
+ run_sched "timehist pid filter" "" timehist -p "${PID1}" -i "${perfdata}"
+ run_sched "timehist prio filter" "" timehist --show-prio --prio 0 -i "${perfdata}"
+ run_sched "timehist with summary" "perf-noploop" timehist -S -i "${perfdata}"
+}
+
+test_sched_stats_live() {
+ echo "Sched stats live"
- if ! perf sched script -i "${perfdata}" | grep -q perf-noploop
+ ret=0
+ timeout -s INT -k 5 3 perf sched stats > "${schedout}" 2>&1 || ret=$?
+ if [ "${ret}" != 0 ] && [ "${ret}" != 124 ]
then
- echo "Sched script [Failed missing output]"
+ echo "Sched stats live [Failed: perf sched stats failed]"
+ cat "${schedout}"
err=1
+ return
fi
-}
-test_sched_map() {
- echo "Sched map"
-
- if ! perf sched map -i "${perfdata}" | grep -q perf-noploop
+ if ! grep -q "Description" "${schedout}"
then
- echo "Sched map [Failed missing output]"
+ echo "Sched stats live [Failed missing output]"
err=1
+ return
fi
+ echo "Sched stats live [Success]"
}
-test_sched_timehist() {
- echo "Sched timehist"
-
- if ! perf sched timehist -i "${perfdata}" | grep -q perf-noploop
+test_sched_stats_record() {
+ if ! perf sched stats record -o "${statsdata}" sleep 1
+ then
+ echo "Sched stats record [Failed: perf sched stats record failed]"
+ err=1
+ return
+ fi
+ if [ ! -s "${statsdata}" ]
then
- echo "Sched timehist [Failed missing output]"
+ echo "Sched stats record [Failed: no data file]"
err=1
+ return
fi
+ echo "Sched stats record [Success]"
+}
+
+test_sched_stats_report() {
+ run_sched "stats report" "Description" stats report -i "${statsdata}" -C 0 -v
+}
+
+test_sched_stats_diff() {
+ run_sched "stats diff" "" stats diff "${statsdata}" "${statsdata}"
}
test_sched_record
test_sched_latency
test_sched_latency_histogram
-test_sched_latency_time
+test_sched_latency_options
test_sched_script
test_sched_map
+test_sched_map_options
test_sched_timehist
+test_sched_timehist_options
+test_sched_stats_live
+test_sched_stats_record
+test_sched_stats_report
+test_sched_stats_diff
cleanup
exit $err
-
--
2.56.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v1 03/17] perf tests help: Add a basic perf help test
2026-11-24 18:45 [PATCH v1 00/17] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 01/17] perf tests top: Pin the ring buffer size Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 02/17] perf tests sched: Exercise the sched views and options Arnaldo Carvalho de Melo
@ 2026-11-24 18:45 ` Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 04/17] perf tests config: Exercise the config file and list options Arnaldo Carvalho de Melo
` (14 subsequent siblings)
17 siblings, 0 replies; 30+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-24 18:45 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <acme@redhat.com>
perf help and its -a option were not exercised by the suite. Check the
common command list and the command directory listing.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/shell/help.sh | 80 ++++++++++++++++++++++++++++++++++
1 file changed, 80 insertions(+)
create mode 100755 tools/perf/tests/shell/help.sh
diff --git a/tools/perf/tests/shell/help.sh b/tools/perf/tests/shell/help.sh
new file mode 100755
index 0000000000000000..b7279a97a5615193
--- /dev/null
+++ b/tools/perf/tests/shell/help.sh
@@ -0,0 +1,80 @@
+#!/bin/bash
+# perf help tests
+# SPDX-License-Identifier: GPL-2.0
+
+set -e
+
+err=0
+out=$(mktemp /tmp/__perf_test_help.out.XXXXX)
+exec_path=
+
+cleanup() {
+ rm -f "${out}"
+ [ -z "${exec_path}" ] || rm -rf "${exec_path}"
+
+ trap - EXIT TERM INT
+}
+
+trap_cleanup() {
+ echo "Unexpected signal in ${FUNCNAME[1]}"
+ cleanup
+ exit 1
+}
+trap trap_cleanup EXIT TERM INT
+
+test_help_commands() {
+ echo "perf help commands test"
+ if ! perf help > "${out}" 2>&1; then
+ echo "perf help commands test [Failed: perf help failed]"
+ cat "${out}"
+ err=1
+ return
+ fi
+ if ! grep -q "The most commonly used perf commands are" "${out}"; then
+ echo "perf help commands test [Failed missing command list]"
+ cat "${out}"
+ err=1
+ return
+ fi
+ if ! grep -q "See 'perf help COMMAND'" "${out}"; then
+ echo "perf help commands test [Failed missing help hint]"
+ err=1
+ return
+ fi
+ echo "perf help commands test [Success]"
+}
+
+test_help_all() {
+ echo "perf help -a test"
+ # "available perf commands in" is printed only when the exec path holds
+ # perf-* commands, which a build tree does not have. Give help -a a
+ # temporary exec path with a dummy command to look for.
+ exec_path=$(mktemp -d /tmp/__perf_test_help_exec.XXXXXX)
+ printf '#!/bin/sh\n' > "${exec_path}/perf-dummy"
+ chmod +x "${exec_path}/perf-dummy"
+ if ! PERF_EXEC_PATH="${exec_path}" perf help -a > "${out}" 2>&1; then
+ echo "perf help -a test [Failed: perf help -a failed]"
+ cat "${out}"
+ err=1
+ return
+ fi
+ if ! grep -q "available perf commands in" "${out}"; then
+ echo "perf help -a test [Failed missing command directory]"
+ cat "${out}"
+ err=1
+ return
+ fi
+ if ! grep -q " dummy" "${out}"; then
+ echo "perf help -a test [Failed missing command from exec path]"
+ cat "${out}"
+ err=1
+ return
+ fi
+ echo "perf help -a test [Success]"
+}
+
+test_help_commands
+test_help_all
+
+cleanup
+exit $err
--
2.56.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v1 04/17] perf tests config: Exercise the config file and list options
2026-11-24 18:45 [PATCH v1 00/17] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
` (2 preceding siblings ...)
2026-11-24 18:45 ` [PATCH v1 03/17] perf tests help: Add a basic perf help test Arnaldo Carvalho de Melo
@ 2026-11-24 18:45 ` Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 05/17] perf tests script: Exercise the list, fields and dump options Arnaldo Carvalho de Melo
` (13 subsequent siblings)
17 siblings, 0 replies; 30+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-24 18:45 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Set, read back, update and list two variables under a private HOME,
and check the --user/--system conflict and the invalid key errors.
perf test exports PERF_CONFIG=/dev/null to the shell tests, unset it
so perf config uses the private file.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/shell/config.sh | 134 +++++++++++++++++++++++++++++++
1 file changed, 134 insertions(+)
create mode 100755 tools/perf/tests/shell/config.sh
diff --git a/tools/perf/tests/shell/config.sh b/tools/perf/tests/shell/config.sh
new file mode 100755
index 0000000000000000..fc035bbec2e2ea18
--- /dev/null
+++ b/tools/perf/tests/shell/config.sh
@@ -0,0 +1,134 @@
+#!/bin/bash
+# perf config tests
+# SPDX-License-Identifier: GPL-2.0
+
+set -e
+
+err=0
+tmpdir=$(mktemp -d /tmp/__perf_test_config.XXXXXX)
+out="${tmpdir}/out"
+
+# perf test exports PERF_CONFIG=/dev/null to the shell tests, use a
+# private HOME instead so the file written here is the one being read.
+unset PERF_CONFIG
+export HOME="${tmpdir}"
+
+cleanup() {
+ rm -rf "${tmpdir}"
+
+ trap - EXIT TERM INT
+}
+
+trap_cleanup() {
+ echo "Unexpected signal in ${FUNCNAME[1]}"
+ cleanup
+ exit 1
+}
+trap trap_cleanup EXIT TERM INT
+
+test_config_empty() {
+ echo "Empty config test"
+ if ! perf config --user --list > "${out}" 2>&1; then
+ echo "Empty config [Failed: perf config --user --list failed]"
+ cat "${out}"
+ err=1
+ return
+ fi
+ if [ -s "${out}" ]; then
+ echo "Empty config [Failed: unexpected output]"
+ cat "${out}"
+ err=1
+ return
+ fi
+ echo "Empty config [Success]"
+}
+
+test_config_set_get() {
+ echo "Config set and get test"
+ if ! perf config report.show-nr-samples=true call-graph.print-limit=5; then
+ echo "Config set [Failed: perf config failed]"
+ err=1
+ return
+ fi
+ if [ ! -s "${HOME}/.perfconfig" ]; then
+ echo "Config set [Failed: no config file]"
+ err=1
+ return
+ fi
+
+ if ! perf config --user report.show-nr-samples | grep -qx "report.show-nr-samples=true"; then
+ echo "Config get [Failed: wrong report.show-nr-samples]"
+ err=1
+ return
+ fi
+ if ! perf config --user call-graph.print-limit | grep -qx "call-graph.print-limit=5"; then
+ echo "Config get [Failed: wrong call-graph.print-limit]"
+ err=1
+ return
+ fi
+
+ if ! perf config --user --list > "${out}" 2>&1 ||
+ ! grep -qx "report.show-nr-samples=true" "${out}" ||
+ ! grep -qx "call-graph.print-limit=5" "${out}"; then
+ echo "Config list [Failed: missing variables]"
+ cat "${out}"
+ err=1
+ return
+ fi
+ if ! perf config --list > "${out}" 2>&1 ||
+ ! grep -qx "report.show-nr-samples=true" "${out}"; then
+ echo "Config list [Failed: missing user variable in the merged view]"
+ cat "${out}"
+ err=1
+ return
+ fi
+
+ if ! perf config report.show-nr-samples=false; then
+ echo "Config update [Failed: perf config failed]"
+ err=1
+ return
+ fi
+ if ! perf config report.show-nr-samples | grep -qx "report.show-nr-samples=false"; then
+ echo "Config update [Failed: value not updated]"
+ err=1
+ return
+ fi
+ echo "Config set and get test [Success]"
+}
+
+test_config_errors() {
+ echo "Config error test"
+ if perf config --user --system --list > "${out}" 2>&1; then
+ echo "Config error [Failed: --user --system succeeded]"
+ cat "${out}"
+ err=1
+ return
+ fi
+ if ! grep -q "only one config file at a time" "${out}"; then
+ echo "Config error [Failed: missing file option error]"
+ cat "${out}"
+ err=1
+ return
+ fi
+
+ if perf config nosection > "${out}" 2>&1; then
+ echo "Config error [Failed: invalid variable succeeded]"
+ cat "${out}"
+ err=1
+ return
+ fi
+ if ! grep -q "does not contain a section name" "${out}"; then
+ echo "Config error [Failed: missing invalid variable error]"
+ cat "${out}"
+ err=1
+ return
+ fi
+ echo "Config error test [Success]"
+}
+
+test_config_empty
+test_config_set_get
+test_config_errors
+
+cleanup
+exit $err
--
2.56.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v1 05/17] perf tests script: Exercise the list, fields and dump options
2026-11-24 18:45 [PATCH v1 00/17] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
` (3 preceding siblings ...)
2026-11-24 18:45 ` [PATCH v1 04/17] perf tests config: Exercise the config file and list options Arnaldo Carvalho de Melo
@ 2026-11-24 18:45 ` Arnaldo Carvalho de Melo
2026-11-24 18:54 ` sashiko-bot
2026-11-24 18:45 ` [PATCH v1 06/17] perf tests sort: Exercise the report and diff sort keys Arnaldo Carvalho de Melo
` (12 subsequent siblings)
17 siblings, 1 reply; 30+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-24 18:45 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <acme@redhat.com>
The script test only runs the parallel-perf script. Cover the script
list, a wide -F field set and the +field/-field syntax, per-event dumps,
the data file header, the task and mmap event display and the reltime,
deltatime, show-info, latency, ns and raw dump options.
The list is read from the scripts dir in the perf exec path, which in a
build tree points at a prefix that was never installed, so point
PERF_EXEC_PATH at the source tree when it is unset. A missing python3
or parallel-perf.py is a skip only when nothing failed above, otherwise
the exit status hides the failure behind an exit 2, which perf test
reports as skipped.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/shell/script.sh | 131 ++++++++++++++++++++++++++++++-
1 file changed, 129 insertions(+), 2 deletions(-)
diff --git a/tools/perf/tests/shell/script.sh b/tools/perf/tests/shell/script.sh
index af687c7cfe44c2c6..a74d45d51ae47cb1 100755
--- a/tools/perf/tests/shell/script.sh
+++ b/tools/perf/tests/shell/script.sh
@@ -4,6 +4,22 @@
set -e
+shelldir=$(dirname "$0")
+# shellcheck source=lib/perf_has_symbol.sh
+. "${shelldir}"/lib/perf_has_symbol.sh
+
+# perf script -l reads the scripts directory from the perf exec path,
+# which in a build tree points at a prefix that is not installed
+if [ -z "${PERF_EXEC_PATH}" ] && [ -d "${shelldir}"/../../python ]; then
+ PERF_EXEC_PATH=$(cd "${shelldir}"/../.. && pwd)
+ export PERF_EXEC_PATH
+fi
+
+testprog="perf test -w thloop"
+testsym="test_loop"
+
+skip_test_missing_symbol "${testsym}"
+
temp_dir=$(mktemp -d /tmp/perf-test-script.XXXXXXXXXX)
err=0
@@ -27,18 +43,123 @@ trap_cleanup()
trap trap_cleanup EXIT TERM INT
+script_data="${temp_dir}/script-perf.data"
+
+test_script_list()
+{
+ echo "perf script list test"
+ if ! perf script -l | grep -q "List of available scripts"
+ then
+ echo "perf script list test [Failed missing list header]"
+ err=1
+ return
+ fi
+ if ! perf script -l | grep -q "export-to-sqlite"
+ then
+ echo "perf script list test [Failed missing export-to-sqlite]"
+ err=1
+ fi
+}
+
+test_script_fields()
+{
+ echo "perf script fields test"
+ perf record -o "${script_data}" -e cpu-clock --sample-cpu ${testprog}
+ if ! perf script -i "${script_data}" -F comm,tid,pid,time,cpu,event,ip,sym,dso,dsoff,symoff,period,machine_pid,vcpu,ipc,insn,insnlen,disasm,misc,metric,synth,callindent,flags | grep -q "${testsym}"
+ then
+ echo "perf script fields test [Failed missing ${testsym}]"
+ err=1
+ return
+ fi
+ if ! perf script -i "${script_data}" -F +cpu | grep -q "${testsym}"
+ then
+ echo "perf script fields test [Failed to add the cpu field]"
+ err=1
+ fi
+ if ! perf script -i "${script_data}" -F -comm | grep -q "${testsym}"
+ then
+ echo "perf script fields test [Failed to remove the comm field]"
+ err=1
+ fi
+}
+
+test_script_per_event_dump()
+{
+ echo "perf script per-event dump test"
+ if ! perf script -i "${script_data}" --per-event-dump > /dev/null
+ then
+ echo "perf script per-event dump test [Failed to write the dumps]"
+ err=1
+ return
+ fi
+ if ! grep -q "${testsym}" "${script_data}".*.dump
+ then
+ echo "perf script per-event dump test [Failed missing ${testsym}]"
+ err=1
+ fi
+}
+
+test_script_header()
+{
+ echo "perf script header test"
+ if ! perf script -i "${script_data}" --header | grep -q "captured on"
+ then
+ echo "perf script header test [Failed missing the header]"
+ err=1
+ return
+ fi
+ if ! perf script -i "${script_data}" --header-only | grep -q "captured on"
+ then
+ echo "perf script header test [Failed missing the header only output]"
+ err=1
+ fi
+}
+
+test_script_events()
+{
+ echo "perf script events test"
+ if ! perf script -i "${script_data}" --show-task-events --show-mmap-events | grep -q "PERF_RECORD_"
+ then
+ echo "perf script events test [Failed missing the events]"
+ err=1
+ fi
+}
+
+test_script_misc()
+{
+ echo "perf script misc options test"
+ for opt in --reltime --deltatime -I -L --ns
+ do
+ if ! perf script -i "${script_data}" ${opt} | grep -q "${testsym}"
+ then
+ echo "perf script misc options test [Failed ${opt}]"
+ err=1
+ fi
+ done
+ if ! perf script -i "${script_data}" -D | grep -q "PERF_RECORD_SAMPLE"
+ then
+ echo "perf script misc options test [Failed --dump-raw-trace]"
+ err=1
+ fi
+}
+
test_parallel_perf()
{
echo "parallel-perf test"
if ! python3 --version >/dev/null 2>&1 ; then
echo "SKIP: no python3"
- err=2
+ # Don't turn a failure in the tests above into a skip
+ if [ ${err} -eq 0 ]; then
+ err=2
+ fi
return
fi
pp=$(dirname "$0")/../../python/parallel-perf.py
if [ ! -f "${pp}" ] ; then
echo "SKIP: parallel-perf.py script not found "
- err=2
+ if [ ${err} -eq 0 ]; then
+ err=2
+ fi
return
fi
perf_data="${temp_dir}/pp-perf.data"
@@ -50,6 +171,12 @@ test_parallel_perf()
echo "parallel-perf test [Success]"
}
+test_script_list
+test_script_fields
+test_script_per_event_dump
+test_script_header
+test_script_events
+test_script_misc
test_parallel_perf
cleanup
--
2.56.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v1 06/17] perf tests sort: Exercise the report and diff sort keys
2026-11-24 18:45 [PATCH v1 00/17] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
` (4 preceding siblings ...)
2026-11-24 18:45 ` [PATCH v1 05/17] perf tests script: Exercise the list, fields and dump options Arnaldo Carvalho de Melo
@ 2026-11-24 18:45 ` Arnaldo Carvalho de Melo
2026-11-24 19:02 ` sashiko-bot
2026-11-24 18:45 ` [PATCH v1 07/17] perf tests diff: Exercise the output options Arnaldo Carvalho de Melo
` (11 subsequent siblings)
17 siblings, 1 reply; 30+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-24 18:45 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Record a workload and report it sorted by the common keys, then diff
the file against itself with the same keys, checking that the workload
symbol still shows up.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/shell/sort.sh | 72 ++++++++++++++++++++++++++++++++++
1 file changed, 72 insertions(+)
create mode 100755 tools/perf/tests/shell/sort.sh
diff --git a/tools/perf/tests/shell/sort.sh b/tools/perf/tests/shell/sort.sh
new file mode 100755
index 0000000000000000..19f42ded2b895317
--- /dev/null
+++ b/tools/perf/tests/shell/sort.sh
@@ -0,0 +1,72 @@
+#!/bin/bash
+# perf report and diff sort key tests
+# SPDX-License-Identifier: GPL-2.0
+
+set -e
+
+shelldir=$(dirname "$0")
+# shellcheck source=lib/perf_has_symbol.sh
+. "${shelldir}"/lib/perf_has_symbol.sh
+
+testprog="perf test -w thloop"
+testsym="test_loop"
+sort_keys="pid,comm,dso,symbol,cpu,srcline,period,time,socket,weight,transaction,type,srcfile,cgroup"
+
+skip_test_missing_symbol "${testsym}"
+
+perfdata=$(mktemp /tmp/__perf_test_sort.perf.data.XXXXX)
+out=$(mktemp /tmp/__perf_test_sort.out.XXXXX)
+err=0
+
+cleanup() {
+ rm -f "${perfdata}" "${perfdata}".old
+ rm -f "${out}"
+
+ trap - EXIT TERM INT
+}
+
+trap_cleanup() {
+ echo "Unexpected signal in ${FUNCNAME[1]}"
+ cleanup
+ exit 1
+}
+trap trap_cleanup EXIT TERM INT
+
+test_report_sort() {
+ echo "perf report sort keys test"
+ perf record -o "${perfdata}" --sample-cpu ${testprog}
+ if ! perf report -i "${perfdata}" --stdio -q -s "${sort_keys}" > "${out}" 2>&1; then
+ echo "perf report sort keys test [Failed: perf report failed]"
+ cat "${out}"
+ err=1
+ return
+ fi
+ if ! grep -q "${testsym}" "${out}"; then
+ echo "perf report sort keys test [Failed missing ${testsym}]"
+ err=1
+ return
+ fi
+ echo "perf report sort keys test [Success]"
+}
+
+test_diff_sort() {
+ echo "perf diff sort keys test"
+ if ! perf diff -s "${sort_keys}" "${perfdata}" "${perfdata}" > "${out}" 2>&1; then
+ echo "perf diff sort keys test [Failed: perf diff failed]"
+ cat "${out}"
+ err=1
+ return
+ fi
+ if ! grep -q "${testsym}" "${out}"; then
+ echo "perf diff sort keys test [Failed missing ${testsym}]"
+ err=1
+ return
+ fi
+ echo "perf diff sort keys test [Success]"
+}
+
+test_report_sort
+test_diff_sort
+
+cleanup
+exit $err
--
2.56.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v1 07/17] perf tests diff: Exercise the output options
2026-11-24 18:45 [PATCH v1 00/17] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
` (5 preceding siblings ...)
2026-11-24 18:45 ` [PATCH v1 06/17] perf tests sort: Exercise the report and diff sort keys Arnaldo Carvalho de Melo
@ 2026-11-24 18:45 ` Arnaldo Carvalho de Melo
2026-11-24 18:57 ` sashiko-bot
2026-11-24 18:45 ` [PATCH v1 08/17] perf tests annotate: Exercise the output and filter options Arnaldo Carvalho de Melo
` (10 subsequent siblings)
17 siblings, 1 reply; 30+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-24 18:45 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <acme@redhat.com>
The diff test only diffs files recorded with the same workload. Add
the compute formulas, each checked by the column it prints, the
formula, period, field separator, sort and raw trace dump options, and
the time window, checked with a window that leaves nothing.
As delta-abs is the default compute, a plain diff prints its column as
well: the default header is pinned before the option runs, and the
delta-abs run then only checks that the option is accepted and that
the column is not dropped.
Record the third file with the noploop workload: with it the
baseline-only and order options can be checked on a second file whose
entries have no match in the baseline. The --percentage and --verbose
options only change the numbers when entries are filtered in the TUI
and the debug output, they run here as a check that the table is still
printed.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/shell/diff.sh | 191 +++++++++++++++++++++++++++++++--
1 file changed, 184 insertions(+), 7 deletions(-)
diff --git a/tools/perf/tests/shell/diff.sh b/tools/perf/tests/shell/diff.sh
index 88f37b8ef8936be4..d2fbc8a8c2c3680a 100755
--- a/tools/perf/tests/shell/diff.sh
+++ b/tools/perf/tests/shell/diff.sh
@@ -8,14 +8,18 @@ err=0
perfdata1=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
perfdata2=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
perfdata3=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
+diffout=$(mktemp /tmp/__perf_test.perf.diff.out.XXXXX)
testprog="perf test -w thloop"
+testprog2="perf test -w noploop"
shelldir=$(dirname "$0")
. "${shelldir}"/lib/perf_has_symbol.sh
testsym="test_loop"
+testsym2="noploop"
skip_test_missing_symbol ${testsym}
+skip_test_missing_symbol ${testsym2}
cleanup() {
rm -rf "${perfdata1}"
@@ -24,6 +28,7 @@ cleanup() {
rm -rf "${perfdata2}".old
rm -rf "${perfdata3}"
rm -rf "${perfdata3}".old
+ rm -f "${diffout}"
trap - EXIT TERM INT
}
@@ -36,13 +41,15 @@ trap trap_cleanup EXIT TERM INT
make_data() {
file="$1"
- if ! perf record -o "${file}" ${testprog} 2> /dev/null
+ prog="$2"
+ sym="$3"
+ if ! perf record -o "${file}" ${prog} 2> /dev/null
then
echo "Workload record [Failed record]" >&2
echo 1
return
fi
- if ! perf report -i "${file}" -q | grep -q "${testsym}"
+ if ! perf report -i "${file}" -q | grep -q "${sym}"
then
echo "Workload record [Failed missing output]" >&2
echo 1
@@ -53,12 +60,12 @@ make_data() {
test_two_files() {
echo "Basic two file diff test"
- err=$(make_data "${perfdata1}")
+ err=$(make_data "${perfdata1}" "${testprog}" "${testsym}")
if [ "$err" != 0 ]
then
return
fi
- err=$(make_data "${perfdata2}")
+ err=$(make_data "${perfdata2}" "${testprog}" "${testsym}")
if [ "$err" != 0 ]
then
return
@@ -75,17 +82,20 @@ test_two_files() {
test_three_files() {
echo "Basic three file diff test"
- err=$(make_data "${perfdata1}")
+ err=$(make_data "${perfdata1}" "${testprog}" "${testsym}")
if [ "$err" != 0 ]
then
return
fi
- err=$(make_data "${perfdata2}")
+ err=$(make_data "${perfdata2}" "${testprog}" "${testsym}")
if [ "$err" != 0 ]
then
return
fi
- err=$(make_data "${perfdata3}")
+ # The third file is recorded with another workload, so that the
+ # baseline-only and order option checks below can tell which entries
+ # are shown and in what order.
+ err=$(make_data "${perfdata3}" "${testprog2}" "${testsym2}")
if [ $err != 0 ]
then
return
@@ -100,8 +110,175 @@ test_three_files() {
echo "Basic three file diff test [Success]"
}
+test_options() {
+ echo "Diff options test"
+
+ # delta-abs is the default compute, so a plain diff prints the same
+ # header: pin it here, the option run below then only checks that
+ # --compute delta-abs is accepted and still prints its column
+ if ! perf diff "${perfdata1}" "${perfdata2}" | \
+ grep -qE 'Baseline[[:space:]]+Delta Abs[[:space:]]+Shared Object'
+ then
+ echo "Diff options test [Failed: default compute is not delta-abs]"
+ err=1
+ return
+ fi
+
+ # Every compute formula prints a column of its own
+ for compute in delta delta-abs ratio wdiff:1,2
+ do
+ case "${compute}" in
+ delta) expect='Delta[[:space:]]+Shared Object' ;;
+ delta-abs) expect='Delta Abs' ;;
+ ratio) expect='Ratio' ;;
+ wdiff:1,2) expect='Weighted diff' ;;
+ esac
+ if ! perf diff --compute "${compute}" "${perfdata1}" "${perfdata2}" | \
+ grep -qE "${expect}"
+ then
+ echo "Diff options test [Failed: --compute ${compute}]"
+ err=1
+ return
+ fi
+ done
+
+ if ! perf diff -F "${perfdata1}" "${perfdata2}" | grep -q "Formula"
+ then
+ echo "Diff options test [Failed: --formula]"
+ err=1
+ return
+ fi
+
+ if ! perf diff -p "${perfdata1}" "${perfdata2}" | grep -q "Base period"
+ then
+ echo "Diff options test [Failed: --period]"
+ err=1
+ return
+ fi
+
+ # -b keeps the entries matched in the baseline: with two files of
+ # the same workload the loop entry stays
+ if ! perf diff -b "${perfdata1}" "${perfdata2}" | grep -q "${testsym}"
+ then
+ echo "Diff options test [Failed: --baseline-only drops common entries]"
+ err=1
+ return
+ fi
+
+ # The noploop workload is only in the third file
+ if ! perf diff "${perfdata1}" "${perfdata3}" > "${diffout}" 2> /dev/null
+ then
+ echo "Diff options test [Failed: diff of different workloads]"
+ err=1
+ return
+ fi
+ if ! grep -q "${testsym2}" "${diffout}"
+ then
+ echo "Diff options test [Failed: ${testsym2} missing from the diff]"
+ err=1
+ return
+ fi
+
+ # and with a second file recorded with another workload its entries
+ # have no match in the baseline and disappear
+ if ! perf diff -b "${perfdata1}" "${perfdata3}" > "${diffout}" 2> /dev/null
+ then
+ echo "Diff options test [Failed: --baseline-only]"
+ err=1
+ return
+ fi
+ if grep -q "${testsym2}" "${diffout}"
+ then
+ echo "Diff options test [Failed: --baseline-only shows non-baseline entries]"
+ err=1
+ return
+ fi
+
+ if ! perf diff -t, "${perfdata1}" "${perfdata2}" | grep -q "Baseline,"
+ then
+ echo "Diff options test [Failed: --field-separator]"
+ err=1
+ return
+ fi
+
+ # -o 0 puts the entry with the biggest baseline first, the loop in
+ # the first file, while the default starts with the loop in the
+ # second file
+ if ! perf diff -o 0 "${perfdata1}" "${perfdata3}" > "${diffout}" 2> /dev/null
+ then
+ echo "Diff options test [Failed: --order]"
+ err=1
+ return
+ fi
+ if ! grep -v '^#' "${diffout}" | grep -v '^[[:space:]]*$' | head -1 | \
+ grep -q "${testsym}"
+ then
+ echo "Diff options test [Failed: --order 0 does not sort by the baseline]"
+ err=1
+ return
+ fi
+
+ # A window starting at the beginning of the data shows it all, a
+ # window starting after the last sample shows nothing
+ if ! perf diff --time 0, "${perfdata1}" "${perfdata2}" | grep -q "${testsym}"
+ then
+ echo "Diff options test [Failed: --time]"
+ err=1
+ return
+ fi
+ if perf diff --time 9000000000000000000, "${perfdata1}" "${perfdata2}" | \
+ grep -q "${testsym}"
+ then
+ echo "Diff options test [Failed: --time shows samples outside the window]"
+ err=1
+ return
+ fi
+
+ # --percentage only shows up when entries are filtered in the TUI
+ # and --verbose only adds debug output, check the table is printed
+ if ! perf diff --percentage relative "${perfdata1}" "${perfdata2}" | grep -q "${testsym}"
+ then
+ echo "Diff options test [Failed: --percentage relative]"
+ err=1
+ return
+ fi
+
+ if ! perf diff --percentage absolute "${perfdata1}" "${perfdata2}" | grep -q "${testsym}"
+ then
+ echo "Diff options test [Failed: --percentage absolute]"
+ err=1
+ return
+ fi
+
+ if ! perf diff -s comm "${perfdata1}" "${perfdata2}" | grep -q "Command"
+ then
+ echo "Diff options test [Failed: --sort comm]"
+ err=1
+ return
+ fi
+
+ if ! perf diff -v "${perfdata1}" "${perfdata2}" 2> /dev/null | \
+ grep -q "${testsym}"
+ then
+ echo "Diff options test [Failed: --verbose]"
+ err=1
+ return
+ fi
+
+ if ! perf diff --dump-raw-trace "${perfdata1}" "${perfdata2}" 2>&1 | \
+ grep -q "PERF_RECORD_SAMPLE"
+ then
+ echo "Diff options test [Failed: --dump-raw-trace]"
+ err=1
+ return
+ fi
+
+ echo "Diff options test [Success]"
+}
+
test_two_files
test_three_files
+test_options
cleanup
exit $err
--
2.56.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v1 08/17] perf tests annotate: Exercise the output and filter options
2026-11-24 18:45 [PATCH v1 00/17] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
` (6 preceding siblings ...)
2026-11-24 18:45 ` [PATCH v1 07/17] perf tests diff: Exercise the output options Arnaldo Carvalho de Melo
@ 2026-11-24 18:45 ` Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 09/17] perf tests report: Exercise the output and format options Arnaldo Carvalho de Melo
` (9 subsequent siblings)
17 siblings, 0 replies; 30+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-24 18:45 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <acme@redhat.com>
The annotate test covers the stdio and pipe modes. Add the --stdio2
output, --print-line, --asm-raw with --show-total-period,
--show-nr-samples, --percent-type and the DSO filter, the last one
checked by also annotating through a DSO that is not in the data.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/shell/annotate.sh | 64 ++++++++++++++++++++++++++++++
1 file changed, 64 insertions(+)
diff --git a/tools/perf/tests/shell/annotate.sh b/tools/perf/tests/shell/annotate.sh
index 26411edf5cb4ece1..d799414690402fc0 100755
--- a/tools/perf/tests/shell/annotate.sh
+++ b/tools/perf/tests/shell/annotate.sh
@@ -105,8 +105,72 @@ test_basic() {
echo "${mode} annotate test [Success]"
}
+test_options() {
+ echo "Options annotate test"
+ perf record -o "${perfdata}" ${testprog} 2> /dev/null
+
+ # --stdio2 prints each instruction with the symbol header
+ if ! perf annotate -i "${perfdata}" --stdio2 -s "${testsym}" 2> /dev/null | grep -q "${testsym}()"
+ then
+ echo "Options annotate [Failed: missing --stdio2 output]"
+ err=1
+ return
+ fi
+
+ # -l/--print-line prints a summary of the annotated file with source lines
+ if ! perf annotate -i "${perfdata}" --stdio --print-line -s "${testsym}" 2> /dev/null | grep -q "Sorted summary for file"
+ then
+ echo "Options annotate [Failed: missing --print-line output]"
+ err=1
+ return
+ fi
+
+ # --show-total-period adds a period column; --asm-raw is the default
+ if ! perf annotate -i "${perfdata}" --stdio --asm-raw --show-total-period -s "${testsym}" 2> /dev/null | grep -q "Period"
+ then
+ echo "Options annotate [Failed: missing --show-total-period output]"
+ err=1
+ return
+ fi
+
+ # --show-nr-samples adds a samples column
+ if ! perf annotate -i "${perfdata}" --stdio -n -s "${testsym}" 2> /dev/null | grep -q "Samples"
+ then
+ echo "Options annotate [Failed: missing --show-nr-samples output]"
+ err=1
+ return
+ fi
+
+ # --percent-type selects the percentage type shown in the header
+ if ! perf annotate -i "${perfdata}" --stdio --percent-type global-period -s "${testsym}" 2> /dev/null | grep -q "percent: global period"
+ then
+ echo "Options annotate [Failed: missing --percent-type output]"
+ err=1
+ return
+ fi
+
+ # -d limits the annotation to the given DSO: perf has the symbol, a
+ # DSO absent from the data produces no annotation
+ if ! perf annotate -i "${perfdata}" --stdio -s "${testsym}" -d perf 2> /dev/null | grep -q "Disassembly of"
+ then
+ echo "Options annotate [Failed: missing -d output]"
+ err=1
+ return
+ fi
+
+ if perf annotate -i "${perfdata}" --stdio -s "${testsym}" -d nonexistent-dso 2> /dev/null | grep -q "Disassembly of"
+ then
+ echo "Options annotate [Failed: -d did not filter the DSO]"
+ err=1
+ return
+ fi
+
+ echo "Options annotate test [Success]"
+}
+
test_basic Basic
test_basic Pipe
+test_options
cleanup
exit $err
--
2.56.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v1 09/17] perf tests report: Exercise the output and format options
2026-11-24 18:45 [PATCH v1 00/17] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
` (7 preceding siblings ...)
2026-11-24 18:45 ` [PATCH v1 08/17] perf tests annotate: Exercise the output and filter options Arnaldo Carvalho de Melo
@ 2026-11-24 18:45 ` Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 10/17] perf tests record: Exercise more record options Arnaldo Carvalho de Melo
` (8 subsequent siblings)
17 siblings, 0 replies; 30+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-24 18:45 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Cover the Samples column -n adds, the field list, the field separator
and the fixed column widths, each checked in the header it prints, and
--no-children, checked against a file recorded with call graphs, where
the Children column it removes is visible. --disable-order is checked
by the rejection it triggers together with a latency field. The
options that change nothing in this output, -U, --percentage, --inline
and --full-source-path, run as a check that perf takes them and still
prints the table.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/shell/report_options.sh | 122 +++++++++++++++++++++++
1 file changed, 122 insertions(+)
create mode 100755 tools/perf/tests/shell/report_options.sh
diff --git a/tools/perf/tests/shell/report_options.sh b/tools/perf/tests/shell/report_options.sh
new file mode 100755
index 0000000000000000..7e2bdaca656ce5b2
--- /dev/null
+++ b/tools/perf/tests/shell/report_options.sh
@@ -0,0 +1,122 @@
+#!/bin/bash
+# perf report option tests
+# SPDX-License-Identifier: GPL-2.0
+
+set -e
+
+shelldir=$(dirname "$0")
+# shellcheck source=lib/perf_has_symbol.sh
+. "${shelldir}"/lib/perf_has_symbol.sh
+
+testprog="perf test -w thloop"
+testsym="test_loop"
+
+skip_test_missing_symbol "${testsym}"
+
+perfdata=$(mktemp /tmp/__perf_test_report_opts.perf.data.XXXXX)
+cgdata=$(mktemp /tmp/__perf_test_report_opts.cg.data.XXXXX)
+perfout=$(mktemp /tmp/__perf_test_report_opts.perf.out.XXXXX)
+err=0
+
+cleanup() {
+ rm -f "${perfdata}" "${perfdata}".old
+ rm -f "${cgdata}" "${cgdata}".old
+ rm -f "${perfout}"
+
+ trap - EXIT TERM INT
+}
+
+trap_cleanup() {
+ echo "Unexpected signal in ${FUNCNAME[1]}"
+ cleanup
+ exit 1
+}
+trap trap_cleanup EXIT TERM INT
+
+check_report() {
+ local desc="$1" expect="$2"
+
+ shift 2
+ echo "Report ${desc}"
+ if ! perf report -i "${perfdata}" --stdio "$@" > "${perfout}" 2>&1
+ then
+ echo "Report ${desc} [Failed: perf report failed]"
+ err=1
+ return
+ fi
+ if ! grep -qE "${expect}" "${perfout}"
+ then
+ echo "Report ${desc} [Failed: missing '${expect}']"
+ cat "${perfout}"
+ err=1
+ return
+ fi
+ echo "Report ${desc} [Success]"
+}
+
+# The call graph data, for --no-children: 'absent', when set, must not
+# be found in the output
+check_cg_report() {
+ local desc="$1" expect="$2" absent="$3"
+
+ shift 3
+ echo "Report ${desc}"
+ if ! perf report -i "${cgdata}" --stdio "$@" > "${perfout}" 2>&1
+ then
+ echo "Report ${desc} [Failed: perf report failed]"
+ err=1
+ return
+ fi
+ if [ -n "${absent}" ] && grep -qE "${absent}" "${perfout}"
+ then
+ echo "Report ${desc} [Failed: still has '${absent}']"
+ err=1
+ return
+ fi
+ if ! grep -qE "${expect}" "${perfout}"
+ then
+ echo "Report ${desc} [Failed: missing '${expect}']"
+ cat "${perfout}"
+ err=1
+ return
+ fi
+ echo "Report ${desc} [Success]"
+}
+
+perf record -q -e cpu-clock --sample-cpu -o "${perfdata}" ${testprog}
+
+# -n adds a Samples column, -t, joins the header fields with commas,
+# -w pads them to the given width. -U, --percentage, --inline and
+# --full-source-path change nothing in this output: every entry
+# resolves to a symbol, nothing is filtered and no source lines are
+# printed, so they run to check that perf takes them and still prints
+# the table.
+check_report "nr samples" "Overhead[[:space:]]+Samples" -n
+check_report "hide unresolved" "^# Overhead" -U
+check_report "fields" "^ *perf " -F comm,dso,symbol,period
+check_report "percentage" "^# Overhead" --percentage absolute
+check_report "field separator" "^# Overhead," -t,
+check_report "inline" "^# Overhead" --inline
+check_report "full source path" "^# Overhead" --full-source-path
+check_report "column widths" "^# {2,}Overhead" -w 20,20,20,20,20,20
+
+# --disable-order is rejected together with a latency field, which
+# tells that the option reached the event ordering code
+echo "Report disable order"
+if ! perf report -i "${perfdata}" --stdio -F latency --disable-order 2>&1 | \
+ grep -q "incompatible with --disable-order"
+then
+ echo "Report disable order [Failed: missing the rejection]"
+ err=1
+else
+ echo "Report disable order [Success]"
+fi
+
+# Recording call graphs adds a Children column, --no-children must
+# remove it while keeping the entries
+perf record -q --call-graph fp -e cpu-clock --sample-cpu -o "${cgdata}" ${testprog}
+check_cg_report "children column" "Children" ""
+check_cg_report "no children" "${testsym}" "Children" --no-children
+
+cleanup
+exit $err
--
2.56.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v1 10/17] perf tests record: Exercise more record options
2026-11-24 18:45 [PATCH v1 00/17] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
` (8 preceding siblings ...)
2026-11-24 18:45 ` [PATCH v1 09/17] perf tests report: Exercise the output and format options Arnaldo Carvalho de Melo
@ 2026-11-24 18:45 ` Arnaldo Carvalho de Melo
2026-11-24 19:03 ` sashiko-bot
2026-11-24 18:45 ` [PATCH v1 11/17] perf tests trace: Exercise the tracing options Arnaldo Carvalho de Melo
` (7 subsequent siblings)
17 siblings, 1 reply; 30+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-24 18:45 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Add the dry-run, no samples, buildid, synthesis, sampling, buffering,
aio, affinity, delay, overwrite, callchain, mmap pages and clockid
variants.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/shell/record_options.sh | 173 +++++++++++++++++++++++
1 file changed, 173 insertions(+)
create mode 100755 tools/perf/tests/shell/record_options.sh
diff --git a/tools/perf/tests/shell/record_options.sh b/tools/perf/tests/shell/record_options.sh
new file mode 100755
index 0000000000000000..b2bf51b5dc44c189
--- /dev/null
+++ b/tools/perf/tests/shell/record_options.sh
@@ -0,0 +1,173 @@
+#!/bin/bash
+# perf record option tests
+# SPDX-License-Identifier: GPL-2.0
+
+set -e
+
+temp_dir=$(mktemp -d /tmp/__perf_test_record_opts.XXXXXX)
+err=0
+
+cleanup() {
+ rm -rf "${temp_dir}"
+
+ trap - EXIT TERM INT
+}
+
+trap_cleanup() {
+ echo "Unexpected signal in ${FUNCNAME[1]}"
+ cleanup
+ exit 1
+}
+trap trap_cleanup EXIT TERM INT
+
+test_record() {
+ local desc="$1" out="$2"
+
+ shift 2
+ echo "Record ${desc}"
+ if ! perf record -q -e cpu-clock -c 1 "$@" -o "${temp_dir}/${out}" -- sleep 0.1
+ then
+ echo "Record ${desc} [Failed: perf record failed]"
+ err=1
+ return
+ fi
+ if ! perf report -i "${temp_dir}/${out}" -q 2> /dev/null | grep -q sleep
+ then
+ echo "Record ${desc} [Failed: no samples]"
+ err=1
+ return
+ fi
+ echo "Record ${desc} [Success]"
+}
+
+test_timestamp_filename() {
+ echo "Record timestamp filename"
+ if ! perf record -q -e cpu-clock -c 1 --timestamp-filename \
+ -o "${temp_dir}/tsfn" -- sleep 0.1
+ then
+ echo "Record timestamp filename [Failed: perf record failed]"
+ err=1
+ return
+ fi
+ if ! ls "${temp_dir}/tsfn".* > /dev/null 2>&1
+ then
+ echo "Record timestamp filename [Failed: no timestamped file]"
+ err=1
+ return
+ fi
+ echo "Record timestamp filename [Success]"
+}
+
+test_switch_output() {
+ echo "Record switch output"
+ if ! perf record -q -e cpu-clock -c 1 --switch-output=size=64K \
+ -o "${temp_dir}/sw" -- sleep 0.2
+ then
+ echo "Record switch output [Failed: perf record failed]"
+ err=1
+ return
+ fi
+ if ! ls "${temp_dir}/sw".* > /dev/null 2>&1
+ then
+ echo "Record switch output [Failed: no switched files]"
+ err=1
+ return
+ fi
+ echo "Record switch output [Success]"
+}
+
+test_clockid() {
+ echo "Record clockid"
+ if ! perf record -q -e cpu-clock -c 1 -k CLOCK_MONOTONIC \
+ -o "${temp_dir}/clock" -- sleep 0.1
+ then
+ echo "Record clockid [Failed: perf record failed]"
+ err=1
+ return
+ fi
+ if ! perf script -i "${temp_dir}/clock" -F tod 2> /dev/null | \
+ grep -qE '^[0-9]{4}-[0-9]{2}-[0-9]{2}'
+ then
+ echo "Record clockid [Failed: no wall clock timestamps]"
+ err=1
+ return
+ fi
+ echo "Record clockid [Success]"
+}
+
+test_record_option() {
+ local desc="$1"
+
+ shift 1
+ echo "Record option ${desc}"
+ rm -f "${temp_dir}/${desc}.data"
+ if ! perf record -q -e cpu-clock -c 1 "$@" -o "${temp_dir}/${desc}.data" -- sleep 0.1
+ then
+ echo "Record option ${desc} [Failed: perf record failed]"
+ err=1
+ return
+ fi
+ if [ ! -s "${temp_dir}/${desc}.data" ]
+ then
+ echo "Record option ${desc} [Failed: no data recorded]"
+ err=1
+ return
+ fi
+ echo "Record option ${desc} [Success]"
+}
+
+test_dry_run() {
+ echo "Record option dry run"
+ if ! perf record -q -e cpu-clock -c 1 --dry-run \
+ -o "${temp_dir}/dry-run.data" -- sleep 0.1
+ then
+ echo "Record option dry run [Failed: perf record failed]"
+ err=1
+ return
+ fi
+ if [ -e "${temp_dir}/dry-run.data" ]
+ then
+ echo "Record option dry run [Failed: recorded data]"
+ err=1
+ return
+ fi
+ echo "Record option dry run [Success]"
+}
+
+test_record "aio" "aio" --aio=2
+test_record "threads core" "threads-core" --threads=core
+test_record "threads package" "threads-package" --threads=package
+test_record "threads numa" "threads-numa" --threads=numa
+test_record "affinity" "affinity" --affinity=cpu
+test_record "mmap flush" "mmap-flush" --mmap-flush=1
+test_record "max size" "max-size" --max-size=1M
+test_record "timestamp boundary" "ts-boundary" --timestamp-boundary
+test_record "user callchains" "callchains" --user-callchains --call-graph fp
+test_timestamp_filename
+test_switch_output
+test_clockid
+test_dry_run
+test_record_option no-samples -n
+test_record_option buildid-all --buildid-all
+test_record_option buildid-mmap --buildid-mmap
+test_record_option synth-no --synth no
+test_record_option synth-task --synth task
+test_record_option synth-mmap --synth mmap
+test_record_option sample-cpu --sample-cpu
+test_record_option weight -W
+test_record_option raw-samples -R
+test_record_option no-buffering --no-buffering
+test_record_option no-bpf-event --no-bpf-event
+test_record_option proc-map-timeout --proc-map-timeout 100
+test_record_option num-thread-synthesize --num-thread-synthesize 1
+test_record_option aio-one --aio=1
+test_record_option affinity-node --affinity=node
+test_record_option delay -D 10
+test_record_option tail-synthesize --tail-synthesize
+test_record_option overwrite --overwrite
+test_record_option data -d
+test_record_option mmap-pages -m 4,8
+test_record_option clockid-monotonic-raw -k CLOCK_MONOTONIC_RAW
+
+cleanup
+exit $err
--
2.56.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v1 11/17] perf tests trace: Exercise the tracing options
2026-11-24 18:45 [PATCH v1 00/17] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
` (9 preceding siblings ...)
2026-11-24 18:45 ` [PATCH v1 10/17] perf tests record: Exercise more record options Arnaldo Carvalho de Melo
@ 2026-11-24 18:45 ` Arnaldo Carvalho de Melo
2026-11-24 19:02 ` sashiko-bot
2026-11-24 18:45 ` [PATCH v1 12/17] perf tests timechart: Exercise the report options Arnaldo Carvalho de Melo
` (6 subsequent siblings)
17 siblings, 1 reply; 30+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-24 18:45 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Cover page faults, scheduler stats, syscall and failure summaries,
event limits, callchains, target filters and the remaining tracing
options. Like the summary test it needs root.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/shell/trace_options.sh | 97 +++++++++++++++++++++++++
1 file changed, 97 insertions(+)
create mode 100755 tools/perf/tests/shell/trace_options.sh
diff --git a/tools/perf/tests/shell/trace_options.sh b/tools/perf/tests/shell/trace_options.sh
new file mode 100755
index 0000000000000000..3f686a293bb9d557
--- /dev/null
+++ b/tools/perf/tests/shell/trace_options.sh
@@ -0,0 +1,97 @@
+#!/bin/bash
+# perf trace option tests
+# SPDX-License-Identifier: GPL-2.0
+
+set -e
+
+. "$(dirname $0)"/lib/probe.sh
+
+skip_if_no_perf_trace || exit 2
+
+# The syscall tracepoints need root to open.
+if [ "$(id -u)" != 0 ]; then
+ echo "[Skip] No root permission"
+ exit 2
+fi
+
+err=0
+out=$(mktemp /tmp/__perf_test_trace_opts.out.XXXXX)
+
+cleanup() {
+ rm -f "${out}"
+
+ trap - EXIT TERM INT
+}
+
+trap_cleanup() {
+ echo "Unexpected signal in ${FUNCNAME[1]}"
+ cleanup
+ exit 1
+}
+trap trap_cleanup EXIT TERM INT
+
+run_trace() {
+ local desc="$1" expect="$2"
+
+ shift 2
+ echo "Trace ${desc}"
+ if ! perf trace "$@" > "${out}" 2>&1; then
+ echo "Trace ${desc} [Failed: perf trace failed]"
+ cat "${out}"
+ err=1
+ return
+ fi
+ if [ -n "${expect}" ] && ! grep -qE "${expect}" "${out}"; then
+ echo "Trace ${desc} [Failed: missing '${expect}']"
+ cat "${out}"
+ err=1
+ return
+ fi
+ echo "Trace ${desc} [Success]"
+}
+
+# Page faults are software events, not syscalls, and exercise the
+# separate page fault printing path.
+run_trace "pagefaults" "fault \[" -F all -- perf test -w noploop 1
+run_trace "minor pagefaults" "fault \[" -F min -- perf test -w noploop 1
+run_trace "major pagefaults" "" -F maj -- sleep 0.1
+
+# sched_stat_runtime feeds the "sched" summary counters.
+run_trace "sched" "" --sched -s -- sleep 0.1
+
+run_trace "syscalls" "" --syscalls -- true
+run_trace "events" "openat" -e openat -e read -e write -- cat /dev/null
+run_trace "failure" "" --failure -- false
+run_trace "errno summary" "" --errno-summary -s -- cat /dev/null
+run_trace "summary" "" -S --summary-mode=total -- cat /dev/null
+run_trace "summary thread" "" -s --summary-mode=thread -- cat /dev/null
+run_trace "duration filter" "" --duration 0.01 -- cat /dev/null
+run_trace "max events" "" --max-events 5 -e write -- seq 1 100
+run_trace "sort events" "" --sort-events -e write -- echo hello
+run_trace "call graph" "" --call-graph fp --max-stack 5 --min-stack 1 \
+ -e write -- echo hello
+run_trace "kernel syscall graph" "" --kernel-syscall-graph \
+ --call-graph fp -e write -- echo hello
+run_trace "libtraceevent print" "" --libtraceevent_print \
+ -e kmem:kmalloc -- true
+run_trace "filter pids" "" --filter-pids 1 -- cat /dev/null
+run_trace "proc map timeout" "" --proc-map-timeout 100 -- cat /dev/null
+run_trace "mmap pages" "" -m 8 -- sleep 0.1
+run_trace "delay" "" -D 10 -- sleep 0.1
+run_trace "no inherit" "" --no-inherit -- sleep 0.1
+run_trace "uid" "" -u "$(id -un)" -- true
+run_trace "cpu" "" -C 0 -- sleep 0.1
+run_trace "pid" "" -p $$ -- sleep 0.1
+run_trace "tid" "" -t $$ -- sleep 0.1
+run_trace "verbose" "" -v -e write -- echo hello
+run_trace "bitmask list" "" --bitmask-list -e openat -- cat /dev/null
+run_trace "print sample" "" --print-sample -e write -- echo hello
+
+echo "Trace invalid pagefault type"
+if perf trace -F bogus -- true > "${out}" 2>&1; then
+ echo "Trace invalid pagefault type [Failed: accepted invalid value]"
+ err=1
+fi
+
+cleanup
+exit $err
--
2.56.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v1 12/17] perf tests timechart: Exercise the report options
2026-11-24 18:45 [PATCH v1 00/17] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
` (10 preceding siblings ...)
2026-11-24 18:45 ` [PATCH v1 11/17] perf tests trace: Exercise the tracing options Arnaldo Carvalho de Melo
@ 2026-11-24 18:45 ` Arnaldo Carvalho de Melo
2026-11-24 18:46 ` [PATCH v1 13/17] perf tests kmem: Add a basic perf kmem test Arnaldo Carvalho de Melo
` (5 subsequent siblings)
17 siblings, 0 replies; 30+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-24 18:45 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Run the report with width, process count, topology, highlight,
process, power and tasks only, io and force options.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/shell/timechart.sh | 46 +++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/tools/perf/tests/shell/timechart.sh b/tools/perf/tests/shell/timechart.sh
index 40072b32171a9a1c..ec592e304cdedfd8 100755
--- a/tools/perf/tests/shell/timechart.sh
+++ b/tools/perf/tests/shell/timechart.sh
@@ -59,6 +59,33 @@ test_timechart() {
echo "perf timechart ${NAME} test [Success]"
}
+test_timechart_report_option() {
+ NAME=$1
+
+ shift 1
+ echo "perf timechart report ${NAME} test"
+
+ if ! perf timechart -i "${perfdata}" -o "${output}" "$@" > /dev/null 2>&1; then
+ echo "perf timechart report ${NAME} test [Failed: perf timechart command failed]"
+ err=1
+ return
+ fi
+
+ if [ ! -s "${output}" ]; then
+ echo "perf timechart report ${NAME} test [Failed: output file is empty or missing]"
+ err=1
+ return
+ fi
+
+ if ! grep -q "svg" "${output}"; then
+ echo "perf timechart report ${NAME} test [Failed: output doesn't look like SVG]"
+ err=1
+ return
+ fi
+
+ echo "perf timechart report ${NAME} test [Success]"
+}
+
if ! perf check feature -q libtraceevent ; then
echo "perf timechart is not supported. Skip."
cleanup
@@ -69,5 +96,24 @@ test_timechart "Basic" ""
test_timechart "IO-only" "-I"
test_timechart "Backtrace" "-g"
+if [ ! -s "${perfdata}" ]; then
+ echo "perf timechart report options [Skipped: no recorded data]"
+ cleanup
+ exit 0
+fi
+
+# Reuse the data recorded by the last test to exercise the report options.
+test_timechart_report_option "width" -w 1024
+test_timechart_report_option "proc-num" -n 4
+test_timechart_report_option "topology" -t
+test_timechart_report_option "highlight time" --highlight 1
+test_timechart_report_option "highlight name" --highlight true
+test_timechart_report_option "process" -p true
+test_timechart_report_option "power-only" -P
+test_timechart_report_option "tasks-only" -T
+test_timechart_report_option "io options" --io-min-time 1us \
+ --io-merge-dist 1us --io-skip-eagain
+test_timechart_report_option "force" -f
+
cleanup
exit $err
--
2.56.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v1 13/17] perf tests kmem: Add a basic perf kmem test
2026-11-24 18:45 [PATCH v1 00/17] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
` (11 preceding siblings ...)
2026-11-24 18:45 ` [PATCH v1 12/17] perf tests timechart: Exercise the report options Arnaldo Carvalho de Melo
@ 2026-11-24 18:46 ` Arnaldo Carvalho de Melo
2026-11-24 18:57 ` sashiko-bot
2026-11-24 18:46 ` [PATCH v1 14/17] perf tests bench: Add smoke tests for perf bench Arnaldo Carvalho de Melo
` (4 subsequent siblings)
17 siblings, 1 reply; 30+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-24 18:46 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Exercise the slab and page allocators, their sort, caller and
allocation views, the live page stats and the time filter.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/shell/kmem.sh | 215 +++++++++++++++++++++++++++++++++
1 file changed, 215 insertions(+)
create mode 100755 tools/perf/tests/shell/kmem.sh
diff --git a/tools/perf/tests/shell/kmem.sh b/tools/perf/tests/shell/kmem.sh
new file mode 100755
index 0000000000000000..c1eda5b2261f77ec
--- /dev/null
+++ b/tools/perf/tests/shell/kmem.sh
@@ -0,0 +1,215 @@
+#!/bin/bash
+# perf kmem tests
+# SPDX-License-Identifier: GPL-2.0
+
+set -e
+
+# Root permissions required for tracing events.
+if [ "$(id -u)" != 0 ]; then
+ echo "[Skip] No root permission"
+ exit 2
+fi
+
+if [ ! -e /sys/kernel/tracing/events/kmem/kmalloc ] &&
+ [ ! -e /sys/kernel/debug/tracing/events/kmem/kmalloc ]; then
+ echo "[Skip] No kmem tracepoints"
+ exit 2
+fi
+
+err=0
+slabdata=$(mktemp /tmp/__perf_test_kmem.slab.XXXXX)
+pagedata=$(mktemp /tmp/__perf_test_kmem.page.XXXXX)
+out=$(mktemp /tmp/__perf_test_kmem.out.XXXXX)
+
+cleanup() {
+ rm -f "${slabdata}" "${slabdata}".old
+ rm -f "${pagedata}" "${pagedata}".old
+ rm -f "${out}"
+
+ trap - EXIT TERM INT
+}
+
+trap_cleanup() {
+ echo "Unexpected signal in ${FUNCNAME[1]}"
+ cleanup
+ exit 1
+}
+trap trap_cleanup EXIT TERM INT
+
+fail() {
+ echo "$1 [Failed: $2]"
+ cat "${out}"
+ err=1
+}
+
+test_kmem_record() {
+ echo "Kmem record"
+ perf kmem record -o "${slabdata}" -- sleep 1
+ echo "Kmem record [Success]"
+}
+
+test_kmem_slab_stat() {
+ echo "Kmem slab stat"
+ if ! perf kmem -i "${slabdata}" stat > "${out}" 2>&1; then
+ fail "Kmem slab stat" "perf kmem stat failed"
+ return
+ fi
+ if ! grep -q "SUMMARY (SLAB allocator)" "${out}"; then
+ fail "Kmem slab stat" "missing summary"
+ return
+ fi
+ echo "Kmem slab stat [Success]"
+}
+
+test_kmem_slab_stat_options() {
+ echo "Kmem slab stat options"
+ if ! perf kmem -i "${slabdata}" --sort hit,bytes --line 5 stat > "${out}" 2>&1; then
+ fail "Kmem slab stat options" "perf kmem stat failed"
+ return
+ fi
+ if ! grep -q "SUMMARY (SLAB allocator)" "${out}"; then
+ fail "Kmem slab stat options" "missing summary"
+ return
+ fi
+ echo "Kmem slab stat options [Success]"
+}
+
+test_kmem_page_record() {
+ echo "Kmem page record"
+ perf kmem --page record -c 1000 -o "${pagedata}" -- sleep 1
+ echo "Kmem page record [Success]"
+}
+
+test_kmem_page_stat() {
+ echo "Kmem page stat"
+ if ! perf kmem --page -i "${pagedata}" stat > "${out}" 2>&1; then
+ fail "Kmem page stat" "perf kmem stat failed"
+ return
+ fi
+ if ! grep -q "SUMMARY (page allocator)" "${out}"; then
+ fail "Kmem page stat" "missing summary"
+ return
+ fi
+ echo "Kmem page stat [Success]"
+}
+
+test_kmem_page_stat_options() {
+ echo "Kmem page stat options"
+ if ! perf kmem --page -i "${pagedata}" --sort order,gfp --line 5 stat > "${out}" 2>&1; then
+ fail "Kmem page stat options" "perf kmem stat failed"
+ return
+ fi
+ if ! grep -q "SUMMARY (page allocator)" "${out}"; then
+ fail "Kmem page stat options" "missing summary"
+ return
+ fi
+ echo "Kmem page stat options [Success]"
+}
+
+test_kmem_slab_alloc() {
+ echo "Kmem slab alloc stats"
+ if ! perf kmem -i "${slabdata}" --alloc --sort bytes --line 5 stat > "${out}" 2>&1; then
+ fail "Kmem slab alloc stats" "perf kmem stat failed"
+ return
+ fi
+ if ! grep -q "SUMMARY (SLAB allocator)" "${out}"; then
+ fail "Kmem slab alloc stats" "missing summary"
+ return
+ fi
+ echo "Kmem slab alloc stats [Success]"
+}
+
+test_kmem_page_caller() {
+ echo "Kmem page caller stats"
+ if ! perf kmem --page -i "${pagedata}" --caller --sort bytes --line 5 stat > "${out}" 2>&1; then
+ fail "Kmem page caller stats" "perf kmem stat failed"
+ return
+ fi
+ if ! grep -q "SUMMARY (page allocator)" "${out}"; then
+ fail "Kmem page caller stats" "missing summary"
+ return
+ fi
+ echo "Kmem page caller stats [Success]"
+}
+
+test_kmem_page_caller_raw() {
+ echo "Kmem page caller raw ip stats"
+ if ! perf kmem --page -i "${pagedata}" --caller --raw-ip --sort callsite --line 5 stat > "${out}" 2>&1; then
+ fail "Kmem page caller raw ip stats" "perf kmem stat failed"
+ return
+ fi
+ if ! grep -q "SUMMARY (page allocator)" "${out}"; then
+ fail "Kmem page caller raw ip stats" "missing summary"
+ return
+ fi
+ echo "Kmem page caller raw ip stats [Success]"
+}
+
+test_kmem_page_alloc() {
+ echo "Kmem page alloc stats"
+ if ! perf kmem --page -i "${pagedata}" --alloc --sort bytes --line 5 stat > "${out}" 2>&1; then
+ fail "Kmem page alloc stats" "perf kmem stat failed"
+ return
+ fi
+ if ! grep -q "SUMMARY (page allocator)" "${out}"; then
+ fail "Kmem page alloc stats" "missing summary"
+ return
+ fi
+ echo "Kmem page alloc stats [Success]"
+}
+
+test_kmem_page_live() {
+ echo "Kmem page live stats"
+ if ! perf kmem --page --live -i "${pagedata}" --sort page --line 5 stat > "${out}" 2>&1; then
+ fail "Kmem page live stats" "perf kmem stat failed"
+ return
+ fi
+ if ! grep -q "SUMMARY (page allocator)" "${out}"; then
+ fail "Kmem page live stats" "missing summary"
+ return
+ fi
+ echo "Kmem page live stats [Success]"
+}
+
+test_kmem_slab_caller() {
+ echo "Kmem slab caller stats"
+ if ! perf kmem -i "${slabdata}" --caller --sort callsite --line 5 stat > "${out}" 2>&1; then
+ fail "Kmem slab caller stats" "perf kmem stat failed"
+ return
+ fi
+ if ! grep -q "SUMMARY (SLAB allocator)" "${out}"; then
+ fail "Kmem slab caller stats" "missing summary"
+ return
+ fi
+ echo "Kmem slab caller stats [Success]"
+}
+
+test_kmem_time_filter() {
+ echo "Kmem time filter"
+ if ! perf kmem -i "${slabdata}" --time 0, stat > "${out}" 2>&1; then
+ fail "Kmem time filter" "perf kmem stat failed"
+ return
+ fi
+ if ! grep -q "SUMMARY (SLAB allocator)" "${out}"; then
+ fail "Kmem time filter" "missing summary"
+ return
+ fi
+ echo "Kmem time filter [Success]"
+}
+
+test_kmem_record
+test_kmem_slab_stat
+test_kmem_slab_stat_options
+test_kmem_slab_alloc
+test_kmem_slab_caller
+test_kmem_time_filter
+test_kmem_page_record
+test_kmem_page_stat
+test_kmem_page_stat_options
+test_kmem_page_caller
+test_kmem_page_caller_raw
+test_kmem_page_alloc
+test_kmem_page_live
+
+cleanup
+exit $err
--
2.56.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v1 14/17] perf tests bench: Add smoke tests for perf bench
2026-11-24 18:45 [PATCH v1 00/17] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
` (12 preceding siblings ...)
2026-11-24 18:46 ` [PATCH v1 13/17] perf tests kmem: Add a basic perf kmem test Arnaldo Carvalho de Melo
@ 2026-11-24 18:46 ` Arnaldo Carvalho de Melo
2026-11-24 19:03 ` sashiko-bot
2026-11-24 18:46 ` [PATCH v1 15/17] perf tests lock: Exercise perf lock report and info Arnaldo Carvalho de Melo
` (3 subsequent siblings)
17 siblings, 1 reply; 30+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-24 18:46 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Run the numa, sched, futex, epoll, syscall, mem, internals, breakpoint
and uprobe benchmarks with small workloads, including the numa
convergence, perturbation and single node variants, and skip the ones
that need root or hardware that is not present.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/shell/bench.sh | 130 ++++++++++++++++++++++++++++++++
1 file changed, 130 insertions(+)
create mode 100755 tools/perf/tests/shell/bench.sh
diff --git a/tools/perf/tests/shell/bench.sh b/tools/perf/tests/shell/bench.sh
new file mode 100755
index 0000000000000000..7f5bca2c126a58aa
--- /dev/null
+++ b/tools/perf/tests/shell/bench.sh
@@ -0,0 +1,130 @@
+#!/bin/bash
+# perf bench tests
+# SPDX-License-Identifier: GPL-2.0
+
+set -e
+
+err=0
+out=$(mktemp /tmp/__perf_test_bench.out.XXXXX)
+
+cleanup() {
+ rm -f "${out}"
+
+ trap - EXIT TERM INT
+}
+
+trap_cleanup() {
+ echo "Unexpected signal in ${FUNCNAME[1]}"
+ cleanup
+ exit 1
+}
+trap trap_cleanup EXIT TERM INT
+
+# Some benchmarks need root, others only report that the hardware is
+# not there, so treat the environment as a skip and a missing result
+# as a failure.
+bench_skip_reasons="No hardware support|perf_event_open: Permission denied"
+
+run_bench() {
+ local name="$1" expect="$2"
+
+ shift 2
+ echo "Bench ${name}"
+ if ! perf bench "$@" > "${out}" 2>&1; then
+ if grep -qE "${bench_skip_reasons}" "${out}"; then
+ echo "Bench ${name} [Skipped: not supported here]"
+ return
+ fi
+ echo "Bench ${name} [Failed: perf bench failed]"
+ cat "${out}"
+ err=1
+ return
+ fi
+ # A benchmark can also decline to run and exit 0, printing that
+ # the hardware is not there, as the breakpoint ones do; that is a
+ # skip, not a success
+ if grep -qE "${bench_skip_reasons}" "${out}"; then
+ echo "Bench ${name} [Skipped: not supported here]"
+ return
+ fi
+ if ! grep -qE "${expect}" "${out}"; then
+ echo "Bench ${name} [Failed missing '${expect}']"
+ cat "${out}"
+ err=1
+ return
+ fi
+ echo "Bench ${name} [Success]"
+}
+
+run_bench numa/mem "GB/sec" numa mem -p 2 -t 2 -P 2 -T 1 -s 1 -l 1
+run_bench numa/mem/options "GB/sec" numa mem -p 1 -t 1 -P 2 -s 1 -l 1 -c -d -r -z -B -R -W
+run_bench numa/mem/init "GB/sec" numa mem -p 1 -t 1 -P 2 -s 1 -l 1 -I -H 1 -S -u 1 -B -r -z -Z
+if taskset -c 0 true > /dev/null 2>&1; then
+ run_bench numa/mem/bind "GB/sec" numa mem -p 2 -t 2 -P 2 -T 1 -s 1 -l 1 -C 0,1 -M 0,0
+else
+ echo "Bench numa/mem/bind [Skipped: cpu 0 not available]"
+fi
+run_bench numa/mem/convergence "GB/sec" numa mem -p 1 -t 1 -P 512 -l 1 -s 1 -c -m
+run_bench numa/mem/perturb "GB/sec" numa mem -p 1 -t 1 -P 512 -l 1 -s 1 -x 1 -S -d -d
+run_bench numa/mem/zero "GB/sec" numa mem -p 1 -t 2 -T 64 -l 1 -s 1 -C 0 -M 0 -B -Z -H -1
+run_bench sched/messaging "Total time" sched messaging -g 1 -l 10
+run_bench sched/pipe "ops/sec" sched pipe -l 1000
+run_bench sched/seccomp-notify "ops/sec" sched seccomp-notify -l 10
+run_bench futex/hash "operations/sec" futex hash -t 2 -r 1 -s
+run_bench futex/wake "Wokeup" futex wake -t 2
+run_bench futex/wake-parallel "Avg per-thread latency" futex wake-parallel -t 2 -w 1
+run_bench futex/requeue "Requeued" futex requeue -t 2
+run_bench futex/lock-pi "operations/sec" futex lock-pi -t 2 -r 1
+run_bench epoll/wait "operations/sec" epoll wait -r 1 -t 2
+run_bench epoll/ctl "operations" epoll ctl -r 1 -t 2
+run_bench syscall/basic "ops/sec" syscall basic -l 100
+run_bench syscall/getpgid "ops/sec" syscall getpgid -l 100
+run_bench syscall/fork "ops/sec" syscall fork -l 10
+run_bench syscall/execve "ops/sec" syscall execve -l 10
+run_bench mem/memcpy "Copying" mem memcpy -s 4KB -l 1
+run_bench mem/memset "Copying" mem memset -s 4KB -l 1
+run_bench mem/mmap "Copying" mem mmap -s 4KB -l 1
+run_bench internals/synthesize "Average data synthesis took" internals synthesize -s -i 1
+run_bench internals/synthesize-mt "Average synthesis took" internals synthesize -t -m 1 -M 2 -I 1
+run_bench internals/kallsyms-parse "Average kallsyms__parse took" internals kallsyms-parse -i 1
+run_bench internals/inject-build-id "Average build-id injection took" internals inject-build-id -i 2 -m 2 -n 2
+run_bench internals/pmu-scan "Average PMU scanning took" internals pmu-scan -i 1
+run_bench breakpoint/thread "Created/joined" breakpoint thread -t 2 -b 2 -p 1
+run_bench breakpoint/enable "Enabled/disabled" breakpoint enable -p 1 -a 1
+run_bench uprobe/baseline "usecs/op" uprobe baseline -l 2
+
+if [ "$(id -u)" = 0 ]; then
+ run_bench internals/evlist-open-close "Number of events" internals evlist-open-close -i 2
+else
+ echo "Bench internals/evlist-open-close [Skipped: no root permission]"
+fi
+
+# The uprobe programs attach to usleep in libc, which needs BPF and,
+# on distributions using musl, is not available by that name.
+if perf version --build-options | grep -q 'bpf_skeletons: *\[ on' && [ "$(id -u)" = 0 ]; then
+ for mode in empty trace_printk empty_ret trace_printk_ret; do
+ echo "Bench uprobe/${mode}"
+ if ! perf bench uprobe "${mode}" -l 2 > "${out}" 2>&1; then
+ if grep -qE 'Failed to (attach bench uprobe|load and verify BPF skeleton)' "${out}"; then
+ echo "Bench uprobe/${mode} [Skipped: no uprobe support]"
+ continue
+ fi
+ echo "Bench uprobe/${mode} [Failed: perf bench failed]"
+ cat "${out}"
+ err=1
+ continue
+ fi
+ if ! grep -q "usecs/op" "${out}"; then
+ echo "Bench uprobe/${mode} [Failed missing result]"
+ cat "${out}"
+ err=1
+ continue
+ fi
+ echo "Bench uprobe/${mode} [Success]"
+ done
+else
+ echo "Bench uprobe [Skipped: needs root and BPF skeletons]"
+fi
+
+cleanup
+exit $err
--
2.56.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v1 15/17] perf tests lock: Exercise perf lock report and info
2026-11-24 18:45 [PATCH v1 00/17] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
` (13 preceding siblings ...)
2026-11-24 18:46 ` [PATCH v1 14/17] perf tests bench: Add smoke tests for perf bench Arnaldo Carvalho de Melo
@ 2026-11-24 18:46 ` Arnaldo Carvalho de Melo
2026-11-24 18:46 ` [PATCH v1 16/17] perf tests probe: Exercise the variable and line listing Arnaldo Carvalho de Melo
` (2 subsequent siblings)
17 siblings, 0 replies; 30+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-24 18:46 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <acme@redhat.com>
The lock contention test records and reads a perf.data file, but only
through perf lock contention. Walk the report sort keys, combine the
locks, and check the thread and lock lists of perf lock info on the
same file.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/shell/lock_contention.sh | 40 +++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/tools/perf/tests/shell/lock_contention.sh b/tools/perf/tests/shell/lock_contention.sh
index 5df9a0cd48a34f4f..a3056136e3767eec 100755
--- a/tools/perf/tests/shell/lock_contention.sh
+++ b/tools/perf/tests/shell/lock_contention.sh
@@ -65,6 +65,44 @@ test_record()
fi
}
+test_report()
+{
+ echo "Testing perf lock report"
+ # the output goes to the stderr and all keys are printed unless -F
+ # selects a subset, so walk the sort keys
+ for key in acquired contended avg_wait wait_total wait_max wait_min; do
+ perf lock report -i ${perfdata} -k ${key} -E 5 2> ${result}
+ if ! grep -q "Name" "${result}"; then
+ echo "[Fail] perf lock report --key ${key} has no output:" "$(cat "${result}")"
+ err=1
+ exit
+ fi
+ done
+
+ perf lock report -i ${perfdata} -c -v -E 5 2> ${result}
+ if ! grep -q "Name" "${result}"; then
+ echo "[Fail] perf lock report --combine-locks has no output:" "$(cat "${result}")"
+ err=1
+ exit
+ fi
+}
+
+test_info()
+{
+ echo "Testing perf lock info"
+ perf lock info -i ${perfdata} 2> ${result}
+ if ! grep -q "Thread ID" "${result}"; then
+ echo "[Fail] perf lock info has no thread list:" "$(cat "${result}")"
+ err=1
+ exit
+ fi
+ if ! grep -q "Address of instance" "${result}"; then
+ echo "[Fail] perf lock info has no lock list:" "$(cat "${result}")"
+ err=1
+ exit
+ fi
+}
+
test_bpf()
{
echo "Testing perf lock contention --use-bpf"
@@ -347,6 +385,8 @@ test_csv_output()
check
test_record
+test_report
+test_info
test_bpf
test_record_concurrent
test_aggr_task
--
2.56.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v1 16/17] perf tests probe: Exercise the variable and line listing
2026-11-24 18:45 [PATCH v1 00/17] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
` (14 preceding siblings ...)
2026-11-24 18:46 ` [PATCH v1 15/17] perf tests lock: Exercise perf lock report and info Arnaldo Carvalho de Melo
@ 2026-11-24 18:46 ` Arnaldo Carvalho de Melo
2026-11-24 19:00 ` sashiko-bot
2026-11-24 18:46 ` [PATCH v1 17/17] perf tests report: Exercise the TUI browsers Arnaldo Carvalho de Melo
2026-11-24 19:03 ` [PATCH v1 00/17] perf tests: Add coverage for the untested perf subcommands sashiko-bot
17 siblings, 1 reply; 30+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-24 18:46 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Show the variables, source lines and probe-able functions of a kernel
function, and check the missing argument error.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/shell/probe_vars.sh | 80 ++++++++++++++++++++++++++++
1 file changed, 80 insertions(+)
create mode 100755 tools/perf/tests/shell/probe_vars.sh
diff --git a/tools/perf/tests/shell/probe_vars.sh b/tools/perf/tests/shell/probe_vars.sh
new file mode 100755
index 0000000000000000..1e9476635b1ebc75
--- /dev/null
+++ b/tools/perf/tests/shell/probe_vars.sh
@@ -0,0 +1,80 @@
+#!/bin/bash
+# perf probe variable and line listing tests
+# SPDX-License-Identifier: GPL-2.0
+
+set -e
+
+. "$(dirname $0)"/lib/probe.sh
+
+skip_if_no_perf_probe || exit 2
+
+err=0
+out=$(mktemp /tmp/__perf_test_probe_vars.out.XXXXX)
+
+cleanup() {
+ rm -f "${out}"
+
+ trap - EXIT TERM INT
+}
+
+trap_cleanup() {
+ echo "Unexpected signal in ${FUNCNAME[1]}"
+ cleanup
+ exit 1
+}
+trap trap_cleanup EXIT TERM INT
+
+run_probe() {
+ local desc="$1" expect="$2"
+
+ shift 2
+ echo "Probe ${desc}"
+ if ! perf probe "$@" > "${out}" 2>&1; then
+ echo "Probe ${desc} [Failed: perf probe failed]"
+ cat "${out}"
+ err=1
+ return
+ fi
+ if [ -n "${expect}" ] && ! grep -q "${expect}" "${out}"; then
+ echo "Probe ${desc} [Failed: missing '${expect}']"
+ cat "${out}"
+ err=1
+ return
+ fi
+ echo "Probe ${desc} [Success]"
+}
+
+# The variable and line listings need debug info, skip when the kernel
+# was built without it.
+if ! perf probe -V schedule > "${out}" 2>&1; then
+ echo "Probe variable listing [Skipped: no debug info for schedule]"
+ cleanup
+ exit 2
+fi
+
+run_probe "vars" "Available variables at schedule" -V schedule
+run_probe "vars long option" "Available variables at schedule" --vars schedule
+run_probe "vars offset" "Available variables at schedule" -V schedule+0
+run_probe "line" "schedule" -L schedule
+run_probe "line long option" "schedule" --line schedule
+
+if [ "$(id -u)" = 0 ]; then
+ run_probe "funcs" "schedule" --funcs
+ run_probe "funcs filter" "schedule" --funcs "sched*"
+else
+ echo "Probe funcs [Skipped: needs root to read the kernel symbols]"
+fi
+
+echo "Probe missing add argument"
+if perf probe -a > "${out}" 2>&1; then
+ echo "Probe missing add argument [Failed: accepted no argument]"
+ err=1
+else
+ if ! grep -q "Usage:" "${out}"; then
+ echo "Probe missing add argument [Failed: missing usage]"
+ err=1
+ fi
+fi
+
+cleanup
+exit $err
--
2.56.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v1 17/17] perf tests report: Exercise the TUI browsers
2026-11-24 18:45 [PATCH v1 00/17] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
` (15 preceding siblings ...)
2026-11-24 18:46 ` [PATCH v1 16/17] perf tests probe: Exercise the variable and line listing Arnaldo Carvalho de Melo
@ 2026-11-24 18:46 ` Arnaldo Carvalho de Melo
2026-11-24 19:01 ` sashiko-bot
2026-11-24 19:03 ` [PATCH v1 00/17] perf tests: Add coverage for the untested perf subcommands sashiko-bot
17 siblings, 1 reply; 30+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-24 18:46 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Run report and annotate on a pty and press the help, zoom and source
keys, then check that the screens were drawn. Needs python and
libslang.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/shell/report_tui.sh | 112 +++++++++++++++++++++++++++
1 file changed, 112 insertions(+)
create mode 100755 tools/perf/tests/shell/report_tui.sh
diff --git a/tools/perf/tests/shell/report_tui.sh b/tools/perf/tests/shell/report_tui.sh
new file mode 100755
index 0000000000000000..bf5ff1c4c3f6ff7f
--- /dev/null
+++ b/tools/perf/tests/shell/report_tui.sh
@@ -0,0 +1,112 @@
+#!/bin/bash
+# perf report and annotate TUI tests
+# SPDX-License-Identifier: GPL-2.0
+
+set -e
+
+# shellcheck source=lib/setup_python.sh
+. "$(dirname "$0")/lib/setup_python.sh"
+
+if ! perf check feature -q libslang; then
+ echo "[Skip] No libslang support"
+ exit 2
+fi
+
+err=0
+tmpdir=$(mktemp -d /tmp/__perf_test_tui.XXXXXX)
+perfdata="${tmpdir}/perf.data"
+tui_keys="${tmpdir}/tui_keys.py"
+
+cleanup() {
+ rm -rf "${tmpdir}"
+
+ trap - EXIT TERM INT
+}
+
+trap_cleanup() {
+ echo "Unexpected signal in ${FUNCNAME[1]}"
+ cleanup
+ exit 1
+}
+trap trap_cleanup EXIT TERM INT
+
+# The TUI needs a terminal, so run it on a pty and feed it the keys a
+# user would press.
+cat > "${tui_keys}" <<'PY'
+import fcntl, os, pty, select, struct, sys, termios, time
+
+outfile = sys.argv[1]
+keys = sys.argv[2].encode()
+cmd = sys.argv[3:]
+
+pid, fd = pty.fork()
+if pid == 0:
+ os.environ["TERM"] = "xterm"
+ os.execvp(cmd[0], cmd)
+
+fcntl.ioctl(fd, termios.TIOCSWINSZ, struct.pack("HHHH", 40, 120, 0, 0))
+
+start = time.time()
+next_key = start + 1.5
+deadline = start + 20
+with open(outfile, "wb") as out:
+ while True:
+ now = time.time()
+ if now > deadline:
+ os.kill(pid, 9)
+ sys.exit(2)
+ if keys and now >= next_key:
+ os.write(fd, keys[:1])
+ keys = keys[1:]
+ next_key = now + 0.7
+ r, _, _ = select.select([fd], [], [], 0.1)
+ if r:
+ try:
+ chunk = os.read(fd, 65536)
+ except OSError:
+ break
+ if not chunk:
+ break
+ out.write(chunk)
+ out.flush()
+
+_, status = os.waitpid(pid, 0)
+sys.exit(os.waitstatus_to_exitcode(status))
+PY
+
+run_tui() {
+ local desc="$1" keys="$2" expect="$3"
+
+ shift 3
+ echo "TUI ${desc}"
+ if ! "${PYTHON}" "${tui_keys}" "${tmpdir}/${desc}.out" "${keys}" "$@"; then
+ echo "TUI ${desc} [Failed: TUI exited with an error]"
+ err=1
+ return
+ fi
+ if ! grep -qa "${expect}" "${tmpdir}/${desc}.out"; then
+ echo "TUI ${desc} [Failed: missing '${expect}']"
+ err=1
+ return
+ fi
+ echo "TUI ${desc} [Success]"
+}
+
+echo "TUI record"
+if ! perf record -q -o "${perfdata}" -- perf test -w noploop 1; then
+ echo "TUI record [Failed: perf record failed]"
+ cleanup
+ exit 1
+fi
+
+run_tui "report" "q" "Overhead" perf report --tui -i "${perfdata}"
+run_tui "report help" "?qq" "Help" perf report --tui -i "${perfdata}"
+run_tui "report dso zoom" "dq" "Overhead" perf report --tui -i "${perfdata}"
+run_tui "report thread zoom" "tq" "Overhead" perf report --tui -i "${perfdata}"
+run_tui "annotate" "q" "Percent" perf annotate --tui -i "${perfdata}"
+# noploop is built without debug info, so 's' opens the "no source code"
+# warning and the first 'q' only dismisses it; the second one quits.
+run_tui "annotate source" "sqq" "Percent" perf annotate --tui -i "${perfdata}"
+
+cleanup
+exit $err
--
2.56.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* Re: [PATCH v1 05/17] perf tests script: Exercise the list, fields and dump options
2026-11-24 18:45 ` [PATCH v1 05/17] perf tests script: Exercise the list, fields and dump options Arnaldo Carvalho de Melo
@ 2026-11-24 18:54 ` sashiko-bot
0 siblings, 0 replies; 30+ messages in thread
From: sashiko-bot @ 2026-11-24 18:54 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo; +Cc: linux-perf-users
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] perf tests script: disasm in test_script_fields() fails
without libcapstone
--
commit 11f72d07cda14b3cc3bb37ec5610a17a52bfd7b5
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
perf tests script: Exercise the list, fields and dump options
This commit expands the perf script shell test to exercise script listing,
output field selection, per-event dumps, header output, task and mmap
events, and miscellaneous display options.
> diff --git a/tools/perf/tests/shell/script.sh b/tools/perf/tests/shell/script.sh
> index af687c7cfe44c..a74d45d51ae47 100755
> --- a/tools/perf/tests/shell/script.sh
> +++ b/tools/perf/tests/shell/script.sh
[ ... ]
> @@ -27,18 +43,123 @@ trap_cleanup()
>
> trap trap_cleanup EXIT TERM INT
>
> +script_data="${temp_dir}/script-perf.data"
[ ... ]
> +test_script_fields()
> +{
> + echo "perf script fields test"
> + perf record -o "${script_data}" -e cpu-clock --sample-cpu ${testprog}
> + if ! perf script -i "${script_data}" -F comm,tid,pid,time,cpu,event,ip,sym,dso,dsoff,symoff,period,machine_pid,vcpu,ipc,insn,insnlen,disasm,misc,metric,synth,callindent,flags | grep -q "${testsym}"
> + then
> + echo "perf script fields test [Failed missing ${testsym}]"
> + err=1
> + return
> + fi
[Severity: Medium]
Does test_script_fields() fail when perf is built without libcapstone
support?
In tools/perf/builtin-script.c, parse_output_fields() rejects -F disasm
with -EINVAL unless HAVE_LIBCAPSTONE_SUPPORT is defined, which causes
perf script to exit without output, sets err=1, and returns early before
the +cpu and -comm checks run. Guarding the disasm field with
"perf check feature -q libcapstone" would avoid failing on builds
without capstone.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124184604.24983-1-acme@kernel.org?part=5
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v1 07/17] perf tests diff: Exercise the output options
2026-11-24 18:45 ` [PATCH v1 07/17] perf tests diff: Exercise the output options Arnaldo Carvalho de Melo
@ 2026-11-24 18:57 ` sashiko-bot
0 siblings, 0 replies; 30+ messages in thread
From: sashiko-bot @ 2026-11-24 18:57 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo; +Cc: linux-perf-users
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] perf tests diff: unchecked perf diff exit status and u64
overflow in --time
- [Low] perf tests diff: mktemp files leaked when
skip_test_missing_symbol() exits
- [Low] perf tests diff: test_three_files() overwrites err and
test_options() runs
--
commit c0af815c226f5a563d83e161e3f9885c8829c0ce
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
perf tests diff: Exercise the output options
This commit extends the perf diff shell test to record a second workload
for the third data file and adds test_options() to verify output and
filtering options.
> diff --git a/tools/perf/tests/shell/diff.sh b/tools/perf/tests/shell/diff.sh
> index 88f37b8ef8936..d2fbc8a8c2c36 100755
> --- a/tools/perf/tests/shell/diff.sh
> +++ b/tools/perf/tests/shell/diff.sh
> @@ -8,14 +8,18 @@ err=0
> perfdata1=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
> perfdata2=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
> perfdata3=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
> +diffout=$(mktemp /tmp/__perf_test.perf.diff.out.XXXXX)
> testprog="perf test -w thloop"
> +testprog2="perf test -w noploop"
>
> shelldir=$(dirname "$0")
> . "${shelldir}"/lib/perf_has_symbol.sh
>
> testsym="test_loop"
> +testsym2="noploop"
>
> skip_test_missing_symbol ${testsym}
> +skip_test_missing_symbol ${testsym2}
[Severity: Low]
Does skip_test_missing_symbol leak perfdata1, perfdata2, perfdata3, and
diffout in /tmp when either symbol is missing? skip_test_missing_symbol
calls exit 2 before trap_cleanup is installed on EXIT.
[ ... ]
> @@ -100,8 +110,175 @@ test_three_files() {
> echo "Basic three file diff test [Success]"
> }
>
> +test_options() {
> + echo "Diff options test"
[ ... ]
> + # A window starting at the beginning of the data shows it all, a
> + # window starting after the last sample shows nothing
> + if ! perf diff --time 0, "${perfdata1}" "${perfdata2}" | grep -q "${testsym}"
> + then
> + echo "Diff options test [Failed: --time]"
> + err=1
> + return
> + fi
> + if perf diff --time 9000000000000000000, "${perfdata1}" "${perfdata2}" | \
> + grep -q "${testsym}"
> + then
> + echo "Diff options test [Failed: --time shows samples outside the window]"
> + err=1
> + return
> + fi
[Severity: Medium]
Can this negative --time check pass even if perf diff fails, and does
9000000000000000000 overflow u64 in parse_nsec_time()?
Because the pipeline runs inside a positive if condition without pipefail,
any error exit from perf diff produces no stdout, causing grep -q to return
1 and the check to succeed silently (unlike the --baseline-only check
above, which writes to ${diffout} and checks perf diff's status first).
In addition, parse_nsec_time() treats the number before the decimal point
as seconds and multiplies by NSEC_PER_SEC in u64 arithmetic:
tools/perf/util/time-utils.c:parse_nsec_time() {
...
time_sec = strtoull(str, &end, 10);
...
*ptime = time_sec * NSEC_PER_SEC + time_nsec;
return 0;
}
9000000000000000000 overflows u64 when multiplied by 10^9 and wraps to
~5.3e18 ns.
[ ... ]
> test_two_files
> test_three_files
> +test_options
>
> cleanup
> exit $err
[Severity: Low]
If test_two_files fails (setting err=1), or if make_data fails partway
through test_three_files, should the subsequent test functions still run?
test_three_files overwrites global err with 0 when make_data succeeds,
masking an earlier failure in test_two_files, and an early return from
test_three_files leaves test_options running against unrecorded mktemp
files.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124184604.24983-1-acme@kernel.org?part=7
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v1 13/17] perf tests kmem: Add a basic perf kmem test
2026-11-24 18:46 ` [PATCH v1 13/17] perf tests kmem: Add a basic perf kmem test Arnaldo Carvalho de Melo
@ 2026-11-24 18:57 ` sashiko-bot
0 siblings, 0 replies; 30+ messages in thread
From: sashiko-bot @ 2026-11-24 18:57 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo; +Cc: linux-perf-users
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] perf tests kmem: missing libtraceevent feature check in kmem.sh
--
commit 99c0cb23329714ac0762285488be24974461c863
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
perf tests kmem: Add a basic perf kmem test
This commit adds a shell test exercising perf kmem recording and stat
reporting for slab and page allocators.
> diff --git a/tools/perf/tests/shell/kmem.sh b/tools/perf/tests/shell/kmem.sh
> new file mode 100755
> index 0000000000000..c1eda5b2261f7
> --- /dev/null
> +++ b/tools/perf/tests/shell/kmem.sh
> @@ -0,0 +1,215 @@
> +#!/bin/bash
> +# perf kmem tests
> +# SPDX-License-Identifier: GPL-2.0
> +
> +set -e
> +
> +# Root permissions required for tracing events.
> +if [ "$(id -u)" != 0 ]; then
> + echo "[Skip] No root permission"
> + exit 2
> +fi
> +
> +if [ ! -e /sys/kernel/tracing/events/kmem/kmalloc ] &&
> + [ ! -e /sys/kernel/debug/tracing/events/kmem/kmalloc ]; then
> + echo "[Skip] No kmem tracepoints"
> + exit 2
> +fi
[Severity: Low]
Should this test also check "perf check feature -q libtraceevent" before
running?
When perf is built without libtraceevent (NO_LIBTRACEEVENT=1), cmd_kmem
is defined via DECLARE_LIBTRACEEVENT_STUB(kmem) and fails with -1.
Because the tracepoint check above inspects tracefs/debugfs directly and
set -e is active, test_kmem_record() will hit trap_cleanup() and exit
with 1 (failure) instead of 2 (skip).
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124184604.24983-1-acme@kernel.org?part=13
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v1 02/17] perf tests sched: Exercise the sched views and options
2026-11-24 18:45 ` [PATCH v1 02/17] perf tests sched: Exercise the sched views and options Arnaldo Carvalho de Melo
@ 2026-11-24 18:58 ` sashiko-bot
0 siblings, 0 replies; 30+ messages in thread
From: sashiko-bot @ 2026-11-24 18:58 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo; +Cc: linux-perf-users
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] perf tests sched: untriggered migration check in
test_sched_timehist_options()
- [Medium] perf tests sched: missing /proc/schedstat check before
running stats tests
--
commit f3373bb8ae42cb050e4a69b6377d03f44916ae77
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
perf tests sched: Exercise the sched views and options
This commit captures perf sched output to a temporary file before
checking it with grep, drops --no-inherit from perf sched record, and
adds test cases for latency, map, timehist, and schedstat options.
> diff --git a/tools/perf/tests/shell/sched.sh b/tools/perf/tests/shell/sched.sh
> index 113df962a51c8..e1aa8570b21f4 100755
> --- a/tools/perf/tests/shell/sched.sh
> +++ b/tools/perf/tests/shell/sched.sh
[ ... ]
> @@ -56,90 +61,153 @@ cleanup_noploops() {
[ ... ]
> +test_sched_timehist_options() {
> + run_sched "timehist summary" "Runtime summary" timehist --summary -i "${perfdata}"
> + run_sched "timehist wakeups" "awakened:" timehist -w -i "${perfdata}"
> + run_sched "timehist migrations" "migrated:" timehist -M -i "${perfdata}"
[Severity: Medium]
Can this test fail when no task migration occurs during the 1-second
recording window?
start_noploops() pins both perf-noploop workload processes to CPU 0 with
taskset -pc 0 before perf sched record runs, so neither workload task can
migrate across CPUs. timehist_print_migration_event() only prints
"migrated:" when a sched:sched_migrate_task event is present in
perf.data, so on single-CPU systems or quiet multi-CPU systems where no
unrelated task migrates during sleep 1, this check fails with missing
'migrated:'.
> + run_sched "timehist idle" "Idle-time summary" timehist -I --summary -i "${perfdata}"
> + run_sched "timehist state" "sch delay" \
> + timehist --state --show-prio -V -P -i "${perfdata}"
> + run_sched "timehist call graph" "" timehist -g --max-stack 3 -i "${perfdata}"
> + run_sched "timehist pid filter" "" timehist -p "${PID1}" -i "${perfdata}"
> + run_sched "timehist prio filter" "" timehist --show-prio --prio 0 -i "${perfdata}"
> + run_sched "timehist with summary" "perf-noploop" timehist -S -i "${perfdata}"
> +}
> +
> +test_sched_stats_live() {
> + echo "Sched stats live"
>
> - if ! perf sched script -i "${perfdata}" | grep -q perf-noploop
> + ret=0
> + timeout -s INT -k 5 3 perf sched stats > "${schedout}" 2>&1 || ret=$?
> + if [ "${ret}" != 0 ] && [ "${ret}" != 124 ]
> then
> - echo "Sched script [Failed missing output]"
> + echo "Sched stats live [Failed: perf sched stats failed]"
> + cat "${schedout}"
> err=1
> + return
> fi
> -}
>
> -test_sched_map() {
> - echo "Sched map"
> -
> - if ! perf sched map -i "${perfdata}" | grep -q perf-noploop
> + if ! grep -q "Description" "${schedout}"
> then
> - echo "Sched map [Failed missing output]"
> + echo "Sched stats live [Failed missing output]"
> err=1
> + return
> fi
> + echo "Sched stats live [Success]"
> }
>
> -test_sched_timehist() {
> - echo "Sched timehist"
> -
> - if ! perf sched timehist -i "${perfdata}" | grep -q perf-noploop
> +test_sched_stats_record() {
> + if ! perf sched stats record -o "${statsdata}" sleep 1
> then
> - echo "Sched timehist [Failed missing output]"
> + echo "Sched stats record [Failed: perf sched stats record failed]"
> err=1
> + return
> fi
> + if [ ! -s "${statsdata}" ]
> then
> + echo "Sched stats record [Failed: no data file]"
> + err=1
> + return
> + fi
> + echo "Sched stats record [Success]"
> +}
> +
> +test_sched_stats_report() {
> + run_sched "stats report" "Description" stats report -i "${statsdata}" -C 0 -v
> +}
> +
> +test_sched_stats_diff() {
> + run_sched "stats diff" "" stats diff "${statsdata}" "${statsdata}"
> }
[Severity: Medium]
Should the stats subtests be skipped when /proc/schedstat is absent?
Unlike perf sched record, which checks schedstat_events_exposed() before
adding sched_stat tracepoints, perf sched stats live and record call
perf_event__synthesize_schedstat() and enable_sched_schedstats(), which
require /proc/schedstat and /proc/sys/kernel/sched_schedstats. On
kernels built with CONFIG_SCHEDSTATS=n (the default in
lib/Kconfig.debug), these stats tests fail the suite.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124184604.24983-1-acme@kernel.org?part=2
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v1 16/17] perf tests probe: Exercise the variable and line listing
2026-11-24 18:46 ` [PATCH v1 16/17] perf tests probe: Exercise the variable and line listing Arnaldo Carvalho de Melo
@ 2026-11-24 19:00 ` sashiko-bot
0 siblings, 0 replies; 30+ messages in thread
From: sashiko-bot @ 2026-11-24 19:00 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo; +Cc: linux-perf-users
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] perf tests probe: -L/--line tests fail when kernel source files
are missing
--
commit de96d208624e6809de0b6f80a8a08a4c06516441
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
perf tests probe: Exercise the variable and line listing
This commit adds a shell test for perf probe that exercises variable
listing (-V/--vars), source line listing (-L/--line), function listing
(--funcs), and missing argument error handling.
> diff --git a/tools/perf/tests/shell/probe_vars.sh b/tools/perf/tests/shell/probe_vars.sh
> new file mode 100755
> index 0000000000000..1e9476635b1eb
> --- /dev/null
> +++ b/tools/perf/tests/shell/probe_vars.sh
[ ... ]
> +# The variable and line listings need debug info, skip when the kernel
> +# was built without it.
> +if ! perf probe -V schedule > "${out}" 2>&1; then
> + echo "Probe variable listing [Skipped: no debug info for schedule]"
> + cleanup
> + exit 2
> +fi
> +
> +run_probe "vars" "Available variables at schedule" -V schedule
> +run_probe "vars long option" "Available variables at schedule" --vars schedule
> +run_probe "vars offset" "Available variables at schedule" -V schedule+0
> +run_probe "line" "schedule" -L schedule
> +run_probe "line long option" "schedule" --line schedule
[Severity: Low]
Will the -L and --line subtests fail when vmlinux debug info is installed
without the corresponding kernel source tree on disk?
show_available_vars() (-V) only reads DWARF from vmlinux, whereas
__show_line_range() (-L/--line) also calls find_source_path() and fopen()
to read the C source file. On systems with debuginfo packages installed
but no source files at the build path, perf probe -V schedule succeeds and
the -L/--line subtests fail instead of being skipped.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124184604.24983-1-acme@kernel.org?part=16
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v1 01/17] perf tests top: Pin the ring buffer size
2026-11-24 18:45 ` [PATCH v1 01/17] perf tests top: Pin the ring buffer size Arnaldo Carvalho de Melo
@ 2026-11-24 19:01 ` sashiko-bot
0 siblings, 0 replies; 30+ messages in thread
From: sashiko-bot @ 2026-11-24 19:01 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo; +Cc: linux-perf-users
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] perf tests top: -m 128 assumes 4K pages and can fail with
EPERM on 64K kernels
- [Medium] perf tests top: BPF sideband evlist ignores -m and uses
perf_event_mlock_kb
--
commit a27a5c7becc862ff1f80abad85898b11bfc88147
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
perf tests top: Pin the ring buffer size
This commit passes -m 128 to the perf top invocations in top.sh so the ring
buffer size does not scale with host kernel.perf_event_mlock_kb settings.
> diff --git a/tools/perf/tests/shell/top.sh b/tools/perf/tests/shell/top.sh
> index 3d52677ccb5fd..4808d79275178 100755
> --- a/tools/perf/tests/shell/top.sh
> +++ b/tools/perf/tests/shell/top.sh
> @@ -19,6 +19,9 @@ trap_cleanup() {
> }
> trap trap_cleanup EXIT TERM INT
>
> +# perf top sizes its default ring buffer from kernel.perf_event_mlock_kb,
> +# which a test host may have tuned large, pin it to the upstream default
> +# of 128 pages (516 KiB) so the test does not depend on the host setting.
> test_basic_perf_top() {
> echo "Basic perf top test"
>
> @@ -36,7 +39,7 @@ test_basic_perf_top() {
> # Use -e cpu-clock to ensure we get samples
> # Use sleep to keep stdin open but silent, preventing EOF loop or interactive spam
> retval=0
> - sleep 10 | timeout 5s perf top --stdio -d 1 -e cpu-clock \
> + sleep 10 | timeout 5s perf top --stdio -d 1 -m 128 -e cpu-clock \
> -p $PID > "${log_file}" 2>&1 || retval=$?
[Severity: Medium]
Can passing -m 128 cause perf top to fail with EPERM on 64K page kernels?
parse_pages_arg() treats a bare integer without a unit suffix as a page
count rather than a byte size, whereas the upstream default
sysctl_perf_event_mlock is 512 + (PAGE_SIZE / 1024) KiB (only 8 data pages
plus 1 control page per CPU on 64K page kernels). On a 64K page kernel,
-m 128 requests 8,256 KiB per ring buffer (16,512 KiB across the two
thloop threads), which can exceed the default per-CPU mlock budget and the
8 MiB RLIMIT_MEMLOCK for an unprivileged user.
Passing -m 512K in both test_basic_perf_top() and
test_hybrid_merge_perf_top() would pin the data buffer to 512 KiB
regardless of the kernel page size.
> @@ -83,7 +86,7 @@ test_hybrid_merge_perf_top() {
> # environments can seamlessly fall back to cpu-clock while real
> # hybrid hardware will naturally cover the merge logic.
> retval=0
> - sleep 10 | timeout 5s perf top \
> + sleep 10 | timeout 5s perf top -m 128 \
> --stdio --hybrid-merge -d 1 -p $PID > "${log_file}" 2>&1 || retval=$?
[Severity: Medium]
Does the BPF sideband evlist in perf top still size its ring buffers from
kernel.perf_event_mlock_kb even when -m is passed?
Before __cmd_top() maps top.evlist with opts->mmap_pages, cmd_top() starts
the BPF sideband thread via evlist__start_sb_thread(top.sb_evlist, target),
which calls evlist__do_mmap(evlist, UINT_MAX). With UINT_MAX,
evlist__mmap_size() falls back to perf_event_mlock_kb_in_pages(), so on a
host with a large kernel.perf_event_mlock_kb setting, top.sb_evlist still
maps two huge ring buffers for the thloop threads and can exhaust memory
or the mlock budget before top.evlist is mapped.
Passing --no-bpf-event to both perf top invocations (or sizing the
sideband evlist intelligently) would avoid depending on
kernel.perf_event_mlock_kb.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124184604.24983-1-acme@kernel.org?part=1
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v1 17/17] perf tests report: Exercise the TUI browsers
2026-11-24 18:46 ` [PATCH v1 17/17] perf tests report: Exercise the TUI browsers Arnaldo Carvalho de Melo
@ 2026-11-24 19:01 ` sashiko-bot
0 siblings, 0 replies; 30+ messages in thread
From: sashiko-bot @ 2026-11-24 19:01 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo; +Cc: linux-perf-users
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] perf tests report_tui: multi-event menu and kptr_restrict
modal dialog hang
- [Medium] perf tests report_tui: debuginfo and os.write() EIO failure
in annotate test
--
commit a2002eeed86b16048de69b871224382c3a77c477
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
perf tests report: Exercise the TUI browsers
This commit adds a shell test that runs perf report and perf annotate in
TUI mode inside a Python pty harness and verifies that the expected browser
screens are rendered in response to key presses.
> diff --git a/tools/perf/tests/shell/report_tui.sh b/tools/perf/tests/shell/report_tui.sh
> new file mode 100755
> index 0000000000000..bf5ff1c4c3f6f
> --- /dev/null
> +++ b/tools/perf/tests/shell/report_tui.sh
> @@ -0,0 +1,112 @@
[ ... ]
> +with open(outfile, "wb") as out:
> + while True:
> + now = time.time()
> + if now > deadline:
> + os.kill(pid, 9)
> + sys.exit(2)
> + if keys and now >= next_key:
> + os.write(fd, keys[:1])
> + keys = keys[1:]
> + next_key = now + 0.7
> + r, _, _ = select.select([fd], [], [], 0.1)
> + if r:
> + try:
> + chunk = os.read(fd, 65536)
> + except OSError:
> + break
[ ... ]
> +echo "TUI record"
> +if ! perf record -q -o "${perfdata}" -- perf test -w noploop 1; then
> + echo "TUI record [Failed: perf record failed]"
> + cleanup
> + exit 1
> +fi
> +
> +run_tui "report" "q" "Overhead" perf report --tui -i "${perfdata}"
> +run_tui "report help" "?qq" "Help" perf report --tui -i "${perfdata}"
> +run_tui "report dso zoom" "dq" "Overhead" perf report --tui -i "${perfdata}"
> +run_tui "report thread zoom" "tq" "Overhead" perf report --tui -i "${perfdata}"
[Severity: Medium]
Can running perf record without a single user-space event and perf report
without -q cause these tests to fail or hang until the 20-second timeout?
When no event is specified, evlist__new_default() creates one cycles event
per core PMU. On hybrid systems with multiple core PMUs, perf.data holds
multiple events, so evlist__tui_browse_hists() enters the event-selection
menu in perf_evsel_menu__run() instead of opening the histogram browser.
In that menu, pressing q exits before Overhead is ever drawn, while
pressing d or t opens an unhandled-hotkey modal dialog that consumes the q
key and leaves perf report blocked until the deadline kills it. Similarly,
__cmd_annotate() iterates over each evsel with samples, so a single q only
closes the first PMU's browser.
In addition, default recording captures kernel samples when
perf_event_paranoid <= 1. If kallsyms addresses are restricted by
kptr_restrict, report__warn_kptr_restrict() calls ui__warning() on startup,
opening a modal warning dialog that consumes the first key sent by
tui_keys.py.
Passing -e cpu-clock:u (or -e cycles:u) to perf record and -q to perf
report --tui would ensure a single user-space event and suppress startup
warning dialogs.
> +run_tui "annotate" "q" "Percent" perf annotate --tui -i "${perfdata}"
> +# noploop is built without debug info, so 's' opens the "no source code"
> +# warning and the first 'q' only dismisses it; the second one quits.
> +run_tui "annotate source" "sqq" "Percent" perf annotate --tui -i "${perfdata}"
[Severity: Medium]
Can the annotate source test fail with an unhandled OSError in tui_keys.py
when perf is built with debug info?
tools/perf/tests/workloads/Build compiles noploop.o with the default
CORE_CFLAGS, which includes -g in debug builds (such as DEBUG=1 or
EXTRA_CFLAGS=-g). When DWARF info is present, pressing s in
annotate_browser__toggle_source() finds annotation__has_source(notes) true
and toggles the source view without opening a warning dialog. The first q
in sqq then exits perf annotate immediately, and when tui_keys.py sends the
second q via os.write(fd, keys[:1]) (which, unlike os.read(), is not
wrapped in try/except OSError), writing to the closed pty raises EIO and
fails the test.
Conversely, if a user's ~/.perfconfig sets annotate.hide_src_code = false
and debug info is absent, __hist_entry__tui_annotate() opens the "Annotation
has no source code." modal warning on startup, consuming the single q in
the first annotate test and causing it to hang until the timeout.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124184604.24983-1-acme@kernel.org?part=17
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v1 11/17] perf tests trace: Exercise the tracing options
2026-11-24 18:45 ` [PATCH v1 11/17] perf tests trace: Exercise the tracing options Arnaldo Carvalho de Melo
@ 2026-11-24 19:02 ` sashiko-bot
0 siblings, 0 replies; 30+ messages in thread
From: sashiko-bot @ 2026-11-24 19:02 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo; +Cc: linux-perf-users
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] perf tests trace: multiple -e syscall flags overwrite
ev_qualifier
- [Low] perf tests trace: missing bpf_skeletons check before -u uid
subtest
--
commit 8d2dfbecd217c63b535805ea0723b5374531748c
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
perf tests trace: Exercise the tracing options
This commit adds a shell test exercising various perf trace command-line
options including page faults, scheduler stats, summaries, and filters.
> diff --git a/tools/perf/tests/shell/trace_options.sh b/tools/perf/tests/shell/trace_options.sh
> new file mode 100755
> index 0000000000000..3f686a293bb9d
> --- /dev/null
> +++ b/tools/perf/tests/shell/trace_options.sh
> @@ -0,0 +1,97 @@
[ ... ]
> +run_trace "syscalls" "" --syscalls -- true
> +run_trace "events" "openat" -e openat -e read -e write -- cat /dev/null
[Severity: Medium]
Does passing separate -e flags for syscalls cause "openat" and "read" to
be overwritten by "write", failing the grep for "openat"?
Each -e syscall flag calls trace__parse_events_option(), which overwrites
trace->ev_qualifier with strlist__new() and calls
trace__validate_ev_qualifier() to allocate a new
trace->ev_qualifier_ids.entries array without preserving earlier entries:
tools/perf/builtin-trace.c:trace__parse_events_option() {
...
trace->ev_qualifier = strlist__new(lists[1], &slist_config);
if (trace->ev_qualifier == NULL) {
fputs("Not enough memory to parse event qualifier", trace->output);
goto out;
}
if (trace__validate_ev_qualifier(trace))
goto out;
...
}
Only "write" remains enabled in trace->ev_qualifier_ids, so openat is
filtered out and the test fails. Passing a comma-separated list (-e
openat,read,write) or accumulating syscall qualifiers across multiple -e
options would avoid this.
[ ... ]
> +run_trace "no inherit" "" --no-inherit -- sleep 0.1
> +run_trace "uid" "" -u "$(id -un)" -- true
[Severity: Low]
Will the "uid" subtest fail when perf is built without BPF skeleton
support?
In cmd_trace(), -u calls parse_uid_filter(trace.evlist, uid) before
trace__run() populates non-BPF syscall tracepoints. parse_uid_filter()
applies a BPF sample filter to the last evsel in trace.evlist via
perf_bpf_filter__parse(), which fails when HAVE_BPF_SKEL is disabled or
augmented_syscalls__prepare() cannot load the skeleton. Guarding this
subtest with "perf check feature -q bpf_skeletons" would avoid false
failures on builds without BPF skeletons.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124184604.24983-1-acme@kernel.org?part=11
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v1 06/17] perf tests sort: Exercise the report and diff sort keys
2026-11-24 18:45 ` [PATCH v1 06/17] perf tests sort: Exercise the report and diff sort keys Arnaldo Carvalho de Melo
@ 2026-11-24 19:02 ` sashiko-bot
0 siblings, 0 replies; 30+ messages in thread
From: sashiko-bot @ 2026-11-24 19:02 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo; +Cc: linux-perf-users
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] perf tests sort: unconditional type sort key fails without
libdw support
--
commit d19ec29559a834aa0b14ae9d2476eaf1a9318b64
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
perf tests sort: Exercise the report and diff sort keys
This commit adds a shell test that records a workload and runs perf
report and perf diff with a set of common sort keys.
> diff --git a/tools/perf/tests/shell/sort.sh b/tools/perf/tests/shell/sort.sh
> new file mode 100755
> index 0000000000000..19f42ded2b895
> --- /dev/null
> +++ b/tools/perf/tests/shell/sort.sh
> @@ -0,0 +1,72 @@
> +#!/bin/bash
> +# perf report and diff sort key tests
> +# SPDX-License-Identifier: GPL-2.0
> +
> +set -e
> +
> +shelldir=$(dirname "$0")
> +# shellcheck source=lib/perf_has_symbol.sh
> +. "${shelldir}"/lib/perf_has_symbol.sh
> +
> +testprog="perf test -w thloop"
> +testsym="test_loop"
> +sort_keys="pid,comm,dso,symbol,cpu,srcline,period,time,socket,weight,transaction,type,srcfile,cgroup"
[Severity: Medium]
Will including "type" unconditionally in sort_keys cause
test_report_sort() to fail when perf is built without libdw support?
When HAVE_LIBDW_SUPPORT is not defined, cmd_report() rejects the "type"
sort key before generating any report output:
tools/perf/builtin-report.c:cmd_report() {
...
if (sort_order && strstr(sort_order, "type")) {
report.data_type_profile = true;
annotate_opts.annotate_src = false;
#ifndef HAVE_LIBDW_SUPPORT
pr_err("Error: Data type profiling is disabled due to missing DWARF support\n");
goto error;
#endif
...
}
As a result, perf report produces no histogram entries in ${out}, and
grep -q "${testsym}" "${out}" fails. Gating the "type" sort key on
"perf check feature -q dwarf" would avoid failing on builds without
DWARF support.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124184604.24983-1-acme@kernel.org?part=6
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v1 14/17] perf tests bench: Add smoke tests for perf bench
2026-11-24 18:46 ` [PATCH v1 14/17] perf tests bench: Add smoke tests for perf bench Arnaldo Carvalho de Melo
@ 2026-11-24 19:03 ` sashiko-bot
0 siblings, 0 replies; 30+ messages in thread
From: sashiko-bot @ 2026-11-24 19:03 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo; +Cc: linux-perf-users
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [Medium] perf tests bench: uprobe skip check unreachable when
bench_uprobe() returns 0
- [Medium] perf tests bench: incomplete taskset CPU checks for
numa/mem/bind and zero
- [Low] perf tests bench: missing libnuma feature check before numa/mem
benchmarks
- [Low] perf tests bench: missing skip handling for unsupported hardware
breakpoints
--
commit d897107fc32e43a1f8a01917f38114b9c2da689a
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
perf tests bench: Add smoke tests for perf bench
This commit adds a shell smoke test that exercises the numa, sched,
futex, epoll, syscall, mem, internals, breakpoint, and uprobe benchmarks
in perf bench with small workloads.
> diff --git a/tools/perf/tests/shell/bench.sh b/tools/perf/tests/shell/bench.sh
> new file mode 100755
> index 0000000000000..7f5bca2c126a5
> --- /dev/null
> +++ b/tools/perf/tests/shell/bench.sh
> @@ -0,0 +1,130 @@
[ ... ]
> +# Some benchmarks need root, others only report that the hardware is
> +# not there, so treat the environment as a skip and a missing result
> +# as a failure.
> +bench_skip_reasons="No hardware support|perf_event_open: Permission denied"
[ ... ]
> +run_bench numa/mem "GB/sec" numa mem -p 2 -t 2 -P 2 -T 1 -s 1 -l 1
> +run_bench numa/mem/options "GB/sec" numa mem -p 1 -t 1 -P 2 -s 1 -l 1 -c -d -r -z -B -R -W
> +run_bench numa/mem/init "GB/sec" numa mem -p 1 -t 1 -P 2 -s 1 -l 1 -I -H 1 -S -u 1 -B -r -z -Z
[Severity: Low]
Will the numa/mem subtests fail when perf is built without
HAVE_LIBNUMA_SUPPORT? Without libnuma, the numa collection is omitted
from collections[] in tools/perf/builtin-bench.c, so perf bench numa mem
exits with status 1 ("Unknown collection: 'numa'"). Should these
subtests be guarded by checking whether libnuma support is compiled in?
> +if taskset -c 0 true > /dev/null 2>&1; then
> + run_bench numa/mem/bind "GB/sec" numa mem -p 2 -t 2 -P 2 -T 1 -s 1 -l 1 -C 0,1 -M 0,0
> +else
> + echo "Bench numa/mem/bind [Skipped: cpu 0 not available]"
> +fi
> +run_bench numa/mem/convergence "GB/sec" numa mem -p 1 -t 1 -P 512 -l 1 -s 1 -c -m
> +run_bench numa/mem/perturb "GB/sec" numa mem -p 1 -t 1 -P 512 -l 1 -s 1 -x 1 -S -d -d
> +run_bench numa/mem/zero "GB/sec" numa mem -p 1 -t 2 -T 64 -l 1 -s 1 -C 0 -M 0 -B -Z -H -1
[Severity: Medium]
Does the taskset check for numa/mem/bind verify both CPUs passed to
-C 0,1, and should numa/mem/zero also be guarded by a CPU 0 check?
In tools/perf/bench/numa.c, parse_setup_cpu_list() rejects CPU indices
that are offline or >= nr_cpus, and bind_to_cpumask() hits BUG_ON(ret) if
sched_setaffinity() fails. Because the guard only tests taskset -c 0,
numa/mem/bind will fail on single-CPU systems or when CPU 1 is offline or
excluded by the current cpuset. In addition, numa/mem/zero passes -C 0
outside the taskset -c 0 guard, so it will fail when CPU 0 is unavailable.
[ ... ]
> +run_bench breakpoint/thread "Created/joined" breakpoint thread -t 2 -b 2 -p 1
> +run_bench breakpoint/enable "Enabled/disabled" breakpoint enable -p 1 -a 1
[Severity: Low]
Will breakpoint/thread and breakpoint/enable fail instead of skipping on
systems without hardware watchpoints or with only one watchpoint slot?
In tools/perf/bench/breakpoint.c, bench_breakpoint_thread() and
bench_breakpoint_enable() only print "No hardware support" when
perf_event_open() fails with ENODEV, calling perror("perf_event_open")
and exiting with EXIT_FAILURE on other errors. Kernels without
CONFIG_HAVE_HW_BREAKPOINT (such as s390x) fail with ENOENT, systems with
zero data watchpoint slots fail with EOPNOTSUPP, and passing -b 2 to
breakpoint/thread fails with ENOSPC on CPUs with only one data watchpoint
slot (such as PowerPC without CPU_FTR_DAWR1). None of those messages
match bench_skip_reasons.
[ ... ]
> +# The uprobe programs attach to usleep in libc, which needs BPF and,
> +# on distributions using musl, is not available by that name.
> +if perf version --build-options | grep -q 'bpf_skeletons: *\[ on' && [ "$(id -u)" = 0 ]; then
> + for mode in empty trace_printk empty_ret trace_printk_ret; do
> + echo "Bench uprobe/${mode}"
> + if ! perf bench uprobe "${mode}" -l 2 > "${out}" 2>&1; then
> + if grep -qE 'Failed to (attach bench uprobe|load and verify BPF skeleton)' "${out}"; then
> + echo "Bench uprobe/${mode} [Skipped: no uprobe support]"
> + continue
> + fi
> + echo "Bench uprobe/${mode} [Failed: perf bench failed]"
> + cat "${out}"
> + err=1
> + continue
> + fi
> + if ! grep -q "usecs/op" "${out}"; then
> + echo "Bench uprobe/${mode} [Failed missing result]"
> + cat "${out}"
> + err=1
> + continue
> + fi
> + echo "Bench uprobe/${mode} [Success]"
> + done
[Severity: Medium]
Is the skip check for uprobe/${mode} reachable when
bench_uprobe__setup_bpf_skel() fails?
tools/perf/bench/uprobe.c:bench_uprobe() {
...
if (bench != BENCH_UPROBE__BASELINE && bench_uprobe__setup_bpf_skel(bench) < 0)
return 0;
...
}
When loading the BPF skeleton or attaching the uprobe to libc's usleep
fails (for example on musl systems or kernels without uprobe support),
bench_uprobe() still returns 0 without running the benchmark or printing
"usecs/op". Because perf bench uprobe exits with 0, the script skips the
failure branch and fails at the grep -q "usecs/op" check instead of
skipping the subtest.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124184604.24983-1-acme@kernel.org?part=14
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v1 10/17] perf tests record: Exercise more record options
2026-11-24 18:45 ` [PATCH v1 10/17] perf tests record: Exercise more record options Arnaldo Carvalho de Melo
@ 2026-11-24 19:03 ` sashiko-bot
0 siblings, 0 replies; 30+ messages in thread
From: sashiko-bot @ 2026-11-24 19:03 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo; +Cc: linux-perf-users
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [Medium] perf tests record: invalid --switch-output=size=64K in
test_switch_output()
- [Medium] perf tests record: unguarded --aio options fail when
HAVE_AIO_SUPPORT=n
- [Medium] perf tests record: unguarded --threads=numa fails without
NUMA or node CPUs
- [Medium] perf tests record: --threads tests do not raise soft
RLIMIT_NOFILE ulimit
--
commit effd3981a11a3f57fa8f8fe4b22989f457d3f787
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
perf tests record: Exercise more record options
This commit adds a new shell test script, record_options.sh, to exercise
various perf record command-line options.
> diff --git a/tools/perf/tests/shell/record_options.sh b/tools/perf/tests/shell/record_options.sh
> new file mode 100755
> index 0000000000000..b2bf51b5dc44c
> --- /dev/null
> +++ b/tools/perf/tests/shell/record_options.sh
> @@ -0,0 +1,173 @@
[ ... ]
> +test_switch_output() {
> + echo "Record switch output"
> + if ! perf record -q -e cpu-clock -c 1 --switch-output=size=64K \
> + -o "${temp_dir}/sw" -- sleep 0.2
> + then
> + echo "Record switch output [Failed: perf record failed]"
> + err=1
> + return
> + fi
> + if ! ls "${temp_dir}/sw".* > /dev/null 2>&1
> + then
> + echo "Record switch output [Failed: no switched files]"
> + err=1
> + return
> + fi
> + echo "Record switch output [Success]"
> +}
[Severity: Medium]
Does --switch-output=size=64K actually enable size-based output switching
in switch_output_setup()?
switch_output_setup() expects a bare size or time value such as
--switch-output=64K without a "size=" prefix. With "size=64K",
parse_tag_value(s->str, tags_size) fails because strtoul() stops at the
leading 's', and parse_tag_value(s->str, tags_time) then matches the
leading 's' as a 0-second time tag, leaving both s->size and s->time as 0.
Because switch_output_setup() still sets rec->timestamp_filename = true,
perf record renames the single output file to sw.<timestamp> at exit and
the ls check passes without any output switch occurring.
[ ... ]
> +test_record "aio" "aio" --aio=2
[Severity: Medium]
Will this test and the "test_record_option aio-one --aio=1" test below
fail on builds without HAVE_AIO_SUPPORT?
In tools/perf/builtin-record.c, the --aio option is only compiled in when
HAVE_AIO_SUPPORT is defined, so passing --aio unconditionally fails with
an unknown option error when perf is built with NO_AIO=1 or against a
libc without POSIX AIO. Guarding both subtests with
"perf check feature -q aio" would avoid this failure.
> +test_record "threads core" "threads-core" --threads=core
> +test_record "threads package" "threads-package" --threads=package
[Severity: Medium]
Can the --threads subtests fail with EMFILE on high-core-count systems?
Each --threads run opens per-CPU event descriptors, per-CPU directory data
files, and control pipes per worker thread across all online CPUs, which
exceeds the default soft RLIMIT_NOFILE limit of 1024 on systems with 128
or more CPUs unless ulimit -Sn is raised (as record.sh does with
16 * nr_cpus).
> +test_record "threads numa" "threads-numa" --threads=numa
[Severity: Medium]
Can --threads=numa fail on kernels built without CONFIG_NUMA or on systems
with CPU-less NUMA nodes?
record__init_thread_numa_masks() calls numa_topology__new(), which fails
when /sys/devices/system/node/online is absent, and then passes each
online node's cpulist to record__init_thread_masks_spec(), which rejects
empty cpulists on memory-only NUMA nodes with -EINVAL.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124184604.24983-1-acme@kernel.org?part=10
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v1 00/17] perf tests: Add coverage for the untested perf subcommands
2026-11-24 18:45 [PATCH v1 00/17] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
` (16 preceding siblings ...)
2026-11-24 18:46 ` [PATCH v1 17/17] perf tests report: Exercise the TUI browsers Arnaldo Carvalho de Melo
@ 2026-11-24 19:03 ` sashiko-bot
17 siblings, 0 replies; 30+ messages in thread
From: sashiko-bot @ 2026-11-24 19:03 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo; +Cc: linux-perf-users
Sashiko has finished reviewing this 17-patch series:
- Patches 3, 4, 8, 9, 12, and 15: no issues found.
- Patch 1 ("perf tests top: Pin the ring buffer size"): 2 potential
issues (2 Medium)
- Patch 2 ("perf tests sched: Exercise the sched views and options"): 2
potential issues (2 Medium)
- Patch 5 ("perf tests script: Exercise the list, fields and dum..."): 1
potential issue (1 Medium)
- Patch 6 ("perf tests sort: Exercise the report and diff sort keys"): 1
potential issue (1 Medium)
- Patch 7 ("perf tests diff: Exercise the output options"): 3 potential
issues (1 Medium, 2 Low)
- Patch 10 ("perf tests record: Exercise more record options"): 4
potential issues (4 Medium)
- Patch 11 ("perf tests trace: Exercise the tracing options"): 2
potential issues (1 Medium, 1 Low)
- Patch 13 ("perf tests kmem: Add a basic perf kmem test"): 1 potential
issue (1 Low)
- Patch 14 ("perf tests bench: Add smoke tests for perf bench"): 4
potential issues (2 Medium, 2 Low)
- Patch 16 ("perf tests probe: Exercise the variable and line lis..."):
1 potential issue (1 Low)
- Patch 17 ("perf tests report: Exercise the TUI browsers"): 2 potential
issues (2 Medium)
Detailed reviews have been sent as separate replies to patches 1, 2,
5-7, 10, 11, 13, 14, 16, and 17.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124184604.24983-1-acme@kernel.org
^ permalink raw reply [flat|nested] 30+ messages in thread
end of thread, other threads:[~2026-11-24 19:03 UTC | newest]
Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 18:45 [PATCH v1 00/17] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 01/17] perf tests top: Pin the ring buffer size Arnaldo Carvalho de Melo
2026-11-24 19:01 ` sashiko-bot
2026-11-24 18:45 ` [PATCH v1 02/17] perf tests sched: Exercise the sched views and options Arnaldo Carvalho de Melo
2026-11-24 18:58 ` sashiko-bot
2026-11-24 18:45 ` [PATCH v1 03/17] perf tests help: Add a basic perf help test Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 04/17] perf tests config: Exercise the config file and list options Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 05/17] perf tests script: Exercise the list, fields and dump options Arnaldo Carvalho de Melo
2026-11-24 18:54 ` sashiko-bot
2026-11-24 18:45 ` [PATCH v1 06/17] perf tests sort: Exercise the report and diff sort keys Arnaldo Carvalho de Melo
2026-11-24 19:02 ` sashiko-bot
2026-11-24 18:45 ` [PATCH v1 07/17] perf tests diff: Exercise the output options Arnaldo Carvalho de Melo
2026-11-24 18:57 ` sashiko-bot
2026-11-24 18:45 ` [PATCH v1 08/17] perf tests annotate: Exercise the output and filter options Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 09/17] perf tests report: Exercise the output and format options Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 10/17] perf tests record: Exercise more record options Arnaldo Carvalho de Melo
2026-11-24 19:03 ` sashiko-bot
2026-11-24 18:45 ` [PATCH v1 11/17] perf tests trace: Exercise the tracing options Arnaldo Carvalho de Melo
2026-11-24 19:02 ` sashiko-bot
2026-11-24 18:45 ` [PATCH v1 12/17] perf tests timechart: Exercise the report options Arnaldo Carvalho de Melo
2026-11-24 18:46 ` [PATCH v1 13/17] perf tests kmem: Add a basic perf kmem test Arnaldo Carvalho de Melo
2026-11-24 18:57 ` sashiko-bot
2026-11-24 18:46 ` [PATCH v1 14/17] perf tests bench: Add smoke tests for perf bench Arnaldo Carvalho de Melo
2026-11-24 19:03 ` sashiko-bot
2026-11-24 18:46 ` [PATCH v1 15/17] perf tests lock: Exercise perf lock report and info Arnaldo Carvalho de Melo
2026-11-24 18:46 ` [PATCH v1 16/17] perf tests probe: Exercise the variable and line listing Arnaldo Carvalho de Melo
2026-11-24 19:00 ` sashiko-bot
2026-11-24 18:46 ` [PATCH v1 17/17] perf tests report: Exercise the TUI browsers Arnaldo Carvalho de Melo
2026-11-24 19:01 ` sashiko-bot
2026-11-24 19:03 ` [PATCH v1 00/17] perf tests: Add coverage for the untested perf subcommands sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox