Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ftrace/scripts: Update the instructions for ftrace-bisect.sh

The instructions for the ftrace-bisect.sh script, which is used to find
what function is being traced that is causing a kernel crash, and possibly
a triple fault reboot, uses the old method. In 5.1, a new feature was
added that let the user write in the index into available_filter_functions
that maps to the function a user wants to set in set_ftrace_filter (or
set_ftrace_notrace). This takes O(1) to set, as suppose to writing a
function name, which takes O(n) (where n is the number of functions in
available_filter_functions).

The ftrace-bisect.sh requires setting half of the functions in
available_filter_functions, which is O(n^2) using the name method to enable
and can take several minutes to complete. The number method is O(n) which
takes less than a second to complete. Using the number method for any
kernel 5.1 and after is the proper way to do the bisect.

Update the usage to reflect the new change, as well as using the
/sys/kernel/tracing path instead of the obsolete debugfs path.

Link: https://lkml.kernel.org/r/20230123112252.022003dd@gandalf.local.home

Cc: stable@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Fixes: f79b3f338564e ("ftrace: Allow enabling of filters via index of available_filter_functions")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

+26 -8
+26 -8
scripts/tracing/ftrace-bisect.sh
··· 12 12 # (note, if this is a problem with function_graph tracing, then simply 13 13 # replace "function" with "function_graph" in the following steps). 14 14 # 15 - # # cd /sys/kernel/debug/tracing 15 + # # cd /sys/kernel/tracing 16 16 # # echo schedule > set_ftrace_filter 17 17 # # echo function > current_tracer 18 18 # ··· 20 20 # 21 21 # # echo nop > current_tracer 22 22 # 23 - # # cat available_filter_functions > ~/full-file 23 + # Starting with v5.1 this can be done with numbers, making it much faster: 24 + # 25 + # The old (slow) way, for kernels before v5.1. 26 + # 27 + # [old-way] # cat available_filter_functions > ~/full-file 28 + # 29 + # [old-way] *** Note *** this process will take several minutes to update the 30 + # [old-way] filters. Setting multiple functions is an O(n^2) operation, and we 31 + # [old-way] are dealing with thousands of functions. So go have coffee, talk 32 + # [old-way] with your coworkers, read facebook. And eventually, this operation 33 + # [old-way] will end. 34 + # 35 + # The new way (using numbers) is an O(n) operation, and usually takes less than a second. 36 + # 37 + # seq `wc -l available_filter_functions | cut -d' ' -f1` > ~/full-file 38 + # 39 + # This will create a sequence of numbers that match the functions in 40 + # available_filter_functions, and when echoing in a number into the 41 + # set_ftrace_filter file, it will enable the corresponding function in 42 + # O(1) time. Making enabling all functions O(n) where n is the number of 43 + # functions to enable. 44 + # 45 + # For either the new or old way, the rest of the operations remain the same. 46 + # 24 47 # # ftrace-bisect ~/full-file ~/test-file ~/non-test-file 25 48 # # cat ~/test-file > set_ftrace_filter 26 - # 27 - # *** Note *** this will take several minutes. Setting multiple functions is 28 - # an O(n^2) operation, and we are dealing with thousands of functions. So go 29 - # have coffee, talk with your coworkers, read facebook. And eventually, this 30 - # operation will end. 31 49 # 32 50 # # echo function > current_tracer 33 51 # ··· 53 35 # 54 36 # Reboot back to test kernel. 55 37 # 56 - # # cd /sys/kernel/debug/tracing 38 + # # cd /sys/kernel/tracing 57 39 # # mv ~/test-file ~/full-file 58 40 # 59 41 # If it didn't crash.