ftrace
Linux kernel configuration
Ref: https://www.kernel.org/doc/Documentation/trace/ftrace.txt
<board>_defconfig
kernel/trace/Kconfig
: 설정 가능한 옵션, 의존성, 설명 등이 있으므로 참고하시기 바랍니다.arch/<architecture>/configs/<board>_defconfig
Options
CONFIG_FTRACE=y
: Enables the kernel tracing infrastructure.CONFIG_FUNCTION_TRACER=y
: Enables the kernel to trace every kernel function.CONFIG_FUNCTION_GRAPH_TRACER=y
: Enables the kernel to trace a function at both its return and its entry.CONFIG_FUNCTION_PROFILER=y
: Enables the kernel function profiler. A file is created in debugfs called function_profile_enabled which defaults to zero. When a 1 is echoed into this file profiling begins, and when a zero is entered, profiling stops. A "functions" file is created in the trace_stats directory; this file shows the list of functions that have been hit and their counters.
CONFIG_IRQSOFF_TRACER=y
: Measures the time spent in irqs-off critical sections, with microsecond accuracy.CONFIG_SCHED_TRACER=y
: Tracks the latency of the highest priority task to be scheduled in, starting from the point it has woken up.CONFIG_TRACER_SNAPSHOT=y
: Allows tracing users to take snapshot of the current buffer using the ftrace interface.CONFIG_STACK_TRACER=y
: Records the maximum stack footprint of the kernel and displays it in /sys/kernel/debug/tracing/stack_trace.CONFIG_DYNAMIC_FTRACE=y
: This option will modify all the calls to function tracing dynamically (will patch them out of the binary image and replace them with a No-Op instruction) on boot up. During compile time, a table is made of all the locations that ftrace can function trace, and this table is linked into the kernel image. When this is enabled, functions can be individually enabled, and the functions not enabled will not affect performance of the system.
trace_printk
<linux/kernel.h>
에 정의되어 있는 함수입니다.
Ftrace introduces a new form of printk() called trace_printk(). It can be used just like printk(), and can also be used in any context (interrupt code, NMI code, and scheduler code). What is nice about trace_printk() is that it does not output to the console. Instead it writes to the Ftrace ring buffer and can be read via the trace file.