[PATCH] tracing/selftests: Make sure trace_printk is set to top instance
From: Steven Rostedt
Date: Mon Nov 23 2026 - 14:59:38 EST
From: Steven Rostedt <rostedt@xxxxxxxxxxx>
In order to debug a kernel crash, the boot command line added
the traceprintk flag to have trace_printk() go to the persistent ring
buffer. When the fix was found, the command line wasn't updated.
Later, when running the ftrace selftests, the direct function tests were
failing. The reason for this was because these tests would load the
ftrace-direct.ko module which would add a trampoline that did a
trace_printk. The test would then search the top level instance buffer for
the trace_printk output. The issue is that the kernel command line had
moved the destination to the persistent ring buffer causing the writes of
trace_printk to go there and not the top level instance and because the
tests did not find the output it was looking for, they failed.
Update the tests to set the trace_printk destination to the top level
instance at the start of the tests to force the output to go there so that
the tests will not fail in such a case again.
Signed-off-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
---
.../testing/selftests/ftrace/test.d/direct/ftrace-direct.tc | 5 +++++
.../testing/selftests/ftrace/test.d/direct/kprobe-direct.tc | 5 +++++
2 files changed, 10 insertions(+)
diff --git a/tools/testing/selftests/ftrace/test.d/direct/ftrace-direct.tc b/tools/testing/selftests/ftrace/test.d/direct/ftrace-direct.tc
index d75a8695bc21..359257123e6d 100644
--- a/tools/testing/selftests/ftrace/test.d/direct/ftrace-direct.tc
+++ b/tools/testing/selftests/ftrace/test.d/direct/ftrace-direct.tc
@@ -2,6 +2,11 @@
# SPDX-License-Identifier: GPL-2.0
# description: Test ftrace direct functions against tracers
+# Make sure trace_printk goes to the main buffer
+if [ -f options/trace_printk_dest ]; then
+ echo 1 > options/trace_printk_dest
+fi
+
rmmod ftrace-direct ||:
if ! modprobe ftrace-direct ; then
echo "No ftrace-direct sample module - please make CONFIG_SAMPLE_FTRACE_DIRECT=m"
diff --git a/tools/testing/selftests/ftrace/test.d/direct/kprobe-direct.tc b/tools/testing/selftests/ftrace/test.d/direct/kprobe-direct.tc
index e52e470a1f8f..b22e3fb1c468 100644
--- a/tools/testing/selftests/ftrace/test.d/direct/kprobe-direct.tc
+++ b/tools/testing/selftests/ftrace/test.d/direct/kprobe-direct.tc
@@ -3,6 +3,11 @@
# description: Test ftrace direct functions against kprobes
# requires: kprobe_events
+# Make sure trace_printk goes to the main buffer
+if [ -f options/trace_printk_dest ]; then
+ echo 1 > options/trace_printk_dest
+fi
+
rmmod ftrace-direct ||:
if ! modprobe ftrace-direct ; then
echo "No ftrace-direct sample module - please build with CONFIG_SAMPLE_FTRACE_DIRECT=m"
--
2.53.0