Linux Perf Users
 help / color / mirror / Atom feed
* [PATCH v2 00/18] perf tests: Add coverage for the untested perf subcommands
@ 2026-11-27  1:37 Arnaldo Carvalho de Melo
  2026-11-27  1:37 ` [PATCH v2 01/18] perf kmem: Use the allocation order when matching page frees Arnaldo Carvalho de Melo
                   ` (18 more replies)
  0 siblings, 19 replies; 22+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-27  1:37 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Clark Williams, linux-perf-users,
	Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <acme@redhat.com>

Hi,

The v13 "perf coverage: A harness for perf, and the fixes it found"
series is posted but still unmerged.  The coverage analysis showed
that several perf subcommands had no shell test coverage at all, and it
also caught issues in the existing tests and in perf kmem.  This series
is that result, made independent of the harness: everything here applies
to perf-tools-next with nothing from v13, so it can be considered on its
own while that series is still being reviewed.

Patch 1 fixes perf kmem, patches 2-3 fix existing tests, patches 4-18
add or extend tests for the subcommands the analysis found untested.
The only production change is (1); the rest is in tools/perf/tests/shell/.

  - perf kmem's page free path looked up the alloc tree with the order
    from the free event but the other key fields from the allocation,
    so a split or reused page missed the entry and the whole stat failed
    with -ENOMEM.  Take the order from the allocation record as well (1).
  - 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 (2).
  - 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 (3).
  - help (4) and config (5) get their first tests; help -a works in
    build trees via a dummy exec path.
  - script list, fields and dump (6), report and diff sort keys (7).
  - diff options (8) 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 (9) and report (10) options the same way; the ones with
    nothing to observe in stdio output run as parse checks.
  - record (11), trace (12) and timechart (13) options.
  - kmem (14) and bench (15) 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 (16) report and info, probe (17) variable and line listing.
  - report TUI (18): the six browsers are driven from a pty.

Running as non-root on this host, 12 of the 17 scripts exit 0; perf
sched, kmem, lock and trace need root and exit 2 with their skip
message, as designed, and timechart exits 2 when perf timechart record
is not permitted.  Running as root, the five root-only scripts and the
two with root-gated subtests all pass, including the page allocator
stats that exposed (1).  All option names and expectations were checked
against the built perf -h output and the sources.

What changed from v1
--------------------
Sashiko found environment-dependent failures in eleven patches; a
review pass found four more, and a final check caught the cleanup
trap turning a missing-symbol skip into a failure.  All are fixed in
place, with no Fixes: or Reported-by: tags added.

  - top (2): -m 512K and --no-bpf-event, so neither the main nor the
    sideband evlist sizes its ring buffer from perf_event_mlock_kb.
  - sched (3): no migration is expected from the pinned workloads, and
    the stats tests skip when /proc/schedstat is absent.
  - script (6), sort (7), kmem (14): disasm, the "type" sort key and
    kmem are gated on libcapstone, DWARF and libtraceevent support.
  - diff (8): cleanup runs before the symbol skips and preserves exit
    2; --time stays in range and checks perf's status, and later
    tests cannot mask failures or run on unrecorded files.
  - record (11): --switch-output=4K with a check that a switch really
    happened, a raised fd limit for parallel streaming, and aio and
    NUMA gates that skip CPU-less nodes.
  - trace (12): the syscall list is one -e argument, not three that
    overwrite each other, and the uid test needs BPF skeletons.
  - timechart (13): the report option tests exit 2 as a skip when
    nothing could be recorded, they were reported as Ok.
  - bench (15): libnuma and CPU gates, hardware breakpoint skips, and
    a missing uprobe result treated as a skip.
  - lock (16): a failing perf lock report or info now fails the test,
    the error trap used to exit with status 0.
  - probe (17): line listing skips when the kernel source is absent.
  - report TUI (18): one user-space event and -q avoid the event menu
    and the kptr_restrict dialog; a closed pty no longer raises EIO.
  - kmem tool (1): a root run of the new test found page frees that
    failed with -ENOMEM; the alloc-tree lookup now uses the order
    recorded at allocation time.

The tests, the three fixes and the review fixes were developed with an
AI coding assistant (OpenCode): it drafted the tests, found the three
issues above and processed five rounds of review findings.  Every
commit was reviewed, amended and run here before posting.

Arnaldo Carvalho de Melo (18):
  perf kmem: Use the allocation order when matching page frees
  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/builtin-kmem.c                 |   6 +
 tools/perf/tests/shell/annotate.sh        |  64 +++++++++
 tools/perf/tests/shell/bench.sh           | 154 ++++++++++++++++++++
 tools/perf/tests/shell/config.sh          | 134 +++++++++++++++++
 tools/perf/tests/shell/diff.sh            | 232 ++++++++++++++++++++++++++++--
 tools/perf/tests/shell/help.sh            |  80 +++++++++++
 tools/perf/tests/shell/kmem.sh            | 222 ++++++++++++++++++++++++++++
 tools/perf/tests/shell/lock_contention.sh |  55 +++++++
 tools/perf/tests/shell/probe_vars.sh      |  87 +++++++++++
 tools/perf/tests/shell/record_options.sh  | 215 +++++++++++++++++++++++++++
 tools/perf/tests/shell/report_options.sh  | 122 +++++++++++++++
 tools/perf/tests/shell/report_tui.sh      | 120 ++++++++++++++++
 tools/perf/tests/shell/sched.sh           | 164 +++++++++++++++------
 tools/perf/tests/shell/script.sh          | 135 +++++++++++++++++-
 tools/perf/tests/shell/sort.sh            |  77 ++++++++++
 tools/perf/tests/shell/timechart.sh       |  46 +++++
 tools/perf/tests/shell/top.sh             |  11 +-
 tools/perf/tests/shell/trace_options.sh   | 103 +++++++++++++
 18 files changed, 1964 insertions(+), 63 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] 22+ messages in thread

* [PATCH v2 01/18] perf kmem: Use the allocation order when matching page frees
  2026-11-27  1:37 [PATCH v2 00/18] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
@ 2026-11-27  1:37 ` Arnaldo Carvalho de Melo
  2026-11-27  1:53   ` sashiko-bot
  2026-11-27  1:37 ` [PATCH v2 02/18] perf tests top: Pin the ring buffer size Arnaldo Carvalho de Melo
                   ` (17 subsequent siblings)
  18 siblings, 1 reply; 22+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-27  1:37 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Clark Williams, linux-perf-users,
	Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <acme@redhat.com>

The page alloc tree is keyed by the values recorded at allocation
time, but the free path looks it up with the order from the free
event while taking the other key fields from the live page record.
When a page is split or reused the orders differ, the lookup misses
and the whole stat fails with a misleading -ENOMEM.

Use the order from the live page record, as is already done for the
gfp flags, migrate type and callsite, so the lookup finds the entry
created at allocation time.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-kmem.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 8693c6b135cad773..3accb5276bd53e5b 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -928,6 +928,12 @@ static int evsel__process_page_free_event(struct perf_sample *sample)
 		return 0;
 	}
 
+	/*
+	 * The alloc tree is keyed by the values recorded at allocation
+	 * time.  Use the order from the live page as well, otherwise a
+	 * free of a split/reused page looks up the wrong entry.
+	 */
+	this.order = pstat->order;
 	this.gfp_flags = pstat->gfp_flags;
 	this.migrate_type = pstat->migrate_type;
 	this.callsite = pstat->callsite;
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v2 02/18] perf tests top: Pin the ring buffer size
  2026-11-27  1:37 [PATCH v2 00/18] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
  2026-11-27  1:37 ` [PATCH v2 01/18] perf kmem: Use the allocation order when matching page frees Arnaldo Carvalho de Melo
@ 2026-11-27  1:37 ` Arnaldo Carvalho de Melo
  2026-11-27  1:37 ` [PATCH v2 03/18] perf tests sched: Exercise the sched views and options Arnaldo Carvalho de Melo
                   ` (16 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-27  1:37 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Clark Williams, 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.  The BPF sideband evlist ignores -m and uses
the same host setting.

Pass -m 512K, a byte size that does not grow with the kernel page size,
and --no-bpf-event to both invocations, 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 | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/tools/perf/tests/shell/top.sh b/tools/perf/tests/shell/top.sh
index 3d52677ccb5fd309..deb0782e991e42fc 100755
--- a/tools/perf/tests/shell/top.sh
+++ b/tools/perf/tests/shell/top.sh
@@ -19,6 +19,11 @@ 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 the data buffer to 512K,
+# a byte size that does not grow with the kernel page size, and disable
+# the BPF sideband evlist, which ignores -m and would still use the host
+# setting.
 test_basic_perf_top() {
 	echo "Basic perf top test"
 
@@ -36,8 +41,8 @@ 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 \
-		-p $PID > "${log_file}" 2>&1 || retval=$?
+	sleep 10 | timeout 5s perf top --stdio -d 1 -m 512K --no-bpf-event \
+		-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)]"
 		head -n 50 "${log_file}"
@@ -83,7 +88,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 512K --no-bpf-event \
 			--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] 22+ messages in thread

* [PATCH v2 03/18] perf tests sched: Exercise the sched views and options
  2026-11-27  1:37 [PATCH v2 00/18] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
  2026-11-27  1:37 ` [PATCH v2 01/18] perf kmem: Use the allocation order when matching page frees Arnaldo Carvalho de Melo
  2026-11-27  1:37 ` [PATCH v2 02/18] perf tests top: Pin the ring buffer size Arnaldo Carvalho de Melo
@ 2026-11-27  1:37 ` Arnaldo Carvalho de Melo
  2026-11-27  1:37 ` [PATCH v2 04/18] perf tests help: Add a basic perf help test Arnaldo Carvalho de Melo
                   ` (15 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-27  1:37 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Clark Williams, 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 | 164 +++++++++++++++++++++++---------
 1 file changed, 121 insertions(+), 43 deletions(-)

diff --git a/tools/perf/tests/shell/sched.sh b/tools/perf/tests/shell/sched.sh
index 113df962a51c878f..cc7b4d1191877771 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,163 @@ 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}"
+  # Both noploop workloads are pinned to CPU 0, so no migration event
+  # is guaranteed to be recorded; just check that -M runs.
+  run_sched "timehist migrations" "" 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}"
+}
 
-  if ! perf sched script -i "${perfdata}" | grep -q perf-noploop
+test_sched_stats_live() {
+  echo "Sched stats live"
+
+  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
+
+# perf sched stats needs /proc/schedstat, which CONFIG_SCHEDSTATS=n
+# kernels do not expose; the record path checks for it but the stats
+# commands do not.
+if [ -r /proc/schedstat ]; then
+  test_sched_stats_live
+  test_sched_stats_record
+  test_sched_stats_report
+  test_sched_stats_diff
+else
+  echo "Sched stats [Skipped: no /proc/schedstat]"
+fi
 
 cleanup
 exit $err
-
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v2 04/18] perf tests help: Add a basic perf help test
  2026-11-27  1:37 [PATCH v2 00/18] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
                   ` (2 preceding siblings ...)
  2026-11-27  1:37 ` [PATCH v2 03/18] perf tests sched: Exercise the sched views and options Arnaldo Carvalho de Melo
@ 2026-11-27  1:37 ` Arnaldo Carvalho de Melo
  2026-11-27  1:37 ` [PATCH v2 05/18] perf tests config: Exercise the config file and list options Arnaldo Carvalho de Melo
                   ` (14 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-27  1:37 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Clark Williams, 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] 22+ messages in thread

* [PATCH v2 05/18] perf tests config: Exercise the config file and list options
  2026-11-27  1:37 [PATCH v2 00/18] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
                   ` (3 preceding siblings ...)
  2026-11-27  1:37 ` [PATCH v2 04/18] perf tests help: Add a basic perf help test Arnaldo Carvalho de Melo
@ 2026-11-27  1:37 ` Arnaldo Carvalho de Melo
  2026-11-27  1:37 ` [PATCH v2 06/18] perf tests script: Exercise the list, fields and dump options Arnaldo Carvalho de Melo
                   ` (13 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-27  1:37 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Clark Williams, 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] 22+ messages in thread

* [PATCH v2 06/18] perf tests script: Exercise the list, fields and dump options
  2026-11-27  1:37 [PATCH v2 00/18] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
                   ` (4 preceding siblings ...)
  2026-11-27  1:37 ` [PATCH v2 05/18] perf tests config: Exercise the config file and list options Arnaldo Carvalho de Melo
@ 2026-11-27  1:37 ` Arnaldo Carvalho de Melo
  2026-11-27  1:37 ` [PATCH v2 07/18] perf tests sort: Exercise the report and diff sort keys Arnaldo Carvalho de Melo
                   ` (12 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-27  1:37 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Clark Williams, 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 | 135 ++++++++++++++++++++++++++++++-
 1 file changed, 133 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/shell/script.sh b/tools/perf/tests/shell/script.sh
index af687c7cfe44c2c6..26fd0b9c7798339e 100755
--- a/tools/perf/tests/shell/script.sh
+++ b/tools/perf/tests/shell/script.sh
@@ -4,6 +4,26 @@
 
 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"
+script_fields="comm,tid,pid,time,cpu,event,ip,sym,dso,dsoff,symoff,period,machine_pid,vcpu,ipc,insn,insnlen,misc,metric,synth,callindent,flags"
+if perf check feature -q libcapstone; then
+	script_fields="${script_fields},disasm"
+fi
+
+skip_test_missing_symbol "${testsym}"
+
 temp_dir=$(mktemp -d /tmp/perf-test-script.XXXXXXXXXX)
 
 err=0
@@ -27,18 +47,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 "${script_fields}" | 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 +175,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] 22+ messages in thread

* [PATCH v2 07/18] perf tests sort: Exercise the report and diff sort keys
  2026-11-27  1:37 [PATCH v2 00/18] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
                   ` (5 preceding siblings ...)
  2026-11-27  1:37 ` [PATCH v2 06/18] perf tests script: Exercise the list, fields and dump options Arnaldo Carvalho de Melo
@ 2026-11-27  1:37 ` Arnaldo Carvalho de Melo
  2026-11-27  1:37 ` [PATCH v2 08/18] perf tests diff: Exercise the output options Arnaldo Carvalho de Melo
                   ` (11 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-27  1:37 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Clark Williams, 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 | 77 ++++++++++++++++++++++++++++++++++
 1 file changed, 77 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..12dbdbc1edfd0045
--- /dev/null
+++ b/tools/perf/tests/shell/sort.sh
@@ -0,0 +1,77 @@
+#!/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,srcfile,cgroup"
+# The "type" sort key turns on data type profiling, which perf rejects
+# outright when built without DWARF support.
+if perf check feature -q dwarf; then
+	sort_keys="${sort_keys},type"
+fi
+
+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] 22+ messages in thread

* [PATCH v2 08/18] perf tests diff: Exercise the output options
  2026-11-27  1:37 [PATCH v2 00/18] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
                   ` (6 preceding siblings ...)
  2026-11-27  1:37 ` [PATCH v2 07/18] perf tests sort: Exercise the report and diff sort keys Arnaldo Carvalho de Melo
@ 2026-11-27  1:37 ` Arnaldo Carvalho de Melo
  2026-11-27  1:37 ` [PATCH v2 09/18] perf tests annotate: Exercise the output and filter options Arnaldo Carvalho de Melo
                   ` (10 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-27  1:37 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Clark Williams, 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 | 232 ++++++++++++++++++++++++++++++---
 1 file changed, 217 insertions(+), 15 deletions(-)

diff --git a/tools/perf/tests/shell/diff.sh b/tools/perf/tests/shell/diff.sh
index 88f37b8ef8936be4..5bddb06166339ce7 100755
--- a/tools/perf/tests/shell/diff.sh
+++ b/tools/perf/tests/shell/diff.sh
@@ -8,14 +8,15 @@ 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"
-
-skip_test_missing_symbol ${testsym}
+testsym2="noploop"
 
 cleanup() {
   rm -rf "${perfdata1}"
@@ -24,25 +25,37 @@ cleanup() {
   rm -rf "${perfdata2}".old
   rm -rf "${perfdata3}"
   rm -rf "${perfdata3}".old
+  rm -f "${diffout}"
 
   trap - EXIT TERM INT
 }
 
 trap_cleanup() {
+  local status=$?
   cleanup
-  exit 1
+  if [ "${status}" -eq 0 ]; then
+    status=1
+  fi
+  exit "${status}"
 }
 trap trap_cleanup EXIT TERM INT
 
+# Install the cleanup trap before the symbol skips, which exit 2, so
+# the mktemp files are removed on that path too.
+skip_test_missing_symbol ${testsym}
+skip_test_missing_symbol ${testsym2}
+
 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,14 +66,16 @@ make_data() {
 
 test_two_files() {
   echo "Basic two file diff test"
-  err=$(make_data "${perfdata1}")
-  if [ "$err" != 0 ]
+  ret=$(make_data "${perfdata1}" "${testprog}" "${testsym}")
+  if [ "$ret" != 0 ]
   then
+    err=1
     return
   fi
-  err=$(make_data "${perfdata2}")
-  if [ "$err" != 0 ]
+  ret=$(make_data "${perfdata2}" "${testprog}" "${testsym}")
+  if [ "$ret" != 0 ]
   then
+    err=1
     return
   fi
 
@@ -75,19 +90,25 @@ test_two_files() {
 
 test_three_files() {
   echo "Basic three file diff test"
-  err=$(make_data "${perfdata1}")
-  if [ "$err" != 0 ]
+  ret=$(make_data "${perfdata1}" "${testprog}" "${testsym}")
+  if [ "$ret" != 0 ]
   then
+    err=1
     return
   fi
-  err=$(make_data "${perfdata2}")
-  if [ "$err" != 0 ]
+  ret=$(make_data "${perfdata2}" "${testprog}" "${testsym}")
+  if [ "$ret" != 0 ]
   then
+    err=1
     return
   fi
-  err=$(make_data "${perfdata3}")
-  if [ $err != 0 ]
+  # 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.
+  ret=$(make_data "${perfdata3}" "${testprog2}" "${testsym2}")
+  if [ "$ret" != 0 ]
   then
+    err=1
     return
   fi
 
@@ -100,8 +121,189 @@ 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
+  # 9999999999 is beyond the recording's timestamps and, unlike a
+  # 19-digit value, does not overflow u64 when scaled to nanoseconds.
+  # Capture the output so a failing perf diff cannot masquerade as an
+  # empty window.
+  if ! perf diff --time 9999999999, "${perfdata1}" "${perfdata2}" > "${diffout}" 2> /dev/null
+  then
+    echo "Diff options test [Failed: --time after the last sample]"
+    err=1
+    return
+  fi
+  if grep -q "${testsym}" "${diffout}"
+  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
 
+if [ -s "${perfdata1}" ] && [ -s "${perfdata2}" ] && [ -s "${perfdata3}" ]; then
+  test_options
+else
+  echo "Diff options test [Skipped: recordings incomplete]"
+fi
+
 cleanup
 exit $err
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v2 09/18] perf tests annotate: Exercise the output and filter options
  2026-11-27  1:37 [PATCH v2 00/18] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
                   ` (7 preceding siblings ...)
  2026-11-27  1:37 ` [PATCH v2 08/18] perf tests diff: Exercise the output options Arnaldo Carvalho de Melo
@ 2026-11-27  1:37 ` Arnaldo Carvalho de Melo
  2026-11-27  1:37 ` [PATCH v2 10/18] perf tests report: Exercise the output and format options Arnaldo Carvalho de Melo
                   ` (9 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-27  1:37 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Clark Williams, 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] 22+ messages in thread

* [PATCH v2 10/18] perf tests report: Exercise the output and format options
  2026-11-27  1:37 [PATCH v2 00/18] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
                   ` (8 preceding siblings ...)
  2026-11-27  1:37 ` [PATCH v2 09/18] perf tests annotate: Exercise the output and filter options Arnaldo Carvalho de Melo
@ 2026-11-27  1:37 ` Arnaldo Carvalho de Melo
  2026-11-27  1:37 ` [PATCH v2 11/18] perf tests record: Exercise more record options Arnaldo Carvalho de Melo
                   ` (8 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-27  1:37 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Clark Williams, 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] 22+ messages in thread

* [PATCH v2 11/18] perf tests record: Exercise more record options
  2026-11-27  1:37 [PATCH v2 00/18] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
                   ` (9 preceding siblings ...)
  2026-11-27  1:37 ` [PATCH v2 10/18] perf tests report: Exercise the output and format options Arnaldo Carvalho de Melo
@ 2026-11-27  1:37 ` Arnaldo Carvalho de Melo
  2026-11-27  1:52   ` sashiko-bot
  2026-11-27  1:37 ` [PATCH v2 12/18] perf tests trace: Exercise the tracing options Arnaldo Carvalho de Melo
                   ` (7 subsequent siblings)
  18 siblings, 1 reply; 22+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-27  1:37 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Clark Williams, 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 | 215 +++++++++++++++++++++++
 1 file changed, 215 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..ccedb1ebc3dad8de
--- /dev/null
+++ b/tools/perf/tests/shell/record_options.sh
@@ -0,0 +1,215 @@
+#!/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
+
+# Parallel streaming opens per-CPU data files and pipes; raise the soft
+# fd limit the way record.sh does.
+default_fd_limit=$(ulimit -Sn)
+min_fd_limit=$(($(getconf _NPROCESSORS_ONLN) * 16))
+if [ "${default_fd_limit}" != unlimited ] &&
+   [ "${default_fd_limit}" -lt "${min_fd_limit}" ]; then
+	ulimit -Sn "${min_fd_limit}"
+fi
+
+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=4K \
+			-o "${temp_dir}/sw" -- sleep 0.2
+	then
+		echo "Record switch output [Failed: perf record failed]"
+		err=1
+		return
+	fi
+	# --switch-output also timestamps the file at exit, so checking for
+	# a sw.<timestamp> file is not enough, there has to be more than one.
+	if [ "$(find "${temp_dir}" -maxdepth 1 -name 'sw.*' | wc -l)" -lt 2 ]
+	then
+		echo "Record switch output [Failed: no switch happened]"
+		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]"
+}
+
+# perf record --threads=numa needs every online NUMA node to have CPUs,
+# a memory-only node (empty cpulist) makes the NUMA topology setup fail,
+# so only run the test when that is the case.
+threads_numa_supported() {
+	local range lo hi n
+
+	[ -r /sys/devices/system/node/online ] || return 1
+
+	local IFS=,
+	for range in $(cat /sys/devices/system/node/online); do
+		lo=${range%%-*}
+		hi=${range##*-}
+		for ((n = lo; n <= hi; n++)); do
+			[ -s "/sys/devices/system/node/node${n}/cpulist" ] || return 1
+		done
+	done
+	return 0
+}
+
+if perf check feature -q aio; then
+	test_record "aio" "aio" --aio=2
+else
+	echo "Record aio [Skipped: no aio support]"
+fi
+test_record "threads core" "threads-core" --threads=core
+test_record "threads package" "threads-package" --threads=package
+if threads_numa_supported; then
+	test_record "threads numa" "threads-numa" --threads=numa
+else
+	echo "Record threads numa [Skipped: no NUMA topology with CPUs]"
+fi
+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
+if perf check feature -q aio; then
+	test_record_option aio-one --aio=1
+else
+	echo "Record option aio-one [Skipped: no aio support]"
+fi
+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] 22+ messages in thread

* [PATCH v2 12/18] perf tests trace: Exercise the tracing options
  2026-11-27  1:37 [PATCH v2 00/18] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
                   ` (10 preceding siblings ...)
  2026-11-27  1:37 ` [PATCH v2 11/18] perf tests record: Exercise more record options Arnaldo Carvalho de Melo
@ 2026-11-27  1:37 ` Arnaldo Carvalho de Melo
  2026-11-27  1:37 ` [PATCH v2 13/18] perf tests timechart: Exercise the report options Arnaldo Carvalho de Melo
                   ` (6 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-27  1:37 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Clark Williams, 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 | 103 ++++++++++++++++++++++++
 1 file changed, 103 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..5935f9ced6effa03
--- /dev/null
+++ b/tools/perf/tests/shell/trace_options.sh
@@ -0,0 +1,103 @@
+#!/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
+# -e is a callback that replaces ev_qualifier, so the syscall list must
+# be a single comma-separated argument rather than three -e flags.
+run_trace "events" "openat" -e openat,read,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
+if perf check feature -q bpf_skeletons; then
+	run_trace "uid" "" -u "$(id -un)" -- true
+else
+	echo "Trace uid [Skipped: no BPF skeleton support]"
+fi
+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] 22+ messages in thread

* [PATCH v2 13/18] perf tests timechart: Exercise the report options
  2026-11-27  1:37 [PATCH v2 00/18] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
                   ` (11 preceding siblings ...)
  2026-11-27  1:37 ` [PATCH v2 12/18] perf tests trace: Exercise the tracing options Arnaldo Carvalho de Melo
@ 2026-11-27  1:37 ` Arnaldo Carvalho de Melo
  2026-11-27  1:37 ` [PATCH v2 14/18] perf tests kmem: Add a basic perf kmem test Arnaldo Carvalho de Melo
                   ` (5 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-27  1:37 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Clark Williams, 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..c55ddc5f923b2bcc 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 2
+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] 22+ messages in thread

* [PATCH v2 14/18] perf tests kmem: Add a basic perf kmem test
  2026-11-27  1:37 [PATCH v2 00/18] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
                   ` (12 preceding siblings ...)
  2026-11-27  1:37 ` [PATCH v2 13/18] perf tests timechart: Exercise the report options Arnaldo Carvalho de Melo
@ 2026-11-27  1:37 ` Arnaldo Carvalho de Melo
  2026-11-27  1:37 ` [PATCH v2 15/18] perf tests bench: Add smoke tests for perf bench Arnaldo Carvalho de Melo
                   ` (4 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-27  1:37 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Clark Williams, 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 | 222 +++++++++++++++++++++++++++++++++
 1 file changed, 222 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..196f1a723930161b
--- /dev/null
+++ b/tools/perf/tests/shell/kmem.sh
@@ -0,0 +1,222 @@
+#!/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
+
+# Without libtraceevent cmd_kmem is a stub that fails instead of
+# reporting the tracepoints below as unavailable.
+if ! perf check feature -q libtraceevent; then
+	echo "[Skip] No libtraceevent support"
+	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] 22+ messages in thread

* [PATCH v2 15/18] perf tests bench: Add smoke tests for perf bench
  2026-11-27  1:37 [PATCH v2 00/18] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
                   ` (13 preceding siblings ...)
  2026-11-27  1:37 ` [PATCH v2 14/18] perf tests kmem: Add a basic perf kmem test Arnaldo Carvalho de Melo
@ 2026-11-27  1:37 ` Arnaldo Carvalho de Melo
  2026-11-27  1:37 ` [PATCH v2 16/18] perf tests lock: Exercise perf lock report and info Arnaldo Carvalho de Melo
                   ` (3 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-27  1:37 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Clark Williams, 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 | 154 ++++++++++++++++++++++++++++++++
 1 file changed, 154 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..2a9c402c99f24a34
--- /dev/null
+++ b/tools/perf/tests/shell/bench.sh
@@ -0,0 +1,154 @@
+#!/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|perf_event_open: No such file or directory|perf_event_open: Operation not supported|perf_event_open: No space left on device"
+
+# The NUMA benchmarks are compiled out without libnuma, and some pass
+# explicit CPU numbers that must be online and in the current cpuset.
+numa_ok=0
+if perf check feature -q libnuma; then
+	numa_ok=1
+fi
+cpu0_ok=0
+cpu1_ok=0
+if taskset -c 0 true > /dev/null 2>&1; then
+	cpu0_ok=1
+fi
+if taskset -c 1 true > /dev/null 2>&1; then
+	cpu1_ok=1
+fi
+
+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]"
+}
+
+if [ "${numa_ok}" -eq 1 ]; then
+	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 [ "${cpu0_ok}" -eq 1 ] && [ "${cpu1_ok}" -eq 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 and 1 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
+	if [ "${cpu0_ok}" -eq 1 ]; then
+		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
+	else
+		echo "Bench numa/mem/zero [Skipped: cpu 0 not available]"
+	fi
+else
+	echo "Bench numa/mem [Skipped: no libnuma support]"
+fi
+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
+			# bench_uprobe() returns 0 when the skeleton loads but the
+			# uprobe cannot be attached, so a missing result here is
+			# an unsupported environment, not a test failure.
+			echo "Bench uprobe/${mode} [Skipped: no result]"
+			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] 22+ messages in thread

* [PATCH v2 16/18] perf tests lock: Exercise perf lock report and info
  2026-11-27  1:37 [PATCH v2 00/18] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
                   ` (14 preceding siblings ...)
  2026-11-27  1:37 ` [PATCH v2 15/18] perf tests bench: Add smoke tests for perf bench Arnaldo Carvalho de Melo
@ 2026-11-27  1:37 ` Arnaldo Carvalho de Melo
  2026-11-27  1:38 ` [PATCH v2 17/18] perf tests probe: Exercise the variable and line listing Arnaldo Carvalho de Melo
                   ` (2 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-27  1:37 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Clark Williams, 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 | 55 +++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/tools/perf/tests/shell/lock_contention.sh b/tools/perf/tests/shell/lock_contention.sh
index 5df9a0cd48a34f4f..ebff99bd3688bb94 100755
--- a/tools/perf/tests/shell/lock_contention.sh
+++ b/tools/perf/tests/shell/lock_contention.sh
@@ -65,6 +65,59 @@ 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
+		if ! perf lock report -i ${perfdata} -k ${key} -E 5 2> ${result}
+		then
+			echo "[Fail] perf lock report --key ${key} failed"
+			err=1
+			return
+		fi
+		if ! grep -q "Name" "${result}"; then
+			echo "[Fail] perf lock report --key ${key} has no output:" "$(cat "${result}")"
+			err=1
+			exit
+		fi
+	done
+
+	if ! perf lock report -i ${perfdata} -c -v -E 5 2> ${result}
+	then
+		echo "[Fail] perf lock report --combine-locks failed"
+		err=1
+		return
+	fi
+	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"
+	if ! perf lock info -i ${perfdata} 2> ${result}
+	then
+		echo "[Fail] perf lock info failed"
+		err=1
+		return
+	fi
+	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 +400,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] 22+ messages in thread

* [PATCH v2 17/18] perf tests probe: Exercise the variable and line listing
  2026-11-27  1:37 [PATCH v2 00/18] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
                   ` (15 preceding siblings ...)
  2026-11-27  1:37 ` [PATCH v2 16/18] perf tests lock: Exercise perf lock report and info Arnaldo Carvalho de Melo
@ 2026-11-27  1:38 ` Arnaldo Carvalho de Melo
  2026-11-27  1:38 ` [PATCH v2 18/18] perf tests report: Exercise the TUI browsers Arnaldo Carvalho de Melo
  2026-11-27  1:53 ` [PATCH v2 00/18] perf tests: Add coverage for the untested perf subcommands sashiko-bot
  18 siblings, 0 replies; 22+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-27  1:38 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Clark Williams, 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 | 87 ++++++++++++++++++++++++++++
 1 file changed, 87 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..bacf055d84bd92cb
--- /dev/null
+++ b/tools/perf/tests/shell/probe_vars.sh
@@ -0,0 +1,87 @@
+#!/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
+
+# -V only reads DWARF, while -L also opens the C source file at the path
+# recorded in the debug info, which may not be installed.
+if perf probe -L schedule > "${out}" 2>&1; then
+	run_probe "line" "schedule" -L schedule
+	run_probe "line long option" "schedule" --line schedule
+else
+	echo "Probe line listing [Skipped: no kernel source for schedule]"
+fi
+
+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] 22+ messages in thread

* [PATCH v2 18/18] perf tests report: Exercise the TUI browsers
  2026-11-27  1:37 [PATCH v2 00/18] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
                   ` (16 preceding siblings ...)
  2026-11-27  1:38 ` [PATCH v2 17/18] perf tests probe: Exercise the variable and line listing Arnaldo Carvalho de Melo
@ 2026-11-27  1:38 ` Arnaldo Carvalho de Melo
  2026-11-27  1:53 ` [PATCH v2 00/18] perf tests: Add coverage for the untested perf subcommands sashiko-bot
  18 siblings, 0 replies; 22+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-27  1:38 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Clark Williams, 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 | 120 +++++++++++++++++++++++++++
 1 file changed, 120 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..bc96e1452ee93b97
--- /dev/null
+++ b/tools/perf/tests/shell/report_tui.sh
@@ -0,0 +1,120 @@
+#!/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:
+			# The browser may exit before all keys are consumed,
+			# which closes the pty and makes os.write() raise EIO.
+			try:
+				os.write(fd, keys[:1])
+			except OSError:
+				break
+			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"
+# One user-space event keeps perf.data from opening the multi-event
+# selection menu on hybrid systems; -q on report suppresses startup
+# dialogs such as the kptr_restrict warning that would eat a key.
+if ! perf record -q -e cpu-clock:u -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 -q --tui -i "${perfdata}"
+run_tui "report help" "?qq" "Help" perf report -q --tui -i "${perfdata}"
+run_tui "report dso zoom" "dq" "Overhead" perf report -q --tui -i "${perfdata}"
+run_tui "report thread zoom" "tq" "Overhead" perf report -q --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] 22+ messages in thread

* Re: [PATCH v2 11/18] perf tests record: Exercise more record options
  2026-11-27  1:37 ` [PATCH v2 11/18] perf tests record: Exercise more record options Arnaldo Carvalho de Melo
@ 2026-11-27  1:52   ` sashiko-bot
  0 siblings, 0 replies; 22+ messages in thread
From: sashiko-bot @ 2026-11-27  1:52 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 record: always-true test -s on sysfs cpulist in
  threads_numa_supported()
- [Medium] perf tests record: unreliable 4K switch threshold in
  test_switch_output()
--

commit 9516ae4b075b086c3162b32da08e72df6c1965fa
Author: Arnaldo Carvalho de Melo <acme@redhat.com>

perf tests record: Exercise more record options

This commit adds a new shell test script that exercises additional 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..ccedb1ebc3dad
> --- /dev/null
> +++ b/tools/perf/tests/shell/record_options.sh
> @@ -0,0 +1,215 @@

[ ... ]

> +test_switch_output() {
> +	echo "Record switch output"
> +	if ! perf record -q -e cpu-clock -c 1 --switch-output=4K \
> +			-o "${temp_dir}/sw" -- sleep 0.2
> +	then
> +		echo "Record switch output [Failed: perf record failed]"
> +		err=1
> +		return
> +	fi
> +	# --switch-output also timestamps the file at exit, so checking for
> +	# a sw.<timestamp> file is not enough, there has to be more than one.
> +	if [ "$(find "${temp_dir}" -maxdepth 1 -name 'sw.*' | wc -l)" -lt 2 ]
> +	then
> +		echo "Record switch output [Failed: no switch happened]"
> +		err=1
> +		return
> +	fi
> +	echo "Record switch output [Success]"
> +}

[Severity: Medium]
Can test_switch_output() produce only one sw.<timestamp> file and fail on
systems with few or no loaded kernel modules?

Without -a, cpu-clock only fires while sleep 0.2 is on-CPU during exec
and exit, so reaching the 4K threshold before the workload finishes
depends on synthesized startup module MMAP events exceeding 4KB.  When
startup synthesis is smaller than 4KB, any threshold switch is deferred
until ring-buffer drain at child exit and runs back-to-back with the
final at-exit switch; because fetch_current_timestamp() uses 10ms
granularity, both switches generate the same sw.<timestamp> filename and
rename() overwrites the first file.

[ ... ]

> +# perf record --threads=numa needs every online NUMA node to have CPUs,
> +# a memory-only node (empty cpulist) makes the NUMA topology setup fail,
> +# so only run the test when that is the case.
> +threads_numa_supported() {
> +	local range lo hi n
> +
> +	[ -r /sys/devices/system/node/online ] || return 1
> +
> +	local IFS=,
> +	for range in $(cat /sys/devices/system/node/online); do
> +		lo=${range%%-*}
> +		hi=${range##*-}
> +		for ((n = lo; n <= hi; n++)); do
> +			[ -s "/sys/devices/system/node/node${n}/cpulist" ] || return 1
> +		done
> +	done
> +	return 0
> +}

[Severity: Medium]
Does [ -s "/sys/devices/system/node/node${n}/cpulist" ] always evaluate
to true, even on memory-only NUMA nodes?

In drivers/base/node.c, cpulist is declared with BIN_ATTR_RO(cpulist,
CPULIST_FILE_MAX_BYTES), so stat() always reports st_size >= PAGE_SIZE
(and reading an empty node's cpulist outputs a single newline byte).  On
a system with an online CPU-less NUMA node, threads_numa_supported()
still returns 0 and perf record --threads=numa fails in
record__init_thread_masks_spec() with -EINVAL.  Checking that the file
contents are non-empty after stripping the newline (for example,
[ -n "$(cat "/sys/devices/system/node/node${n}/cpulist")" ]) would detect
CPU-less nodes.

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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v2 01/18] perf kmem: Use the allocation order when matching page frees
  2026-11-27  1:37 ` [PATCH v2 01/18] perf kmem: Use the allocation order when matching page frees Arnaldo Carvalho de Melo
@ 2026-11-27  1:53   ` sashiko-bot
  0 siblings, 0 replies; 22+ messages in thread
From: sashiko-bot @ 2026-11-27  1:53 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 kmem: mismatched live byte accounting in
  evsel__process_page_free_event()
- [Medium] perf kmem: stale order on reused page_live_tree entry causes
  -ENOENT on free
- [Low] perf kmem: missing Fixes: trailer in commit message
--

commit 638b1c81610cb380bfc3f707e98e97a94a357759
Author: Arnaldo Carvalho de Melo <acme@redhat.com>

> perf kmem: Use the allocation order when matching page frees
>
> The page alloc tree is keyed by the values recorded at allocation
> time, but the free path looks it up with the order from the free
> event while taking the other key fields from the live page record.
> When a page is split or reused the orders differ, the lookup misses
> and the whole stat fails with a misleading -ENOMEM.
>
> Use the order from the live page record, as is already done for the
> gfp flags, migrate type and callsite, so the lookup finds the entry
> created at allocation time.
>
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

[Severity: Low]
Should this include a Fixes tag for the commit that introduced page
allocator event tracking?

  Fixes: 0d68bc92c481 ("perf kmem: Analyze page allocator events also")

> diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
> index 8693c6b135cad..3accb5276bd53 100644
> --- a/tools/perf/builtin-kmem.c
> +++ b/tools/perf/builtin-kmem.c
> @@ -928,6 +928,12 @@ static int evsel__process_page_free_event(struct perf_sample *sample)
>  		return 0;
>  	}
>  
> +	/*
> +	 * The alloc tree is keyed by the values recorded at allocation
> +	 * time.  Use the order from the live page as well, otherwise a
> +	 * free of a split/reused page looks up the wrong entry.
> +	 */
> +	this.order = pstat->order;
>  	this.gfp_flags = pstat->gfp_flags;
>  	this.migrate_type = pstat->migrate_type;
>  	this.callsite = pstat->callsite;

[Severity: Medium]
Does live_page accounting in evsel__process_page_free_event() corrupt
pstat->alloc_bytes when the free order differs from pstat->order?

bytes is still computed from the free event's order (kmem_page_size <<
order), while page_stat__find_caller(&this) now looks up the caller entry
for this.order:

tools/perf/builtin-kmem.c:evsel__process_page_free_event() {
	...
	if (live_page) {
		pstat->nr_alloc--;
		pstat->alloc_bytes -= bytes;

		if (pstat->nr_alloc == 0) {
			rb_erase(&pstat->node, &page_caller_tree);
			free(pstat);
		}
	}
}

When a higher-order allocation is split and freed in smaller chunks, only
the head page matches in page_live_tree and is erased, so pstat->nr_alloc
drops by one full allocation while pstat->alloc_bytes only subtracts the
smaller free size.  If a coalesced free has order > this.order while
another allocation on the same caller entry remains live, subtracting
bytes underflows pstat->alloc_bytes.

[Severity: Medium]
Can page_stat__find_caller(&this) fail with -ENOENT when a page already
present in page_live_tree is reused with a different order and callsite?

When page_stat__findnew_page() finds an existing entry in page_live_tree
(for example, when frees were not captured due to sampling or a tail page
was freed as part of a coalesced higher-order block),
__page_stat__findnew_page() returns the existing node without updating
data->order, data->gfp_flags, or data->migrate_type, while
evsel__process_page_alloc_event() overwrites pstat->callsite and inserts
into page_caller_tree using the new order and callsite:

tools/perf/builtin-kmem.c:evsel__process_page_alloc_event() {
	...
	this.page = page;
	pstat = page_stat__findnew_page(&this);
	if (pstat == NULL)
		return -ENOMEM;

	pstat->nr_alloc++;
	pstat->alloc_bytes += bytes;
	pstat->callsite = callsite;
	...
	this.callsite = callsite;
	pstat = page_stat__findnew_caller(&this);

On the next free of that page, evsel__process_page_free_event() combines
the old pstat->order with the new pstat->callsite, producing a hybrid key
that does not exist in page_caller_tree and aborting stat processing with
-ENOENT.

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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v2 00/18] perf tests: Add coverage for the untested perf subcommands
  2026-11-27  1:37 [PATCH v2 00/18] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
                   ` (17 preceding siblings ...)
  2026-11-27  1:38 ` [PATCH v2 18/18] perf tests report: Exercise the TUI browsers Arnaldo Carvalho de Melo
@ 2026-11-27  1:53 ` sashiko-bot
  18 siblings, 0 replies; 22+ messages in thread
From: sashiko-bot @ 2026-11-27  1:53 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: linux-perf-users

Sashiko has finished reviewing this 18-patch series:

- Patches 2-10 and 12-18: no issues found.
- Patch 1 ("perf kmem: Use the allocation order when matching pa..."): 3
  potential issues (2 Medium, 1 Low)
- Patch 11 ("perf tests record: Exercise more record options"): 2
  potential issues (2 Medium)

Detailed reviews have been sent as separate replies to patches 1 and 11.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261127013801.14841-1-acme@kernel.org

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2026-11-27  1:53 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27  1:37 [PATCH v2 00/18] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
2026-11-27  1:37 ` [PATCH v2 01/18] perf kmem: Use the allocation order when matching page frees Arnaldo Carvalho de Melo
2026-11-27  1:53   ` sashiko-bot
2026-11-27  1:37 ` [PATCH v2 02/18] perf tests top: Pin the ring buffer size Arnaldo Carvalho de Melo
2026-11-27  1:37 ` [PATCH v2 03/18] perf tests sched: Exercise the sched views and options Arnaldo Carvalho de Melo
2026-11-27  1:37 ` [PATCH v2 04/18] perf tests help: Add a basic perf help test Arnaldo Carvalho de Melo
2026-11-27  1:37 ` [PATCH v2 05/18] perf tests config: Exercise the config file and list options Arnaldo Carvalho de Melo
2026-11-27  1:37 ` [PATCH v2 06/18] perf tests script: Exercise the list, fields and dump options Arnaldo Carvalho de Melo
2026-11-27  1:37 ` [PATCH v2 07/18] perf tests sort: Exercise the report and diff sort keys Arnaldo Carvalho de Melo
2026-11-27  1:37 ` [PATCH v2 08/18] perf tests diff: Exercise the output options Arnaldo Carvalho de Melo
2026-11-27  1:37 ` [PATCH v2 09/18] perf tests annotate: Exercise the output and filter options Arnaldo Carvalho de Melo
2026-11-27  1:37 ` [PATCH v2 10/18] perf tests report: Exercise the output and format options Arnaldo Carvalho de Melo
2026-11-27  1:37 ` [PATCH v2 11/18] perf tests record: Exercise more record options Arnaldo Carvalho de Melo
2026-11-27  1:52   ` sashiko-bot
2026-11-27  1:37 ` [PATCH v2 12/18] perf tests trace: Exercise the tracing options Arnaldo Carvalho de Melo
2026-11-27  1:37 ` [PATCH v2 13/18] perf tests timechart: Exercise the report options Arnaldo Carvalho de Melo
2026-11-27  1:37 ` [PATCH v2 14/18] perf tests kmem: Add a basic perf kmem test Arnaldo Carvalho de Melo
2026-11-27  1:37 ` [PATCH v2 15/18] perf tests bench: Add smoke tests for perf bench Arnaldo Carvalho de Melo
2026-11-27  1:37 ` [PATCH v2 16/18] perf tests lock: Exercise perf lock report and info Arnaldo Carvalho de Melo
2026-11-27  1:38 ` [PATCH v2 17/18] perf tests probe: Exercise the variable and line listing Arnaldo Carvalho de Melo
2026-11-27  1:38 ` [PATCH v2 18/18] perf tests report: Exercise the TUI browsers Arnaldo Carvalho de Melo
2026-11-27  1:53 ` [PATCH v2 00/18] 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