1TRACE-CMD-REPORT(1) libtracefs Manual TRACE-CMD-REPORT(1)
2
3
4
6 trace-cmd-report - show in ASCII a trace created by trace-cmd record
7
9 trace-cmd report [OPTIONS] [input-file]
10
12 The trace-cmd(1) report command will output a human readable report of
13 a trace created by trace-cmd record.
14
16 -i input-file
17 By default, trace-cmd report will read the file trace.dat. But the
18 -i option open up the given input-file instead. Note, the input
19 file may also be specified as the last item on the command line.
20
21 -e
22 This outputs the endianess of the file. trace-cmd report is smart
23 enough to be able to read big endian files on little endian
24 machines, and vise versa.
25
26 -f
27 This outputs the list of all functions that have been mapped in the
28 trace.dat file. Note, this list may contain functions that may not
29 appear in the trace, as it is the list of mappings to translate
30 function addresses into function names.
31
32 -P
33 This outputs the list of "trace_printk()" data. The raw trace data
34 points to static pointers in the kernel. This must be stored in the
35 trace.dat file.
36
37 -E
38 This lists the possible events in the file (but this list is not
39 necessarily the list of events in the file).
40
41 --events
42 This will list the event formats that are stored in the trace.dat
43 file.
44
45 --event regex
46 This will print events that match the given regex. If a colon is
47 specified, then the characters before the colon will be used to
48 match the system and the characters after the colon will match the
49 event.
50
51 trace-cmd report --event sys:read
52
53 The above will only match events where the system name contains "sys"
54 and the event name contains "read".
55
56 trace-cmd report --event read
57
58 The above will match all events that contain "read" in its name. Also it
59 may list all events of a system that contains "read" as well.
60
61 --check-events
62 This will parse the event format strings that are stored in the
63 trace.dat file and return whether the formats can be parsed
64 correctly. It will load plugins unless -N is specified.
65
66 -t
67 Print the full timestamp. The timestamps in the data file are
68 usually recorded to the nanosecond. But the default display of the
69 timestamp is only to the microsecond. To see the full timestamp,
70 add the -t option.
71
72 -F filter
73 Add a filter to limit what events are displayed. The format of the
74 filter is:
75
76
77 .ft C
78 <events> ':' <filter>
79 <events> = SYSTEM'/'EVENT | SYSTEM | EVENT | <events> ',' <events>
80 <filter> = EVENT_FIELD <op> <value> | <filter> '&&' <filter> |
81 <filter> '||' <filter> | '(' <filter> ')' | '!' <filter>
82 <op> = '==' | '!=' | '>=' | '<=' | '>' | '<' | '&' | '|' | '^' |
83 '+' | '-' | '*' | '/' | '%'
84 <value> = NUM | STRING | EVENT_FIELD
85 .ft
86
87
88 SYSTEM is the name of the system to filter on. If the EVENT is left out,
89 then it applies to all events under the SYSTEM. If only one string is used
90 without the '/' to deliminate between SYSTEM and EVENT, then the filter
91 will be applied to all systems and events that match the given string.
92
93 Whitespace is ignored, such that "sched:next_pid==123" is equivalent to
94 "sched : next_pid == 123".
95
96 STRING is defined with single or double quotes (single quote must end with
97 single quote, and double with double). Whitespace within quotes are not
98 ignored.
99
100 The representation of a SYSTEM or EVENT may also be a regular expression
101 as defined by 'regcomp(3)'.
102
103 The EVENT_FIELD is the name of the field of an event that is being
104 filtered. If the event does not contain the EVENT_FIELD, that part of the
105 equation will be considered false.
106
107
108 .ft C
109 -F 'sched : bogus == 1 || common_pid == 2'
110 .ft
111
112
113 The "bogus == 1" will always evaluate to FALSE because no event has a
114 field called "bogus", but the "common_pid == 2" will still be evaluated
115 since all events have the field "common_pid". Any "sched" event that was
116 traced by the process with the PID of 2 will be shown.
117
118 Note, the EVENT_FIELD is the field name as shown by an events format
119 (as displayed with *--events*), and not what is found in the output.
120 If the output shows "ID:foo" but the field that "foo" belongs to was
121 called "name" in the event format, then "name" must be used in the filter.
122 The same is true about values. If the value that is displayed is converted
123 by to a string symbol, the filter checks the original value and not the
124 value displayed. For example, to filter on all tasks that were in the
125 running state at a context switch:
126
127
128 .ft C
129 -F 'sched/sched_switch : prev_state==0'
130 .ft
131
132
133 Although the output displays 'R', having 'prev_stat=="R"' will not work.
134
135 Note: You can also specify 'COMM' as an EVENT_FIELD. This will use the
136 task name (or comm) of the record to compare. For example, to filter out
137 all of the "trace-cmd" tasks:
138
139
140 .ft C
141 -F '.*:COMM != "trace-cmd"'
142 .ft
143
144
145 -I
146 Do not print events where the HARDIRQ latency flag is set. This
147 will filter out most events that are from interrupt context. Note,
148 it may not filter out function traced functions that are in
149 interrupt context but were called before the kernel "in interrupt"
150 flag was set.
151
152 -S
153 Do not print events where the SOFTIRQ latency flag is set. This
154 will filter out most events that are from soft interrupt context.
155
156 -v
157 This causes the following filters of -F to filter out the matching
158 events.
159
160
161 .ft C
162 -v -F 'sched/sched_switch : prev_state == 0'
163 .ft
164
165
166 Will not display any sched_switch events that have a prev_state of 0.
167 Removing the *-v* will only print out those events.
168
169 -T
170 Test the filters of -F. After processing a filter string, the
171 resulting filter will be displayed for each event. This is useful
172 for using a filter for more than one event where a field may not
173 exist in all events. Also it can be used to make sure there are no
174 misspelled event field names, as they will simply be ignored. -T
175 is ignored if -F is not specified.
176
177 -V
178 Show verbose messages (see --verbose but only for the numbers)
179
180 -L
181 This will not load system wide plugins. It loads "local only". That
182 is what it finds in the ~/.trace-cmd/plugins directory.
183
184 -N
185 This will not load any plugins.
186
187 -n event-re
188 This will cause all events that match the option to ignore any
189 registered handler (by the plugins) to print the event. The normal
190 event will be printed instead. The event-re is a regular expression
191 as defined by regcomp(3).
192
193 --profile
194 With the --profile option, "trace-cmd report" will process all the
195 events first, and then output a format showing where tasks have
196 spent their time in the kernel, as well as where they are blocked
197 the most, and where wake up latencies are.
198
199 See trace-cmd-profile(1) for more details and examples.
200
201 -G
202 Set interrupt (soft and hard) events as global (associated to CPU
203 instead of tasks). Only works for --profile.
204
205 -H event-hooks
206 Add custom event matching to connect any two events together.
207
208 See trace-cmd-profile(1) for format.
209
210 -R
211 This will show the events in "raw" format. That is, it will ignore
212 the event’s print formatting and just print the contents of each
213 field.
214
215 -r event-re
216 This will cause all events that match the option to print its raw
217 fields. The event-re is a regular expression as defined by
218 regcomp(3).
219
220 -l
221 This adds a "latency output" format. Information about interrupts
222 being disabled, soft irq being disabled, the "need_resched" flag
223 being set, preempt count, and big kernel lock are all being
224 recorded with every event. But the default display does not show
225 this information. This option will set display this information
226 with 6 characters. When one of the fields is zero or N/A a '.\' is
227 shown.
228
229
230 .ft C
231 <idle>-0 0d.h1. 106467.859747: function: ktime_get <-- tick_check_idle
232 .ft
233
234
235 The 0d.h1. denotes this information. The first character is never a '.'
236 and represents what CPU the trace was recorded on (CPU 0). The 'd' denotes
237 that interrupts were disabled. The 'h' means that this was called inside
238 an interrupt handler. The '1' is the preemption disabled (preempt_count)
239 was set to one. The two '.'s are "need_resched" flag and kernel lock
240 counter. If the "need_resched" flag is set, then that character would be a
241 'N'.
242
243 -w
244 If both the sched_switch and sched_wakeup events are enabled, then
245 this option will report the latency between the time the task was
246 first woken, and the time it was scheduled in.
247
248 -q
249 Quiet non critical warnings.
250
251 -O
252 Pass options to the trace-cmd plugins that are loaded.
253
254 -O plugin:var=value
255
256 The 'plugin:' and '=value' are optional. Value may be left off for options
257 that are boolean. If the 'plugin:' is left off, then any variable that matches
258 in all plugins will be set.
259
260 Example: -O fgraph:tailprint
261
262 --cpu <cpu list>
263 List of CPUs, separated by "," or ":", used for filtering the
264 events. A range of CPUs can be specified using "cpuX-cpuY"
265 notation, where all CPUs in the range between cpuX and cpuY will be
266 included in the list. The order of CPUs in the list must be from
267 lower to greater.
268
269 Example: "--cpu 0,3" - show events from CPUs 0 and 3
270 "--cpu 2-4" - show events from CPUs 2, 3 and 4
271
272 --cpus
273 List the CPUs that have data in the trace file then exit.
274
275 --stat
276 If the trace.dat file recorded the final stats (outputed at the end
277 of record) the --stat option can be used to retrieve them.
278
279 --uname
280 If the trace.dat file recorded uname during the run, this will
281 retrieve that information.
282
283 --version
284 If the trace.dat file recorded the version of the executable used
285 to create it, report that version.
286
287 --ts-offset offset
288 Add (or subtract if negative) an offset for all timestamps of the
289 previous data file specified with -i. This is useful to merge sort
290 multiple trace.dat files where the difference in the timestamp is
291 known. For example if a trace is done on a virtual guest, and
292 another trace is done on the host. If the host timestamp is 1000
293 units ahead of the guest, the following can be done:
294
295 trace-cmd report -i host.dat --ts-offset -1000 -i guest.dat
296
297 This will subtract 1000 timestamp units from all the host events as it merges
298 with the guest.dat events. Note, the units is for the raw units recorded in
299 the trace. If the units are nanoseconds, the addition (or subtraction) from
300 the offset will be nanoseconds even if the displayed units are microseconds.
301
302 --ts2secs HZ
303 Convert the current clock source into a second (nanosecond
304 resolution) output. When using clocks like x86-tsc, if the
305 frequency is known, by passing in the clock frequency, this will
306 convert the time to seconds.
307
308 This option affects any trace.dat file given with *-i* proceeding it.
309 If this option comes before any *-i* option, then that value becomes
310 the default conversion for all other trace.dat files. If another
311 --ts2secs option appears after a *-i* trace.dat file, than that option
312 will override the default value.
313
314 Example: On a 3.4 GHz machine
315
316 trace-cmd record -p function -C x86-tsc
317
318 trace-cmd report --ts2ns 3400000000
319
320 The report will convert the cycles timestamps into a readable second
321 display. The default display resolution is microseconds, unless *-t*
322 is used.
323
324 The value of --ts-offset must still be in the raw timestamp units, even
325 with this option. The offset will be converted as well.
326
327 --ts-diff
328 Show the time differences between events. The difference will
329 appear in parenthesis just after the timestamp.
330
331 --ts-check
332 Make sure no timestamp goes backwards, and if it does, print out a
333 warning message of the fact.
334
335 --nodate
336 Ignore converting the timestamps to the date set by trace-cmd
337 record(3) --date option.
338
339 --raw-ts
340 Display raw timestamps, without any corrections.
341
342 --align-ts
343 Display timestamps aligned to the first event.
344
345 --verbose[=level]
346 Set the log level. Supported log levels are "none", "crit", "err",
347 "warn", "info", "debug", "all" or their identifiers "0", "1", "2",
348 "3", "4", "5", "6". Setting the log level to specific value enables
349 all logs from that and all previous levels. The level will default
350 to "info" if one is not specified.
351
352 Example: enable all critical, error and warning logs
353
354 trace-cmd report --verbose=warning
355
357 Using a trace.dat file that was created with:
358
359
360 .ft C
361 # trace-cmd record -p function -e all sleep 5
362 .ft
363
364
365 The default report shows:
366
367
368 .ft C
369 # trace-cmd report
370 trace-cmd-16129 [002] 158126.498411: function: __mutex_unlock_slowpath <-- mutex_unlock
371 trace-cmd-16131 [000] 158126.498411: kmem_cache_alloc: call_site=811223c5 ptr=0xffff88003ecf2b40 bytes_req=272 bytes_alloc=320 gfp_flags=GFP_KERNEL|GFP_ZERO
372 trace-cmd-16130 [003] 158126.498411: function: do_splice_to <-- sys_splice
373 sleep-16133 [001] 158126.498412: function: inotify_inode_queue_event <-- vfs_write
374 trace-cmd-16129 [002] 158126.498420: lock_release: 0xffff88003f1fa4f8 &sb->s_type->i_mutex_key
375 trace-cmd-16131 [000] 158126.498421: function: security_file_alloc <-- get_empty_filp
376 sleep-16133 [001] 158126.498422: function: __fsnotify_parent <-- vfs_write
377 trace-cmd-16130 [003] 158126.498422: function: rw_verify_area <-- do_splice_to
378 trace-cmd-16131 [000] 158126.498424: function: cap_file_alloc_security <-- security_file_alloc
379 trace-cmd-16129 [002] 158126.498425: function: syscall_trace_leave <-- int_check_syscall_exit_work
380 sleep-16133 [001] 158126.498426: function: inotify_dentry_parent_queue_event <-- vfs_write
381 trace-cmd-16130 [003] 158126.498426: function: security_file_permission <-- rw_verify_area
382 trace-cmd-16129 [002] 158126.498428: function: audit_syscall_exit <-- syscall_trace_leave
383 [...]
384 .ft
385
386
387 To see everything but the function traces:
388
389
390 .ft C
391 # trace-cmd report -v -F 'function'
392 trace-cmd-16131 [000] 158126.498411: kmem_cache_alloc: call_site=811223c5 ptr=0xffff88003ecf2b40 bytes_req=272 bytes_alloc=320 gfp_flags=GFP_KERNEL|GFP_ZERO
393 trace-cmd-16129 [002] 158126.498420: lock_release: 0xffff88003f1fa4f8 &sb->s_type->i_mutex_key
394 trace-cmd-16130 [003] 158126.498436: lock_acquire: 0xffffffff8166bf78 read all_cpu_access_lock
395 trace-cmd-16131 [000] 158126.498438: lock_acquire: 0xffff88003df5b520 read &fs->lock
396 trace-cmd-16129 [002] 158126.498446: kfree: call_site=810a7abb ptr=0x0
397 trace-cmd-16130 [003] 158126.498448: lock_acquire: 0xffff880002250a80 &per_cpu(cpu_access_lock, cpu)
398 trace-cmd-16129 [002] 158126.498450: sys_exit_splice: 0xfffffff5
399 trace-cmd-16131 [000] 158126.498454: lock_release: 0xffff88003df5b520 &fs->lock
400 sleep-16133 [001] 158126.498456: kfree: call_site=810a7abb ptr=0x0
401 sleep-16133 [001] 158126.498460: sys_exit_write: 0x1
402 trace-cmd-16130 [003] 158126.498462: kmalloc: call_site=810bf95b ptr=0xffff88003dedc040 bytes_req=24 bytes_alloc=32 gfp_flags=GFP_KERNEL|GFP_ZERO
403 .ft
404
405
406 To see only the kmalloc calls that were greater than 1000 bytes:
407
408
409 .ft C
410 #trace-cmd report -F 'kmalloc: bytes_req > 1000'
411 <idle>-0 [000] 158128.126641: kmalloc: call_site=81330635 ptr=0xffff88003c2fd000 bytes_req=2096 bytes_alloc=4096 gfp_flags=GFP_ATOMIC
412 .ft
413
414
415 To see wakeups and sched switches that left the previous task in the
416 running state:
417
418
419 .ft C
420 # trace-cmd report -F 'sched: prev_state == 0 || (success == 1)'
421 trace-cmd-16132 [002] 158126.499951: sched_wakeup: comm=trace-cmd pid=16129 prio=120 success=1 target_cpu=002
422 trace-cmd-16132 [002] 158126.500401: sched_switch: prev_comm=trace-cmd prev_pid=16132 prev_prio=120 prev_state=R ==> next_comm=trace-cmd next_pid=16129 next_prio=120
423 <idle>-0 [003] 158126.500585: sched_wakeup: comm=trace-cmd pid=16130 prio=120 success=1 target_cpu=003
424 <idle>-0 [003] 158126.501241: sched_switch: prev_comm=swapper prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=trace-cmd next_pid=16130 next_prio=120
425 trace-cmd-16132 [000] 158126.502475: sched_wakeup: comm=trace-cmd pid=16131 prio=120 success=1 target_cpu=000
426 trace-cmd-16131 [002] 158126.506516: sched_wakeup: comm=trace-cmd pid=16129 prio=120 success=1 target_cpu=002
427 <idle>-0 [003] 158126.550110: sched_switch: prev_comm=swapper prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=trace-cmd next_pid=16130 next_prio=120
428 trace-cmd-16131 [003] 158126.570243: sched_wakeup: comm=trace-cmd pid=16129 prio=120 success=1 target_cpu=003
429 trace-cmd-16130 [002] 158126.618202: sched_switch: prev_comm=trace-cmd prev_pid=16130 prev_prio=120 prev_state=R ==> next_comm=yum-updatesd next_pid=3088 next_prio=1 20
430 trace-cmd-16129 [003] 158126.622379: sched_wakeup: comm=trace-cmd pid=16131 prio=120 success=1 target_cpu=003
431 trace-cmd-16129 [000] 158126.649287: sched_wakeup: comm=trace-cmd pid=16131 prio=120 success=1 target_cpu=000
432 .ft
433
434
435 The above needs a little explanation. The filter specifies the "sched"
436 subsystem, which includes both sched_switch and sched_wakeup events.
437 Any event that does not have the format field "prev_state" or
438 "success", will evaluate those expressions as FALSE, and will not
439 produce a match. Using "||" will have the "prev_state" test happen for
440 the "sched_switch" event and the "success" test happen for the
441 "sched_wakeup" event.
442
443
444 .ft C
445 # trace-cmd report -w -F 'sched_switch, sched_wakeup.*'
446 [...]
447 trace-cmd-16130 [003] 158131.580616: sched_wakeup: comm=trace-cmd pid=16131 prio=120 success=1 target_cpu=003
448 trace-cmd-16129 [000] 158131.581502: sched_switch: prev_comm=trace-cmd prev_pid=16129 prev_prio=120 prev_state=S ==> next_comm=trace-cmd next_pid=16131 next_prio=120 Latency: 885.901 usecs
449 trace-cmd-16131 [000] 158131.582414: sched_wakeup: comm=trace-cmd pid=16129 prio=120 success=1 target_cpu=000
450 trace-cmd-16132 [001] 158131.583219: sched_switch: prev_comm=trace-cmd prev_pid=16132 prev_prio=120 prev_state=S ==> next_comm=trace-cmd next_pid=16129 next_prio=120 Latency: 804.809 usecs
451 sleep-16133 [002] 158131.584121: sched_wakeup: comm=trace-cmd pid=16120 prio=120 success=1 target_cpu=002
452 trace-cmd-16129 [001] 158131.584128: sched_wakeup: comm=trace-cmd pid=16132 prio=120 success=1 target_cpu=001
453 sleep-16133 [002] 158131.584275: sched_switch: prev_comm=sleep prev_pid=16133 prev_prio=120 prev_state=R ==> next_comm=trace-cmd next_pid=16120 next_prio=120 Latency: 153.915 usecs
454 trace-cmd-16130 [003] 158131.585284: sched_switch: prev_comm=trace-cmd prev_pid=16130 prev_prio=120 prev_state=S ==> next_comm=trace-cmd next_pid=16132 next_prio=120 Latency: 1155.677 usecs
455
456 Average wakeup latency: 26626.656 usecs
457 .ft
458
459
460 The above trace produces the wakeup latencies of the tasks. The
461 "sched_switch" event reports each individual latency after writing the
462 event information. At the end of the report, the average wakeup latency
463 is reported.
464
465
466 .ft C
467 # trace-cmd report -w -F 'sched_switch, sched_wakeup.*: prio < 100 || next_prio < 100'
468 <idle>-0 [003] 158131.516753: sched_wakeup: comm=ksoftirqd/3 pid=13 prio=49 success=1 target_cpu=003
469 <idle>-0 [003] 158131.516855: sched_switch: prev_comm=swapper prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=ksoftirqd/3 next_pid=13 next_prio=49 Latency: 101.244 usecs
470 <idle>-0 [003] 158131.533781: sched_wakeup: comm=ksoftirqd/3 pid=13 prio=49 success=1 target_cpu=003
471 <idle>-0 [003] 158131.533897: sched_switch: prev_comm=swapper prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=ksoftirqd/3 next_pid=13 next_prio=49 Latency: 115.608 usecs
472 <idle>-0 [003] 158131.569730: sched_wakeup: comm=ksoftirqd/3 pid=13 prio=49 success=1 target_cpu=003
473 <idle>-0 [003] 158131.569851: sched_switch: prev_comm=swapper prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=ksoftirqd/3 next_pid=13 next_prio=49 Latency: 121.024 usecs
474
475 Average wakeup latency: 110.021 usecs
476 .ft
477
478
479 The above version will only show the wakeups and context switches of
480 Real Time tasks. The prio used inside the kernel starts at 0 for
481 highest priority. That is prio 0 is equivalent to user space real time
482 priority 99, and priority 98 is equivalent to user space real time
483 priority 1. Prios less than 100 represent Real Time tasks.
484
485 An example of the profile:
486
487
488 .ft C
489 # trace-cmd record --profile sleep 1
490 # trace-cmd report --profile --comm sleep
491 task: sleep-21611
492 Event: sched_switch:R (1) Total: 99442 Avg: 99442 Max: 99442 Min:99442
493 <stack> 1 total:99442 min:99442 max:99442 avg=99442
494 => ftrace_raw_event_sched_switch (0xffffffff8105f812)
495 => __schedule (0xffffffff8150810a)
496 => preempt_schedule (0xffffffff8150842e)
497 => ___preempt_schedule (0xffffffff81273354)
498 => cpu_stop_queue_work (0xffffffff810b03c5)
499 => stop_one_cpu (0xffffffff810b063b)
500 => sched_exec (0xffffffff8106136d)
501 => do_execve_common.isra.27 (0xffffffff81148c89)
502 => do_execve (0xffffffff811490b0)
503 => SyS_execve (0xffffffff811492c4)
504 => return_to_handler (0xffffffff8150e3c8)
505 => stub_execve (0xffffffff8150c699)
506 Event: sched_switch:S (1) Total: 1000506680 Avg: 1000506680 Max: 1000506680 Min:1000506680
507 <stack> 1 total:1000506680 min:1000506680 max:1000506680 avg=1000506680
508 => ftrace_raw_event_sched_switch (0xffffffff8105f812)
509 => __schedule (0xffffffff8150810a)
510 => schedule (0xffffffff815084b8)
511 => do_nanosleep (0xffffffff8150b22c)
512 => hrtimer_nanosleep (0xffffffff8108d647)
513 => SyS_nanosleep (0xffffffff8108d72c)
514 => return_to_handler (0xffffffff8150e3c8)
515 => tracesys_phase2 (0xffffffff8150c304)
516 Event: sched_wakeup:21611 (1) Total: 30326 Avg: 30326 Max: 30326 Min:30326
517 <stack> 1 total:30326 min:30326 max:30326 avg=30326
518 => ftrace_raw_event_sched_wakeup_template (0xffffffff8105f653)
519 => ttwu_do_wakeup (0xffffffff810606eb)
520 => ttwu_do_activate.constprop.124 (0xffffffff810607c8)
521 => try_to_wake_up (0xffffffff8106340a)
522 .ft
523
524
526 trace-cmd(1), trace-cmd-record(1), trace-cmd-start(1),
527 trace-cmd-stop(1), trace-cmd-extract(1), trace-cmd-reset(1),
528 trace-cmd-split(1), trace-cmd-list(1), trace-cmd-listen(1),
529 trace-cmd-profile(1)
530
532 Written by Steven Rostedt, <rostedt@goodmis.org[1]>
533
535 https://git.kernel.org/pub/scm/utils/trace-cmd/trace-cmd.git/
536
538 Copyright (C) 2010 Red Hat, Inc. Free use of this software is granted
539 under the terms of the GNU Public License (GPL).
540
542 1. rostedt@goodmis.org
543 mailto:rostedt@goodmis.org
544
545
546
547libtracefs 04/15/2022 TRACE-CMD-REPORT(1)