* [PATCH 1/3] perf test: fix nanosleep check in the ftrace test
2026-04-27 9:01 [PATCH 0/3] perf: fix some tests for musl Martin Kaiser
@ 2026-04-27 9:01 ` Martin Kaiser
2026-04-27 9:01 ` [PATCH 2/3] perf test: fix sys_enter_openat event test for musl Martin Kaiser
2026-04-27 9:01 ` [PATCH 3/3] perf test: fix "trace summary" test for musl-based systems Martin Kaiser
2 siblings, 0 replies; 6+ messages in thread
From: Martin Kaiser @ 2026-04-27 9:01 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim
Cc: Ian Rogers, James Clark, linux-perf-users, linux-kernel,
Martin Kaiser
The perf ftrace test case runs
perf ftrace profile --graph-opts depth=5 sleep 0.1
and checks that the output contains a *clock_nanosleep function with a
count of 1.
This fails on a risc-v system that uses musl as its C library. musl's
nanosleep syscall wrapper uses either the nanosleep or the
clock_nanosleep syscall.
Filter for sys_*nanosleep to allow both syscalls.
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
tools/perf/tests/shell/ftrace.sh | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/tools/perf/tests/shell/ftrace.sh b/tools/perf/tests/shell/ftrace.sh
index 7f8aafcbb761..9f6e590f6437 100755
--- a/tools/perf/tests/shell/ftrace.sh
+++ b/tools/perf/tests/shell/ftrace.sh
@@ -71,9 +71,10 @@ test_ftrace_profile() {
grep ^# "${output}"
time_re="[[:space:]]+1[[:digit:]]{5}\.[[:digit:]]{3}"
# 100283.000 100283.000 100283.000 1 __x64_sys_clock_nanosleep
- # Check for one *clock_nanosleep line with a Count of just 1 that takes a bit more than 0.1 seconds
- # Strip the _x64_sys part to work with other architectures
- grep -E "^${time_re}${time_re}${time_re}[[:space:]]+1[[:space:]]+.*clock_nanosleep" "${output}"
+ # Check for one *sys_*nanosleep line with a Count of just 1 that takes a bit more than 0.1 seconds
+ # Strip the _x64_ part to work with other architectures, strip the clock part to support
+ # C libraries that use the nanosleep syscall instead of clock_nanosleep
+ grep -E "^${time_re}${time_re}${time_re}[[:space:]]+1[[:space:]]+.*sys_.*nanosleep" "${output}"
echo "perf ftrace profile test [Success]"
}
--
2.43.7
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/3] perf test: fix sys_enter_openat event test for musl
2026-04-27 9:01 [PATCH 0/3] perf: fix some tests for musl Martin Kaiser
2026-04-27 9:01 ` [PATCH 1/3] perf test: fix nanosleep check in the ftrace test Martin Kaiser
@ 2026-04-27 9:01 ` Martin Kaiser
2026-04-27 9:49 ` sashiko-bot
2026-04-27 9:01 ` [PATCH 3/3] perf test: fix "trace summary" test for musl-based systems Martin Kaiser
2 siblings, 1 reply; 6+ messages in thread
From: Martin Kaiser @ 2026-04-27 9:01 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim
Cc: Ian Rogers, James Clark, linux-perf-users, linux-kernel,
Martin Kaiser
The "syscalls:sys_enter_openat event fields" test calls
openat(AT_FDCWD, "/etc/passwd", O_RDONLY | O_DIRECTORY)
and verifies that the flags of the captured event are matching.
This fails for musl, where the openat syscall wrapper always adds
O_LARGEFILE.
Update the check to allow for additional flags. Fail the test only if one
of our flags is missing.
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
tools/perf/tests/openat-syscall-tp-fields.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/perf/tests/openat-syscall-tp-fields.c b/tools/perf/tests/openat-syscall-tp-fields.c
index 2a139d2781a8..366b3bf39def 100644
--- a/tools/perf/tests/openat-syscall-tp-fields.c
+++ b/tools/perf/tests/openat-syscall-tp-fields.c
@@ -120,7 +120,8 @@ static int test__syscall_openat_tp_fields(struct test_suite *test __maybe_unused
tp_flags = evsel__intval(evsel, &sample, "flags");
perf_sample__exit(&sample);
- if (flags != tp_flags) {
+ /* C library wrapper may set additional flags */
+ if ((tp_flags & flags) != flags) {
pr_debug("%s: Expected flags=%#x, got %#x\n",
__func__, flags, tp_flags);
goto out_delete_evlist;
--
2.43.7
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 2/3] perf test: fix sys_enter_openat event test for musl
2026-04-27 9:01 ` [PATCH 2/3] perf test: fix sys_enter_openat event test for musl Martin Kaiser
@ 2026-04-27 9:49 ` sashiko-bot
0 siblings, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-04-27 9:49 UTC (permalink / raw)
To: Martin Kaiser; +Cc: linux-perf-users
Sashiko AI review found 1 potential issue(s):
- [Medium] The updated bitwise check `(tp_flags & flags) != flags` fails to verify the `O_RDONLY` access mode and permits arbitrary unrelated flags, severely weakening the test.
--
commit 0700122c98ba7f263a329cd8f9fbeef95b67603e
Author: Martin Kaiser <martin@kaiser.cx>
perf test: fix sys_enter_openat event test for musl
This commit updates the sys_enter_openat test to allow additional flags in the
captured event. It replaces the strict equality check with a bitwise mask check
to accommodate the O_LARGEFILE flag implicitly added by musl libc.
> diff --git a/tools/perf/tests/openat-syscall-tp-fields.c b/tools/perf/tests/openat-syscall-tp-fields.c
> --- a/tools/perf/tests/openat-syscall-tp-fields.c
> +++ b/tools/perf/tests/openat-syscall-tp-fields.c
[ ... ]
> @@ -120,7 +120,8 @@ static int test__syscall_openat_tp_fields(struct test_suite *test __maybe_unused
>
> tp_flags = evsel__intval(evsel, &sample, "flags");
> perf_sample__exit(&sample);
> - if (flags != tp_flags) {
> + /* C library wrapper may set additional flags */
> + if ((tp_flags & flags) != flags) {
Does this check still verify the O_RDONLY access mode?
Since O_RDONLY is defined as 0, the flags variable evaluates to exactly
O_DIRECTORY. This means the condition functionally becomes
(tp_flags & O_DIRECTORY) != O_DIRECTORY.
Does this unintentionally permit other access modes like O_WRONLY or O_RDWR,
and ignore other unrelated flags as long as O_DIRECTORY is set?
> pr_debug("%s: Expected flags=%#x, got %#x\n",
> __func__, flags, tp_flags);
> goto out_delete_evlist;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260427090225.794482-1-martin@kaiser.cx?part=2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/3] perf test: fix "trace summary" test for musl-based systems
2026-04-27 9:01 [PATCH 0/3] perf: fix some tests for musl Martin Kaiser
2026-04-27 9:01 ` [PATCH 1/3] perf test: fix nanosleep check in the ftrace test Martin Kaiser
2026-04-27 9:01 ` [PATCH 2/3] perf test: fix sys_enter_openat event test for musl Martin Kaiser
@ 2026-04-27 9:01 ` Martin Kaiser
2026-04-27 9:57 ` sashiko-bot
2 siblings, 1 reply; 6+ messages in thread
From: Martin Kaiser @ 2026-04-27 9:01 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim
Cc: Ian Rogers, James Clark, linux-perf-users, linux-kernel,
Martin Kaiser
The trace summary test calls /bin/true and filters for open, read and
close events. These events are coming from shared library loads.
On a musl system, the loader and libc may point to the same file. true
needs only libc, no further shared libraries are loaded at startup. The
test fails since no open, read and close events are captured.
root@host:~# ldd /bin/true
/lib/ld-musl-riscv64.so.1 (0x3fb8882000)
libc.so => /lib/ld-musl-riscv64.so.1 (0x3fb8882000)
root@host:~# file /lib/ld-musl-riscv64.so.1
/lib/ld-musl-riscv64.so.1: symbolic link to /usr/lib/libc.so
root@host:~# strace -f /bin/true
execve("/bin/true", ["/bin/true", ...], ... /* 18 vars */) = 1
set_tid_address(0x3fa1f7bf70) = 330
mprotect(0x2ad6b8e000, 12288, PROT_READ) = 0
exit_group(0) = ?
+++ exited with 0 +++
Run "ps --help" instead of "true". ps needs at least libprocps and we'll
get the events that are needed for the test.
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
tools/perf/tests/shell/trace_summary.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/tests/shell/trace_summary.sh b/tools/perf/tests/shell/trace_summary.sh
index 22e2651d5919..03be213bb7bf 100755
--- a/tools/perf/tests/shell/trace_summary.sh
+++ b/tools/perf/tests/shell/trace_summary.sh
@@ -14,7 +14,7 @@ OUTPUT=$(mktemp /tmp/perf_trace_test.XXXXX)
test_perf_trace() {
args=$1
- workload="true"
+ workload="ps --help"
search="^\s*(open|read|close).*[0-9]+%$"
echo "testing: perf trace ${args} -- ${workload}"
--
2.43.7
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 3/3] perf test: fix "trace summary" test for musl-based systems
2026-04-27 9:01 ` [PATCH 3/3] perf test: fix "trace summary" test for musl-based systems Martin Kaiser
@ 2026-04-27 9:57 ` sashiko-bot
0 siblings, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-04-27 9:57 UTC (permalink / raw)
To: Martin Kaiser; +Cc: linux-perf-users
Sashiko AI review found 1 potential issue(s):
- [Medium] The `ps --help` test workload is brittle and will continue to fail on many musl-based systems that use BusyBox.
--
commit 41e18297314ee059526c7fb6d14d02d61ba92d64
Author: Martin Kaiser <martin@kaiser.cx>
perf test: fix "trace summary" test for musl-based systems
This commit updates the trace summary test to use ps --help instead
of true. The goal is to ensure the test workload triggers open, read,
and close events from dynamic library loading on musl-based systems.
> diff --git a/tools/perf/tests/shell/trace_summary.sh b/tools/perf/tests/shell/trace_summary.sh
> --- a/tools/perf/tests/shell/trace_summary.sh
> +++ b/tools/perf/tests/shell/trace_summary.sh
> @@ -14,7 +14,7 @@ OUTPUT=$(mktemp /tmp/perf_trace_test.XXXXX)
>
> test_perf_trace() {
> args=$1
> - workload="true"
> + workload="ps --help"
Will this workload still fail on musl-based systems that use BusyBox?
Many musl-based distributions, such as Alpine Linux or OpenWrt, frequently
use BusyBox to provide standard utilities. BusyBox's ps is typically
statically linked or links only to libc, without depending on libprocps.
Furthermore, running ps --help in BusyBox generally prints the usage string
and exits without performing file I/O, which means no open, read, or close
events will be generated.
Would a command that natively performs file I/O, such as cat /dev/null or
dd if=/dev/null of=/dev/null, be more robust here?
> search="^\s*(open|read|close).*[0-9]+%$"
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260427090225.794482-1-martin@kaiser.cx?part=3
^ permalink raw reply [flat|nested] 6+ messages in thread