From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796213731; b=fHFzNFrFkFR157FzzSsT3bi40bPHbM/BjUlAUfuJd+dSPnvTnTw8M8kXAe8c4zONRPLQ JKv5fsmuNYkU9LotkdvhnCWXi8r5jbc3JYh2osuDSynOb21rYfINGCOVW3EitjzUAapYp 4oZFyxR/IZAXEp1+X8o3jc1iopKnwr7vWs8HZf2ZJwVTNLJ6El5H+gbLgWoR8O6+8/NEo ULXjr1ud82QOqJTWQjI7+R36raTaxnxvVUxA2/UWlYoH7vWcA2pjYbxN7PaolxNGShnOt lCOdhIUJNyXimic7kAQuQARYyqLopKYQHYj01pLL1/GPIh9xoQc3BOB+DDRQ4OkKtQg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796213731; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=VFy2SikHC2MFc47eUZRwRWPPL4iS2KbE1gKkbMJfZkc=; b=ThZiz1ZBm4xuYXIvfiY98muuPFdmoBhUcXIN2BmFk/OdxC1jz6ka0EixHggyfGLOj5cf BCWBC53kcd5aSzfzYW1BYFaVbfeA6tGKs64MTzPxHOWFkDGwb3G52mHni2KVGN7vb6DZJ MtFruu1oasxJhHWfTBNSKaEFb3LjnDvE/0PPW3lw+4JPdSk7m+YKbX44JNwEYexd7+AzP GvhUMibWoK06Rp2rs4OIV12QBbMIy1M+JH7VrmL3PMijNio4aBazDzqgKNLT3qOdux7Qq MjAmwRYXkcOIBtXh5Z4P3cO5Diq+EhfSMPe4PJqZU4dSpJI5KBfF6XqpNQ17gjqjsgg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jCCYADSb; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2FAA6606A31A for ; Wed, 2 Dec 2026 12:15:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jCCYADSb Received: by smtp.kernel.org (Postfix) with ESMTPSA id 307181F00897; Wed, 2 Dec 2026 12:15:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796213730; bh=VFy2SikHC2MFc47eUZRwRWPPL4iS2KbE1gKkbMJfZkc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=jCCYADSb6AYpHgiUZquKWO/65gxgHHC1wqmDfEyPzQMjO+vFGT2Yutr3oFOoul4rx xYSCDtt1YqK/L/kdV+p6vIPS6yf/5UiL0ll9czMrcYyITT+JPRpVDVehXPlgxz3K1z Nov1+PxwAMe4xfHeEMdTs4lDAKvkGZRGetHCninSlEYh43ogflmx3GVjaswZJZHN6l mmn5aEHNXX/6exHZh7dv37+LiKdqDeXSlEZYKcJj8yIL1MOopt+in0qtUtScwmFU4w jz3MckLkOUcWIv19uQkTU0hs+ax+N/H0IQxbZ6O512KE8cOCUIiWPZs3CotlzH/jqU 2ID45vq8Hcuhw== From: Arnaldo Carvalho de Melo To: Namhyung Kim Cc: Ingo Molnar , Thomas Gleixner , James Clark , Jiri Olsa , Ian Rogers , Adrian Hunter , Clark Williams , linux-perf-users@vger.kernel.org, Arnaldo Carvalho de Melo , Athira Rajeev Subject: [PATCH v3 11/18] perf tests record: Exercise more record options Date: Wed, 2 Dec 2026 09:14:27 -0300 Message-ID: <20261202121434.2224-12-acme@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261202121434.2224-1-acme@kernel.org> References: <20261202121434.2224-1-acme@kernel.org> X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Arnaldo Carvalho de Melo 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 Tested-by: Athira Rajeev Signed-off-by: Arnaldo Carvalho de Melo --- 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. 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