perf-script-python.txt 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. perf-script-python(1)
  2. ====================
  3. NAME
  4. ----
  5. perf-script-python - Process trace data with a Python script
  6. SYNOPSIS
  7. --------
  8. [verse]
  9. 'perf script' [-s [Python]:script[.py] ]
  10. DESCRIPTION
  11. -----------
  12. This perf script option is used to process perf script data using perf's
  13. built-in Python interpreter. It reads and processes the input file and
  14. displays the results of the trace analysis implemented in the given
  15. Python script, if any.
  16. A QUICK EXAMPLE
  17. ---------------
  18. This section shows the process, start to finish, of creating a working
  19. Python script that aggregates and extracts useful information from a
  20. raw perf script stream. You can avoid reading the rest of this
  21. document if an example is enough for you; the rest of the document
  22. provides more details on each step and lists the library functions
  23. available to script writers.
  24. This example actually details the steps that were used to create the
  25. 'syscall-counts' script you see when you list the available perf script
  26. scripts via 'perf script -l'. As such, this script also shows how to
  27. integrate your script into the list of general-purpose 'perf script'
  28. scripts listed by that command.
  29. The syscall-counts script is a simple script, but demonstrates all the
  30. basic ideas necessary to create a useful script. Here's an example
  31. of its output (syscall names are not yet supported, they will appear
  32. as numbers):
  33. ----
  34. syscall events:
  35. event count
  36. ---------------------------------------- -----------
  37. sys_write 455067
  38. sys_getdents 4072
  39. sys_close 3037
  40. sys_swapoff 1769
  41. sys_read 923
  42. sys_sched_setparam 826
  43. sys_open 331
  44. sys_newfstat 326
  45. sys_mmap 217
  46. sys_munmap 216
  47. sys_futex 141
  48. sys_select 102
  49. sys_poll 84
  50. sys_setitimer 12
  51. sys_writev 8
  52. 15 8
  53. sys_lseek 7
  54. sys_rt_sigprocmask 6
  55. sys_wait4 3
  56. sys_ioctl 3
  57. sys_set_robust_list 1
  58. sys_exit 1
  59. 56 1
  60. sys_access 1
  61. ----
  62. Basically our task is to keep a per-syscall tally that gets updated
  63. every time a system call occurs in the system. Our script will do
  64. that, but first we need to record the data that will be processed by
  65. that script. Theoretically, there are a couple of ways we could do
  66. that:
  67. - we could enable every event under the tracing/events/syscalls
  68. directory, but this is over 600 syscalls, well beyond the number
  69. allowable by perf. These individual syscall events will however be
  70. useful if we want to later use the guidance we get from the
  71. general-purpose scripts to drill down and get more detail about
  72. individual syscalls of interest.
  73. - we can enable the sys_enter and/or sys_exit syscalls found under
  74. tracing/events/raw_syscalls. These are called for all syscalls; the
  75. 'id' field can be used to distinguish between individual syscall
  76. numbers.
  77. For this script, we only need to know that a syscall was entered; we
  78. don't care how it exited, so we'll use 'perf record' to record only
  79. the sys_enter events:
  80. ----
  81. # perf record -a -e raw_syscalls:sys_enter
  82. ^C[ perf record: Woken up 1 times to write data ]
  83. [ perf record: Captured and wrote 56.545 MB perf.data (~2470503 samples) ]
  84. ----
  85. The options basically say to collect data for every syscall event
  86. system-wide and multiplex the per-cpu output into a single stream.
  87. That single stream will be recorded in a file in the current directory
  88. called perf.data.
  89. Once we have a perf.data file containing our data, we can use the -g
  90. 'perf script' option to generate a Python script that will contain a
  91. callback handler for each event type found in the perf.data trace
  92. stream (for more details, see the STARTER SCRIPTS section).
  93. ----
  94. # perf script -g python
  95. generated Python script: perf-script.py
  96. The output file created also in the current directory is named
  97. perf-script.py. Here's the file in its entirety:
  98. # perf script event handlers, generated by perf script -g python
  99. # Licensed under the terms of the GNU GPL License version 2
  100. # The common_* event handler fields are the most useful fields common to
  101. # all events. They don't necessarily correspond to the 'common_*' fields
  102. # in the format files. Those fields not available as handler params can
  103. # be retrieved using Python functions of the form common_*(context).
  104. # See the perf-script-python Documentation for the list of available functions.
  105. import os
  106. import sys
  107. sys.path.append(os.environ['PERF_EXEC_PATH'] + \
  108. '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
  109. from perf_trace_context import *
  110. from Core import *
  111. def trace_begin():
  112. print "in trace_begin"
  113. def trace_end():
  114. print "in trace_end"
  115. def raw_syscalls__sys_enter(event_name, context, common_cpu,
  116. common_secs, common_nsecs, common_pid, common_comm,
  117. id, args):
  118. print_header(event_name, common_cpu, common_secs, common_nsecs,
  119. common_pid, common_comm)
  120. print "id=%d, args=%s\n" % \
  121. (id, args),
  122. def trace_unhandled(event_name, context, event_fields_dict):
  123. print ' '.join(['%s=%s'%(k,str(v))for k,v in sorted(event_fields_dict.items())])
  124. def print_header(event_name, cpu, secs, nsecs, pid, comm):
  125. print "%-20s %5u %05u.%09u %8u %-20s " % \
  126. (event_name, cpu, secs, nsecs, pid, comm),
  127. ----
  128. At the top is a comment block followed by some import statements and a
  129. path append which every perf script script should include.
  130. Following that are a couple generated functions, trace_begin() and
  131. trace_end(), which are called at the beginning and the end of the
  132. script respectively (for more details, see the SCRIPT_LAYOUT section
  133. below).
  134. Following those are the 'event handler' functions generated one for
  135. every event in the 'perf record' output. The handler functions take
  136. the form subsystem\__event_name, and contain named parameters, one for
  137. each field in the event; in this case, there's only one event,
  138. raw_syscalls__sys_enter(). (see the EVENT HANDLERS section below for
  139. more info on event handlers).
  140. The final couple of functions are, like the begin and end functions,
  141. generated for every script. The first, trace_unhandled(), is called
  142. every time the script finds an event in the perf.data file that
  143. doesn't correspond to any event handler in the script. This could
  144. mean either that the record step recorded event types that it wasn't
  145. really interested in, or the script was run against a trace file that
  146. doesn't correspond to the script.
  147. The script generated by -g option simply prints a line for each
  148. event found in the trace stream i.e. it basically just dumps the event
  149. and its parameter values to stdout. The print_header() function is
  150. simply a utility function used for that purpose. Let's rename the
  151. script and run it to see the default output:
  152. ----
  153. # mv perf-script.py syscall-counts.py
  154. # perf script -s syscall-counts.py
  155. raw_syscalls__sys_enter 1 00840.847582083 7506 perf id=1, args=
  156. raw_syscalls__sys_enter 1 00840.847595764 7506 perf id=1, args=
  157. raw_syscalls__sys_enter 1 00840.847620860 7506 perf id=1, args=
  158. raw_syscalls__sys_enter 1 00840.847710478 6533 npviewer.bin id=78, args=
  159. raw_syscalls__sys_enter 1 00840.847719204 6533 npviewer.bin id=142, args=
  160. raw_syscalls__sys_enter 1 00840.847755445 6533 npviewer.bin id=3, args=
  161. raw_syscalls__sys_enter 1 00840.847775601 6533 npviewer.bin id=3, args=
  162. raw_syscalls__sys_enter 1 00840.847781820 6533 npviewer.bin id=3, args=
  163. .
  164. .
  165. .
  166. ----
  167. Of course, for this script, we're not interested in printing every
  168. trace event, but rather aggregating it in a useful way. So we'll get
  169. rid of everything to do with printing as well as the trace_begin() and
  170. trace_unhandled() functions, which we won't be using. That leaves us
  171. with this minimalistic skeleton:
  172. ----
  173. import os
  174. import sys
  175. sys.path.append(os.environ['PERF_EXEC_PATH'] + \
  176. '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
  177. from perf_trace_context import *
  178. from Core import *
  179. def trace_end():
  180. print "in trace_end"
  181. def raw_syscalls__sys_enter(event_name, context, common_cpu,
  182. common_secs, common_nsecs, common_pid, common_comm,
  183. id, args):
  184. ----
  185. In trace_end(), we'll simply print the results, but first we need to
  186. generate some results to print. To do that we need to have our
  187. sys_enter() handler do the necessary tallying until all events have
  188. been counted. A hash table indexed by syscall id is a good way to
  189. store that information; every time the sys_enter() handler is called,
  190. we simply increment a count associated with that hash entry indexed by
  191. that syscall id:
  192. ----
  193. syscalls = autodict()
  194. try:
  195. syscalls[id] += 1
  196. except TypeError:
  197. syscalls[id] = 1
  198. ----
  199. The syscalls 'autodict' object is a special kind of Python dictionary
  200. (implemented in Core.py) that implements Perl's 'autovivifying' hashes
  201. in Python i.e. with autovivifying hashes, you can assign nested hash
  202. values without having to go to the trouble of creating intermediate
  203. levels if they don't exist e.g syscalls[comm][pid][id] = 1 will create
  204. the intermediate hash levels and finally assign the value 1 to the
  205. hash entry for 'id' (because the value being assigned isn't a hash
  206. object itself, the initial value is assigned in the TypeError
  207. exception. Well, there may be a better way to do this in Python but
  208. that's what works for now).
  209. Putting that code into the raw_syscalls__sys_enter() handler, we
  210. effectively end up with a single-level dictionary keyed on syscall id
  211. and having the counts we've tallied as values.
  212. The print_syscall_totals() function iterates over the entries in the
  213. dictionary and displays a line for each entry containing the syscall
  214. name (the dictionary keys contain the syscall ids, which are passed to
  215. the Util function syscall_name(), which translates the raw syscall
  216. numbers to the corresponding syscall name strings). The output is
  217. displayed after all the events in the trace have been processed, by
  218. calling the print_syscall_totals() function from the trace_end()
  219. handler called at the end of script processing.
  220. The final script producing the output shown above is shown in its
  221. entirety below (syscall_name() helper is not yet available, you can
  222. only deal with id's for now):
  223. ----
  224. import os
  225. import sys
  226. sys.path.append(os.environ['PERF_EXEC_PATH'] + \
  227. '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
  228. from perf_trace_context import *
  229. from Core import *
  230. from Util import *
  231. syscalls = autodict()
  232. def trace_end():
  233. print_syscall_totals()
  234. def raw_syscalls__sys_enter(event_name, context, common_cpu,
  235. common_secs, common_nsecs, common_pid, common_comm,
  236. id, args):
  237. try:
  238. syscalls[id] += 1
  239. except TypeError:
  240. syscalls[id] = 1
  241. def print_syscall_totals():
  242. if for_comm is not None:
  243. print "\nsyscall events for %s:\n\n" % (for_comm),
  244. else:
  245. print "\nsyscall events:\n\n",
  246. print "%-40s %10s\n" % ("event", "count"),
  247. print "%-40s %10s\n" % ("----------------------------------------", \
  248. "-----------"),
  249. for id, val in sorted(syscalls.iteritems(), key = lambda(k, v): (v, k), \
  250. reverse = True):
  251. print "%-40s %10d\n" % (syscall_name(id), val),
  252. ----
  253. The script can be run just as before:
  254. # perf script -s syscall-counts.py
  255. So those are the essential steps in writing and running a script. The
  256. process can be generalized to any tracepoint or set of tracepoints
  257. you're interested in - basically find the tracepoint(s) you're
  258. interested in by looking at the list of available events shown by
  259. 'perf list' and/or look in /sys/kernel/debug/tracing/events/ for
  260. detailed event and field info, record the corresponding trace data
  261. using 'perf record', passing it the list of interesting events,
  262. generate a skeleton script using 'perf script -g python' and modify the
  263. code to aggregate and display it for your particular needs.
  264. After you've done that you may end up with a general-purpose script
  265. that you want to keep around and have available for future use. By
  266. writing a couple of very simple shell scripts and putting them in the
  267. right place, you can have your script listed alongside the other
  268. scripts listed by the 'perf script -l' command e.g.:
  269. ----
  270. # perf script -l
  271. List of available trace scripts:
  272. wakeup-latency system-wide min/max/avg wakeup latency
  273. rw-by-file <comm> r/w activity for a program, by file
  274. rw-by-pid system-wide r/w activity
  275. ----
  276. A nice side effect of doing this is that you also then capture the
  277. probably lengthy 'perf record' command needed to record the events for
  278. the script.
  279. To have the script appear as a 'built-in' script, you write two simple
  280. scripts, one for recording and one for 'reporting'.
  281. The 'record' script is a shell script with the same base name as your
  282. script, but with -record appended. The shell script should be put
  283. into the perf/scripts/python/bin directory in the kernel source tree.
  284. In that script, you write the 'perf record' command-line needed for
  285. your script:
  286. ----
  287. # cat kernel-source/tools/perf/scripts/python/bin/syscall-counts-record
  288. #!/bin/bash
  289. perf record -a -e raw_syscalls:sys_enter
  290. ----
  291. The 'report' script is also a shell script with the same base name as
  292. your script, but with -report appended. It should also be located in
  293. the perf/scripts/python/bin directory. In that script, you write the
  294. 'perf script -s' command-line needed for running your script:
  295. ----
  296. # cat kernel-source/tools/perf/scripts/python/bin/syscall-counts-report
  297. #!/bin/bash
  298. # description: system-wide syscall counts
  299. perf script -s ~/libexec/perf-core/scripts/python/syscall-counts.py
  300. ----
  301. Note that the location of the Python script given in the shell script
  302. is in the libexec/perf-core/scripts/python directory - this is where
  303. the script will be copied by 'make install' when you install perf.
  304. For the installation to install your script there, your script needs
  305. to be located in the perf/scripts/python directory in the kernel
  306. source tree:
  307. ----
  308. # ls -al kernel-source/tools/perf/scripts/python
  309. total 32
  310. drwxr-xr-x 4 trz trz 4096 2010-01-26 22:30 .
  311. drwxr-xr-x 4 trz trz 4096 2010-01-26 22:29 ..
  312. drwxr-xr-x 2 trz trz 4096 2010-01-26 22:29 bin
  313. -rw-r--r-- 1 trz trz 2548 2010-01-26 22:29 check-perf-script.py
  314. drwxr-xr-x 3 trz trz 4096 2010-01-26 22:49 Perf-Trace-Util
  315. -rw-r--r-- 1 trz trz 1462 2010-01-26 22:30 syscall-counts.py
  316. ----
  317. Once you've done that (don't forget to do a new 'make install',
  318. otherwise your script won't show up at run-time), 'perf script -l'
  319. should show a new entry for your script:
  320. ----
  321. # perf script -l
  322. List of available trace scripts:
  323. wakeup-latency system-wide min/max/avg wakeup latency
  324. rw-by-file <comm> r/w activity for a program, by file
  325. rw-by-pid system-wide r/w activity
  326. syscall-counts system-wide syscall counts
  327. ----
  328. You can now perform the record step via 'perf script record':
  329. # perf script record syscall-counts
  330. and display the output using 'perf script report':
  331. # perf script report syscall-counts
  332. STARTER SCRIPTS
  333. ---------------
  334. You can quickly get started writing a script for a particular set of
  335. trace data by generating a skeleton script using 'perf script -g
  336. python' in the same directory as an existing perf.data trace file.
  337. That will generate a starter script containing a handler for each of
  338. the event types in the trace file; it simply prints every available
  339. field for each event in the trace file.
  340. You can also look at the existing scripts in
  341. ~/libexec/perf-core/scripts/python for typical examples showing how to
  342. do basic things like aggregate event data, print results, etc. Also,
  343. the check-perf-script.py script, while not interesting for its results,
  344. attempts to exercise all of the main scripting features.
  345. EVENT HANDLERS
  346. --------------
  347. When perf script is invoked using a trace script, a user-defined
  348. 'handler function' is called for each event in the trace. If there's
  349. no handler function defined for a given event type, the event is
  350. ignored (or passed to a 'trace_unhandled' function, see below) and the
  351. next event is processed.
  352. Most of the event's field values are passed as arguments to the
  353. handler function; some of the less common ones aren't - those are
  354. available as calls back into the perf executable (see below).
  355. As an example, the following perf record command can be used to record
  356. all sched_wakeup events in the system:
  357. # perf record -a -e sched:sched_wakeup
  358. Traces meant to be processed using a script should be recorded with
  359. the above option: -a to enable system-wide collection.
  360. The format file for the sched_wakeup event defines the following fields
  361. (see /sys/kernel/debug/tracing/events/sched/sched_wakeup/format):
  362. ----
  363. format:
  364. field:unsigned short common_type;
  365. field:unsigned char common_flags;
  366. field:unsigned char common_preempt_count;
  367. field:int common_pid;
  368. field:char comm[TASK_COMM_LEN];
  369. field:pid_t pid;
  370. field:int prio;
  371. field:int success;
  372. field:int target_cpu;
  373. ----
  374. The handler function for this event would be defined as:
  375. ----
  376. def sched__sched_wakeup(event_name, context, common_cpu, common_secs,
  377. common_nsecs, common_pid, common_comm,
  378. comm, pid, prio, success, target_cpu):
  379. pass
  380. ----
  381. The handler function takes the form subsystem__event_name.
  382. The common_* arguments in the handler's argument list are the set of
  383. arguments passed to all event handlers; some of the fields correspond
  384. to the common_* fields in the format file, but some are synthesized,
  385. and some of the common_* fields aren't common enough to to be passed
  386. to every event as arguments but are available as library functions.
  387. Here's a brief description of each of the invariant event args:
  388. event_name the name of the event as text
  389. context an opaque 'cookie' used in calls back into perf
  390. common_cpu the cpu the event occurred on
  391. common_secs the secs portion of the event timestamp
  392. common_nsecs the nsecs portion of the event timestamp
  393. common_pid the pid of the current task
  394. common_comm the name of the current process
  395. All of the remaining fields in the event's format file have
  396. counterparts as handler function arguments of the same name, as can be
  397. seen in the example above.
  398. The above provides the basics needed to directly access every field of
  399. every event in a trace, which covers 90% of what you need to know to
  400. write a useful trace script. The sections below cover the rest.
  401. SCRIPT LAYOUT
  402. -------------
  403. Every perf script Python script should start by setting up a Python
  404. module search path and 'import'ing a few support modules (see module
  405. descriptions below):
  406. ----
  407. import os
  408. import sys
  409. sys.path.append(os.environ['PERF_EXEC_PATH'] + \
  410. '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
  411. from perf_trace_context import *
  412. from Core import *
  413. ----
  414. The rest of the script can contain handler functions and support
  415. functions in any order.
  416. Aside from the event handler functions discussed above, every script
  417. can implement a set of optional functions:
  418. *trace_begin*, if defined, is called before any event is processed and
  419. gives scripts a chance to do setup tasks:
  420. ----
  421. def trace_begin():
  422. pass
  423. ----
  424. *trace_end*, if defined, is called after all events have been
  425. processed and gives scripts a chance to do end-of-script tasks, such
  426. as display results:
  427. ----
  428. def trace_end():
  429. pass
  430. ----
  431. *trace_unhandled*, if defined, is called after for any event that
  432. doesn't have a handler explicitly defined for it. The standard set
  433. of common arguments are passed into it:
  434. ----
  435. def trace_unhandled(event_name, context, event_fields_dict):
  436. pass
  437. ----
  438. *process_event*, if defined, is called for any non-tracepoint event
  439. ----
  440. def process_event(param_dict):
  441. pass
  442. ----
  443. *context_switch*, if defined, is called for any context switch
  444. ----
  445. def context_switch(ts, cpu, pid, tid, np_pid, np_tid, machine_pid, out, out_preempt, *x):
  446. pass
  447. ----
  448. *auxtrace_error*, if defined, is called for any AUX area tracing error
  449. ----
  450. def auxtrace_error(typ, code, cpu, pid, tid, ip, ts, msg, cpumode, *x):
  451. pass
  452. ----
  453. The remaining sections provide descriptions of each of the available
  454. built-in perf script Python modules and their associated functions.
  455. AVAILABLE MODULES AND FUNCTIONS
  456. -------------------------------
  457. The following sections describe the functions and variables available
  458. via the various perf script Python modules. To use the functions and
  459. variables from the given module, add the corresponding 'from XXXX
  460. import' line to your perf script script.
  461. Core.py Module
  462. ~~~~~~~~~~~~~~
  463. These functions provide some essential functions to user scripts.
  464. The *flag_str* and *symbol_str* functions provide human-readable
  465. strings for flag and symbolic fields. These correspond to the strings
  466. and values parsed from the 'print fmt' fields of the event format
  467. files:
  468. flag_str(event_name, field_name, field_value) - returns the string representation corresponding to field_value for the flag field field_name of event event_name
  469. symbol_str(event_name, field_name, field_value) - returns the string representation corresponding to field_value for the symbolic field field_name of event event_name
  470. The *autodict* function returns a special kind of Python
  471. dictionary that implements Perl's 'autovivifying' hashes in Python
  472. i.e. with autovivifying hashes, you can assign nested hash values
  473. without having to go to the trouble of creating intermediate levels if
  474. they don't exist.
  475. autodict() - returns an autovivifying dictionary instance
  476. perf_trace_context Module
  477. ~~~~~~~~~~~~~~~~~~~~~~~~~
  478. Some of the 'common' fields in the event format file aren't all that
  479. common, but need to be made accessible to user scripts nonetheless.
  480. perf_trace_context defines a set of functions that can be used to
  481. access this data in the context of the current event. Each of these
  482. functions expects a context variable, which is the same as the
  483. context variable passed into every tracepoint event handler as the second
  484. argument. For non-tracepoint events, the context variable is also present
  485. as perf_trace_context.perf_script_context .
  486. common_pc(context) - returns common_preempt count for the current event
  487. common_flags(context) - returns common_flags for the current event
  488. common_lock_depth(context) - returns common_lock_depth for the current event
  489. perf_sample_insn(context) - returns the machine code instruction
  490. perf_set_itrace_options(context, itrace_options) - set --itrace options if they have not been set already
  491. perf_sample_srcline(context) - returns source_file_name, line_number
  492. perf_sample_srccode(context) - returns source_file_name, line_number, source_line
  493. Util.py Module
  494. ~~~~~~~~~~~~~~
  495. Various utility functions for use with perf script:
  496. nsecs(secs, nsecs) - returns total nsecs given secs/nsecs pair
  497. nsecs_secs(nsecs) - returns whole secs portion given nsecs
  498. nsecs_nsecs(nsecs) - returns nsecs remainder given nsecs
  499. nsecs_str(nsecs) - returns printable string in the form secs.nsecs
  500. avg(total, n) - returns average given a sum and a total number of values
  501. SUPPORTED FIELDS
  502. ----------------
  503. Currently supported fields:
  504. ev_name, comm, pid, tid, cpu, ip, time, period, phys_addr, addr,
  505. symbol, symoff, dso, time_enabled, time_running, values, callchain,
  506. brstack, brstacksym, datasrc, datasrc_decode, iregs, uregs,
  507. weight, transaction, raw_buf, attr, cpumode.
  508. Fields that may also be present:
  509. flags - sample flags
  510. flags_disp - sample flags display
  511. insn_cnt - instruction count for determining instructions-per-cycle (IPC)
  512. cyc_cnt - cycle count for determining IPC
  513. addr_correlates_sym - addr can correlate to a symbol
  514. addr_dso - addr dso
  515. addr_symbol - addr symbol
  516. addr_symoff - addr symbol offset
  517. Some fields have sub items:
  518. brstack:
  519. from, to, from_dsoname, to_dsoname, mispred,
  520. predicted, in_tx, abort, cycles.
  521. brstacksym:
  522. items: from, to, pred, in_tx, abort (converted string)
  523. For example,
  524. We can use this code to print brstack "from", "to", "cycles".
  525. if 'brstack' in dict:
  526. for entry in dict['brstack']:
  527. print "from %s, to %s, cycles %s" % (entry["from"], entry["to"], entry["cycles"])
  528. SEE ALSO
  529. --------
  530. linkperf:perf-script[1]