tracing/selftests: Make sure trace_printk is set to top instance
Steven Rostedt
maintainerPATCH 1/1 tracing/selftests: Make sure trace_printk is set to top instance
From: Steven Rostedt <[email protected]>
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.
--- .../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(+)
tools/testing/selftests/ftrace/test.d/direct/ftrace-direct.tc +5 -0
@@ -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"
tools/testing/selftests/ftrace/test.d/direct/kprobe-direct.tc +5 -0
@@ -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"
Signature · 1 line
2.53.0
Steven Rostedt
maintainerMasami,
You OK with this patch?
If so...
Shuah, can you take this patch if Masami acks it. It's not urgent and can go in the next merge window.
Thanks,
-- Steve
Quoted 57 lines · On Mon, 23 Nov 2026 14:59:18 -0500 Steven Rostedt <[email protected]> wrote:
From: Steven Rostedt <[email protected]>
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 thetrace_printkoutput. The issue is that the kernel command line had moved the destination to the persistent ring buffer causing the writes oftrace_printkto 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_printkdestination 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 <[email protected]>--- .../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(+)tools/testing/selftests/ftrace/test.d/direct/ftrace-direct.tc +5
-0@@ -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"tools/testing/selftests/ftrace/test.d/direct/kprobe-direct.tc +5
-0@@ -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"