From 1968ad911d0769e58a484bb721d275814baf9f2f Mon Sep 17 00:00:00 2001 From: Shawn Bohrer Date: Tue, 30 Nov 2010 19:57:09 -0600 Subject: perf annotate: Document missing options. Cc: Ingo Molnar Cc: Paul Mackerras Cc: Peter Zijlstra LKML-Reference: <1291168642-11402-2-git-send-email-shawn.bohrer@gmail.com> Signed-off-by: Shawn Bohrer Signed-off-by: Arnaldo Carvalho de Melo diff --git a/tools/perf/Documentation/perf-annotate.txt b/tools/perf/Documentation/perf-annotate.txt index b2c6330..6f5a4986 100644 --- a/tools/perf/Documentation/perf-annotate.txt +++ b/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 -------- -- cgit v0.10.2 From b6a535dbf615e168e796eec7318c77d1a3b7047f Mon Sep 17 00:00:00 2001 From: Shawn Bohrer Date: Tue, 30 Nov 2010 19:57:10 -0600 Subject: perf buildid-list: Document missing options Cc: Ingo Molnar Cc: Paul Mackerras Cc: Peter Zijlstra LKML-Reference: <1291168642-11402-3-git-send-email-shawn.bohrer@gmail.com> Signed-off-by: Shawn Bohrer Signed-off-by: Arnaldo Carvalho de Melo diff --git a/tools/perf/Documentation/perf-buildid-list.txt b/tools/perf/Documentation/perf-buildid-list.txt index 01b642c..5eaac6f 100644 --- a/tools/perf/Documentation/perf-buildid-list.txt +++ b/tools/perf/Documentation/perf-buildid-list.txt @@ -18,6 +18,9 @@ perf report. OPTIONS ------- +-H:: +--with-hits:: + Show only DSOs with hits. -i:: --input=:: Input file name. (default: perf.data) -- cgit v0.10.2 From 342955593af08f185279e074b3d77719d2f23b82 Mon Sep 17 00:00:00 2001 From: Shawn Bohrer Date: Tue, 30 Nov 2010 19:57:11 -0600 Subject: perf diff: Fix displacement and modules options short flag The --displacement and --modules options to perf diff both use -m as a short flag. Change --displacement to use -M since other perf commands use -m, --modules. Cc: Ingo Molnar Cc: Paul Mackerras Cc: Peter Zijlstra LKML-Reference: <1291168642-11402-4-git-send-email-shawn.bohrer@gmail.com> Signed-off-by: Shawn Bohrer Signed-off-by: Arnaldo Carvalho de Melo diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index fca1d44..221b823 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -173,7 +173,7 @@ static const char * const diff_usage[] = { static const struct option options[] = { OPT_INCR('v', "verbose", &verbose, "be more verbose (show symbol address, etc)"), - OPT_BOOLEAN('m', "displacement", &show_displacement, + OPT_BOOLEAN('M', "displacement", &show_displacement, "Show position displacement relative to baseline"), OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, "dump raw trace in ASCII"), -- cgit v0.10.2 From 5ea4f857850450dc1442144a00547d6623d79d78 Mon Sep 17 00:00:00 2001 From: Shawn Bohrer Date: Tue, 30 Nov 2010 19:57:12 -0600 Subject: perf diff: Document missing options Cc: Ingo Molnar Cc: Paul Mackerras Cc: Peter Zijlstra LKML-Reference: <1291168642-11402-5-git-send-email-shawn.bohrer@gmail.com> Signed-off-by: Shawn Bohrer Signed-off-by: Arnaldo Carvalho de Melo diff --git a/tools/perf/Documentation/perf-diff.txt b/tools/perf/Documentation/perf-diff.txt index 20d97d8..6a9ec2b 100644 --- a/tools/perf/Documentation/perf-diff.txt +++ b/tools/perf/Documentation/perf-diff.txt @@ -19,6 +19,18 @@ If no parameters are passed it will assume perf.data.old and perf.data. OPTIONS ------- +-M:: +--displacement:: + Show position displacement relative to baseline. + +-D:: +--dump-raw-trace:: + Dump raw trace in ASCII. + +-m:: +--modules:: + Load module symbols. WARNING: use only with -k and LIVE kernel + -d:: --dsos=:: Only consider symbols in these dsos. CSV that understands @@ -42,7 +54,7 @@ OPTIONS --field-separator=:: Use a special separator character and don't pad with spaces, replacing - all occurances of this separator in symbol names (and other output) + all occurrences of this separator in symbol names (and other output) with a '.' character, that thus it's the only non valid separator. -v:: @@ -50,6 +62,11 @@ OPTIONS Be verbose, for instance, show the raw counts in addition to the diff. +-f:: +--force:: + Don't complain, do it. + + SEE ALSO -------- linkperf:perf-record[1] -- cgit v0.10.2 From 5c0ef0ab077c8bdb224540fea60473439be1bdb4 Mon Sep 17 00:00:00 2001 From: Shawn Bohrer Date: Tue, 30 Nov 2010 19:57:13 -0600 Subject: perf kvm: Document missing options Cc: Ingo Molnar Cc: Paul Mackerras Cc: Peter Zijlstra LKML-Reference: <1291168642-11402-6-git-send-email-shawn.bohrer@gmail.com> Signed-off-by: Shawn Bohrer Signed-off-by: Arnaldo Carvalho de Melo diff --git a/tools/perf/Documentation/perf-kvm.txt b/tools/perf/Documentation/perf-kvm.txt index d004e19..dd84cb2 100644 --- a/tools/perf/Documentation/perf-kvm.txt +++ b/tools/perf/Documentation/perf-kvm.txt @@ -22,7 +22,7 @@ There are a couple of variants of perf kvm: a performance counter profile of guest os in realtime of an arbitrary workload. - 'perf kvm record ' to record the performance couinter profile + 'perf kvm record ' to record the performance counter profile of an arbitrary workload and save it into a perf data file. If both --host and --guest are input, the perf data file name is perf.data.kvm. If there is no --host but --guest, the file name is perf.data.guest. @@ -40,6 +40,12 @@ There are a couple of variants of perf kvm: OPTIONS ------- +-i:: +--input=:: + Input file name. +-o:: +--output:: + Output file name. --host=:: Collect host side performance profile. --guest=:: -- cgit v0.10.2 From 4aace251519745977f4b5ddf625b630b4807be3a Mon Sep 17 00:00:00 2001 From: Shawn Bohrer Date: Tue, 30 Nov 2010 19:57:14 -0600 Subject: perf lock: Document missing options Cc: Ingo Molnar Cc: Paul Mackerras Cc: Peter Zijlstra LKML-Reference: <1291168642-11402-7-git-send-email-shawn.bohrer@gmail.com> Signed-off-by: Shawn Bohrer Signed-off-by: Arnaldo Carvalho de Melo diff --git a/tools/perf/Documentation/perf-lock.txt b/tools/perf/Documentation/perf-lock.txt index b317102..921de25 100644 --- a/tools/perf/Documentation/perf-lock.txt +++ b/tools/perf/Documentation/perf-lock.txt @@ -24,6 +24,21 @@ and statistics with this 'perf lock' command. 'perf lock report' reports statistical data. +OPTIONS +------- + +-i:: +--input=:: + Input file name. + +-v:: +--verbose:: + Be more verbose (show symbol address, etc). + +-D:: +--dump-raw-trace:: + Dump raw trace in ASCII. + SEE ALSO -------- linkperf:perf[1] -- cgit v0.10.2 From 9d5b7f5b2b2c1ceade1fbbaefb2bd9167436329d Mon Sep 17 00:00:00 2001 From: Shawn Bohrer Date: Tue, 30 Nov 2010 19:57:15 -0600 Subject: perf probe: Fix spelling mistake in documentation Acked-by: Masami Hiramatsu Cc: Ingo Molnar Cc: Paul Mackerras Cc: Peter Zijlstra LKML-Reference: <1291168642-11402-8-git-send-email-shawn.bohrer@gmail.com> Signed-off-by: Shawn Bohrer Signed-off-by: Arnaldo Carvalho de Melo diff --git a/tools/perf/Documentation/perf-probe.txt b/tools/perf/Documentation/perf-probe.txt index 62de1b7..4e23232 100644 --- a/tools/perf/Documentation/perf-probe.txt +++ b/tools/perf/Documentation/perf-probe.txt @@ -115,7 +115,7 @@ Each probe argument follows below syntax. LINE SYNTAX ----------- -Line range is descripted by following syntax. +Line range is described by following syntax. "FUNC[:RLN[+NUM|-RLN2]]|SRC:ALN[+NUM|-ALN2]" -- cgit v0.10.2 From 08dbd7e3fa2398910713b21399cca7c6e4b43011 Mon Sep 17 00:00:00 2001 From: Shawn Bohrer Date: Tue, 30 Nov 2010 19:57:16 -0600 Subject: perf record: Document missing options Cc: Ingo Molnar Cc: Paul Mackerras Cc: Peter Zijlstra LKML-Reference: <1291168642-11402-9-git-send-email-shawn.bohrer@gmail.com> Signed-off-by: Shawn Bohrer Signed-off-by: Arnaldo Carvalho de Melo diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt index a91f9f9..0ad1bc7 100644 --- a/tools/perf/Documentation/perf-record.txt +++ b/tools/perf/Documentation/perf-record.txt @@ -39,15 +39,24 @@ OPTIONS be passed as follows: '\mem:addr[:[r][w][x]]'. If you want to profile read-write accesses in 0x1000, just set 'mem:0x1000:rw'. + +--filter=:: + Event filter. + -a:: - System-wide collection. +--all-cpus:: + System-wide collection from all CPUs. -l:: Scale counter values. -p:: --pid=:: - Record events on existing pid. + Record events on existing process ID. + +-t:: +--tid=:: + Record events on existing thread ID. -r:: --realtime=:: @@ -109,8 +118,8 @@ Collect raw sample records from all opened counters (default for tracepoint coun -C:: --cpu:: -Collect samples only on the list of cpus provided. Multiple CPUs can be provided as a -comma-sperated list with no space: 0,1. Ranges of CPUs are specified with -: 0-2. +Collect samples only on the list of CPUs provided. Multiple CPUs can be provided as a +comma-separated list with no space: 0,1. Ranges of CPUs are specified with -: 0-2. In per-thread mode with inheritance mode on (default), samples are captured only when the thread executes on the designated CPUs. Default is to monitor all CPUs. -- cgit v0.10.2 From e04fffc321aeebab4962cfc120952272f2d1df98 Mon Sep 17 00:00:00 2001 From: Shawn Bohrer Date: Tue, 30 Nov 2010 19:57:17 -0600 Subject: perf report: Document missing options Cc: Ingo Molnar Cc: Paul Mackerras Cc: Peter Zijlstra LKML-Reference: <1291168642-11402-10-git-send-email-shawn.bohrer@gmail.com> Signed-off-by: Shawn Bohrer Signed-off-by: Arnaldo Carvalho de Melo diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt index 12052c9..59a1f57 100644 --- a/tools/perf/Documentation/perf-report.txt +++ b/tools/perf/Documentation/perf-report.txt @@ -20,6 +20,11 @@ OPTIONS -i:: --input=:: Input file name. (default: perf.data) + +-v:: +--verbose:: + Be more verbose. (show symbol address, etc) + -d:: --dsos=:: Only consider symbols in these dsos. CSV that understands @@ -27,6 +32,10 @@ OPTIONS -n:: --show-nr-samples:: Show the number of samples for each symbol + +--showcpuutilization:: + Show sample percentage for different cpu modes. + -T:: --threads:: Show per-thread event counters @@ -39,12 +48,24 @@ OPTIONS Only consider these symbols. CSV that understands file://filename entries. +-U:: +--hide-unresolved:: + Only display entries resolved to a symbol. + -s:: --sort=:: Sort by key(s): pid, comm, dso, symbol, parent. +-p:: +--parent=:: + regex filter to identify parent, see: '--sort parent' + +-x:: +--exclude-other:: + Only display entries with parent-match. + -w:: ---field-width=:: +--column-widths=:: Force each column width to the provided list, for large terminal readability. @@ -52,19 +73,26 @@ OPTIONS --field-separator=:: Use a special separator character and don't pad with spaces, replacing - all occurances of this separator in symbol names (and other output) + all occurrences of this separator in symbol names (and other output) with a '.' character, that thus it's the only non valid separator. +-D:: +--dump-raw-trace:: + Dump raw trace in ASCII. + -g [type,min]:: --call-graph:: - Display callchains using type and min percent threshold. + Display call chains using type and min percent threshold. type can be either: - - flat: single column, linear exposure of callchains. + - flat: single column, linear exposure of call chains. - graph: use a graph tree, displaying absolute overhead rates. - fractal: like graph, but displays relative rates. Each branch of the tree is considered as a new profiled object. + Default: fractal,0.5. +--pretty=:: + Pretty printing style. key: normal, raw + --stdio:: Use the stdio interface. --tui:: Use the TUI interface, that is integrated with annotate and allows @@ -72,6 +100,19 @@ OPTIONS requires a tty, if one is not present, as when piping to other commands, the stdio interface is used. +-k:: +--vmlinux=:: + vmlinux pathname + +-m:: +--modules:: + Load module symbols. WARNING: This should only be used with -k and + a LIVE kernel. + +-f:: +--force:: + Don't complain, do it. + SEE ALSO -------- linkperf:perf-stat[1] -- cgit v0.10.2 From 1eacc94a66ce347abbf75f223361b21461331383 Mon Sep 17 00:00:00 2001 From: Shawn Bohrer Date: Tue, 30 Nov 2010 19:57:18 -0600 Subject: perf sched: Document missing options Cc: Ingo Molnar Cc: Paul Mackerras Cc: Peter Zijlstra LKML-Reference: <1291168642-11402-11-git-send-email-shawn.bohrer@gmail.com> Signed-off-by: Shawn Bohrer Signed-off-by: Arnaldo Carvalho de Melo diff --git a/tools/perf/Documentation/perf-sched.txt b/tools/perf/Documentation/perf-sched.txt index 8417644..46822d5 100644 --- a/tools/perf/Documentation/perf-sched.txt +++ b/tools/perf/Documentation/perf-sched.txt @@ -8,11 +8,11 @@ perf-sched - Tool to trace/measure scheduler properties (latencies) SYNOPSIS -------- [verse] -'perf sched' {record|latency|replay|trace} +'perf sched' {record|latency|map|replay|trace} DESCRIPTION ----------- -There are four variants of perf sched: +There are five variants of perf sched: 'perf sched record ' to record the scheduling events of an arbitrary workload. @@ -30,8 +30,22 @@ There are four variants of perf sched: of the workload as it occurred when it was recorded - and can repeat it a number of times, measuring its performance.) + 'perf sched map' to print a textual context-switching outline of + workload captured via perf sched record. Columns stand for + individual CPUs, and the two-letter shortcuts stand for tasks that + are running on a CPU. A '*' denotes the CPU that had the event, and + a dot signals an idle CPU. + OPTIONS ------- +-i:: +--input=:: + Input file name. (default: perf.data) + +-v:: +--verbose:: + Be more verbose. (show symbol address, etc) + -D:: --dump-raw-trace=:: Display verbose dump of the sched data. -- cgit v0.10.2 From 2e7a988198b11877d844d147ec81c7caea82c314 Mon Sep 17 00:00:00 2001 From: Shawn Bohrer Date: Tue, 30 Nov 2010 19:57:21 -0600 Subject: perf top: Document missing options Cc: Ingo Molnar Cc: Paul Mackerras Cc: Peter Zijlstra LKML-Reference: <1291168642-11402-14-git-send-email-shawn.bohrer@gmail.com> Signed-off-by: Shawn Bohrer Signed-off-by: Arnaldo Carvalho de Melo diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt index 1f96876..f6eb1cd 100644 --- a/tools/perf/Documentation/perf-top.txt +++ b/tools/perf/Documentation/perf-top.txt @@ -12,7 +12,7 @@ SYNOPSIS DESCRIPTION ----------- -This command generates and displays a performance counter profile in realtime. +This command generates and displays a performance counter profile in real time. OPTIONS @@ -27,8 +27,8 @@ OPTIONS -C :: --cpu=:: -Monitor only on the list of cpus provided. Multiple CPUs can be provided as a -comma-sperated list with no space: 0,1. Ranges of CPUs are specified with -: 0-2. +Monitor only on the list of CPUs provided. Multiple CPUs can be provided as a +comma-separated list with no space: 0,1. Ranges of CPUs are specified with -: 0-2. Default is to monitor all CPUS. -d :: @@ -50,6 +50,10 @@ Default is to monitor all CPUS. --count-filter=:: Only display functions with more events than this. +-g:: +--group:: + Put the counters into a counter group. + -F :: --freq=:: Profile at this frequency. @@ -68,7 +72,11 @@ Default is to monitor all CPUS. -p :: --pid=:: - Profile events on existing pid. + Profile events on existing Process ID. + +-t :: +--tid=:: + Profile events on existing thread ID. -r :: --realtime=:: @@ -78,6 +86,18 @@ Default is to monitor all CPUS. --sym-annotate=:: Annotate this symbol. +-K:: +--hide_kernel_symbols:: + Hide kernel symbols. + +-U:: +--hide_user_symbols:: + Hide user symbols. + +-D:: +--dump-symtab:: + Dump the symbol table used for profiling. + -v:: --verbose:: Be more verbose (show counter open errors, etc). -- cgit v0.10.2 From 646420f1bcf6ddf3e150f92a5f2a8bd7d6057ff8 Mon Sep 17 00:00:00 2001 From: Shawn Bohrer Date: Tue, 30 Nov 2010 19:57:22 -0600 Subject: perf trace: Document missing options Cc: Ingo Molnar Cc: Paul Mackerras Cc: Peter Zijlstra LKML-Reference: <1291168642-11402-15-git-send-email-shawn.bohrer@gmail.com> Signed-off-by: Shawn Bohrer Signed-off-by: Arnaldo Carvalho de Melo diff --git a/tools/perf/Documentation/perf-trace.txt b/tools/perf/Documentation/perf-trace.txt index 26aff6b..1c61ea9 100644 --- a/tools/perf/Documentation/perf-trace.txt +++ b/tools/perf/Documentation/perf-trace.txt @@ -104,6 +104,13 @@ OPTIONS normally don't - this option allows the latter to be run in system-wide mode. +-i:: +--input=:: + Input file name. + +-d:: +--debug-mode:: + Do various checks like samples ordering and lost events. SEE ALSO -------- -- cgit v0.10.2 From f68d6bd451782b58c2b563dc86f0a81ba106c30c Mon Sep 17 00:00:00 2001 From: Shawn Bohrer Date: Tue, 30 Nov 2010 19:57:20 -0600 Subject: perf test: Fix spelling mistake in documentation Cc: Ingo Molnar Cc: Paul Mackerras Cc: Peter Zijlstra LKML-Reference: <1291168642-11402-13-git-send-email-shawn.bohrer@gmail.com> Signed-off-by: Shawn Bohrer Signed-off-by: Arnaldo Carvalho de Melo diff --git a/tools/perf/Documentation/perf-test.txt b/tools/perf/Documentation/perf-test.txt index 1c4b5f5..2c3b462 100644 --- a/tools/perf/Documentation/perf-test.txt +++ b/tools/perf/Documentation/perf-test.txt @@ -12,7 +12,7 @@ SYNOPSIS DESCRIPTION ----------- -This command does assorted sanity tests, initially thru linked routines but +This command does assorted sanity tests, initially through linked routines but also will look for a directory with more tests in the form of scripts. OPTIONS -- cgit v0.10.2 From 8c207692fc8fa3ea1a5ff97ad698efb09a81975a Mon Sep 17 00:00:00 2001 From: Shawn Bohrer Date: Tue, 30 Nov 2010 19:57:19 -0600 Subject: perf stat: Document missing options Cc: Ingo Molnar Cc: Paul Mackerras Cc: Peter Zijlstra LKML-Reference: <1291168642-11402-12-git-send-email-shawn.bohrer@gmail.com> Signed-off-by: Shawn Bohrer Signed-off-by: Arnaldo Carvalho de Melo diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt index c405bca..c469ba5 100644 --- a/tools/perf/Documentation/perf-stat.txt +++ b/tools/perf/Documentation/perf-stat.txt @@ -8,8 +8,8 @@ perf-stat - Run a command and gather performance counter statistics SYNOPSIS -------- [verse] -'perf stat' [-e | --event=EVENT] [-S] [-a] -'perf stat' [-e | --event=EVENT] [-S] [-a] -- [] +'perf stat' [-e | --event=EVENT] [-a] +'perf stat' [-e | --event=EVENT] [-a] -- [] DESCRIPTION ----------- @@ -35,21 +35,33 @@ OPTIONS child tasks do not inherit counters -p:: --pid=:: - stat events on existing pid + stat events on existing process id + +-t:: +--tid=:: + stat events on existing thread id + -a:: - system-wide collection +--all-cpus:: + system-wide collection from all CPUs -c:: - scale counter values +--scale:: + scale/normalize counter values + +-r:: +--repeat=:: + repeat command and print average + stddev (max: 100) -B:: +--big-num:: print large numbers with thousands' separators according to locale -C:: --cpu=:: -Count only on the list of cpus provided. Multiple CPUs can be provided as a -comma-sperated list with no space: 0,1. Ranges of CPUs are specified with -: 0-2. +Count only on the list of CPUs provided. Multiple CPUs can be provided as a +comma-separated list with no space: 0,1. Ranges of CPUs are specified with -: 0-2. In per-thread mode, this option is ignored. The -a option is still necessary to activate system-wide monitoring. Default is to count on all CPUs. @@ -58,6 +70,14 @@ to activate system-wide monitoring. Default is to count on all CPUs. Do not aggregate counts across all monitored CPUs in system-wide mode (-a). This option is only valid in system-wide mode. +-n:: +--null:: + null run - don't start any counters + +-v:: +--verbose:: + be more verbose (show counter open errors, etc) + EXAMPLES -------- -- cgit v0.10.2 From 201e0b06efee80ce090579aa165c65c3d0836d95 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Wed, 1 Dec 2010 17:53:27 -0200 Subject: perf stat: Use --big-num format by default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [acme@mica linux]$ perf stat ls > /dev/null Performance counter stats for 'ls': 1.512532 task-clock-msecs # 0.801 CPUs 2 context-switches # 0.001 M/sec 0 CPU-migrations # 0.000 M/sec 241 page-faults # 0.159 M/sec 2,973,331 cycles # 1965.797 M/sec 1,460,802 instructions # 0.491 IPC 314,642 branches # 208.023 M/sec 18,475 branch-misses # 5.872 % cache-references cache-misses 0.001887676 seconds time elapsed To get the previous behaviour just use --no-big-num: [acme@mica linux]$ perf stat --no-big-num ls > /dev/null Performance counter stats for 'ls': 1.468014 task-clock-msecs # 0.795 CPUs 1 context-switches # 0.001 M/sec 0 CPU-migrations # 0.000 M/sec 241 page-faults # 0.164 M/sec 2900254 cycles # 1975.631 M/sec 1437991 instructions # 0.496 IPC 310905 branches # 211.786 M/sec 17912 branch-misses # 5.761 % cache-references cache-misses 0.001845435 seconds time elapsed [acme@mica linux]$ Suggested-by: Ingo Molnar Cc: Frédéric Weisbecker Cc: Mike Galbraith Cc: Peter Zijlstra Cc: Paul Mackerras Cc: Stephane Eranian LKML-Reference: Signed-off-by: Arnaldo Carvalho de Melo diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 970a7f2..acbf7cc 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -82,7 +82,7 @@ static pid_t *all_tids = NULL; static int thread_num = 0; static pid_t child_pid = -1; static bool null_run = false; -static bool big_num = false; +static bool big_num = true; static const char *cpu_list; -- cgit v0.10.2 From d7470b6afca85ed4388fff57fc9d89f5a3be02ff Mon Sep 17 00:00:00 2001 From: Stephane Eranian Date: Wed, 1 Dec 2010 18:49:05 +0200 Subject: perf stat: Add csv-style output This patch adds an option (-x/--field-separator) to print counts using a CSV-style output. The user can pass a custom separator. This makes it very easy to import counts directly into your favorite spreadsheet without having to write scripts. Example: $ perf stat --field-separator=, -a -- sleep 1 4009.961740,task-clock-msecs 13,context-switches 2,CPU-migrations 189,page-faults 9596385684,cycles 3493659441,instructions 872897069,branches 41562,branch-misses 22424,cache-references 1289,cache-misses Works also in non-aggregated mode: $ perf stat -x , -a -A -- sleep 1 CPU0,1002.526168,task-clock-msecs CPU1,1002.528365,task-clock-msecs CPU2,1002.523360,task-clock-msecs CPU3,1002.519878,task-clock-msecs CPU0,1,context-switches CPU1,5,context-switches CPU2,5,context-switches CPU3,6,context-switches CPU0,0,CPU-migrations CPU1,1,CPU-migrations CPU2,0,CPU-migrations CPU3,1,CPU-migrations CPU0,2,page-faults CPU1,6,page-faults CPU2,9,page-faults CPU3,174,page-faults CPU0,2399439771,cycles CPU1,2380369063,cycles CPU2,2399142710,cycles CPU3,2373161192,cycles CPU0,872900618,instructions CPU1,873030960,instructions CPU2,872714525,instructions CPU3,874460580,instructions CPU0,221556839,branches CPU1,218134342,branches CPU2,218161730,branches CPU3,218284093,branches CPU0,18556,branch-misses CPU1,1449,branch-misses CPU2,3447,branch-misses CPU3,12714,branch-misses CPU0,8330,cache-references CPU1,313844,cache-references CPU2,47993728,cache-references CPU3,826481,cache-references CPU0,272,cache-misses CPU1,5360,cache-misses CPU2,1342193,cache-misses CPU3,13992,cache-misses This second version adds the ability to name a separator and uses field-separator as the long option to be consistent with perf report. Commiter note: Since we enabled --big-num by default in 201e0b0 and -x can't be used with it, we need to notice if the user explicitely enabled or disabled -B, add code to disable big_num if the user didn't explicitely set --big_num when -x is used. Cc: David S. Miller Cc: Frederik Weisbecker Cc: Ingo Molnar Cc: paulus@samba.org Cc: Peter Zijlstra Cc: Robert Richter LKML-Reference: <4cf68aa7.0fedd80a.5294.1203@mx.google.com> Signed-off-by: Stephane Eranian Signed-off-by: Arnaldo Carvalho de Melo diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt index c469ba5..b6da7af 100644 --- a/tools/perf/Documentation/perf-stat.txt +++ b/tools/perf/Documentation/perf-stat.txt @@ -78,6 +78,11 @@ This option is only valid in system-wide mode. --verbose:: be more verbose (show counter open errors, etc) +-x SEP:: +--field-separator SEP:: +print counts using a CSV-style output to make it easy to import directly into +spreadsheets. Columns are separated by the string specified in SEP. + EXAMPLES -------- diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index acbf7cc..7ff746d 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -52,6 +52,8 @@ #include #include +#define DEFAULT_SEPARATOR " " + static struct perf_event_attr default_attrs[] = { { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_TASK_CLOCK }, @@ -83,7 +85,10 @@ static int thread_num = 0; static pid_t child_pid = -1; static bool null_run = false; static bool big_num = true; +static int big_num_opt = -1; static const char *cpu_list; +static const char *csv_sep = NULL; +static bool csv_output = false; static int *fd[MAX_NR_CPUS][MAX_COUNTERS]; @@ -449,12 +454,18 @@ static void print_noise(int counter, double avg) static void nsec_printout(int cpu, int counter, double avg) { double msecs = avg / 1e6; + char cpustr[16] = { '\0', }; + const char *fmt = csv_output ? "%s%.6f%s%s" : "%s%18.6f%s%-24s"; if (no_aggr) - fprintf(stderr, "CPU%-4d %18.6f %-24s", - cpumap[cpu], msecs, event_name(counter)); - else - fprintf(stderr, " %18.6f %-24s", msecs, event_name(counter)); + sprintf(cpustr, "CPU%*d%s", + csv_output ? 0 : -4, + cpumap[cpu], csv_sep); + + fprintf(stderr, fmt, cpustr, msecs, csv_sep, event_name(counter)); + + if (csv_output) + return; if (MATCH_EVENT(SOFTWARE, SW_TASK_CLOCK, counter)) { fprintf(stderr, " # %10.3f CPUs ", @@ -466,18 +477,26 @@ static void abs_printout(int cpu, int counter, double avg) { double total, ratio = 0.0; char cpustr[16] = { '\0', }; + const char *fmt; + + if (csv_output) + fmt = "%s%.0f%s%s"; + else if (big_num) + fmt = "%s%'18.0f%s%-24s"; + else + fmt = "%s%18.0f%s%-24s"; if (no_aggr) - sprintf(cpustr, "CPU%-4d", cpumap[cpu]); + sprintf(cpustr, "CPU%*d%s", + csv_output ? 0 : -4, + cpumap[cpu], csv_sep); else cpu = 0; - if (big_num) - fprintf(stderr, "%s %'18.0f %-24s", - cpustr, avg, event_name(counter)); - else - fprintf(stderr, "%s %18.0f %-24s", - cpustr, avg, event_name(counter)); + fprintf(stderr, fmt, cpustr, avg, csv_sep, event_name(counter)); + + if (csv_output) + return; if (MATCH_EVENT(HARDWARE, HW_INSTRUCTIONS, counter)) { total = avg_stats(&runtime_cycles_stats[cpu]); @@ -515,8 +534,9 @@ static void print_counter_aggr(int counter) int scaled = event_scaled[counter]; if (scaled == -1) { - fprintf(stderr, " %18s %-24s\n", - "", event_name(counter)); + fprintf(stderr, "%*s%s%-24s\n", + csv_output ? 0 : 18, + "", csv_sep, event_name(counter)); return; } @@ -525,6 +545,11 @@ static void print_counter_aggr(int counter) else abs_printout(-1, counter, avg); + if (csv_output) { + fputc('\n', stderr); + return; + } + print_noise(counter, avg); if (scaled) { @@ -554,8 +579,12 @@ static void print_counter(int counter) ena = cpu_counts[cpu][counter].ena; run = cpu_counts[cpu][counter].run; if (run == 0 || ena == 0) { - fprintf(stderr, "CPU%-4d %18s %-24s", cpumap[cpu], - "", event_name(counter)); + fprintf(stderr, "CPU%*d%s%*s%s%-24s", + csv_output ? 0 : -4, + cpumap[cpu], csv_sep, + csv_output ? 0 : 18, + "", csv_sep, + event_name(counter)); fprintf(stderr, "\n"); continue; @@ -566,11 +595,13 @@ static void print_counter(int counter) else abs_printout(cpu, counter, val); - print_noise(counter, 1.0); + if (!csv_output) { + print_noise(counter, 1.0); - if (run != ena) { - fprintf(stderr, " (scaled from %.2f%%)", + if (run != ena) { + fprintf(stderr, " (scaled from %.2f%%)", 100.0 * run / ena); + } } fprintf(stderr, "\n"); } @@ -582,21 +613,23 @@ static void print_stat(int argc, const char **argv) fflush(stdout); - fprintf(stderr, "\n"); - fprintf(stderr, " Performance counter stats for "); - if(target_pid == -1 && target_tid == -1) { - fprintf(stderr, "\'%s", argv[0]); - for (i = 1; i < argc; i++) - fprintf(stderr, " %s", argv[i]); - } else if (target_pid != -1) - fprintf(stderr, "process id \'%d", target_pid); - else - fprintf(stderr, "thread id \'%d", target_tid); + if (!csv_output) { + fprintf(stderr, "\n"); + fprintf(stderr, " Performance counter stats for "); + if(target_pid == -1 && target_tid == -1) { + fprintf(stderr, "\'%s", argv[0]); + for (i = 1; i < argc; i++) + fprintf(stderr, " %s", argv[i]); + } else if (target_pid != -1) + fprintf(stderr, "process id \'%d", target_pid); + else + fprintf(stderr, "thread id \'%d", target_tid); - fprintf(stderr, "\'"); - if (run_count > 1) - fprintf(stderr, " (%d runs)", run_count); - fprintf(stderr, ":\n\n"); + fprintf(stderr, "\'"); + if (run_count > 1) + fprintf(stderr, " (%d runs)", run_count); + fprintf(stderr, ":\n\n"); + } if (no_aggr) { for (counter = 0; counter < nr_counters; counter++) @@ -606,15 +639,17 @@ static void print_stat(int argc, const char **argv) print_counter_aggr(counter); } - fprintf(stderr, "\n"); - fprintf(stderr, " %18.9f seconds time elapsed", - avg_stats(&walltime_nsecs_stats)/1e9); - if (run_count > 1) { - fprintf(stderr, " ( +- %7.3f%% )", + if (!csv_output) { + fprintf(stderr, "\n"); + fprintf(stderr, " %18.9f seconds time elapsed", + avg_stats(&walltime_nsecs_stats)/1e9); + if (run_count > 1) { + fprintf(stderr, " ( +- %7.3f%% )", 100*stddev_stats(&walltime_nsecs_stats) / avg_stats(&walltime_nsecs_stats)); + } + fprintf(stderr, "\n\n"); } - fprintf(stderr, "\n\n"); } static volatile int signr = -1; @@ -644,6 +679,13 @@ static const char * const stat_usage[] = { NULL }; +static int stat__set_big_num(const struct option *opt __used, + const char *s __used, int unset) +{ + big_num_opt = unset ? 0 : 1; + return 0; +} + static const struct option options[] = { OPT_CALLBACK('e', "event", NULL, "event", "event selector. use 'perf list' to list available events", @@ -664,12 +706,15 @@ static const struct option options[] = { "repeat command and print average + stddev (max: 100)"), OPT_BOOLEAN('n', "null", &null_run, "null run - dont start any counters"), - OPT_BOOLEAN('B', "big-num", &big_num, - "print large numbers with thousands\' separators"), + OPT_CALLBACK_NOOPT('B', "big-num", NULL, NULL, + "print large numbers with thousands\' separators", + stat__set_big_num), OPT_STRING('C', "cpu", &cpu_list, "cpu", "list of cpus to monitor in system-wide"), OPT_BOOLEAN('A', "no-aggr", &no_aggr, "disable CPU count aggregation"), + OPT_STRING('x', "field-separator", &csv_sep, "separator", + "print counts with custom separator"), OPT_END() }; @@ -682,6 +727,25 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used) argc = parse_options(argc, argv, options, stat_usage, PARSE_OPT_STOP_AT_NON_OPTION); + + if (csv_sep) + csv_output = true; + else + csv_sep = DEFAULT_SEPARATOR; + + /* + * let the spreadsheet do the pretty-printing + */ + if (csv_output) { + /* User explicitely passed -B? */ + if (big_num_opt == 1) { + fprintf(stderr, "-B option not supported with -x\n"); + usage_with_options(stat_usage, options); + } else /* Nope, so disable big number formatting */ + big_num = false; + } else if (big_num_opt == 0) /* User passed --no-big-num */ + big_num = false; + if (!argc && target_pid == -1 && target_tid == -1) usage_with_options(stat_usage, options); if (run_count <= 0) -- cgit v0.10.2