1- perf-trace -python(1)
1+ perf-script -python(1)
22====================
33
44NAME
55----
6- perf-trace -python - Process trace data with a Python script
6+ perf-script -python - Process trace data with a Python script
77
88SYNOPSIS
99--------
1010[verse]
11- 'perf trace ' [-s [Python]:script[.py] ]
11+ 'perf script ' [-s [Python]:script[.py] ]
1212
1313DESCRIPTION
1414-----------
1515
16- This perf trace option is used to process perf trace data using perf's
16+ This perf script option is used to process perf script data using perf's
1717built-in Python interpreter. It reads and processes the input file and
1818displays the results of the trace analysis implemented in the given
1919Python script, if any.
@@ -23,15 +23,15 @@ A QUICK EXAMPLE
2323
2424This section shows the process, start to finish, of creating a working
2525Python script that aggregates and extracts useful information from a
26- raw perf trace stream. You can avoid reading the rest of this
26+ raw perf script stream. You can avoid reading the rest of this
2727document if an example is enough for you; the rest of the document
2828provides more details on each step and lists the library functions
2929available to script writers.
3030
3131This example actually details the steps that were used to create the
32- 'syscall-counts' script you see when you list the available perf trace
33- scripts via 'perf trace -l'. As such, this script also shows how to
34- integrate your script into the list of general-purpose 'perf trace '
32+ 'syscall-counts' script you see when you list the available perf script
33+ scripts via 'perf script -l'. As such, this script also shows how to
34+ integrate your script into the list of general-purpose 'perf script '
3535scripts listed by that command.
3636
3737The syscall-counts script is a simple script, but demonstrates all the
@@ -105,31 +105,31 @@ That single stream will be recorded in a file in the current directory
105105called perf.data.
106106
107107Once we have a perf.data file containing our data, we can use the -g
108- 'perf trace ' option to generate a Python script that will contain a
108+ 'perf script ' option to generate a Python script that will contain a
109109callback handler for each event type found in the perf.data trace
110110stream (for more details, see the STARTER SCRIPTS section).
111111
112112----
113- # perf trace -g python
114- generated Python script: perf-trace .py
113+ # perf script -g python
114+ generated Python script: perf-script .py
115115
116116The output file created also in the current directory is named
117- perf-trace .py. Here's the file in its entirety:
117+ perf-script .py. Here's the file in its entirety:
118118
119- # perf trace event handlers, generated by perf trace -g python
119+ # perf script event handlers, generated by perf script -g python
120120# Licensed under the terms of the GNU GPL License version 2
121121
122122# The common_* event handler fields are the most useful fields common to
123123# all events. They don't necessarily correspond to the 'common_*' fields
124124# in the format files. Those fields not available as handler params can
125125# be retrieved using Python functions of the form common_*(context).
126- # See the perf-trace -python Documentation for the list of available functions.
126+ # See the perf-script -python Documentation for the list of available functions.
127127
128128import os
129129import sys
130130
131131sys.path.append(os.environ['PERF_EXEC_PATH'] + \
132- '/scripts/python/Perf-Trace -Util/lib/Perf/Trace')
132+ '/scripts/python/perf-script -Util/lib/Perf/Trace')
133133
134134from perf_trace_context import *
135135from Core import *
@@ -160,7 +160,7 @@ def print_header(event_name, cpu, secs, nsecs, pid, comm):
160160----
161161
162162At the top is a comment block followed by some import statements and a
163- path append which every perf trace script should include.
163+ path append which every perf script script should include.
164164
165165Following that are a couple generated functions, trace_begin() and
166166trace_end(), which are called at the beginning and the end of the
@@ -189,8 +189,8 @@ simply a utility function used for that purpose. Let's rename the
189189script and run it to see the default output:
190190
191191----
192- # mv perf-trace .py syscall-counts.py
193- # perf trace -s syscall-counts.py
192+ # mv perf-script .py syscall-counts.py
193+ # perf script -s syscall-counts.py
194194
195195raw_syscalls__sys_enter 1 00840.847582083 7506 perf id=1, args=
196196raw_syscalls__sys_enter 1 00840.847595764 7506 perf id=1, args=
@@ -216,7 +216,7 @@ import os
216216import sys
217217
218218sys.path.append(os.environ['PERF_EXEC_PATH'] + \
219- '/scripts/python/Perf-Trace -Util/lib/Perf/Trace')
219+ '/scripts/python/perf-script -Util/lib/Perf/Trace')
220220
221221from perf_trace_context import *
222222from Core import *
@@ -279,7 +279,7 @@ import os
279279import sys
280280
281281sys.path.append(os.environ['PERF_EXEC_PATH'] + \
282- '/scripts/python/Perf-Trace -Util/lib/Perf/Trace')
282+ '/scripts/python/perf-script -Util/lib/Perf/Trace')
283283
284284from perf_trace_context import *
285285from Core import *
@@ -315,7 +315,7 @@ def print_syscall_totals():
315315
316316The script can be run just as before:
317317
318- # perf trace -s syscall-counts.py
318+ # perf script -s syscall-counts.py
319319
320320So those are the essential steps in writing and running a script. The
321321process can be generalized to any tracepoint or set of tracepoints
@@ -324,17 +324,17 @@ interested in by looking at the list of available events shown by
324324'perf list' and/or look in /sys/kernel/debug/tracing events for
325325detailed event and field info, record the corresponding trace data
326326using 'perf record', passing it the list of interesting events,
327- generate a skeleton script using 'perf trace -g python' and modify the
327+ generate a skeleton script using 'perf script -g python' and modify the
328328code to aggregate and display it for your particular needs.
329329
330330After you've done that you may end up with a general-purpose script
331331that you want to keep around and have available for future use. By
332332writing a couple of very simple shell scripts and putting them in the
333333right place, you can have your script listed alongside the other
334- scripts listed by the 'perf trace -l' command e.g.:
334+ scripts listed by the 'perf script -l' command e.g.:
335335
336336----
337- root@tropicana:~# perf trace -l
337+ root@tropicana:~# perf script -l
338338List of available trace scripts:
339339 workqueue-stats workqueue stats (ins/exe/create/destroy)
340340 wakeup-latency system-wide min/max/avg wakeup latency
@@ -365,14 +365,14 @@ perf record -a -e raw_syscalls:sys_enter
365365The 'report' script is also a shell script with the same base name as
366366your script, but with -report appended. It should also be located in
367367the perf/scripts/python/bin directory. In that script, you write the
368- 'perf trace -s' command-line needed for running your script:
368+ 'perf script -s' command-line needed for running your script:
369369
370370----
371371# cat kernel-source/tools/perf/scripts/python/bin/syscall-counts-report
372372
373373#!/bin/bash
374374# description: system-wide syscall counts
375- perf trace -s ~/libexec/perf-core/scripts/python/syscall-counts.py
375+ perf script -s ~/libexec/perf-core/scripts/python/syscall-counts.py
376376----
377377
378378Note that the location of the Python script given in the shell script
@@ -390,17 +390,17 @@ total 32
390390drwxr-xr-x 4 trz trz 4096 2010-01-26 22:30 .
391391drwxr-xr-x 4 trz trz 4096 2010-01-26 22:29 ..
392392drwxr-xr-x 2 trz trz 4096 2010-01-26 22:29 bin
393- -rw-r--r-- 1 trz trz 2548 2010-01-26 22:29 check-perf-trace .py
394- drwxr-xr-x 3 trz trz 4096 2010-01-26 22:49 Perf-Trace -Util
393+ -rw-r--r-- 1 trz trz 2548 2010-01-26 22:29 check-perf-script .py
394+ drwxr-xr-x 3 trz trz 4096 2010-01-26 22:49 perf-script -Util
395395-rw-r--r-- 1 trz trz 1462 2010-01-26 22:30 syscall-counts.py
396396----
397397
398398Once you've done that (don't forget to do a new 'make install',
399- otherwise your script won't show up at run-time), 'perf trace -l'
399+ otherwise your script won't show up at run-time), 'perf script -l'
400400should show a new entry for your script:
401401
402402----
403- root@tropicana:~# perf trace -l
403+ root@tropicana:~# perf script -l
404404List of available trace scripts:
405405 workqueue-stats workqueue stats (ins/exe/create/destroy)
406406 wakeup-latency system-wide min/max/avg wakeup latency
@@ -409,19 +409,19 @@ List of available trace scripts:
409409 syscall-counts system-wide syscall counts
410410----
411411
412- You can now perform the record step via 'perf trace record':
412+ You can now perform the record step via 'perf script record':
413413
414- # perf trace record syscall-counts
414+ # perf script record syscall-counts
415415
416- and display the output using 'perf trace report':
416+ and display the output using 'perf script report':
417417
418- # perf trace report syscall-counts
418+ # perf script report syscall-counts
419419
420420STARTER SCRIPTS
421421---------------
422422
423423You can quickly get started writing a script for a particular set of
424- trace data by generating a skeleton script using 'perf trace -g
424+ trace data by generating a skeleton script using 'perf script -g
425425python' in the same directory as an existing perf.data trace file.
426426That will generate a starter script containing a handler for each of
427427the event types in the trace file; it simply prints every available
@@ -430,13 +430,13 @@ field for each event in the trace file.
430430You can also look at the existing scripts in
431431~/libexec/perf-core/scripts/python for typical examples showing how to
432432do basic things like aggregate event data, print results, etc. Also,
433- the check-perf-trace .py script, while not interesting for its results,
433+ the check-perf-script .py script, while not interesting for its results,
434434attempts to exercise all of the main scripting features.
435435
436436EVENT HANDLERS
437437--------------
438438
439- When perf trace is invoked using a trace script, a user-defined
439+ When perf script is invoked using a trace script, a user-defined
440440'handler function' is called for each event in the trace. If there's
441441no handler function defined for a given event type, the event is
442442ignored (or passed to a 'trace_handled' function, see below) and the
@@ -510,7 +510,7 @@ write a useful trace script. The sections below cover the rest.
510510SCRIPT LAYOUT
511511-------------
512512
513- Every perf trace Python script should start by setting up a Python
513+ Every perf script Python script should start by setting up a Python
514514module search path and 'import'ing a few support modules (see module
515515descriptions below):
516516
@@ -519,7 +519,7 @@ descriptions below):
519519 import sys
520520
521521 sys.path.append(os.environ['PERF_EXEC_PATH'] + \
522- '/scripts/python/Perf-Trace -Util/lib/Perf/Trace')
522+ '/scripts/python/perf-script -Util/lib/Perf/Trace')
523523
524524 from perf_trace_context import *
525525 from Core import *
@@ -559,15 +559,15 @@ def trace_unhandled(event_name, context, common_cpu, common_secs,
559559----
560560
561561The remaining sections provide descriptions of each of the available
562- built-in perf trace Python modules and their associated functions.
562+ built-in perf script Python modules and their associated functions.
563563
564564AVAILABLE MODULES AND FUNCTIONS
565565-------------------------------
566566
567567The following sections describe the functions and variables available
568- via the various perf trace Python modules. To use the functions and
568+ via the various perf script Python modules. To use the functions and
569569variables from the given module, add the corresponding 'from XXXX
570- import' line to your perf trace script.
570+ import' line to your perf script script.
571571
572572Core.py Module
573573~~~~~~~~~~~~~~
@@ -610,7 +610,7 @@ argument.
610610Util.py Module
611611~~~~~~~~~~~~~~
612612
613- Various utility functions for use with perf trace :
613+ Various utility functions for use with perf script :
614614
615615 nsecs(secs, nsecs) - returns total nsecs given secs/nsecs pair
616616 nsecs_secs(nsecs) - returns whole secs portion given nsecs
@@ -620,4 +620,4 @@ Various utility functions for use with perf trace:
620620
621621SEE ALSO
622622--------
623- linkperf:perf-trace [1]
623+ linkperf:perf-script [1]
0 commit comments