]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests/ftrace: Fix trace_marker_raw test on 64K page kernels
authorTianchen Ding <dtcccc@linux.alibaba.com>
Mon, 1 Jun 2026 02:32:51 +0000 (10:32 +0800)
committerShuah Khan <skhan@linuxfoundation.org>
Wed, 17 Jun 2026 23:17:26 +0000 (17:17 -0600)
On ARM64 kernels with 64K pages, the trace_marker_raw test fails because
bash's printf builtin uses stdio buffering which splits output into
multiple small write() calls to the tracefs file. Since each individual
write is within TRACE_MARKER_MAX_SIZE (4096), they all succeed, causing
the "too big" write test to incorrectly pass.

Fix by writing through dd with iflag=fullblock to guarantee a single
atomic write() syscall to trace_marker_raw.

Link: https://lore.kernel.org/r/20260601023251.1916483-1-dtcccc@linux.alibaba.com
Fixes: 37f46601383a ("selftests/tracing: Add basic test for trace_marker_raw file")
Signed-off-by: Tianchen Ding <dtcccc@linux.alibaba.com>
Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/ftrace/test.d/00basic/trace_marker_raw.tc

index 8e905d4fe6dd22e901e57b7631738f42887121e6..f985ff391463a7f326558de33b7ceebd81d735d8 100644 (file)
@@ -36,15 +36,23 @@ make_str() {
 
        data=`printf -- 'X%.0s' $(seq $cnt)`
 
-       printf "${val}${data}"
+       # Return escape-sequence text (e.g. "\003\000..."); the caller
+       # converts to binary. Shell command substitution strips NUL bytes,
+       # so the binary form cannot survive being captured into a variable.
+       printf '%s' "${val}${data}"
 }
 
 write_buffer() {
        id=$1
        size=$2
 
-       # write the string into the raw marker
-       make_str $id $size > trace_marker_raw
+       str=`make_str $id $size`
+       len=`printf "$str" | wc -c`
+       # Pipe through dd to ensure a single atomic write() syscall
+       # on architectures with 64K pages, where shell's printf builtin
+       # uses stdio buffering which may split the output into multiple
+       # writes.
+       printf "$str" | dd of=trace_marker_raw bs=$len iflag=fullblock
 }