Linux kernel tracing and performance analysis
Though debugging by printing covers most of the debugging needs, there are situations where we need to monitor the Linux kernel at runtime to track strange behavior, including latencies, CPU hogging, scheduling issues, and so on. In the Linux world, the most useful tool for achieving this is part of the kernel itself. The most important is ftrace
, which is a Linux kernel internal tracing tool, and is the main topic of this section.
Using Ftrace to instrument the code
Function Trace, in short Ftrace, does much more than what its name says. For example, it can be used to measure the time it takes to process interrupts, to track time-consuming functions, calculate the time to activate high-priority tasks, to track context switches, and much more.
Developed by Steven Rostedt, Ftrace has been included in the kernel since version 2.6.27 in 2008. This is the framework that provides a debugging ring buffer for recording data. This data...