Trace-cmd
   HOME

TheInfoList



OR:

ftrace (Function Tracer) is a tracing
framework A framework is a generic term commonly referring to an essential supporting structure which other things are built on top of. Framework may refer to: Computing * Application framework, used to implement the structure of an application for an op ...
for the
Linux kernel The Linux kernel is a Free and open-source software, free and open source Unix-like kernel (operating system), kernel that is used in many computer systems worldwide. The kernel was created by Linus Torvalds in 1991 and was soon adopted as the k ...
. Although its original name, Function Tracer, came from ftrace's ability to record information related to various
function call In computer programming, a function (also procedure, method, subroutine, routine, or subprogram) is a callable unit of software logic that has a well-defined interface and behavior and can be invoked multiple times. Callable units provide a p ...
s performed while the
kernel Kernel may refer to: Computing * Kernel (operating system), the central component of most operating systems * Kernel (image processing), a matrix used for image convolution * Compute kernel, in GPGPU programming * Kernel method, in machine learnin ...
is running, ftrace's tracing capabilities cover a much broader range of kernel's internal operations.


Details

With its various tracer plugins, ftrace can be targeted at different static tracepoints, such as
scheduling A schedule (, ) or a timetable, as a basic time-management tool, consists of a list of times at which possible tasks, events, or actions are intended to take place, or of a sequence of events in the chronological order in which such things ...
events,
interrupt In digital computers, an interrupt (sometimes referred to as a trap) is a request for the processor to ''interrupt'' currently executing code (when permitted), so that the event can be processed in a timely manner. If the request is accepted ...
s,
memory-mapped I/O Memory-mapped I/O (MMIO) and port-mapped I/O (PMIO) are two complementary methods of performing input/output (I/O) between the central processing unit (CPU) and peripheral devices in a computer (often mediating access via chipset). An altern ...
, CPU power state transitions, and operations related to file systems and
virtualization In computing, virtualization (abbreviated v12n) is a series of technologies that allows dividing of physical computing resources into a series of virtual machines, operating systems, processes or containers. Virtualization began in the 1960s wit ...
. 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 graph A call graph (also known as a call multigraph) is a control-flow graph, which represents calling relationships between subroutines in a computer program. Each node represents a procedure and each edge ''(f, g)'' indicates that procedure ''f'' c ...
s and provide
stack Stack may refer to: Places * Stack Island, an island game reserve in Bass Strait, south-eastern Australia, in Tasmania’s Hunter Island Group * Blue Stack Mountains, in Co. Donegal, Ireland People * Stack (surname) (including a list of people ...
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. 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 debugfs is a special file system available in the Linux kernel since version 2.6.10-rc3.Linux: DebugFS
, by Jeremy, De ...
file system; as a result, ftrace requires no specialized
userspace A modern computer operating system usually uses virtual memory to provide separate address spaces or regions of a single address space, called user space and kernel space. This separation primarily provides memory protection and hardware prote ...
utilities to operate. 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''. Internally, ftrace relies on the gcc's profiling mechanism to prepend
machine instruction In computer programming, machine code is computer code consisting of machine language instructions, which are used to control a computer's central processing unit (CPU). For conventional binary computers, machine code is the binaryOn nonbi ...
s to the
compile In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs that ...
d versions of all
source Source may refer to: Research * Historical document * Historical source * Source (intelligence) or sub source, typically a confidential provider of non open-source intelligence * Source (journalism), a person, publication, publishing institute ...
-level kernel functions, which redirect the execution of functions to the ftrace's
trampolines A trampoline is a device consisting of a piece of taut, strong fabric stretched between a steel frame often using many coiled springs. People bounce on trampolines for recreational and competitive purposes. The fabric that users bounce on (c ...
and tracer plugins that perform the actual tracing. These "
entry point In computer programming, an entry point is the place in a program where the execution of a program begins, and where the program has access to command line arguments. To start a program's execution, the loader or operating system passes co ...
" 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. ftrace is developed primarily by Steven Rostedt, and it was merged into the
Linux kernel mainline The Linux kernel is a Free and open-source software, free and open source Unix-like kernel (operating system), kernel that is used in many computer systems worldwide. The kernel was created by Linus Torvalds in 1991 and was soon adopted as the k ...
in kernel version 2.6.27, which was released on October 9, 2008.


See also

*
DTrace DTrace is a comprehensive dynamic tracing framework originally created by Sun Microsystems for troubleshooting kernel and application problems on production systems in real time. Originally developed for Solaris, it has since been released un ...
a tracing framework for troubleshooting kernel and application problems, originally developed for Solaris *
ktrace ktrace is a utility included with certain versions of BSD Unix and Mac OS X that traces kernel interaction with a program and dumps it to disk for the purposes of debugging and analysis. Traced kernel operations include system calls, name tran ...
a BSD Unix and Mac OS X utility that traces kernel–program interactions *
ltrace ltrace is a debugging utility in Linux, used to display the calls a userspace application makes to shared libraries. It does this by hooking into the dynamic loading system, allowing it to insert shims which display the parameters which the app ...
a Linux debugging utility, displays the calls a userland application makes to shared libraries *
strace strace is a diagnostic, debugging and instructional userspace utility for Linux. It is used to monitor and tamper with interactions between processes and the Linux kernel, which include system calls, signal deliveries, and changes of process s ...
a debugging utility for Linux and some other Unix-like systems, monitors system calls used by a program and all received signals *
SystemTap In computing, SystemTap () is a scripting language and tool for dynamically instrumenting running production Linux-based operating systems. System administrators can use SystemTap to extract, filter and summarize data in order to enable diagnosi ...
a scripting language and utility used for instrumenting Linux systems


References


External links


Debugging the kernel using Ftrace part 1
an
part 2
LWN.net LWN.net is a computing webzine with an emphasis on free software and software for Linux and other Unix-like operating systems. It consists of a weekly issue, separate stories which are published most days, and threaded discussion attached to ever ...
, December 2009, by Steven Rostedt
Secrets of the Ftrace function tracer
LWN.net, January 20, 2010, by Steven Rostedt
Ftrace: The hidden light switch
LWN.net, August 13, 2014, by Brendan Gregg
The source of the e1000e corruption bug
LWN.net, October 21, 2008, by Jonathan Corbet {{Operating system Debugging Free software programmed in C Linux kernel features Unix programming tools