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=1796213749; b=fxz+ZK4qfn77Yz0nTmJNPFFSt3Ziq64gyHIprC6e1mL7SJbLd9VnNSsuFjjHMsNbb0r8 /9s7T9lCzKprKpFdss+TXyclo8X3pzlykaNRJr9RhU33RCZn4+ZJi8ngXpUHN3Q4aEl8l XS7EXOpa2tZOHxKRp9y1g53mHk4+lXutFgd8LoE3PWloyxlJnBNRE98BTp4kzsOBRZbsV W0/nUWYuCYMm3JBIPVeddJC6ds92u9YdG1CD2yUv2JbQ4FyQ9M3twbd69QStteyMBZroi iPsmp8c2QdZ3RBEjL7Ept/do8ArzEWGjJQI+pwW1VXlOvjgXibq6n+r/K3JLhvuglvQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796213749; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=fGeDnfE4IEr+kVq9sOFkM7BGCO+LX5Svy/QKDeSPjbs=; b=ZokOva0npjB9XpgaEqJQN6xn0Td1oiIurZHFoyZnFBeZPQDM9h8KQY2Pc0ef3r2unLtm Dn73t43apg3fP3NHyeMROUq1Cs/EIRTwv4ZX8PNmrkpaR0leAAncQIOTJL0HPQaJYvOv/ SG/6D/RuycFr9IsPL/52zYfmh7zTFrdv0GrColUuWVtclTvr/7WMNxGoimoNP0cqWiHE2 aRac+1p0B0oo42yUbCmVHJBiljO68Zn0FQuVpgoXys1ESERwMJ9Kin6A1dUu/JiAWddY0 BXFFnly9KJ+8TnakbtdXGdY8ojdnwmfhjeBzl5lvfG7qNYnQ+3+h5FluztKcgDps8BA== 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="NuJs/Zgl"; 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 9A3A8606A327 for ; Wed, 2 Dec 2026 12:15:49 +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=NuJs/Zgl Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43EBE1F00A15; Wed, 2 Dec 2026 12:15:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796213748; bh=fGeDnfE4IEr+kVq9sOFkM7BGCO+LX5Svy/QKDeSPjbs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NuJs/Zglgf5zeAWvVziFraqdmYegujB1KYwjvIx/rYO2UNQbHcOsiU86msE7Oxctz QdlcxW4xsB0NH4k6ZgjOxYzUPvpwy8/uC1chzt7Z6xj3u6pmRMgW9nrc7GFjBPdu/W N1t8BDcJ/2mn/Gm4JCJlet3vwI1DAaPrev1IGwHrPZ8d99EUpbONN24mY+XKEm4ycD A5mr0bh13sqTVQrgnxS2RUnW/t1WDMAQCEMVcASF4WUaX9Dy7skYAAIDfy7SYJqkI+ 2qgNULw7SdhhhDA512VIHL7YYK7+miqq13s0zuax4mVPNOLyaME/7lp+ODF63ENdyE ojXFB30aDW0Jw== 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 15/18] perf tests bench: Add smoke tests for perf bench Date: Wed, 2 Dec 2026 09:14:31 -0300 Message-ID: <20261202121434.2224-16-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 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. Reviewed-by: Athira Rajeev Tested-by: Athira Rajeev Signed-off-by: Arnaldo Carvalho de Melo --- 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