aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/trace-cmd-record.txt
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2010-03-05 15:41:17 -0500
committerSteven Rostedt <rostedt@goodmis.org>2010-03-05 15:41:17 -0500
commitefc0bfac7b966fbf4776f11a7922d6c0d92e7ac8 (patch)
tree95dd86b790d072f5e73d0a84839d6f93756c5606 /Documentation/trace-cmd-record.txt
parent264e6579fade0e9bca9823ce7272a3cbd7f2d647 (diff)
trace-cmd: Add documentation that will become manpages for trace-cmd
Added a Documentation directory that will become the trace-cmd manpages. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'Documentation/trace-cmd-record.txt')
-rw-r--r--Documentation/trace-cmd-record.txt225
1 files changed, 225 insertions, 0 deletions
diff --git a/Documentation/trace-cmd-record.txt b/Documentation/trace-cmd-record.txt
new file mode 100644
index 0000000..9f43d6d
--- /dev/null
+++ b/Documentation/trace-cmd-record.txt
@@ -0,0 +1,225 @@
1TRACE-CMD-RECORD(1)
2===================
3
4NAME
5----
6trace-cmd-record - record a trace from the Ftrace Linux internal tracer
7
8SYNOPSIS
9--------
10*trace-cmd record* ['OPTIONS'] ['command']
11
12DESCRIPTION
13-----------
14The trace-cmd(1) record command will set up the Ftrace Linux kernel tracer to
15record the specified plugins or events that happen while the 'command'
16executes. If no command is given, then it will record until the user hits
17Ctrl-C.
18
19The record command of trace-cmd will set up the Ftrace tracer to start tracing
20the various events or plugins that are given on the command line. It will then
21create a number of tracing processes (one per CPU) that will start recording
22from the kernel ring buffer straight into temporary files. When the command is
23complete (or Ctrl-C is hit) all the files will be combined into a trace.dat
24file that can later be read (see trace-cmd-report(1)).
25
26OPTIONS
27-------
28*-p* 'plugin'::
29 Specify a trace plugin. Plugins are special Ftrace tracers that usually do
30 more than just trace an event. Common plugins are *function*,
31 *function_graph*, *preemptirqsoff*, *irqsoff*, *preemptoff*, and *wakeup*.
32 A plugin must be supported by the running kernel. To see a list of
33 available plugins, see trace-cmd-list(1).
34
35*-e* 'event'::
36 Specify an event to trace. Various static trace points have been added to
37 the Linux kernel. They are grouped by subsystem where you can enable all
38 events of a given subsystem or specify specific events to be enabled. The
39 'event' is of the format "subsystem:event-name". You can also just specify
40 the subsystem without the ':event-name' or the eventname without the
41 "subsystem:". Using "-e sched_switch" will enable the "sched_switch" event
42 where as, "-e sched" will enable all events under the "sched" subsystem.
43
44 The 'event' can also contain glob expressions. That is, "*stat*" will
45 select all events (or subsystems) that have the characters "stat" in their
46 names.
47
48 The keyword 'all' can be used to enable all events.
49
50*-f* 'filter'::
51 Specify a filter for the previous event. This must come after a *-e*. This
52 will filter what events get recorded based on the content of the event.
53 Filtering is passed to the kernel directly so what filtering is allowed
54 may depend on what verison of the kernel you have. Basically, it will
55 let you use C notation to check if an event should be processed or not.
56
57----------------------------------------
58 ==, >=, <=, >, <, &, |, && and ||
59----------------------------------------
60
61 The above are usually safe to use to compare fields.
62
63*-v*::
64 This will cause all events specified after it on the command line to not
65 be traced. This is useful for selecting a subsystem to be traced but to
66 leave out various events. For Example: "-e sched -v -e "\*stat\*"" will
67 enable all events in the sched subsystem except those that have "stat" in
68 their names.
69
70 Note: the *-v* option was taken from the way grep(1) inverts the following
71 matches.
72
73*-F*::
74 This will filter only the executable that is given on the command line. If
75 no command is given, then it will filter itself (pretty pointless).
76 Using *-F* will let you trace only events that are caused by the given
77 command.
78
79*-P* 'pid'::
80 Similar to *-F* but lets you specify a process ID to trace.
81
82*-o* 'output-file'::
83 By default, trace-cmd report will create a 'trace.dat' file. You can
84 specify a different file to write to with the *-o* option.
85
86*-l* 'function-name'::
87 This will limit the 'function' and 'function_graph' tracers to only trace
88 the given function name. More than one *-l* may be specified on the
89 command line to trace more than one function. The limited use of glob
90 expressions are also allowed. These are 'match\*' to only filter functions
91 that start with 'match'. '\*match' to only filter functions that end with
92 'match'. '\*match\*' to only filter on functions that contain 'match'.
93
94*-g* 'function-name'::
95 This option is for the function_graph plugin. It will graph the given
96 function. That is, it will only trace the function and all functions that
97 it calls. You can have more than one *-g* on the command line.
98
99*-n* 'function-name'::
100 This has the opposite effect of *-l*. The function given with the *-n*
101 option will not be traced. This takes precedence, that is, if you include
102 the same function for both *-n* and *-l*, it will not be traced.
103
104*-d*::
105 Some tracer plugins enable the function tracer by default. Like the
106 latency tracers. This option prevents the function tracer from being
107 enabled at start up.
108
109*-O* 'option'::
110 Ftrace has various options that can be enabled or disabled. This allows
111 you to set them. Appending the text 'no' to an option disables it.
112 For example: "-O nograph-time" will disable the "graph-time" Ftrace
113 option.
114
115*-s* 'interval'::
116 The processes that trace-cmd creates to record from the ring buffer need
117 to wake up to do the recording. Setting the 'interval' to zero will cause
118 the processes to wakeup every time new data is written into the buffer.
119 But since Ftrace is recording kernel activity, the act of this processes
120 going back to sleep may cause new events into the ring buffer which will
121 wake the process back up. This will needlessly add extra data into the
122 ring buffer.
123
124 The 'interval' metric is microseconds. The default is set to 1000 (1 ms).
125 This is the time each recording process will sleep before waking up to
126 record any new data that was written to the ring buffer.
127
128*-b* 'size'::
129 This sets the ring buffer size to 'size' kilobytes. Because the Ftrace
130 ring buffer is per CPU, this size is the size of each per CPU ring buffer
131 inside the kernel. Using "-b 10000" on a machine with 4 CPUs will make
132 Ftrace have a total buffer size of 40 Megs.
133
134*-N* 'host:port'::
135 If another machine is running "trace-cmd listen", this option is used to
136 have the data sent to that machine with UDP packets. Instead of writing
137 to an output file, the data is sent off to a remote box. This is ideal for
138 embedded machines with little storage, or having a single machine that
139 will keep all the data in a single repository.
140
141*-t*::
142 This option is used with *-N*, when there's a need to send the live data
143 with TCP packets instead of UDP. Although TCP is not nearly as fast as
144 sending the UDP packets, but it may be needed if the network is not that
145 reliable, the amount of data is not that intensive, and a guarantee is
146 needed that all traced information is transfered successfully.
147
148
149EXAMPLES
150--------
151
152The basic way to trace all events:
153
154------------------------------
155 # trace-cmd record -e all ls > /dev/null
156 # trace-cmd report
157 trace-cmd-13541 [003] 106260.693809: filemap_fault: address=0x128122 offset=0xce
158 trace-cmd-13543 [001] 106260.693809: kmalloc: call_site=81128dd4 ptr=0xffff88003dd83800 bytes_req=768 bytes_alloc=1024 gfp_flags=GFP_KERNEL|GFP_ZERO
159 ls-13545 [002] 106260.693809: kfree: call_site=810a7abb ptr=0x0
160 ls-13545 [002] 106260.693818: sys_exit_write: 0x1
161
162
163------------------------------
164
165
166
167To use the function tracer with sched switch tracing:
168
169------------------------------
170 # trace-cmd record -p function -e sched_switch ls > /dev/null
171 # trace-cmd report
172 ls-13587 [002] 106467.860310: function: hrtick_start_fair <-- pick_next_task_fair
173 ls-13587 [002] 106467.860313: sched_switch: prev_comm=trace-cmd prev_pid=13587 prev_prio=120 prev_state=R ==> next_comm=trace-cmd next_pid=13583 next_prio=120
174 trace-cmd-13585 [001] 106467.860314: function: native_set_pte_at <-- __do_fault
175 trace-cmd-13586 [003] 106467.860314: function: up_read <-- do_page_fault
176 ls-13587 [002] 106467.860317: function: __phys_addr <-- schedule
177 trace-cmd-13585 [001] 106467.860318: function: _raw_spin_unlock <-- __do_fault
178 ls-13587 [002] 106467.860320: function: native_load_sp0 <-- __switch_to
179 trace-cmd-13586 [003] 106467.860322: function: down_read_trylock <-- do_page_fault
180
181
182------------------------------
183
184Here is a nice way to find what interrupts have the highest latency:
185------------------------------------------
186 # trace-cmd record -p function_graph -e irq_handler_entry -l do_IRQ sleep 10
187 # trace-cmd report
188 <idle>-0 [000] 157412.933969: funcgraph_entry: | do_IRQ() {
189 <idle>-0 [000] 157412.933974: irq_handler_entry: irq=48 name=eth0
190 <idle>-0 [000] 157412.934004: funcgraph_exit: + 36.358 us | }
191 <idle>-0 [000] 157413.895004: funcgraph_entry: | do_IRQ() {
192 <idle>-0 [000] 157413.895011: irq_handler_entry: irq=48 name=eth0
193 <idle>-0 [000] 157413.895026: funcgraph_exit: + 24.014 us | }
194 <idle>-0 [000] 157415.891762: funcgraph_entry: | do_IRQ() {
195 <idle>-0 [000] 157415.891769: irq_handler_entry: irq=48 name=eth0
196 <idle>-0 [000] 157415.891784: funcgraph_exit: + 22.928 us | }
197 <idle>-0 [000] 157415.934869: funcgraph_entry: | do_IRQ() {
198 <idle>-0 [000] 157415.934874: irq_handler_entry: irq=48 name=eth0
199 <idle>-0 [000] 157415.934906: funcgraph_exit: + 37.512 us | }
200 <idle>-0 [000] 157417.888373: funcgraph_entry: | do_IRQ() {
201 <idle>-0 [000] 157417.888381: irq_handler_entry: irq=48 name=eth0
202 <idle>-0 [000] 157417.888398: funcgraph_exit: + 25.943 us | }
203
204
205------------------------------------------
206
207SEE ALSO
208--------
209trace-cmd(1), trace-cmd-report(1), trace-cmd-start(1), trace-cmd-stop(1),
210trace-cmd-extract(1), trace-cmd-reset(1), trace-cmd-split(1),
211trace-cmd-list(1), trace-cmd-listen(1)
212
213AUTHOR
214------
215Written by Steven Rostedt, <rostedt@goodmis.org>
216
217RESOURCES
218---------
219git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git
220
221COPYING
222-------
223Copyright \(C) 2010 Red Hat, Inc. Free use of this software is granted under
224the terms of the GNU Public License (GPL).
225