* [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 22:29 ` Namhyung Kim
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, 1 reply; 5+ 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] 5+ messages in thread* Re: [PATCH 1/3] perf test: fix nanosleep check in the ftrace test
2026-04-27 9:01 ` [PATCH 1/3] perf test: fix nanosleep check in the ftrace test Martin Kaiser
@ 2026-04-27 22:29 ` Namhyung Kim
0 siblings, 0 replies; 5+ messages in thread
From: Namhyung Kim @ 2026-04-27 22:29 UTC (permalink / raw)
To: Martin Kaiser
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Ian Rogers,
James Clark, linux-perf-users, linux-kernel
On Mon, Apr 27, 2026 at 11:01:41AM +0200, Martin Kaiser wrote:
> 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>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Thanks,
Namhyung
> ---
> 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 [flat|nested] 5+ 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:01 ` [PATCH 3/3] perf test: fix "trace summary" test for musl-based systems Martin Kaiser
2 siblings, 0 replies; 5+ 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] 5+ 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
2 siblings, 0 replies; 5+ 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] 5+ messages in thread