Kernel #43
Labels
bug
Something isn't working
documentation
Improvements or additions to documentation
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
question
Further information is requested
Copyright 2008 Red Hat Inc.
Author: Steven Rostedt [email protected]
License: The GNU Free Documentation License, Version 1.2
(dual licensed under the GPL v2)
Original Reviewers: Elias Oltmanns, Randy Dunlap, Andrew Morton,
John Kacur, and David Teigland.
Written for: 2.6.28-rc2
Updated for: 3.10
Updated for: 4.13 - Copyright 2017 VMware Inc. Steven Rostedt
Introduction
Ftrace is an internal tracer designed to help out developers and
designers of systems to find what is going on inside the kernel.
It can be used for debugging or analyzing latencies and
performance issues that take place outside of user-space.
Although ftrace is typically considered the function tracer, it
is really a frame work of several assorted tracing utilities.
There's latency tracing to examine what occurs between interrupts
disabled and enabled, as well as for preemption and from a time
a task is woken to the task is actually scheduled in.
One of the most common uses of ftrace is the event tracing.
Through out the kernel is hundreds of static event points that
can be enabled via the tracefs file system to see what is
going on in certain parts of the kernel.
See events.txt for more information.
Implementation Details
See ftrace-design.txt for details for arch porters and such.
The File System
Ftrace uses the tracefs file system to hold the control files as
well as the files to display output.
When tracefs is configured into the kernel (which selecting any ftrace
option will do) the directory /sys/kernel/tracing will be created. To mount
this directory, you can add to your /etc/fstab file:
tracefs /sys/kernel/tracing tracefs defaults 0 0
Or you can mount it at run time with:
mount -t tracefs nodev /sys/kernel/tracing
For quicker access to that directory you may want to make a soft link to
it:
ln -s /sys/kernel/tracing /tracing
Before 4.1, all ftrace tracing control files were within the debugfs
file system, which is typically located at /sys/kernel/debug/tracing.
For backward compatibility, when mounting the debugfs file system,
the tracefs file system will be automatically mounted at:
/sys/kernel/debug/tracing
All files located in the tracefs file system will be located in that
debugfs file system directory as well.
Any selected ftrace option will also create the tracefs file system.
The rest of the document will assume that you are in the ftrace directory
(cd /sys/kernel/tracing) and will only concentrate on the files within that
directory and not distract from the content with the extended
"/sys/kernel/tracing" path name.
That's it! (assuming that you have ftrace configured into your kernel)
After mounting tracefs you will have access to the control and output files
of ftrace. Here is a list of some of the key files:
Note: all time values are in microseconds.
current_tracer:
available_tracers:
tracing_on:
trace:
trace_pipe:
trace_options:
options:
tracing_max_latency:
tracing_thresh:
buffer_size_kb:
buffer_total_size_kb:
free_buffer:
tracing_cpumask:
set_ftrace_filter:
set_ftrace_notrace:
set_ftrace_pid:
set_event_pid:
set_graph_function:
set_graph_notrace:
available_filter_functions:
dyn_ftrace_total_info:
enabled_functions:
function_profile_enabled:
trace_stats:
kprobe_events:
kprobe_profile:
max_graph_depth:
printk_formats:
saved_cmdlines:
saved_cmdlines_size:
saved_tgids:
snapshot:
stack_max_size:
stack_trace:
stack_trace_filter:
trace_clock:
trace_marker:
trace_marker_raw:
uprobe_events:
uprobe_profile:
instances:
events:
set_event:
available_events:
hwlat_detector:
per_cpu:
per_cpu/cpu0/buffer_size_kb:
per_cpu/cpu0/trace:
per_cpu/cpu0/trace_pipe
per_cpu/cpu0/trace_pipe_raw
per_cpu/cpu0/snapshot:
per_cpu/cpu0/snapshot_raw:
The text was updated successfully, but these errors were encountered: