Ftrace Explained

ftrace
Developer:Steven Rostedt and others
Operating System:Linux
Genre:Kernel extension
License:GNU GPL version 2[1]

ftrace (Function Tracer) is a tracing framework for the Linux kernel. Although its original name, Function Tracer, came from ftrace's ability to record information related to various function calls performed while the kernel is running, ftrace's tracing capabilities cover a much broader range of kernel's internal operations.[2] [3]

Details

With its various tracer plugins, ftrace can be targeted at different static tracepoints, such as scheduling events, interrupts, memory-mapped I/O, CPU power state transitions, and operations related to file systems and virtualization. Also, dynamic tracking of kernel function calls is available, optionally restrictable to a subset of functions by using globs, and with the possibility to generate call graphs and provide stack usage reports. At the same time, ftrace can be used to measure various latencies within the Linux kernel, such as for how long interrupts or preemption are disabled.[4] [5]

An ftrace-enabled Linux kernel is built by enabling the kernel configuration option. The entire runtime interaction with ftrace is performed through readable and writable virtual files contained in a specifically mounted debugfs file system; as a result, ftrace requires no specialized userspace utilities to operate.[6] However, there are additional userspace utilities that provide more advanced features for data recording, analysis and visualization; examples of such utilities are trace-cmd and KernelShark.[7] [8]

Internally, ftrace relies on the gcc's profiling mechanism to prepend machine instructions to the compiled versions of all source-level kernel functions, which redirect the execution of functions to the ftrace's trampolines and tracer plugins that perform the actual tracing. These "entry point" instructions created by gcc are altered by ftrace when the kernel is booted, and varied later at runtime by ftrace between NOPs and actual jumps 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 the Linux kernel mainline in kernel version 2.6.27, which was released on October 9, 2008.[11]

See also

External links

Notes and References

  1. Web site: Linux kernel source: kernel/COPYING file . March 13, 1994 . June 11, 2016 . kernel.org.
  2. Web site: A look at ftrace . March 13, 2009 . July 23, 2014 . Jake Edge . LWN.net.
  3. Web site: Linux kernel documentation: Documentation/trace/ftrace.txt . June 16, 2014 . July 23, 2014 . Steven Rostedt . kernel.org.
  4. Web site: Red Hat Enterprise MRG 2 documentation, Section 3.8. Using the ftrace utility for tracing latencies . May 23, 2014 . July 24, 2014 . Red Hat.
  5. Web site: Ftrace: Linux Kernel Tracing . October 18, 2010 . July 23, 2014 . Steven Rostedt . linuxfoundation.org . https://web.archive.org/web/20130308164230/http://events.linuxfoundation.org/slides/2010/linuxcon_japan/linuxcon_jp2010_rostedt.pdf . March 8, 2013 .
  6. Web site: Red Hat Enterprise Linux 6 documentation, Section 6.5. ftrace . March 14, 2014 . July 23, 2014 . Red Hat.
  7. Web site: trace-cmd: A front-end for Ftrace . October 20, 2010 . January 19, 2015 . Steven Rostedt . LWN.net.
  8. Web site: Using KernelShark to analyze the real-time scheduler . February 2, 2011 . June 11, 2016 . Steven Rostedt . LWN.net.
  9. Web site: Ftrace Kernel Hooks: More than just tracing . January 5, 2015 . June 11, 2016 . Steven Rostedt . linuxplumbersconf.org . 6 - 12, 24, 34, 56 - 58.
  10. Web site: Measuring Function Duration with Ftrace . November 1, 2012 . June 11, 2016 . Tim Bird . elinux.org . 5 - 6, 12 - 14.
  11. Web site: Linux kernel 2.6.27, Section 1.7. ftrace, sysprof support . October 9, 2008 . July 23, 2014 . kernelnewbies.org.