From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
James Clark <james.clark@linaro.org>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Clark Williams <williams@redhat.com>,
linux-perf-users@vger.kernel.org,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Athira Rajeev <atrajeev@linux.ibm.com>
Subject: [PATCH v3 11/18] perf tests record: Exercise more record options
Date: Wed, 2 Dec 2026 09:14:27 -0300 [thread overview]
Message-ID: <20261202121434.2224-12-acme@kernel.org> (raw)
In-Reply-To: <20261202121434.2224-1-acme@kernel.org>
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, switch output
and clockid variants.
Reviewed-by: Athira Rajeev <atrajeev@linux.ibm.com>
Tested-by: Athira Rajeev <atrajeev@linux.ibm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/shell/record_options.sh | 218 +++++++++++++++++++++++
1 file changed, 218 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..dea7fb50580dbd27
--- /dev/null
+++ b/tools/perf/tests/shell/record_options.sh
@@ -0,0 +1,218 @@
+#!/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"
+ # noploop keeps the workload on-CPU for a second, so the 4K
+ # threshold is crossed during the run and does not depend on the
+ # size of the synthesized startup events.
+ if ! perf record -q -e cpu-clock -c 1000 --switch-output=4K \
+ -o "${temp_dir}/sw" -- perf test -w noploop 1
+ 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
+ [ -n "$(cat "/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
next prev parent reply other threads:[~2026-12-02 12:15 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 12:14 [PATCH v3 00/18] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
2026-12-02 12:14 ` [PATCH v3 01/18] perf kmem: Use the allocation order when matching page frees Arnaldo Carvalho de Melo
2026-12-02 12:14 ` [PATCH v3 02/18] perf tests top: Pin the ring buffer size Arnaldo Carvalho de Melo
2026-12-02 12:14 ` [PATCH v3 03/18] perf tests sched: Exercise the sched views and options Arnaldo Carvalho de Melo
2026-12-02 12:14 ` [PATCH v3 04/18] perf tests help: Add a basic perf help test Arnaldo Carvalho de Melo
2026-12-02 12:14 ` [PATCH v3 05/18] perf tests config: Exercise the config file and list options Arnaldo Carvalho de Melo
2026-12-02 12:14 ` [PATCH v3 06/18] perf tests script: Exercise the list, fields and dump options Arnaldo Carvalho de Melo
2026-12-02 12:14 ` [PATCH v3 07/18] perf tests sort: Exercise the report and diff sort keys Arnaldo Carvalho de Melo
2026-12-02 12:14 ` [PATCH v3 08/18] perf tests diff: Exercise the output options Arnaldo Carvalho de Melo
2026-12-02 12:14 ` [PATCH v3 09/18] perf tests annotate: Exercise the output and filter options Arnaldo Carvalho de Melo
2026-12-02 12:14 ` [PATCH v3 10/18] perf tests report: Exercise the output and format options Arnaldo Carvalho de Melo
2026-12-02 12:14 ` Arnaldo Carvalho de Melo [this message]
2026-12-02 12:14 ` [PATCH v3 12/18] perf tests trace: Exercise the tracing options Arnaldo Carvalho de Melo
2026-12-02 12:14 ` [PATCH v3 13/18] perf tests timechart: Exercise the report options Arnaldo Carvalho de Melo
2026-12-02 12:14 ` [PATCH v3 14/18] perf tests kmem: Add a basic perf kmem test Arnaldo Carvalho de Melo
2026-12-02 12:14 ` [PATCH v3 15/18] perf tests bench: Add smoke tests for perf bench Arnaldo Carvalho de Melo
2026-12-02 12:14 ` [PATCH v3 16/18] perf tests lock: Exercise perf lock report and info Arnaldo Carvalho de Melo
2026-12-02 12:14 ` [PATCH v3 17/18] perf tests probe: Exercise the variable and line listing Arnaldo Carvalho de Melo
2026-12-02 12:14 ` [PATCH v3 18/18] perf tests report: Exercise the TUI browsers Arnaldo Carvalho de Melo
2026-12-02 12:30 ` [PATCH v3 00/18] perf tests: Add coverage for the untested perf subcommands sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261202121434.2224-12-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=atrajeev@linux.ibm.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=tglx@linutronix.de \
--cc=williams@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.