| ftrace | |
|---|---|
| Developers | Steven Rostedt and others |
| Initial release | October 9, 2008; 17 years ago (2008-10-09) |
| Operating system | Linux |
| Type | Kernel extension |
| License | GNU GPL version 2[1] |
| Website | www |
ftrace (Function Tracer) is atracingframework for theLinux kernel. Although its original name, Function Tracer, came from ftrace's ability to record information related to variousfunction calls performed while thekernel is running, ftrace's tracing capabilities cover a much broader range of kernel's internal operations.[2][3]
With its various tracer plugins, ftrace can be targeted at different statictracepoints, such asscheduling events,interrupts,memory-mapped I/O,CPU power state transitions, and operations related tofile systems andvirtualization. Also, dynamic tracking of kernel function calls is available, optionally restrictable to a subset offunctions by usingglobs, and with the possibility to generatecall graphs and providestack usage reports. At the same time, ftrace can be used to measure variouslatencies within the Linux kernel, such as for how long interrupts orpreemption are disabled.[2][4][5]: 3–11, 14, 18
An ftrace-enabled Linux kernel is built by enabling theCONFIG_FUNCTION_TRACERkernel configuration option. The entire runtime interaction with ftrace is performed through readable and writablevirtual files contained in a specifically mounteddebugfs file system; as a result, ftrace requires no specializeduserspace utilities to operate.[2][3][6] However, there are additional userspace utilities that provide more advanced features for data recording, analysis and visualization; examples of such utilities aretrace-cmd andKernelShark.[2][5]: 31–47 [7][8]
Internally, ftrace relies on thegcc'sprofiling mechanism to prependmachine instructions to thecompiled versions of allsource-level kernel functions, which redirect the execution of functions to the ftrace'strampolines and tracer plugins that perform the actual tracing. These "entry point" instructions created by gcc are altered by ftrace when the kernel isbooted, and varied later at runtime by ftrace betweenNOPs and actualjumps to the tracing trampolines, depending on the tracing types and options configured at runtime.[9][10]
ftrace is developed primarily by Steven Rostedt, and it was merged into theLinux kernel mainline in kernel version 2.6.27, which was released on October 9, 2008.[11]