Skip to main content
Function tracer (ftrace) provides tracing utilities to perform system-wide profiling and tracing at runtime. To use ftrace, enable the following configuration options:
  • CONFIG_FTRACE
  • CONFIG_HAVE_FUNCTION_TRACER
  • CONFIG_HAVE_FUNCTION_GRAPH_TRACER
  • CONFIG_HAVE_DYNAMIC_FTRACE
  • CONFIG_HAVE_FTRACE_MCOUNT_RECORD
The following are some operations that ftrace can perform to debug kernel issues:

Dump ftrace information to the kmsg buffer

To dump the ftrace information into the kmsg buffer anytime from the source code, call the ftrace_dump(DUMP_ALL) function.
  • To increase the buffer size of the ftrace ring, run the following command:

Enable work queue trace

  • To enable work queue tracing, run the following commands:
    Sample output:

Enable Interrupt request (IRQ) trace

  • To enable interrupt tracing, run the following commands:
    Sample output:

Enable scheduler trace

  • To trace context switches between tasks, run the following commands to enable the sched_switch tracer:
    Sample output:

Find IRQ latency

  • To find the maximum IRQ latency and pre-emption latency in the system, enable ftrace configurations for IRQOFF and PREEMPTIONOFF as follows:
    For this configuration to take effect, recompile the kernel. This configuration detects latency in milliseconds effectively.
  • To enable tracing, run the following commands:
  • To find the maximum latency observed in the system, configure tracing_max_latency = 0. To detect any latency higher than the specified limit, set the threshold level in microseconds. For example,
The following example shows the traces for IRQ latency of 16 ms:
For more information, see the Documentation/trace/ftrace.txt file available in the kernel documentation.