* [PATCH v2 0/3] perf: fix some tests for musl
@ 2026-04-28 14:38 Martin Kaiser
2026-04-28 14:38 ` [PATCH v2 1/3] perf test: fix nanosleep check in the ftrace test Martin Kaiser
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Martin Kaiser @ 2026-04-28 14:38 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
Fix some perf tests for systems that use musl instead of glibc.
v2:
- add Namhyung's Acked-by for patch 1
- stricter flags check for patch 2
- more generic workload in patch 3
Martin Kaiser (3):
perf test: fix nanosleep check in the ftrace test
perf test: fix sys_enter_openat event test for musl
perf test: fix "trace summary" test for musl-based systems
tools/perf/tests/openat-syscall-tp-fields.c | 5 ++++-
tools/perf/tests/shell/ftrace.sh | 7 ++++---
tools/perf/tests/shell/trace_summary.sh | 2 +-
3 files changed, 9 insertions(+), 5 deletions(-)
--
2.43.7
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 1/3] perf test: fix nanosleep check in the ftrace test
2026-04-28 14:38 [PATCH v2 0/3] perf: fix some tests for musl Martin Kaiser
@ 2026-04-28 14:38 ` Martin Kaiser
2026-04-28 14:38 ` [PATCH v2 2/3] perf test: fix sys_enter_openat event test for musl Martin Kaiser
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: Martin Kaiser @ 2026-04-28 14:38 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>
Acked-by: Namhyung Kim <namhyung@kernel.org>
---
v2:
- add Acked-by
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] 8+ messages in thread
* [PATCH v2 2/3] perf test: fix sys_enter_openat event test for musl
2026-04-28 14:38 [PATCH v2 0/3] perf: fix some tests for musl Martin Kaiser
2026-04-28 14:38 ` [PATCH v2 1/3] perf test: fix nanosleep check in the ftrace test Martin Kaiser
@ 2026-04-28 14:38 ` Martin Kaiser
2026-04-29 16:55 ` Ian Rogers
2026-04-28 14:38 ` [PATCH v2 3/3] perf test: fix "trace summary" test for musl-based systems Martin Kaiser
2026-04-28 23:09 ` [PATCH v2 0/3] perf: fix some tests for musl Namhyung Kim
3 siblings, 1 reply; 8+ messages in thread
From: Martin Kaiser @ 2026-04-28 14:38 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, the access mode flags
must be unchanged.
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
v2:
- check that access mode is unchanged
tools/perf/tests/openat-syscall-tp-fields.c | 5 ++++-
1 file changed, 4 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..5523cf4e9321 100644
--- a/tools/perf/tests/openat-syscall-tp-fields.c
+++ b/tools/perf/tests/openat-syscall-tp-fields.c
@@ -120,7 +120,10 @@ 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,
+ access mode must be unchanged */
+ if ((tp_flags & O_ACCMODE) != (flags & O_ACCMODE) ||
+ (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] 8+ messages in thread
* [PATCH v2 3/3] perf test: fix "trace summary" test for musl-based systems
2026-04-28 14:38 [PATCH v2 0/3] perf: fix some tests for musl Martin Kaiser
2026-04-28 14:38 ` [PATCH v2 1/3] perf test: fix nanosleep check in the ftrace test Martin Kaiser
2026-04-28 14:38 ` [PATCH v2 2/3] perf test: fix sys_enter_openat event test for musl Martin Kaiser
@ 2026-04-28 14:38 ` Martin Kaiser
2026-04-29 16:57 ` Ian Rogers
2026-04-28 23:09 ` [PATCH v2 0/3] perf: fix some tests for musl Namhyung Kim
3 siblings, 1 reply; 8+ messages in thread
From: Martin Kaiser @ 2026-04-28 14:38 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 "cat /dev/null" instead of "true". This creates the required events
regardless of the C library and it works for cat from busybox or from
coreutils.
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
v2:
- use cat /dev/null, this works for busybox and coreutils
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..b80dea77cec6 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="cat /dev/null"
search="^\s*(open|read|close).*[0-9]+%$"
echo "testing: perf trace ${args} -- ${workload}"
--
2.43.7
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/3] perf: fix some tests for musl
2026-04-28 14:38 [PATCH v2 0/3] perf: fix some tests for musl Martin Kaiser
` (2 preceding siblings ...)
2026-04-28 14:38 ` [PATCH v2 3/3] perf test: fix "trace summary" test for musl-based systems Martin Kaiser
@ 2026-04-28 23:09 ` Namhyung Kim
3 siblings, 0 replies; 8+ messages in thread
From: Namhyung Kim @ 2026-04-28 23:09 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 Tue, Apr 28, 2026 at 04:38:45PM +0200, Martin Kaiser wrote:
> Fix some perf tests for systems that use musl instead of glibc.
>
> v2:
> - add Namhyung's Acked-by for patch 1
> - stricter flags check for patch 2
> - more generic workload in patch 3
>
> Martin Kaiser (3):
> perf test: fix nanosleep check in the ftrace test
> perf test: fix sys_enter_openat event test for musl
> perf test: fix "trace summary" test for musl-based systems
Acked-by: Namhyung Kim <namhyung@kernel.org>
Thanks,
Namhyung
>
> tools/perf/tests/openat-syscall-tp-fields.c | 5 ++++-
> tools/perf/tests/shell/ftrace.sh | 7 ++++---
> tools/perf/tests/shell/trace_summary.sh | 2 +-
> 3 files changed, 9 insertions(+), 5 deletions(-)
>
> --
> 2.43.7
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/3] perf test: fix sys_enter_openat event test for musl
2026-04-28 14:38 ` [PATCH v2 2/3] perf test: fix sys_enter_openat event test for musl Martin Kaiser
@ 2026-04-29 16:55 ` Ian Rogers
2026-04-30 7:15 ` Martin Kaiser
0 siblings, 1 reply; 8+ messages in thread
From: Ian Rogers @ 2026-04-29 16:55 UTC (permalink / raw)
To: Martin Kaiser
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, James Clark, linux-perf-users, linux-kernel
On Tue, Apr 28, 2026 at 7:39 AM Martin Kaiser <martin@kaiser.cx> wrote:
>
> 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, the access mode flags
> must be unchanged.
>
> Signed-off-by: Martin Kaiser <martin@kaiser.cx>
> ---
> v2:
> - check that access mode is unchanged
>
> tools/perf/tests/openat-syscall-tp-fields.c | 5 ++++-
> 1 file changed, 4 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..5523cf4e9321 100644
> --- a/tools/perf/tests/openat-syscall-tp-fields.c
> +++ b/tools/perf/tests/openat-syscall-tp-fields.c
> @@ -120,7 +120,10 @@ 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,
> + access mode must be unchanged */
I think normal style would be:
```
/*
* C library ...
*/
```
> + if ((tp_flags & O_ACCMODE) != (flags & O_ACCMODE) ||
> + (tp_flags & flags) != flags) {
How can this second condition be true given the first condition?
Thanks,
Ian
> pr_debug("%s: Expected flags=%#x, got %#x\n",
> __func__, flags, tp_flags);
> goto out_delete_evlist;
> --
> 2.43.7
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 3/3] perf test: fix "trace summary" test for musl-based systems
2026-04-28 14:38 ` [PATCH v2 3/3] perf test: fix "trace summary" test for musl-based systems Martin Kaiser
@ 2026-04-29 16:57 ` Ian Rogers
0 siblings, 0 replies; 8+ messages in thread
From: Ian Rogers @ 2026-04-29 16:57 UTC (permalink / raw)
To: Martin Kaiser
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, James Clark, linux-perf-users, linux-kernel
On Tue, Apr 28, 2026 at 7:39 AM Martin Kaiser <martin@kaiser.cx> wrote:
>
> 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 "cat /dev/null" instead of "true". This creates the required events
> regardless of the C library and it works for cat from busybox or from
> coreutils.
>
> Signed-off-by: Martin Kaiser <martin@kaiser.cx>
> ---
> v2:
> - use cat /dev/null, this works for busybox and coreutils
>
> 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..b80dea77cec6 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="cat /dev/null"
Could we capture why the unusual workload in a comment, I know it is
in the commit message.
Acked-by: Ian Rogers <irogers@google.com>
Thanks,
Ian
> search="^\s*(open|read|close).*[0-9]+%$"
>
> echo "testing: perf trace ${args} -- ${workload}"
> --
> 2.43.7
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/3] perf test: fix sys_enter_openat event test for musl
2026-04-29 16:55 ` Ian Rogers
@ 2026-04-30 7:15 ` Martin Kaiser
0 siblings, 0 replies; 8+ messages in thread
From: Martin Kaiser @ 2026-04-30 7:15 UTC (permalink / raw)
To: Ian Rogers
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, James Clark, linux-perf-users, linux-kernel
Thus wrote Ian Rogers (irogers@google.com):
> On Tue, Apr 28, 2026 at 7:39 AM Martin Kaiser <martin@kaiser.cx> wrote:
> > 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, the access mode flags
> > must be unchanged.
> > Signed-off-by: Martin Kaiser <martin@kaiser.cx>
> > ---
> > v2:
> > - check that access mode is unchanged
> > tools/perf/tests/openat-syscall-tp-fields.c | 5 ++++-
> > 1 file changed, 4 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..5523cf4e9321 100644
> > --- a/tools/perf/tests/openat-syscall-tp-fields.c
> > +++ b/tools/perf/tests/openat-syscall-tp-fields.c
> > @@ -120,7 +120,10 @@ 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,
> > + access mode must be unchanged */
> I think normal style would be:
> ```
> /*
> * C library ...
> */
> ```
Ok, will fix this if we need another version.
> > + if ((tp_flags & O_ACCMODE) != (flags & O_ACCMODE) ||
> > + (tp_flags & flags) != flags) {
> How can this second condition be true given the first condition?
Sorry if I am missing something obvious.
The O_ACCMODE check verifies that the two lower bits (access mode flags) in
the syscall and in the recorded event are identical.
The second check tests that all flags from the syscall are also set in the
event. Additional flags in the event are ok.
For tp_flags == 0x0 and flags == 0x4, the first condition is false, the second
one is true.
Best regards,
Martin
> Thanks,
> Ian
> > pr_debug("%s: Expected flags=%#x, got %#x\n",
> > __func__, flags, tp_flags);
> > goto out_delete_evlist;
> > --
> > 2.43.7
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-04-30 7:15 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-28 14:38 [PATCH v2 0/3] perf: fix some tests for musl Martin Kaiser
2026-04-28 14:38 ` [PATCH v2 1/3] perf test: fix nanosleep check in the ftrace test Martin Kaiser
2026-04-28 14:38 ` [PATCH v2 2/3] perf test: fix sys_enter_openat event test for musl Martin Kaiser
2026-04-29 16:55 ` Ian Rogers
2026-04-30 7:15 ` Martin Kaiser
2026-04-28 14:38 ` [PATCH v2 3/3] perf test: fix "trace summary" test for musl-based systems Martin Kaiser
2026-04-29 16:57 ` Ian Rogers
2026-04-28 23:09 ` [PATCH v2 0/3] perf: fix some tests for musl Namhyung Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox