ftrace/selftest: Test combination of function_graph tracer and function profiler

Masami reported a bug when running function graph tracing then the
function profiler. The following commands would cause a kernel crash:

# cd /sys/kernel/tracing/
# echo function_graph > current_tracer
# echo 1 > function_profile_enabled

In that order. Create a test to test this two to make sure this does not
come back as a regression.

Link: https://lore.kernel.org/172398528350.293426.8347220120333730248.stgit@devnote2

Link: https://lore.kernel.org/all/20241010165235.35122877@gandalf.local.home/
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by Steven Rostedt and committed by Shuah Khan 4ee5ca9a a0cc6493

+31
+31
tools/testing/selftests/ftrace/test.d/ftrace/fgraph-profiler.tc
···
··· 1 + #!/bin/sh 2 + # SPDX-License-Identifier: GPL-2.0 3 + # description: ftrace - function profiler with function graph tracing 4 + # requires: function_profile_enabled set_ftrace_filter function_graph:tracer 5 + 6 + # The function graph tracer can now be run along side of the function 7 + # profiler. But there was a bug that caused the combination of the two 8 + # to crash. It also required the function graph tracer to be started 9 + # first. 10 + # 11 + # This test triggers that bug 12 + # 13 + # We need both function_graph and profiling to run this test 14 + 15 + fail() { # mesg 16 + echo $1 17 + exit_fail 18 + } 19 + 20 + echo "Enabling function graph tracer:" 21 + echo function_graph > current_tracer 22 + echo "enable profiler" 23 + 24 + # Older kernels do not allow function_profile to be enabled with 25 + # function graph tracer. If the below fails, mark it as unsupported 26 + echo 1 > function_profile_enabled || exit_unsupported 27 + 28 + # Let it run for a bit to make sure nothing explodes 29 + sleep 1 30 + 31 + exit 0