Linux Perf Users
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Arnaldo Carvalho de Melo" <acme@kernel.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v1 14/17] perf tests bench: Add smoke tests for perf bench
Date: Tue, 24 Nov 2026 19:03:28 +0000	[thread overview]
Message-ID: <sashiko-outbox-231874@kernel.org> (raw)
In-Reply-To: <20261124184604.24983-15-acme@kernel.org>

Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [Medium] perf tests bench: uprobe skip check unreachable when
  bench_uprobe() returns 0
- [Medium] perf tests bench: incomplete taskset CPU checks for
  numa/mem/bind and zero
- [Low] perf tests bench: missing libnuma feature check before numa/mem
  benchmarks
- [Low] perf tests bench: missing skip handling for unsupported hardware
  breakpoints
--

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

perf tests bench: Add smoke tests for perf bench

This commit adds a shell smoke test that exercises the numa, sched,
futex, epoll, syscall, mem, internals, breakpoint, and uprobe benchmarks
in perf bench with small workloads.

> diff --git a/tools/perf/tests/shell/bench.sh b/tools/perf/tests/shell/bench.sh
> new file mode 100755
> index 0000000000000..7f5bca2c126a5
> --- /dev/null
> +++ b/tools/perf/tests/shell/bench.sh
> @@ -0,0 +1,130 @@

[ ... ]

> +# Some benchmarks need root, others only report that the hardware is
> +# not there, so treat the environment as a skip and a missing result
> +# as a failure.
> +bench_skip_reasons="No hardware support|perf_event_open: Permission denied"

[ ... ]

> +run_bench numa/mem "GB/sec" numa mem -p 2 -t 2 -P 2 -T 1 -s 1 -l 1
> +run_bench numa/mem/options "GB/sec" numa mem -p 1 -t 1 -P 2 -s 1 -l 1 -c -d -r -z -B -R -W
> +run_bench numa/mem/init "GB/sec" numa mem -p 1 -t 1 -P 2 -s 1 -l 1 -I -H 1 -S -u 1 -B -r -z -Z

[Severity: Low]
Will the numa/mem subtests fail when perf is built without
HAVE_LIBNUMA_SUPPORT?  Without libnuma, the numa collection is omitted
from collections[] in tools/perf/builtin-bench.c, so perf bench numa mem
exits with status 1 ("Unknown collection: 'numa'").  Should these
subtests be guarded by checking whether libnuma support is compiled in?

> +if taskset -c 0 true > /dev/null 2>&1; then
> +	run_bench numa/mem/bind "GB/sec" numa mem -p 2 -t 2 -P 2 -T 1 -s 1 -l 1 -C 0,1 -M 0,0
> +else
> +	echo "Bench numa/mem/bind [Skipped: cpu 0 not available]"
> +fi
> +run_bench numa/mem/convergence "GB/sec" numa mem -p 1 -t 1 -P 512 -l 1 -s 1 -c -m
> +run_bench numa/mem/perturb "GB/sec" numa mem -p 1 -t 1 -P 512 -l 1 -s 1 -x 1 -S -d -d
> +run_bench numa/mem/zero "GB/sec" numa mem -p 1 -t 2 -T 64 -l 1 -s 1 -C 0 -M 0 -B -Z -H -1

[Severity: Medium]
Does the taskset check for numa/mem/bind verify both CPUs passed to
-C 0,1, and should numa/mem/zero also be guarded by a CPU 0 check?

In tools/perf/bench/numa.c, parse_setup_cpu_list() rejects CPU indices
that are offline or >= nr_cpus, and bind_to_cpumask() hits BUG_ON(ret) if
sched_setaffinity() fails.  Because the guard only tests taskset -c 0,
numa/mem/bind will fail on single-CPU systems or when CPU 1 is offline or
excluded by the current cpuset.  In addition, numa/mem/zero passes -C 0
outside the taskset -c 0 guard, so it will fail when CPU 0 is unavailable.

[ ... ]

> +run_bench breakpoint/thread "Created/joined" breakpoint thread -t 2 -b 2 -p 1
> +run_bench breakpoint/enable "Enabled/disabled" breakpoint enable -p 1 -a 1

[Severity: Low]
Will breakpoint/thread and breakpoint/enable fail instead of skipping on
systems without hardware watchpoints or with only one watchpoint slot?

In tools/perf/bench/breakpoint.c, bench_breakpoint_thread() and
bench_breakpoint_enable() only print "No hardware support" when
perf_event_open() fails with ENODEV, calling perror("perf_event_open")
and exiting with EXIT_FAILURE on other errors.  Kernels without
CONFIG_HAVE_HW_BREAKPOINT (such as s390x) fail with ENOENT, systems with
zero data watchpoint slots fail with EOPNOTSUPP, and passing -b 2 to
breakpoint/thread fails with ENOSPC on CPUs with only one data watchpoint
slot (such as PowerPC without CPU_FTR_DAWR1).  None of those messages
match bench_skip_reasons.

[ ... ]

> +# The uprobe programs attach to usleep in libc, which needs BPF and,
> +# on distributions using musl, is not available by that name.
> +if perf version --build-options | grep -q 'bpf_skeletons: *\[ on' && [ "$(id -u)" = 0 ]; then
> +	for mode in empty trace_printk empty_ret trace_printk_ret; do
> +		echo "Bench uprobe/${mode}"
> +		if ! perf bench uprobe "${mode}" -l 2 > "${out}" 2>&1; then
> +			if grep -qE 'Failed to (attach bench uprobe|load and verify BPF skeleton)' "${out}"; then
> +				echo "Bench uprobe/${mode} [Skipped: no uprobe support]"
> +				continue
> +			fi
> +			echo "Bench uprobe/${mode} [Failed: perf bench failed]"
> +			cat "${out}"
> +			err=1
> +			continue
> +		fi
> +		if ! grep -q "usecs/op" "${out}"; then
> +			echo "Bench uprobe/${mode} [Failed missing result]"
> +			cat "${out}"
> +			err=1
> +			continue
> +		fi
> +		echo "Bench uprobe/${mode} [Success]"
> +	done

[Severity: Medium]
Is the skip check for uprobe/${mode} reachable when
bench_uprobe__setup_bpf_skel() fails?

tools/perf/bench/uprobe.c:bench_uprobe() {
    ...
	if (bench != BENCH_UPROBE__BASELINE && bench_uprobe__setup_bpf_skel(bench) < 0)
		return 0;
    ...
}

When loading the BPF skeleton or attaching the uprobe to libc's usleep
fails (for example on musl systems or kernels without uprobe support),
bench_uprobe() still returns 0 without running the benchmark or printing
"usecs/op".  Because perf bench uprobe exits with 0, the script skips the
failure branch and fails at the grep -q "usecs/op" check instead of
skipping the subtest.

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

  reply	other threads:[~2026-11-24 19:03 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 18:45 [PATCH v1 00/17] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 01/17] perf tests top: Pin the ring buffer size Arnaldo Carvalho de Melo
2026-11-24 19:01   ` sashiko-bot
2026-11-24 18:45 ` [PATCH v1 02/17] perf tests sched: Exercise the sched views and options Arnaldo Carvalho de Melo
2026-11-24 18:58   ` sashiko-bot
2026-11-24 18:45 ` [PATCH v1 03/17] perf tests help: Add a basic perf help test Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 04/17] perf tests config: Exercise the config file and list options Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 05/17] perf tests script: Exercise the list, fields and dump options Arnaldo Carvalho de Melo
2026-11-24 18:54   ` sashiko-bot
2026-11-24 18:45 ` [PATCH v1 06/17] perf tests sort: Exercise the report and diff sort keys Arnaldo Carvalho de Melo
2026-11-24 19:02   ` sashiko-bot
2026-11-24 18:45 ` [PATCH v1 07/17] perf tests diff: Exercise the output options Arnaldo Carvalho de Melo
2026-11-24 18:57   ` sashiko-bot
2026-11-24 18:45 ` [PATCH v1 08/17] perf tests annotate: Exercise the output and filter options Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 09/17] perf tests report: Exercise the output and format options Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 10/17] perf tests record: Exercise more record options Arnaldo Carvalho de Melo
2026-11-24 19:03   ` sashiko-bot
2026-11-24 18:45 ` [PATCH v1 11/17] perf tests trace: Exercise the tracing options Arnaldo Carvalho de Melo
2026-11-24 19:02   ` sashiko-bot
2026-11-24 18:45 ` [PATCH v1 12/17] perf tests timechart: Exercise the report options Arnaldo Carvalho de Melo
2026-11-24 18:46 ` [PATCH v1 13/17] perf tests kmem: Add a basic perf kmem test Arnaldo Carvalho de Melo
2026-11-24 18:57   ` sashiko-bot
2026-11-24 18:46 ` [PATCH v1 14/17] perf tests bench: Add smoke tests for perf bench Arnaldo Carvalho de Melo
2026-11-24 19:03   ` sashiko-bot [this message]
2026-11-24 18:46 ` [PATCH v1 15/17] perf tests lock: Exercise perf lock report and info Arnaldo Carvalho de Melo
2026-11-24 18:46 ` [PATCH v1 16/17] perf tests probe: Exercise the variable and line listing Arnaldo Carvalho de Melo
2026-11-24 19:00   ` sashiko-bot
2026-11-24 18:46 ` [PATCH v1 17/17] perf tests report: Exercise the TUI browsers Arnaldo Carvalho de Melo
2026-11-24 19:01   ` sashiko-bot
2026-11-24 19:03 ` [PATCH v1 00/17] perf tests: Add coverage for the untested perf subcommands sashiko-bot

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=sashiko-outbox-231874@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=acme@kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox