The kernel function tracer, Ftrace
, evolved from work done by Steven Rostedt, and many others, as they were tracking down the causes of high latency. Ftrace
appeared in Linux 2.6.27 and has been actively developed since then. There are a number of documents describing kernel tracing in the kernel source in Documentation/trace
.
Ftrace
consists of a number of tracers that can log various types of activity in the kernel. Here, I am going to talk about the function
and function_graph
tracers, and about the event tracepoints. In Chapter 14, Real-time Programming, I will revisit Ftrace and use it to show real-time latencies.
The function
tracer instruments each kernel function so that calls can be recorded and timestamped. As a matter of interest, it compiles the kernel with the -pg
switch to inject the instrumentation, but there the resemblance to gprof ends. The function_graph
tracer goes further and records both the entry and exit of functions so that it can create a call graph...