From 952e8ce08f6775bd0b47ad51943f92fb183499d2 Mon Sep 17 00:00:00 2001 From: Shawn Bohrer Date: Tue, 30 Nov 2010 19:57:09 -0600 Subject: [PATCH] --- yaml --- r: 223863 b: refs/heads/master c: 1968ad911d0769e58a484bb721d275814baf9f2f h: refs/heads/master i: 223861: 66385de33e365fd34a226c463fb843f83e783a9d 223859: 1817c0cf1ae0bec2fb8c371255adc6e390f4066f 223855: 2d844e912d2419e4bd03c6ae2dc127fd3af026d4 v: v3 --- [refs] | 2 +- .../perf/Documentation/perf-annotate.txt | 37 +++++++- ...rf-script-perl.txt => perf-trace-perl.txt} | 28 +++--- ...cript-python.txt => perf-trace-python.txt} | 88 +++++++++---------- .../{perf-script.txt => perf-trace.txt} | 54 ++++++------ trunk/tools/perf/Makefile | 2 +- trunk/tools/perf/builtin-lock.c | 6 +- trunk/tools/perf/builtin-sched.c | 6 +- .../{builtin-script.c => builtin-trace.c} | 40 ++++----- trunk/tools/perf/builtin.h | 2 +- trunk/tools/perf/command-list.txt | 2 +- trunk/tools/perf/perf.c | 2 +- .../scripts/python/Perf-Trace-Util/Context.c | 2 +- .../util/scripting-engines/trace-event-perl.c | 6 +- .../scripting-engines/trace-event-python.c | 4 +- 15 files changed, 158 insertions(+), 123 deletions(-) rename trunk/tools/perf/Documentation/{perf-script-perl.txt => perf-trace-perl.txt} (90%) rename trunk/tools/perf/Documentation/{perf-script-python.txt => perf-trace-python.txt} (89%) rename trunk/tools/perf/Documentation/{perf-script.txt => perf-trace.txt} (64%) rename trunk/tools/perf/{builtin-script.c => builtin-trace.c} (94%) diff --git a/[refs] b/[refs] index 4fe65b72b70a..95fa29bd0bd8 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: b3d006c0e745bfd2dab4984ffe3279d5cf4e926a +refs/heads/master: 1968ad911d0769e58a484bb721d275814baf9f2f diff --git a/trunk/tools/perf/Documentation/perf-annotate.txt b/trunk/tools/perf/Documentation/perf-annotate.txt index b2c63309a651..6f5a498608b2 100644 --- a/trunk/tools/perf/Documentation/perf-annotate.txt +++ b/trunk/tools/perf/Documentation/perf-annotate.txt @@ -24,12 +24,47 @@ OPTIONS --input=:: Input file name. (default: perf.data) +-d:: +--dsos=:: + Only consider symbols in these dsos. +-s:: +--symbol=:: + Symbol to annotate. + +-f:: +--force:: + Don't complain, do it. + +-v:: +--verbose:: + Be more verbose. (Show symbol address, etc) + +-D:: +--dump-raw-trace:: + Dump raw trace in ASCII. + +-k:: +--vmlinux=:: + vmlinux pathname. + +-m:: +--modules:: + Load module symbols. WARNING: use only with -k and LIVE kernel. + +-l:: +--print-line:: + Print matching source lines (may be slow). + +-P:: +--full-paths:: + Don't shorten the displayed pathnames. + --stdio:: Use the stdio interface. --tui:: Use the TUI interface Use of --tui requires a tty, if one is not present, as when piping to other commands, the stdio interface is used. This interfaces starts by centering on the line with more - samples, TAB/UNTAB cycles thru the lines with more samples. + samples, TAB/UNTAB cycles through the lines with more samples. SEE ALSO -------- diff --git a/trunk/tools/perf/Documentation/perf-script-perl.txt b/trunk/tools/perf/Documentation/perf-trace-perl.txt similarity index 90% rename from trunk/tools/perf/Documentation/perf-script-perl.txt rename to trunk/tools/perf/Documentation/perf-trace-perl.txt index 5bb41e55a3ac..ee6525ee6d69 100644 --- a/trunk/tools/perf/Documentation/perf-script-perl.txt +++ b/trunk/tools/perf/Documentation/perf-trace-perl.txt @@ -1,19 +1,19 @@ -perf-script-perl(1) +perf-trace-perl(1) ================== NAME ---- -perf-script-perl - Process trace data with a Perl script +perf-trace-perl - Process trace data with a Perl script SYNOPSIS -------- [verse] -'perf script' [-s [Perl]:script[.pl] ] +'perf trace' [-s [Perl]:script[.pl] ] DESCRIPTION ----------- -This perf script option is used to process perf script data using perf's +This perf trace option is used to process perf trace data using perf's built-in Perl interpreter. It reads and processes the input file and displays the results of the trace analysis implemented in the given Perl script, if any. @@ -21,7 +21,7 @@ Perl script, if any. STARTER SCRIPTS --------------- -You can avoid reading the rest of this document by running 'perf script +You can avoid reading the rest of this document by running 'perf trace -g perl' in the same directory as an existing perf.data trace file. That will generate a starter script containing a handler for each of the event types in the trace file; it simply prints every available @@ -30,13 +30,13 @@ field for each event in the trace file. You can also look at the existing scripts in ~/libexec/perf-core/scripts/perl for typical examples showing how to do basic things like aggregate event data, print results, etc. Also, -the check-perf-script.pl script, while not interesting for its results, +the check-perf-trace.pl script, while not interesting for its results, attempts to exercise all of the main scripting features. EVENT HANDLERS -------------- -When perf script is invoked using a trace script, a user-defined +When perf trace is invoked using a trace script, a user-defined 'handler function' is called for each event in the trace. If there's no handler function defined for a given event type, the event is ignored (or passed to a 'trace_handled' function, see below) and the @@ -112,13 +112,13 @@ write a useful trace script. The sections below cover the rest. SCRIPT LAYOUT ------------- -Every perf script Perl script should start by setting up a Perl module +Every perf trace Perl script should start by setting up a Perl module search path and 'use'ing a few support modules (see module descriptions below): ---- - use lib "$ENV{'PERF_EXEC_PATH'}/scripts/perl/perf-script-Util/lib"; - use lib "./perf-script-Util/lib"; + use lib "$ENV{'PERF_EXEC_PATH'}/scripts/perl/Perf-Trace-Util/lib"; + use lib "./Perf-Trace-Util/lib"; use Perf::Trace::Core; use Perf::Trace::Context; use Perf::Trace::Util; @@ -162,7 +162,7 @@ sub trace_unhandled ---- The remaining sections provide descriptions of each of the available -built-in perf script Perl modules and their associated functions. +built-in perf trace Perl modules and their associated functions. AVAILABLE MODULES AND FUNCTIONS ------------------------------- @@ -170,7 +170,7 @@ AVAILABLE MODULES AND FUNCTIONS The following sections describe the functions and variables available via the various Perf::Trace::* Perl modules. To use the functions and variables from the given module, add the corresponding 'use -Perf::Trace::XXX' line to your perf script script. +Perf::Trace::XXX' line to your perf trace script. Perf::Trace::Core Module ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -204,7 +204,7 @@ argument. Perf::Trace::Util Module ~~~~~~~~~~~~~~~~~~~~~~~~ -Various utility functions for use with perf script: +Various utility functions for use with perf trace: nsecs($secs, $nsecs) - returns total nsecs given secs/nsecs pair nsecs_secs($nsecs) - returns whole secs portion given nsecs @@ -214,4 +214,4 @@ Various utility functions for use with perf script: SEE ALSO -------- -linkperf:perf-script[1] +linkperf:perf-trace[1] diff --git a/trunk/tools/perf/Documentation/perf-script-python.txt b/trunk/tools/perf/Documentation/perf-trace-python.txt similarity index 89% rename from trunk/tools/perf/Documentation/perf-script-python.txt rename to trunk/tools/perf/Documentation/perf-trace-python.txt index 36b38277422c..693be804dd3d 100644 --- a/trunk/tools/perf/Documentation/perf-script-python.txt +++ b/trunk/tools/perf/Documentation/perf-trace-python.txt @@ -1,19 +1,19 @@ -perf-script-python(1) +perf-trace-python(1) ==================== NAME ---- -perf-script-python - Process trace data with a Python script +perf-trace-python - Process trace data with a Python script SYNOPSIS -------- [verse] -'perf script' [-s [Python]:script[.py] ] +'perf trace' [-s [Python]:script[.py] ] DESCRIPTION ----------- -This perf script option is used to process perf script data using perf's +This perf trace option is used to process perf trace data using perf's built-in Python interpreter. It reads and processes the input file and displays the results of the trace analysis implemented in the given Python script, if any. @@ -23,15 +23,15 @@ A QUICK EXAMPLE This section shows the process, start to finish, of creating a working Python script that aggregates and extracts useful information from a -raw perf script stream. You can avoid reading the rest of this +raw perf trace stream. You can avoid reading the rest of this document if an example is enough for you; the rest of the document provides more details on each step and lists the library functions available to script writers. This example actually details the steps that were used to create the -'syscall-counts' script you see when you list the available perf script -scripts via 'perf script -l'. As such, this script also shows how to -integrate your script into the list of general-purpose 'perf script' +'syscall-counts' script you see when you list the available perf trace +scripts via 'perf trace -l'. As such, this script also shows how to +integrate your script into the list of general-purpose 'perf trace' scripts listed by that command. The 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 called perf.data. Once we have a perf.data file containing our data, we can use the -g -'perf script' option to generate a Python script that will contain a +'perf trace' option to generate a Python script that will contain a callback handler for each event type found in the perf.data trace stream (for more details, see the STARTER SCRIPTS section). ---- -# perf script -g python -generated Python script: perf-script.py +# perf trace -g python +generated Python script: perf-trace.py The output file created also in the current directory is named -perf-script.py. Here's the file in its entirety: +perf-trace.py. Here's the file in its entirety: -# perf script event handlers, generated by perf script -g python +# perf trace event handlers, generated by perf trace -g python # Licensed under the terms of the GNU GPL License version 2 # The common_* event handler fields are the most useful fields common to # all events. They don't necessarily correspond to the 'common_*' fields # in the format files. Those fields not available as handler params can # be retrieved using Python functions of the form common_*(context). -# See the perf-script-python Documentation for the list of available functions. +# See the perf-trace-python Documentation for the list of available functions. import os import sys sys.path.append(os.environ['PERF_EXEC_PATH'] + \ - '/scripts/python/perf-script-Util/lib/Perf/Trace') + '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from perf_trace_context import * from Core import * @@ -160,7 +160,7 @@ def print_header(event_name, cpu, secs, nsecs, pid, comm): ---- At the top is a comment block followed by some import statements and a -path append which every perf script script should include. +path append which every perf trace script should include. Following that are a couple generated functions, trace_begin() and trace_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 script and run it to see the default output: ---- -# mv perf-script.py syscall-counts.py -# perf script -s syscall-counts.py +# mv perf-trace.py syscall-counts.py +# perf trace -s syscall-counts.py raw_syscalls__sys_enter 1 00840.847582083 7506 perf id=1, args= raw_syscalls__sys_enter 1 00840.847595764 7506 perf id=1, args= @@ -216,7 +216,7 @@ import os import sys sys.path.append(os.environ['PERF_EXEC_PATH'] + \ - '/scripts/python/perf-script-Util/lib/Perf/Trace') + '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from perf_trace_context import * from Core import * @@ -279,7 +279,7 @@ import os import sys sys.path.append(os.environ['PERF_EXEC_PATH'] + \ - '/scripts/python/perf-script-Util/lib/Perf/Trace') + '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from perf_trace_context import * from Core import * @@ -315,7 +315,7 @@ def print_syscall_totals(): The script can be run just as before: - # perf script -s syscall-counts.py + # perf trace -s syscall-counts.py So those are the essential steps in writing and running a script. The process 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 'perf list' and/or look in /sys/kernel/debug/tracing events for detailed event and field info, record the corresponding trace data using 'perf record', passing it the list of interesting events, -generate a skeleton script using 'perf script -g python' and modify the +generate a skeleton script using 'perf trace -g python' and modify the code to aggregate and display it for your particular needs. After you've done that you may end up with a general-purpose script that you want to keep around and have available for future use. By writing a couple of very simple shell scripts and putting them in the right place, you can have your script listed alongside the other -scripts listed by the 'perf script -l' command e.g.: +scripts listed by the 'perf trace -l' command e.g.: ---- -root@tropicana:~# perf script -l +root@tropicana:~# perf trace -l List of available trace scripts: workqueue-stats workqueue stats (ins/exe/create/destroy) wakeup-latency system-wide min/max/avg wakeup latency @@ -365,14 +365,14 @@ perf record -a -e raw_syscalls:sys_enter The 'report' script is also a shell script with the same base name as your script, but with -report appended. It should also be located in the perf/scripts/python/bin directory. In that script, you write the -'perf script -s' command-line needed for running your script: +'perf trace -s' command-line needed for running your script: ---- # cat kernel-source/tools/perf/scripts/python/bin/syscall-counts-report #!/bin/bash # description: system-wide syscall counts -perf script -s ~/libexec/perf-core/scripts/python/syscall-counts.py +perf trace -s ~/libexec/perf-core/scripts/python/syscall-counts.py ---- Note that the location of the Python script given in the shell script @@ -390,17 +390,17 @@ total 32 drwxr-xr-x 4 trz trz 4096 2010-01-26 22:30 . drwxr-xr-x 4 trz trz 4096 2010-01-26 22:29 .. drwxr-xr-x 2 trz trz 4096 2010-01-26 22:29 bin --rw-r--r-- 1 trz trz 2548 2010-01-26 22:29 check-perf-script.py -drwxr-xr-x 3 trz trz 4096 2010-01-26 22:49 perf-script-Util +-rw-r--r-- 1 trz trz 2548 2010-01-26 22:29 check-perf-trace.py +drwxr-xr-x 3 trz trz 4096 2010-01-26 22:49 Perf-Trace-Util -rw-r--r-- 1 trz trz 1462 2010-01-26 22:30 syscall-counts.py ---- Once you've done that (don't forget to do a new 'make install', -otherwise your script won't show up at run-time), 'perf script -l' +otherwise your script won't show up at run-time), 'perf trace -l' should show a new entry for your script: ---- -root@tropicana:~# perf script -l +root@tropicana:~# perf trace -l List of available trace scripts: workqueue-stats workqueue stats (ins/exe/create/destroy) wakeup-latency system-wide min/max/avg wakeup latency @@ -409,19 +409,19 @@ List of available trace scripts: syscall-counts system-wide syscall counts ---- -You can now perform the record step via 'perf script record': +You can now perform the record step via 'perf trace record': - # perf script record syscall-counts + # perf trace record syscall-counts -and display the output using 'perf script report': +and display the output using 'perf trace report': - # perf script report syscall-counts + # perf trace report syscall-counts STARTER SCRIPTS --------------- You can quickly get started writing a script for a particular set of -trace data by generating a skeleton script using 'perf script -g +trace data by generating a skeleton script using 'perf trace -g python' in the same directory as an existing perf.data trace file. That will generate a starter script containing a handler for each of the event types in the trace file; it simply prints every available @@ -430,13 +430,13 @@ field for each event in the trace file. You can also look at the existing scripts in ~/libexec/perf-core/scripts/python for typical examples showing how to do basic things like aggregate event data, print results, etc. Also, -the check-perf-script.py script, while not interesting for its results, +the check-perf-trace.py script, while not interesting for its results, attempts to exercise all of the main scripting features. EVENT HANDLERS -------------- -When perf script is invoked using a trace script, a user-defined +When perf trace is invoked using a trace script, a user-defined 'handler function' is called for each event in the trace. If there's no handler function defined for a given event type, the event is ignored (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. SCRIPT LAYOUT ------------- -Every perf script Python script should start by setting up a Python +Every perf trace Python script should start by setting up a Python module search path and 'import'ing a few support modules (see module descriptions below): @@ -519,7 +519,7 @@ descriptions below): import sys sys.path.append(os.environ['PERF_EXEC_PATH'] + \ - '/scripts/python/perf-script-Util/lib/Perf/Trace') + '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from perf_trace_context import * from Core import * @@ -559,15 +559,15 @@ def trace_unhandled(event_name, context, common_cpu, common_secs, ---- The remaining sections provide descriptions of each of the available -built-in perf script Python modules and their associated functions. +built-in perf trace Python modules and their associated functions. AVAILABLE MODULES AND FUNCTIONS ------------------------------- The following sections describe the functions and variables available -via the various perf script Python modules. To use the functions and +via the various perf trace Python modules. To use the functions and variables from the given module, add the corresponding 'from XXXX -import' line to your perf script script. +import' line to your perf trace script. Core.py Module ~~~~~~~~~~~~~~ @@ -610,7 +610,7 @@ argument. Util.py Module ~~~~~~~~~~~~~~ -Various utility functions for use with perf script: +Various utility functions for use with perf trace: nsecs(secs, nsecs) - returns total nsecs given secs/nsecs pair nsecs_secs(nsecs) - returns whole secs portion given nsecs @@ -620,4 +620,4 @@ Various utility functions for use with perf script: SEE ALSO -------- -linkperf:perf-script[1] +linkperf:perf-trace[1] diff --git a/trunk/tools/perf/Documentation/perf-script.txt b/trunk/tools/perf/Documentation/perf-trace.txt similarity index 64% rename from trunk/tools/perf/Documentation/perf-script.txt rename to trunk/tools/perf/Documentation/perf-trace.txt index f442acc105bc..26aff6bf9e50 100644 --- a/trunk/tools/perf/Documentation/perf-script.txt +++ b/trunk/tools/perf/Documentation/perf-trace.txt @@ -1,71 +1,71 @@ -perf-script(1) +perf-trace(1) ============= NAME ---- -perf-script - Read perf.data (created by perf record) and display trace output +perf-trace - Read perf.data (created by perf record) and display trace output SYNOPSIS -------- [verse] -'perf script' [] -'perf script' [] record