2009-04-20 21:52:29 +08:00
|
|
|
perf-stat(1)
|
2008-04-16 04:39:31 +08:00
|
|
|
============
|
2009-04-20 21:52:29 +08:00
|
|
|
|
|
|
|
NAME
|
|
|
|
----
|
|
|
|
perf-stat - Run a command and gather performance counter statistics
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
--------
|
|
|
|
[verse]
|
2010-12-01 09:57:19 +08:00
|
|
|
'perf stat' [-e <EVENT> | --event=EVENT] [-a] <command>
|
|
|
|
'perf stat' [-e <EVENT> | --event=EVENT] [-a] -- <command> [<options>]
|
perf stat record: Add record command
Add 'perf stat record' command support. It creates simple (header only)
perf.data file ATM.
The record command could be specified anywhere among stat options. All
stat command options are valid for stat record command with '-o' option
exception. If specified for record command it denotes the perf data file
name.
Committer note:
Set sample_type to PERF_SAMPLE_IDENTIFIER, which should be harmless
while avoiding that older tools show confusing messages, for instance,
with sample_type = 0, we get:
$ perf stat record usleep 1
Performance counter stats for 'usleep 1':
0.630237 task-clock (msec) # 0.528 CPUs utilized
1 context-switches # 0.002 M/sec
0 cpu-migrations # 0.000 K/sec
52 page-faults # 0.083 M/sec
978,312 cycles # 1.552 GHz
671,931 stalled-cycles-frontend # 68.68% frontend cycles idle
<not supported> stalled-cycles-backend
646,379 instructions # 0.66 insns per cycle
# 1.04 stalled cycles per insn
131,046 branches # 207.931 M/sec
7,073 branch-misses # 5.40% of all branches
0.001193240 seconds time elapsed
$ oldperf evlist
WARNING: The perf.data file's data size field is 0 which is unexpected.
Was the 'perf record' command properly terminated?
non matching sample_type
$
While with sample_type set to PERF_SAMPLE_IDENTIFIER, after we re-run 'perf
stat record usleep' we get:
$ oldperf evlist
WARNING: The perf.data file's data size field is 0 which is unexpected.
Was the 'perf record' command properly terminated?
task-clock
context-switches
cpu-migrations
page-faults
cycles
stalled-cycles-frontend
stalled-cycles-backend
instructions
branches
branch-misses
$
Which at least shows the names of the events in the perf.data file.
Additionally, such files, when passed to 'perf report' will produce:
$ oldperf report --stdio
WARNING: The perf.data file's data size field is 0 which is unexpected.
Was the 'perf record' command properly terminated?
Warning:
Kernel address maps (/proc/{kallsyms,modules}) were restricted.
Check /proc/sys/kernel/kptr_restrict before running 'perf record'.
As no suitable kallsyms nor vmlinux was found, kernel samples
can't be resolved.
Samples in kernel modules can't be resolved as well.
Error:
The perf.data file has no samples!
# To display the perf.data header info, please use --header/--header-only options.
#
$
Which is confusing and can be solved by just adding the kernel mmap record,
which will also remove that warning about the data size field being equal to
zero, after generating the mmap record:
$ perf stat record usleep 1
Performance counter stats for 'usleep 1':
0.600796 task-clock (msec) # 0.478 CPUs utilized
1 context-switches # 0.002 M/sec
0 cpu-migrations # 0.000 K/sec
54 page-faults # 0.090 M/sec
886,844 cycles # 1.476 GHz
582,169 stalled-cycles-frontend # 65.65% frontend cycles idle
<not supported> stalled-cycles-backend
638,344 instructions # 0.72 insns per cycle
# 0.91 stalled cycles per insn
130,204 branches # 216.719 M/sec
7,500 branch-misses # 5.76% of all branches
0.001255897 seconds time elapsed
$ oldperf evlist
task-clock
context-switches
cpu-migrations
page-faults
cycles
stalled-cycles-frontend
stalled-cycles-backend
instructions
branches
branch-misses
$ oldperf report --stdio
Error:
The perf.data file has no samples!
# To display the perf.data header info, please use --header/--header-only options.
#
[acme@zoo linux]$
No warnings, sensible output about what are the events in the perf.data file and also
a "file has no samples" message, which indeed it doesn't.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Kan Liang <kan.liang@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: htp://lkml.kernel.org/r/1446734469-11352-3-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-11-05 22:40:46 +08:00
|
|
|
'perf stat' [-e <EVENT> | --event=EVENT] [-a] record [-o file] -- <command> [<options>]
|
2015-11-05 22:40:55 +08:00
|
|
|
'perf stat' report [-i file]
|
2009-04-20 21:52:29 +08:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
-----------
|
|
|
|
This command runs a command and gathers performance counter statistics
|
|
|
|
from it.
|
|
|
|
|
|
|
|
|
|
|
|
OPTIONS
|
|
|
|
-------
|
|
|
|
<command>...::
|
|
|
|
Any command you can specify in a shell.
|
|
|
|
|
perf stat record: Add record command
Add 'perf stat record' command support. It creates simple (header only)
perf.data file ATM.
The record command could be specified anywhere among stat options. All
stat command options are valid for stat record command with '-o' option
exception. If specified for record command it denotes the perf data file
name.
Committer note:
Set sample_type to PERF_SAMPLE_IDENTIFIER, which should be harmless
while avoiding that older tools show confusing messages, for instance,
with sample_type = 0, we get:
$ perf stat record usleep 1
Performance counter stats for 'usleep 1':
0.630237 task-clock (msec) # 0.528 CPUs utilized
1 context-switches # 0.002 M/sec
0 cpu-migrations # 0.000 K/sec
52 page-faults # 0.083 M/sec
978,312 cycles # 1.552 GHz
671,931 stalled-cycles-frontend # 68.68% frontend cycles idle
<not supported> stalled-cycles-backend
646,379 instructions # 0.66 insns per cycle
# 1.04 stalled cycles per insn
131,046 branches # 207.931 M/sec
7,073 branch-misses # 5.40% of all branches
0.001193240 seconds time elapsed
$ oldperf evlist
WARNING: The perf.data file's data size field is 0 which is unexpected.
Was the 'perf record' command properly terminated?
non matching sample_type
$
While with sample_type set to PERF_SAMPLE_IDENTIFIER, after we re-run 'perf
stat record usleep' we get:
$ oldperf evlist
WARNING: The perf.data file's data size field is 0 which is unexpected.
Was the 'perf record' command properly terminated?
task-clock
context-switches
cpu-migrations
page-faults
cycles
stalled-cycles-frontend
stalled-cycles-backend
instructions
branches
branch-misses
$
Which at least shows the names of the events in the perf.data file.
Additionally, such files, when passed to 'perf report' will produce:
$ oldperf report --stdio
WARNING: The perf.data file's data size field is 0 which is unexpected.
Was the 'perf record' command properly terminated?
Warning:
Kernel address maps (/proc/{kallsyms,modules}) were restricted.
Check /proc/sys/kernel/kptr_restrict before running 'perf record'.
As no suitable kallsyms nor vmlinux was found, kernel samples
can't be resolved.
Samples in kernel modules can't be resolved as well.
Error:
The perf.data file has no samples!
# To display the perf.data header info, please use --header/--header-only options.
#
$
Which is confusing and can be solved by just adding the kernel mmap record,
which will also remove that warning about the data size field being equal to
zero, after generating the mmap record:
$ perf stat record usleep 1
Performance counter stats for 'usleep 1':
0.600796 task-clock (msec) # 0.478 CPUs utilized
1 context-switches # 0.002 M/sec
0 cpu-migrations # 0.000 K/sec
54 page-faults # 0.090 M/sec
886,844 cycles # 1.476 GHz
582,169 stalled-cycles-frontend # 65.65% frontend cycles idle
<not supported> stalled-cycles-backend
638,344 instructions # 0.72 insns per cycle
# 0.91 stalled cycles per insn
130,204 branches # 216.719 M/sec
7,500 branch-misses # 5.76% of all branches
0.001255897 seconds time elapsed
$ oldperf evlist
task-clock
context-switches
cpu-migrations
page-faults
cycles
stalled-cycles-frontend
stalled-cycles-backend
instructions
branches
branch-misses
$ oldperf report --stdio
Error:
The perf.data file has no samples!
# To display the perf.data header info, please use --header/--header-only options.
#
[acme@zoo linux]$
No warnings, sensible output about what are the events in the perf.data file and also
a "file has no samples" message, which indeed it doesn't.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Kan Liang <kan.liang@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: htp://lkml.kernel.org/r/1446734469-11352-3-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-11-05 22:40:46 +08:00
|
|
|
record::
|
|
|
|
See STAT RECORD.
|
2009-06-04 22:33:00 +08:00
|
|
|
|
2015-11-05 22:40:55 +08:00
|
|
|
report::
|
|
|
|
See STAT REPORT.
|
|
|
|
|
2009-04-20 21:52:29 +08:00
|
|
|
-e::
|
|
|
|
--event=::
|
2015-01-08 09:13:53 +08:00
|
|
|
Select the PMU event. Selection can be:
|
|
|
|
|
|
|
|
- a symbolic event name (use 'perf list' to list all events)
|
|
|
|
|
|
|
|
- a raw PMU event (eventsel+umask) in the form of rNNN where NNN is a
|
|
|
|
hexadecimal event descriptor.
|
|
|
|
|
2020-09-02 05:58:53 +08:00
|
|
|
- a symbolic or raw PMU event followed by an optional colon
|
|
|
|
and a list of event modifiers, e.g., cpu-cycles:p. See the
|
|
|
|
linkperf:perf-list[1] man page for details on event modifiers.
|
|
|
|
|
2015-01-08 09:13:53 +08:00
|
|
|
- a symbolically formed event like 'pmu/param1=0x3,param2/' where
|
|
|
|
param1 and param2 are defined as formats for the PMU in
|
2017-08-24 21:20:22 +08:00
|
|
|
/sys/bus/event_source/devices/<pmu>/format/*
|
2015-01-08 09:13:53 +08:00
|
|
|
|
perf stat: Support 'percore' event qualifier
With this patch, we can use the 'percore' event qualifier in perf-stat.
root@skl:/tmp# perf stat -e cpu/event=0,umask=0x3,percore=1/,cpu/event=0,umask=0x3/ -a -A -I1000
1.000773050 S0-C0 98,352,832 cpu/event=0,umask=0x3,percore=1/ (50.01%)
1.000773050 S0-C1 103,763,057 cpu/event=0,umask=0x3,percore=1/ (50.02%)
1.000773050 S0-C2 196,776,995 cpu/event=0,umask=0x3,percore=1/ (50.02%)
1.000773050 S0-C3 176,493,779 cpu/event=0,umask=0x3,percore=1/ (50.02%)
1.000773050 CPU0 47,699,641 cpu/event=0,umask=0x3/ (50.02%)
1.000773050 CPU1 49,052,451 cpu/event=0,umask=0x3/ (49.98%)
1.000773050 CPU2 102,771,422 cpu/event=0,umask=0x3/ (49.98%)
1.000773050 CPU3 100,784,662 cpu/event=0,umask=0x3/ (49.98%)
1.000773050 CPU4 43,171,342 cpu/event=0,umask=0x3/ (49.98%)
1.000773050 CPU5 54,152,158 cpu/event=0,umask=0x3/ (49.98%)
1.000773050 CPU6 93,618,410 cpu/event=0,umask=0x3/ (49.98%)
1.000773050 CPU7 74,477,589 cpu/event=0,umask=0x3/ (49.99%)
In this example, we count the event 'ref-cycles' per-core and per-CPU in
one perf stat command-line. From the output, we can see:
S0-C0 = CPU0 + CPU4
S0-C1 = CPU1 + CPU5
S0-C2 = CPU2 + CPU6
S0-C3 = CPU3 + CPU7
So the result is expected (tiny difference is ignored).
Note that, the 'percore' event qualifier needs to use with option '-A'.
Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Tested-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jin Yao <yao.jin@intel.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1555077590-27664-4-git-send-email-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-04-12 21:59:49 +08:00
|
|
|
'percore' is a event qualifier that sums up the event counts for both
|
|
|
|
hardware threads in a core. For example:
|
|
|
|
perf stat -A -a -e cpu/event,percore=1/,otherevent ...
|
|
|
|
|
2015-01-08 09:13:53 +08:00
|
|
|
- a symbolically formed event like 'pmu/config=M,config1=N,config2=K/'
|
|
|
|
where M, N, K are numbers (in decimal, hex, octal format).
|
|
|
|
Acceptable values for each of 'config', 'config1' and 'config2'
|
|
|
|
parameters are defined by corresponding entries in
|
2017-08-24 21:20:22 +08:00
|
|
|
/sys/bus/event_source/devices/<pmu>/format/*
|
2009-04-20 21:52:29 +08:00
|
|
|
|
2018-03-06 22:04:42 +08:00
|
|
|
Note that the last two syntaxes support prefix and glob matching in
|
2018-12-03 18:22:00 +08:00
|
|
|
the PMU name to simplify creation of events across multiple instances
|
2018-03-06 22:04:42 +08:00
|
|
|
of the same type of PMU in large systems (e.g. memory controller PMUs).
|
|
|
|
Multiple PMU instances are typical for uncore PMUs, so the prefix
|
|
|
|
'uncore_' is also ignored when performing this match.
|
|
|
|
|
|
|
|
|
2009-06-04 22:33:00 +08:00
|
|
|
-i::
|
2010-05-12 16:40:01 +08:00
|
|
|
--no-inherit::
|
|
|
|
child tasks do not inherit counters
|
2009-06-04 22:33:00 +08:00
|
|
|
-p::
|
|
|
|
--pid=<pid>::
|
2012-02-09 00:32:52 +08:00
|
|
|
stat events on existing process id (comma separated list)
|
2010-12-01 09:57:19 +08:00
|
|
|
|
|
|
|
-t::
|
|
|
|
--tid=<tid>::
|
2012-02-09 00:32:52 +08:00
|
|
|
stat events on existing thread id (comma separated list)
|
2010-12-01 09:57:19 +08:00
|
|
|
|
2020-05-06 02:29:43 +08:00
|
|
|
ifdef::HAVE_LIBPFM[]
|
|
|
|
--pfm-events events::
|
|
|
|
Select a PMU event using libpfm4 syntax (see http://perfmon2.sf.net)
|
|
|
|
including support for event filters. For example '--pfm-events
|
|
|
|
inst_retired:any_p:u:c=1:i'. More than one event can be passed to the
|
|
|
|
option using the comma separator. Hardware events and generic hardware
|
|
|
|
events cannot be mixed together. The latter must be used with the -e
|
|
|
|
option. The -e option and this one can be mixed and matched. Events
|
|
|
|
can be grouped using the {} notation.
|
|
|
|
endif::HAVE_LIBPFM[]
|
2009-06-04 22:33:00 +08:00
|
|
|
|
2009-04-20 21:52:29 +08:00
|
|
|
-a::
|
2010-12-01 09:57:19 +08:00
|
|
|
--all-cpus::
|
perf stat: Add -a as default target
Boris asked for default -a option in case we monitor only uncore events.
While implementing that I thought it might be actually useful to make it
overall default.
Running 'perf stat' will now collect system wide data.
Committer note:
Testing it:
# perf stat
^C
Performance counter stats for 'system wide':
3571.559178 cpu-clock (msec) # 4.000 CPUs utilized
3,346 context-switches # 0.937 K/sec
277 cpu-migrations # 0.078 K/sec
57,271 page-faults # 0.016 M/sec
4,535,633,835 cycles # 1.270 GHz
6,389,736,516 instructions # 1.41 insn per cycle
1,541,293,875 branches # 431.547 M/sec
14,526,396 branch-misses # 0.94% of all branches
0.892950118 seconds time elapsed
#
Requested-and-Acked-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20170217170034.GB15389@krava
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2017-02-18 01:00:34 +08:00
|
|
|
system-wide collection from all CPUs (default if no target is specified)
|
2009-04-20 21:52:29 +08:00
|
|
|
|
2019-03-15 06:50:01 +08:00
|
|
|
--no-scale::
|
|
|
|
Don't scale/normalize counter values
|
2010-12-01 09:57:19 +08:00
|
|
|
|
2016-03-08 03:44:44 +08:00
|
|
|
-d::
|
|
|
|
--detailed::
|
|
|
|
print more detailed statistics, can be specified up to 3 times
|
|
|
|
|
|
|
|
-d: detailed events, L1 and LLC data cache
|
|
|
|
-d -d: more detailed events, dTLB and iTLB events
|
|
|
|
-d -d -d: very detailed events, adding prefetch events
|
|
|
|
|
2010-12-01 09:57:19 +08:00
|
|
|
-r::
|
|
|
|
--repeat=<n>::
|
2013-03-02 02:02:27 +08:00
|
|
|
repeat command and print average + stddev (max: 100). 0 means forever.
|
2009-04-20 21:52:29 +08:00
|
|
|
|
perf stat: add perf stat -B to pretty print large numbers
It is hard to read very large numbers so provide an option to perf stat
to separate thousands using a separator. The patch leverages the locale
support of stdio. You need to set your LC_NUMERIC appropriately, for
instance LC_NUMERIC=en_US.UTF8. You need to pass -B to activate this
feature. This way existing scripts parsing the output do not need to be
changed. Here is an example.
$ perf stat noploop 2
noploop for 2 seconds
Performance counter stats for 'noploop 2':
1998.347031 task-clock-msecs # 0.998 CPUs
61 context-switches # 0.000 M/sec
0 CPU-migrations # 0.000 M/sec
118 page-faults # 0.000 M/sec
4,138,410,900 cycles # 2070.917 M/sec (scaled from 70.01%)
2,062,650,268 instructions # 0.498 IPC (scaled from 70.01%)
2,057,653,466 branches # 1029.678 M/sec (scaled from 70.01%)
40,267 branch-misses # 0.002 % (scaled from 30.04%)
2,055,961,348 cache-references # 1028.831 M/sec (scaled from 30.03%)
53,725 cache-misses # 0.027 M/sec (scaled from 30.02%)
2.001393933 seconds time elapsed
$ perf stat -B noploop 2
noploop for 2 seconds
Performance counter stats for 'noploop 2':
1998.297883 task-clock-msecs # 0.998 CPUs
59 context-switches # 0.000 M/sec
0 CPU-migrations # 0.000 M/sec
119 page-faults # 0.000 M/sec
4,131,380,160 cycles # 2067.450 M/sec (scaled from 70.01%)
2,059,096,507 instructions # 0.498 IPC (scaled from 70.01%)
2,054,681,303 branches # 1028.216 M/sec (scaled from 70.01%)
25,650 branch-misses # 0.001 % (scaled from 30.05%)
2,056,283,014 cache-references # 1029.017 M/sec (scaled from 30.03%)
47,097 cache-misses # 0.024 M/sec (scaled from 30.02%)
2.001391016 seconds time elapsed
Cc: David S. Miller <davem@davemloft.net>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <4bf28fe8.914ed80a.01ca.fffff5f5@mx.google.com>
Signed-off-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-05-18 21:00:01 +08:00
|
|
|
-B::
|
2010-12-01 09:57:19 +08:00
|
|
|
--big-num::
|
2020-05-21 00:23:35 +08:00
|
|
|
print large numbers with thousands' separators according to locale.
|
|
|
|
Enabled by default. Use "--no-big-num" to disable.
|
|
|
|
Default setting can be changed with "perf config stat.big-num=false".
|
perf stat: add perf stat -B to pretty print large numbers
It is hard to read very large numbers so provide an option to perf stat
to separate thousands using a separator. The patch leverages the locale
support of stdio. You need to set your LC_NUMERIC appropriately, for
instance LC_NUMERIC=en_US.UTF8. You need to pass -B to activate this
feature. This way existing scripts parsing the output do not need to be
changed. Here is an example.
$ perf stat noploop 2
noploop for 2 seconds
Performance counter stats for 'noploop 2':
1998.347031 task-clock-msecs # 0.998 CPUs
61 context-switches # 0.000 M/sec
0 CPU-migrations # 0.000 M/sec
118 page-faults # 0.000 M/sec
4,138,410,900 cycles # 2070.917 M/sec (scaled from 70.01%)
2,062,650,268 instructions # 0.498 IPC (scaled from 70.01%)
2,057,653,466 branches # 1029.678 M/sec (scaled from 70.01%)
40,267 branch-misses # 0.002 % (scaled from 30.04%)
2,055,961,348 cache-references # 1028.831 M/sec (scaled from 30.03%)
53,725 cache-misses # 0.027 M/sec (scaled from 30.02%)
2.001393933 seconds time elapsed
$ perf stat -B noploop 2
noploop for 2 seconds
Performance counter stats for 'noploop 2':
1998.297883 task-clock-msecs # 0.998 CPUs
59 context-switches # 0.000 M/sec
0 CPU-migrations # 0.000 M/sec
119 page-faults # 0.000 M/sec
4,131,380,160 cycles # 2067.450 M/sec (scaled from 70.01%)
2,059,096,507 instructions # 0.498 IPC (scaled from 70.01%)
2,054,681,303 branches # 1028.216 M/sec (scaled from 70.01%)
25,650 branch-misses # 0.001 % (scaled from 30.05%)
2,056,283,014 cache-references # 1029.017 M/sec (scaled from 30.03%)
47,097 cache-misses # 0.024 M/sec (scaled from 30.02%)
2.001391016 seconds time elapsed
Cc: David S. Miller <davem@davemloft.net>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <4bf28fe8.914ed80a.01ca.fffff5f5@mx.google.com>
Signed-off-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-05-18 21:00:01 +08:00
|
|
|
|
2010-05-28 18:00:01 +08:00
|
|
|
-C::
|
|
|
|
--cpu=::
|
2010-12-01 09:57:19 +08:00
|
|
|
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.
|
2010-05-28 18:00:01 +08:00
|
|
|
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.
|
|
|
|
|
2010-11-16 17:05:01 +08:00
|
|
|
-A::
|
|
|
|
--no-aggr::
|
perf stat: Correct --no-aggr description
Description of --no-aggr in perf-stat man page is outdated. --no-aggr
can also be used while profiling specific set of cpus. For ex,
$ perf stat -e cycles,instructions -C 1-2 --no-aggr -- sleep 1
Performance counter stats for 'CPU(s) 1-2':
CPU1 5,94,92,795 cycles
CPU2 2,69,72,403 cycles
CPU1 2,02,08,327 instructions # 0.34 insn per cycle
CPU2 73,17,123 instructions # 0.12 insn per cycle
1.000989132 seconds time elapsed
Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1490013438-5713-1-git-send-email-ravi.bangoria@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2017-03-20 20:37:18 +08:00
|
|
|
Do not aggregate counts across all monitored CPUs.
|
2010-11-16 17:05:01 +08:00
|
|
|
|
2010-12-01 09:57:19 +08:00
|
|
|
-n::
|
|
|
|
--null::
|
|
|
|
null run - don't start any counters
|
|
|
|
|
|
|
|
-v::
|
|
|
|
--verbose::
|
|
|
|
be more verbose (show counter open errors, etc)
|
|
|
|
|
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 <davem@davemloft.net>
Cc: Frederik Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: paulus@samba.org
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Robert Richter <robert.richter@amd.com>
LKML-Reference: <4cf68aa7.0fedd80a.5294.1203@mx.google.com>
Signed-off-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-12-02 00:49:05 +08:00
|
|
|
-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.
|
|
|
|
|
2018-04-23 17:08:21 +08:00
|
|
|
--table:: Display time for each run (-r option), in a table format, e.g.:
|
|
|
|
|
|
|
|
$ perf stat --null -r 5 --table perf bench sched pipe
|
|
|
|
|
|
|
|
Performance counter stats for 'perf bench sched pipe' (5 runs):
|
|
|
|
|
|
|
|
# Table of individual measurements:
|
2018-04-23 17:08:22 +08:00
|
|
|
5.189 (-0.293) #
|
|
|
|
5.189 (-0.294) #
|
|
|
|
5.186 (-0.296) #
|
|
|
|
5.663 (+0.181) ##
|
|
|
|
6.186 (+0.703) ####
|
2018-04-23 17:08:21 +08:00
|
|
|
|
|
|
|
# Final result:
|
2018-04-23 17:08:22 +08:00
|
|
|
5.483 +- 0.198 seconds time elapsed ( +- 3.62% )
|
2018-04-23 17:08:21 +08:00
|
|
|
|
perf tool: Add cgroup support
This patch adds the ability to filter monitoring based on container groups
(cgroups) for both perf stat and perf record. It is possible to monitor
multiple cgroup in parallel. There is one cgroup per event. The cgroups to
monitor are passed via a new -G option followed by a comma separated list of
cgroup names.
The cgroup filesystem has to be mounted. Given a cgroup name, the perf tool
finds the corresponding directory in the cgroup filesystem and opens it. It
then passes that file descriptor to the kernel.
Example:
$ perf stat -B -a -e cycles:u,cycles:u,cycles:u -G test1,,test2 -- sleep 1
Performance counter stats for 'sleep 1':
2,368,667,414 cycles test1
2,369,661,459 cycles
<not counted> cycles test2
1.001856890 seconds time elapsed
Signed-off-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <4d590290.825bdf0a.7d0a.4890@mx.google.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2011-02-14 17:20:01 +08:00
|
|
|
-G name::
|
|
|
|
--cgroup name::
|
|
|
|
monitor only in the container (cgroup) called "name". This option is available only
|
|
|
|
in per-cpu mode. The cgroup filesystem must be mounted. All threads belonging to
|
|
|
|
container "name" are monitored when they run on the monitored CPUs. Multiple cgroups
|
|
|
|
can be provided. Each cgroup is applied to the corresponding event, i.e., first cgroup
|
|
|
|
to first event, second cgroup to second event and so on. It is possible to provide
|
|
|
|
an empty cgroup (monitor all the time) using, e.g., -G foo,,bar. Cgroups must have
|
|
|
|
corresponding events, i.e., they always refer to events defined earlier on the command
|
2018-01-29 23:48:09 +08:00
|
|
|
line. If the user wants to track multiple events for a specific cgroup, the user can
|
|
|
|
use '-e e1 -e e2 -G foo,foo' or just use '-e e1 -e e2 -G foo'.
|
|
|
|
|
|
|
|
If wanting to monitor, say, 'cycles' for a cgroup and also for system wide, this
|
|
|
|
command line can be used: 'perf stat -e cycles -G cgroup_name -a -e cycles'.
|
perf tool: Add cgroup support
This patch adds the ability to filter monitoring based on container groups
(cgroups) for both perf stat and perf record. It is possible to monitor
multiple cgroup in parallel. There is one cgroup per event. The cgroups to
monitor are passed via a new -G option followed by a comma separated list of
cgroup names.
The cgroup filesystem has to be mounted. Given a cgroup name, the perf tool
finds the corresponding directory in the cgroup filesystem and opens it. It
then passes that file descriptor to the kernel.
Example:
$ perf stat -B -a -e cycles:u,cycles:u,cycles:u -G test1,,test2 -- sleep 1
Performance counter stats for 'sleep 1':
2,368,667,414 cycles test1
2,369,661,459 cycles
<not counted> cycles test2
1.001856890 seconds time elapsed
Signed-off-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <4d590290.825bdf0a.7d0a.4890@mx.google.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2011-02-14 17:20:01 +08:00
|
|
|
|
2011-08-16 04:22:33 +08:00
|
|
|
-o file::
|
2011-09-08 07:14:00 +08:00
|
|
|
--output file::
|
2011-08-16 04:22:33 +08:00
|
|
|
Print the output into the designated file.
|
|
|
|
|
|
|
|
--append::
|
|
|
|
Append to the output file designated with the -o option. Ignored if -o is not specified.
|
|
|
|
|
2011-09-08 07:14:00 +08:00
|
|
|
--log-fd::
|
|
|
|
|
|
|
|
Log output to fd, instead of stderr. Complementary to --output, and mutually exclusive
|
|
|
|
with it. --append may be used here. Examples:
|
|
|
|
3>results perf stat --log-fd 3 -- $cmd
|
|
|
|
3>>results perf stat --log-fd 3 --append -- $cmd
|
|
|
|
|
2020-09-02 18:57:07 +08:00
|
|
|
--control=fifo:ctl-fifo[,ack-fifo]::
|
2020-09-01 17:37:55 +08:00
|
|
|
--control=fd:ctl-fd[,ack-fd]::
|
2020-09-02 18:57:07 +08:00
|
|
|
ctl-fifo / ack-fifo are opened and used as ctl-fd / ack-fd as follows.
|
2020-07-17 15:05:41 +08:00
|
|
|
Listen on ctl-fd descriptor for command to control measurement ('enable': enable events,
|
|
|
|
'disable': disable events). Measurements can be started with events disabled using
|
|
|
|
--delay=-1 option. Optionally send control command completion ('ack\n') to ack-fd descriptor
|
|
|
|
to synchronize with the controlling process. Example of bash shell script to enable and
|
|
|
|
disable events during measurements:
|
|
|
|
|
2020-09-01 17:37:55 +08:00
|
|
|
#!/bin/bash
|
2020-07-17 15:05:41 +08:00
|
|
|
|
2020-09-01 17:37:55 +08:00
|
|
|
ctl_dir=/tmp/
|
2020-07-17 15:05:41 +08:00
|
|
|
|
2020-09-01 17:37:55 +08:00
|
|
|
ctl_fifo=${ctl_dir}perf_ctl.fifo
|
|
|
|
test -p ${ctl_fifo} && unlink ${ctl_fifo}
|
|
|
|
mkfifo ${ctl_fifo}
|
|
|
|
exec {ctl_fd}<>${ctl_fifo}
|
2020-07-17 15:05:41 +08:00
|
|
|
|
2020-09-01 17:37:55 +08:00
|
|
|
ctl_ack_fifo=${ctl_dir}perf_ctl_ack.fifo
|
|
|
|
test -p ${ctl_ack_fifo} && unlink ${ctl_ack_fifo}
|
|
|
|
mkfifo ${ctl_ack_fifo}
|
|
|
|
exec {ctl_fd_ack}<>${ctl_ack_fifo}
|
2020-07-17 15:05:41 +08:00
|
|
|
|
2020-09-01 17:37:55 +08:00
|
|
|
perf stat -D -1 -e cpu-cycles -a -I 1000 \
|
|
|
|
--control fd:${ctl_fd},${ctl_fd_ack} \
|
|
|
|
-- sleep 30 &
|
|
|
|
perf_pid=$!
|
2020-07-17 15:05:41 +08:00
|
|
|
|
2020-09-01 17:37:55 +08:00
|
|
|
sleep 5 && echo 'enable' >&${ctl_fd} && read -u ${ctl_fd_ack} e1 && echo "enabled(${e1})"
|
|
|
|
sleep 10 && echo 'disable' >&${ctl_fd} && read -u ${ctl_fd_ack} d1 && echo "disabled(${d1})"
|
2020-07-17 15:05:41 +08:00
|
|
|
|
2020-09-01 17:37:55 +08:00
|
|
|
exec {ctl_fd_ack}>&-
|
|
|
|
unlink ${ctl_ack_fifo}
|
2020-07-17 15:05:41 +08:00
|
|
|
|
2020-09-01 17:37:55 +08:00
|
|
|
exec {ctl_fd}>&-
|
|
|
|
unlink ${ctl_fifo}
|
2020-07-17 15:05:41 +08:00
|
|
|
|
2020-09-01 17:37:55 +08:00
|
|
|
wait -n ${perf_pid}
|
|
|
|
exit $?
|
2020-07-17 15:05:41 +08:00
|
|
|
|
|
|
|
|
2012-10-23 19:40:14 +08:00
|
|
|
--pre::
|
|
|
|
--post::
|
|
|
|
Pre and post measurement hooks, e.g.:
|
|
|
|
|
|
|
|
perf stat --repeat 10 --null --sync --pre 'make -s O=defconfig-build/clean' -- make -s -j64 O=defconfig-build/ bzImage
|
2011-09-08 07:14:00 +08:00
|
|
|
|
perf stat: Add interval printing
This patch adds a new printing mode for perf stat. It allows interval
printing. That means perf stat can now print event deltas at regular
time interval. This is useful to detect phases in programs.
The -I option enables interval printing. It expects an interval duration
in milliseconds. Minimum is 100ms. Once, activated perf stat prints
events deltas since last printout. All modes are supported.
$ perf stat -I 1000 -e cycles noploop 10
noploop for 10 seconds
# time counts events
1.000109853 2,388,560,546 cycles
2.000262846 2,393,332,358 cycles
3.000354131 2,393,176,537 cycles
4.000439503 2,393,203,790 cycles
5.000527075 2,393,167,675 cycles
6.000609052 2,393,203,670 cycles
7.000691082 2,393,175,678 cycles
The output format makes it easy to feed into a plotting program such as
gnuplot when the -I option is used in combination with the -x option:
$ perf stat -x, -I 1000 -e cycles noploop 10
noploop for 10 seconds
1.000084113,2378775498,cycles
2.000245798,2391056897,cycles
3.000354445,2392089414,cycles
4.000459115,2390936603,cycles
5.000565341,2392108173,cycles
Signed-off-by: Stephane Eranian <eranian@google.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1359460064-3060-3-git-send-email-eranian@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2013-01-29 19:47:44 +08:00
|
|
|
-I msecs::
|
|
|
|
--interval-print msecs::
|
2018-04-04 02:18:33 +08:00
|
|
|
Print count deltas every N milliseconds (minimum: 1ms)
|
2015-10-02 17:04:34 +08:00
|
|
|
The overhead percentage could be high in some cases, for instance with small, sub 100ms intervals. Use with caution.
|
|
|
|
example: 'perf stat -I 1000 -e cycles -a sleep 5'
|
2011-09-08 07:14:00 +08:00
|
|
|
|
perf stat: Improve runtime stat for interval mode
For interval mode, the metric is printed after the '#' character if it
exists. But it's not calculated by the counts generated in this
interval.
See the following examples:
root@kbl-ppc:~# perf stat -M CPI -I1000 --interval-count 2
# time counts unit events
1.000422803 764,809 inst_retired.any # 2.9 CPI
1.000422803 2,234,932 cycles
2.001464585 1,960,061 inst_retired.any # 1.6 CPI
2.001464585 4,022,591 cycles
The second CPI should not be 1.6 (4,022,591/1,960,061 is 2.1)
root@kbl-ppc:~# perf stat -e cycles,instructions -I1000 --interval-count 2
# time counts unit events
1.000429493 2,869,311 cycles
1.000429493 816,875 instructions # 0.28 insn per cycle
2.001516426 9,260,973 cycles
2.001516426 5,250,634 instructions # 0.87 insn per cycle
The second 'insn per cycle' should not be 0.87 (5,250,634/9,260,973 is
0.57).
The current code uses a global variable 'rt_stat' for tracking and
updating the std dev of runtime stat. Unlike the counts, 'rt_stat' is not
reset for interval. While the counts are reset for interval.
perf_stat_process_counter()
{
if (config->interval)
init_stats(ps->res_stats);
}
So for interval mode, the 'rt_stat' variable should be reset too.
This patch resets 'rt_stat' before read_counters(), so the runtime stat
is only calculated by the counts generated in this interval.
With this patch:
root@kbl-ppc:~# perf stat -M CPI -I1000 --interval-count 2
# time counts unit events
1.000420924 2,408,818 inst_retired.any # 2.1 CPI
1.000420924 5,010,111 cycles
2.001448579 2,798,407 inst_retired.any # 1.6 CPI
2.001448579 4,599,861 cycles
root@kbl-ppc:~# perf stat -e cycles,instructions -I1000 --interval-count 2
# time counts unit events
1.000428555 2,769,714 cycles
1.000428555 774,462 instructions # 0.28 insn per cycle
2.001471562 3,595,904 cycles
2.001471562 1,243,703 instructions # 0.35 insn per cycle
Now the second 'insn per cycle' and CPI are calculated by the counts
generated in this interval.
Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Tested-By: Kajol Jain <kjain@linux.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jin Yao <yao.jin@intel.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20200420145417.6864-1-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-04-20 22:54:17 +08:00
|
|
|
If the metric exists, it is calculated by the counts generated in this interval and the metric is printed after #.
|
|
|
|
|
2018-01-29 17:25:22 +08:00
|
|
|
--interval-count times::
|
|
|
|
Print count deltas for fixed number of times.
|
|
|
|
This option should be used together with "-I" option.
|
|
|
|
example: 'perf stat -I 1000 --interval-count 2 -e cycles -a'
|
|
|
|
|
2018-06-07 06:15:06 +08:00
|
|
|
--interval-clear::
|
|
|
|
Clear the screen before next interval.
|
|
|
|
|
2018-01-29 17:25:23 +08:00
|
|
|
--timeout msecs::
|
|
|
|
Stop the 'perf stat' session and print count deltas after N milliseconds (minimum: 10 ms).
|
|
|
|
This option is not supported with the "-I" option.
|
|
|
|
example: 'perf stat --time 2000 -e cycles -a'
|
|
|
|
|
2016-03-04 07:57:36 +08:00
|
|
|
--metric-only::
|
|
|
|
Only print computed metrics. Print them in a single line.
|
2016-03-04 07:57:37 +08:00
|
|
|
Don't show any raw values. Not supported with --per-thread.
|
2016-03-04 07:57:36 +08:00
|
|
|
|
2013-02-14 20:57:28 +08:00
|
|
|
--per-socket::
|
2013-02-06 22:46:02 +08:00
|
|
|
Aggregate counts per processor socket for system-wide mode measurements. This
|
|
|
|
is a useful mode to detect imbalance between sockets. To enable this mode,
|
2013-02-14 20:57:28 +08:00
|
|
|
use --per-socket in addition to -a. (system-wide). The output includes the
|
2013-02-06 22:46:02 +08:00
|
|
|
socket number and the number of online processors on that socket. This is
|
|
|
|
useful to gauge the amount of aggregation.
|
|
|
|
|
2019-06-05 06:50:42 +08:00
|
|
|
--per-die::
|
|
|
|
Aggregate counts per processor die for system-wide mode measurements. This
|
|
|
|
is a useful mode to detect imbalance between dies. To enable this mode,
|
|
|
|
use --per-die in addition to -a. (system-wide). The output includes the
|
|
|
|
die number and the number of online processors on that die. This is
|
|
|
|
useful to gauge the amount of aggregation.
|
|
|
|
|
2013-02-14 20:57:29 +08:00
|
|
|
--per-core::
|
|
|
|
Aggregate counts per physical processor for system-wide mode measurements. This
|
|
|
|
is a useful mode to detect imbalance between physical cores. To enable this mode,
|
|
|
|
use --per-core in addition to -a. (system-wide). The output includes the
|
|
|
|
core number and the number of online logical processors on that physical processor.
|
|
|
|
|
perf stat: Introduce --per-thread option
Currently all the -p option PID arguments tasks values get aggregated
and printed as single values.
Adding --per-tasks option to print values per task.
$ perf stat -e cycles,instructions --per-thread -p 30190,30242
^C
Performance counter stats for process id '30190,30242':
cat-30190 0 cycles
yes-30242 3,842,525,421 cycles
cat-30190 0 instructions
yes-30242 10,370,817,010 instructions
1.143155657 seconds time elapsed
Also works under interval mode:
$ perf stat -e cycles,instructions --per-thread -p 30190,30242 -I 1000
# time comm-pid counts unit events
1.000073435 cat-30190 89,058 cycles
1.000073435 yes-30242 3,360,786,902 cycles (100.00%)
1.000073435 cat-30190 14,066 instructions
1.000073435 yes-30242 9,069,937,462 instructions
2.000204830 cat-30190 0 cycles
2.000204830 yes-30242 3,351,667,626 cycles
2.000204830 cat-30190 0 instructions
2.000204830 yes-30242 9,045,796,885 instructions
^C 2.771286639 cat-30190 0 cycles
2.771286639 yes-30242 2,593,884,166 cycles
2.771286639 cat-30190 0 instructions
2.771286639 yes-30242 7,001,171,191 instructions
It works only with -t and -p options, otherwise following error is
printed:
$ perf stat -e cycles --per-thread -I 1000 ls
The --per-thread option is only available when monitoring via -p -t options.
-p, --pid <pid> stat events on existing process id
-t, --tid <tid> stat events on existing thread id
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1435310967-14570-23-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-26 17:29:27 +08:00
|
|
|
--per-thread::
|
|
|
|
Aggregate counts per monitored threads, when monitoring threads (-t option)
|
|
|
|
or processes (-p option).
|
|
|
|
|
perf stat: Add --per-node agregation support
Adding new --per-node option to aggregate counts per NUMA
nodes for system-wide mode measurements.
You can specify --per-node in live mode:
# perf stat -a -I 1000 -e cycles --per-node
# time node cpus counts unit events
1.000542550 N0 20 6,202,097 cycles
1.000542550 N1 20 639,559 cycles
2.002040063 N0 20 7,412,495 cycles
2.002040063 N1 20 2,185,577 cycles
3.003451699 N0 20 6,508,917 cycles
3.003451699 N1 20 765,607 cycles
...
Or in the record/report stat session:
# perf stat record -a -I 1000 -e cycles
# time counts unit events
1.000536937 10,008,468 cycles
2.002090152 9,578,539 cycles
3.003625233 7,647,869 cycles
4.005135036 7,032,086 cycles
^C 4.340902364 3,923,893 cycles
# perf stat report --per-node
# time node cpus counts unit events
1.000536937 N0 20 9,355,086 cycles
1.000536937 N1 20 653,382 cycles
2.002090152 N0 20 7,712,838 cycles
2.002090152 N1 20 1,865,701 cycles
3.003625233 N0 20 6,604,441 cycles
3.003625233 N1 20 1,043,428 cycles
4.005135036 N0 20 6,350,522 cycles
4.005135036 N1 20 681,564 cycles
4.340902364 N0 20 3,403,188 cycles
4.340902364 N1 20 520,705 cycles
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20190904073415.723-4-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-08-28 16:17:43 +08:00
|
|
|
--per-node::
|
|
|
|
Aggregate counts per NUMA nodes for system-wide mode measurements. This
|
|
|
|
is a useful mode to detect imbalance between NUMA nodes. To enable this
|
|
|
|
mode, use --per-node in addition to -a. (system-wide).
|
|
|
|
|
2013-08-03 08:41:11 +08:00
|
|
|
-D msecs::
|
2014-01-08 06:14:06 +08:00
|
|
|
--delay msecs::
|
2020-07-17 15:04:33 +08:00
|
|
|
After starting the program, wait msecs before measuring (-1: start with events
|
|
|
|
disabled). This is useful to filter out the startup phase of the program,
|
|
|
|
which is often very different.
|
2013-08-03 08:41:11 +08:00
|
|
|
|
2013-08-22 07:47:26 +08:00
|
|
|
-T::
|
|
|
|
--transaction::
|
|
|
|
|
|
|
|
Print statistics of transactional execution if supported.
|
|
|
|
|
2020-05-21 02:20:10 +08:00
|
|
|
--metric-no-group::
|
|
|
|
By default, events to compute a metric are placed in weak groups. The
|
|
|
|
group tries to enforce scheduling all or none of the events. The
|
|
|
|
--metric-no-group option places events outside of groups and may
|
|
|
|
increase the chance of the event being scheduled - leading to more
|
|
|
|
accuracy. However, as events may not be scheduled together accuracy
|
|
|
|
for metrics like instructions per cycle can be lower - as both metrics
|
|
|
|
may no longer be being measured at the same time.
|
|
|
|
|
|
|
|
--metric-no-merge::
|
|
|
|
By default metric events in different weak groups can be shared if one
|
|
|
|
group contains all the events needed by another. In such cases one
|
|
|
|
group will be eliminated reducing event multiplexing and making it so
|
|
|
|
that certain groups of metrics sum to 100%. A downside to sharing a
|
|
|
|
group is that the group may require multiplexing and so accuracy for a
|
|
|
|
small group that need not have multiplexing is lowered. This option
|
|
|
|
forbids the event merging logic from sharing events between groups and
|
|
|
|
may be used to increase accuracy in this case.
|
|
|
|
|
perf stat record: Add record command
Add 'perf stat record' command support. It creates simple (header only)
perf.data file ATM.
The record command could be specified anywhere among stat options. All
stat command options are valid for stat record command with '-o' option
exception. If specified for record command it denotes the perf data file
name.
Committer note:
Set sample_type to PERF_SAMPLE_IDENTIFIER, which should be harmless
while avoiding that older tools show confusing messages, for instance,
with sample_type = 0, we get:
$ perf stat record usleep 1
Performance counter stats for 'usleep 1':
0.630237 task-clock (msec) # 0.528 CPUs utilized
1 context-switches # 0.002 M/sec
0 cpu-migrations # 0.000 K/sec
52 page-faults # 0.083 M/sec
978,312 cycles # 1.552 GHz
671,931 stalled-cycles-frontend # 68.68% frontend cycles idle
<not supported> stalled-cycles-backend
646,379 instructions # 0.66 insns per cycle
# 1.04 stalled cycles per insn
131,046 branches # 207.931 M/sec
7,073 branch-misses # 5.40% of all branches
0.001193240 seconds time elapsed
$ oldperf evlist
WARNING: The perf.data file's data size field is 0 which is unexpected.
Was the 'perf record' command properly terminated?
non matching sample_type
$
While with sample_type set to PERF_SAMPLE_IDENTIFIER, after we re-run 'perf
stat record usleep' we get:
$ oldperf evlist
WARNING: The perf.data file's data size field is 0 which is unexpected.
Was the 'perf record' command properly terminated?
task-clock
context-switches
cpu-migrations
page-faults
cycles
stalled-cycles-frontend
stalled-cycles-backend
instructions
branches
branch-misses
$
Which at least shows the names of the events in the perf.data file.
Additionally, such files, when passed to 'perf report' will produce:
$ oldperf report --stdio
WARNING: The perf.data file's data size field is 0 which is unexpected.
Was the 'perf record' command properly terminated?
Warning:
Kernel address maps (/proc/{kallsyms,modules}) were restricted.
Check /proc/sys/kernel/kptr_restrict before running 'perf record'.
As no suitable kallsyms nor vmlinux was found, kernel samples
can't be resolved.
Samples in kernel modules can't be resolved as well.
Error:
The perf.data file has no samples!
# To display the perf.data header info, please use --header/--header-only options.
#
$
Which is confusing and can be solved by just adding the kernel mmap record,
which will also remove that warning about the data size field being equal to
zero, after generating the mmap record:
$ perf stat record usleep 1
Performance counter stats for 'usleep 1':
0.600796 task-clock (msec) # 0.478 CPUs utilized
1 context-switches # 0.002 M/sec
0 cpu-migrations # 0.000 K/sec
54 page-faults # 0.090 M/sec
886,844 cycles # 1.476 GHz
582,169 stalled-cycles-frontend # 65.65% frontend cycles idle
<not supported> stalled-cycles-backend
638,344 instructions # 0.72 insns per cycle
# 0.91 stalled cycles per insn
130,204 branches # 216.719 M/sec
7,500 branch-misses # 5.76% of all branches
0.001255897 seconds time elapsed
$ oldperf evlist
task-clock
context-switches
cpu-migrations
page-faults
cycles
stalled-cycles-frontend
stalled-cycles-backend
instructions
branches
branch-misses
$ oldperf report --stdio
Error:
The perf.data file has no samples!
# To display the perf.data header info, please use --header/--header-only options.
#
[acme@zoo linux]$
No warnings, sensible output about what are the events in the perf.data file and also
a "file has no samples" message, which indeed it doesn't.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Kan Liang <kan.liang@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: htp://lkml.kernel.org/r/1446734469-11352-3-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-11-05 22:40:46 +08:00
|
|
|
STAT RECORD
|
|
|
|
-----------
|
|
|
|
Stores stat data into perf data file.
|
|
|
|
|
|
|
|
-o file::
|
|
|
|
--output file::
|
|
|
|
Output file name.
|
|
|
|
|
2015-11-05 22:40:55 +08:00
|
|
|
STAT REPORT
|
|
|
|
-----------
|
|
|
|
Reads and reports stat data from perf data file.
|
|
|
|
|
|
|
|
-i file::
|
|
|
|
--input file::
|
|
|
|
Input file name.
|
|
|
|
|
2015-11-05 22:41:02 +08:00
|
|
|
--per-socket::
|
|
|
|
Aggregate counts per processor socket for system-wide mode measurements.
|
|
|
|
|
2019-06-05 06:50:42 +08:00
|
|
|
--per-die::
|
|
|
|
Aggregate counts per processor die for system-wide mode measurements.
|
|
|
|
|
2015-11-05 22:41:02 +08:00
|
|
|
--per-core::
|
|
|
|
Aggregate counts per physical processor for system-wide mode measurements.
|
|
|
|
|
2017-09-01 03:40:31 +08:00
|
|
|
-M::
|
|
|
|
--metrics::
|
|
|
|
Print metrics or metricgroups specified in a comma separated list.
|
|
|
|
For a group all metrics from the group are added.
|
|
|
|
The events from the metrics are automatically measured.
|
|
|
|
See perf list output for the possble metrics and metricgroups.
|
|
|
|
|
2015-11-05 22:41:02 +08:00
|
|
|
-A::
|
|
|
|
--no-aggr::
|
|
|
|
Do not aggregate counts across all monitored CPUs.
|
|
|
|
|
perf stat: Basic support for TopDown in perf stat
Add basic plumbing for TopDown in perf stat
TopDown is intended to replace the frontend cycles idle/ backend cycles
idle metrics in standard perf stat output. These metrics are not
reliable in many workloads, due to out of order effects.
This implements a new --topdown mode in perf stat (similar to
--transaction) that measures the pipe line bottlenecks using
standardized formulas. The measurement can be all done with 5 counters
(one fixed counter)
The result are four metrics:
FrontendBound, BackendBound, BadSpeculation, Retiring
that describe the CPU pipeline behavior on a high level.
The full top down methology has many hierarchical metrics. This
implementation only supports level 1 which can be collected without
multiplexing. A full implementation of top down on top of perf is
available in pmu-tools toplev. (http://github.com/andikleen/pmu-tools)
The current version works on Intel Core CPUs starting with Sandy Bridge,
and Atom CPUs starting with Silvermont. In principle the generic
metrics should be also implementable on other out of order CPUs.
TopDown level 1 uses a set of abstracted metrics which are generic to
out of order CPU cores (although some CPUs may not implement all of
them):
topdown-total-slots Available slots in the pipeline
topdown-slots-issued Slots issued into the pipeline
topdown-slots-retired Slots successfully retired
topdown-fetch-bubbles Pipeline gaps in the frontend
topdown-recovery-bubbles Pipeline gaps during recovery
from misspeculation
These metrics then allow to compute four useful metrics:
FrontendBound, BackendBound, Retiring, BadSpeculation.
Add a new --topdown options to enable events. When --topdown is
specified set up events for all topdown events supported by the kernel.
Add topdown-* as a special case to the event parser, as is needed for
all events containing -.
The actual code to compute the metrics is in follow-on patches.
v2: Use standard sysctl read function.
v3: Move x86 specific code to arch/
v4: Enable --metric-only implicitly for topdown.
v5: Add --single-thread option to not force per core mode
v6: Fix output order of topdown metrics
v7: Allow combining with -d
v8: Remove --single-thread again
v9: Rename functions, adding arch_ and topdown_.
v10: Expand man page and describe TopDown better
Paste intro into commit description.
Print error when malloc fails.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/1464119559-17203-1-git-send-email-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-05-30 23:49:42 +08:00
|
|
|
--topdown::
|
|
|
|
Print top down level 1 metrics if supported by the CPU. This allows to
|
|
|
|
determine bottle necks in the CPU pipeline for CPU bound workloads,
|
|
|
|
by breaking the cycles consumed down into frontend bound, backend bound,
|
|
|
|
bad speculation and retiring.
|
|
|
|
|
|
|
|
Frontend bound means that the CPU cannot fetch and decode instructions fast
|
|
|
|
enough. Backend bound means that computation or memory access is the bottle
|
|
|
|
neck. Bad Speculation means that the CPU wasted cycles due to branch
|
|
|
|
mispredictions and similar issues. Retiring means that the CPU computed without
|
|
|
|
an apparently bottleneck. The bottleneck is only the real bottleneck
|
|
|
|
if the workload is actually bound by the CPU and not by something else.
|
|
|
|
|
|
|
|
For best results it is usually a good idea to use it with interval
|
|
|
|
mode like -I 1000, as the bottleneck of workloads can change often.
|
|
|
|
|
|
|
|
The top down metrics are collected per core instead of per
|
|
|
|
CPU thread. Per core mode is automatically enabled
|
|
|
|
and -a (global monitoring) is needed, requiring root rights or
|
|
|
|
perf.perf_event_paranoid=-1.
|
|
|
|
|
|
|
|
Topdown uses the full Performance Monitoring Unit, and needs
|
|
|
|
disabling of the NMI watchdog (as root):
|
|
|
|
echo 0 > /proc/sys/kernel/nmi_watchdog
|
|
|
|
for best results. Otherwise the bottlenecks may be inconsistent
|
|
|
|
on workload with changing phases.
|
|
|
|
|
2018-12-03 18:22:00 +08:00
|
|
|
This enables --metric-only, unless overridden with --no-metric-only.
|
perf stat: Basic support for TopDown in perf stat
Add basic plumbing for TopDown in perf stat
TopDown is intended to replace the frontend cycles idle/ backend cycles
idle metrics in standard perf stat output. These metrics are not
reliable in many workloads, due to out of order effects.
This implements a new --topdown mode in perf stat (similar to
--transaction) that measures the pipe line bottlenecks using
standardized formulas. The measurement can be all done with 5 counters
(one fixed counter)
The result are four metrics:
FrontendBound, BackendBound, BadSpeculation, Retiring
that describe the CPU pipeline behavior on a high level.
The full top down methology has many hierarchical metrics. This
implementation only supports level 1 which can be collected without
multiplexing. A full implementation of top down on top of perf is
available in pmu-tools toplev. (http://github.com/andikleen/pmu-tools)
The current version works on Intel Core CPUs starting with Sandy Bridge,
and Atom CPUs starting with Silvermont. In principle the generic
metrics should be also implementable on other out of order CPUs.
TopDown level 1 uses a set of abstracted metrics which are generic to
out of order CPU cores (although some CPUs may not implement all of
them):
topdown-total-slots Available slots in the pipeline
topdown-slots-issued Slots issued into the pipeline
topdown-slots-retired Slots successfully retired
topdown-fetch-bubbles Pipeline gaps in the frontend
topdown-recovery-bubbles Pipeline gaps during recovery
from misspeculation
These metrics then allow to compute four useful metrics:
FrontendBound, BackendBound, Retiring, BadSpeculation.
Add a new --topdown options to enable events. When --topdown is
specified set up events for all topdown events supported by the kernel.
Add topdown-* as a special case to the event parser, as is needed for
all events containing -.
The actual code to compute the metrics is in follow-on patches.
v2: Use standard sysctl read function.
v3: Move x86 specific code to arch/
v4: Enable --metric-only implicitly for topdown.
v5: Add --single-thread option to not force per core mode
v6: Fix output order of topdown metrics
v7: Allow combining with -d
v8: Remove --single-thread again
v9: Rename functions, adding arch_ and topdown_.
v10: Expand man page and describe TopDown better
Paste intro into commit description.
Print error when malloc fails.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/1464119559-17203-1-git-send-email-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-05-30 23:49:42 +08:00
|
|
|
|
|
|
|
To interpret the results it is usually needed to know on which
|
|
|
|
CPUs the workload runs on. If needed the CPUs can be forced using
|
|
|
|
taskset.
|
perf stat record: Add record command
Add 'perf stat record' command support. It creates simple (header only)
perf.data file ATM.
The record command could be specified anywhere among stat options. All
stat command options are valid for stat record command with '-o' option
exception. If specified for record command it denotes the perf data file
name.
Committer note:
Set sample_type to PERF_SAMPLE_IDENTIFIER, which should be harmless
while avoiding that older tools show confusing messages, for instance,
with sample_type = 0, we get:
$ perf stat record usleep 1
Performance counter stats for 'usleep 1':
0.630237 task-clock (msec) # 0.528 CPUs utilized
1 context-switches # 0.002 M/sec
0 cpu-migrations # 0.000 K/sec
52 page-faults # 0.083 M/sec
978,312 cycles # 1.552 GHz
671,931 stalled-cycles-frontend # 68.68% frontend cycles idle
<not supported> stalled-cycles-backend
646,379 instructions # 0.66 insns per cycle
# 1.04 stalled cycles per insn
131,046 branches # 207.931 M/sec
7,073 branch-misses # 5.40% of all branches
0.001193240 seconds time elapsed
$ oldperf evlist
WARNING: The perf.data file's data size field is 0 which is unexpected.
Was the 'perf record' command properly terminated?
non matching sample_type
$
While with sample_type set to PERF_SAMPLE_IDENTIFIER, after we re-run 'perf
stat record usleep' we get:
$ oldperf evlist
WARNING: The perf.data file's data size field is 0 which is unexpected.
Was the 'perf record' command properly terminated?
task-clock
context-switches
cpu-migrations
page-faults
cycles
stalled-cycles-frontend
stalled-cycles-backend
instructions
branches
branch-misses
$
Which at least shows the names of the events in the perf.data file.
Additionally, such files, when passed to 'perf report' will produce:
$ oldperf report --stdio
WARNING: The perf.data file's data size field is 0 which is unexpected.
Was the 'perf record' command properly terminated?
Warning:
Kernel address maps (/proc/{kallsyms,modules}) were restricted.
Check /proc/sys/kernel/kptr_restrict before running 'perf record'.
As no suitable kallsyms nor vmlinux was found, kernel samples
can't be resolved.
Samples in kernel modules can't be resolved as well.
Error:
The perf.data file has no samples!
# To display the perf.data header info, please use --header/--header-only options.
#
$
Which is confusing and can be solved by just adding the kernel mmap record,
which will also remove that warning about the data size field being equal to
zero, after generating the mmap record:
$ perf stat record usleep 1
Performance counter stats for 'usleep 1':
0.600796 task-clock (msec) # 0.478 CPUs utilized
1 context-switches # 0.002 M/sec
0 cpu-migrations # 0.000 K/sec
54 page-faults # 0.090 M/sec
886,844 cycles # 1.476 GHz
582,169 stalled-cycles-frontend # 65.65% frontend cycles idle
<not supported> stalled-cycles-backend
638,344 instructions # 0.72 insns per cycle
# 0.91 stalled cycles per insn
130,204 branches # 216.719 M/sec
7,500 branch-misses # 5.76% of all branches
0.001255897 seconds time elapsed
$ oldperf evlist
task-clock
context-switches
cpu-migrations
page-faults
cycles
stalled-cycles-frontend
stalled-cycles-backend
instructions
branches
branch-misses
$ oldperf report --stdio
Error:
The perf.data file has no samples!
# To display the perf.data header info, please use --header/--header-only options.
#
[acme@zoo linux]$
No warnings, sensible output about what are the events in the perf.data file and also
a "file has no samples" message, which indeed it doesn't.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Kan Liang <kan.liang@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: htp://lkml.kernel.org/r/1446734469-11352-3-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-11-05 22:40:46 +08:00
|
|
|
|
perf stat: Collapse identically named events
The uncore PMU has a lot of duplicated PMUs for different subsystems.
When expanding an uncore alias we usually end up with a large
number of identically named aliases, which makes perf stat
output difficult to read.
Automatically sum them up in perf stat, unless --no-merge is specified.
This can be default because only the uncores generally have duplicated
aliases. Other PMUs have unique names.
Before:
% perf stat --no-merge -a -e unc_c_llc_lookup.any sleep 1
Performance counter stats for 'system wide':
694,976 Bytes unc_c_llc_lookup.any
706,304 Bytes unc_c_llc_lookup.any
956,608 Bytes unc_c_llc_lookup.any
782,720 Bytes unc_c_llc_lookup.any
605,696 Bytes unc_c_llc_lookup.any
442,816 Bytes unc_c_llc_lookup.any
659,328 Bytes unc_c_llc_lookup.any
509,312 Bytes unc_c_llc_lookup.any
263,936 Bytes unc_c_llc_lookup.any
592,448 Bytes unc_c_llc_lookup.any
672,448 Bytes unc_c_llc_lookup.any
608,640 Bytes unc_c_llc_lookup.any
641,024 Bytes unc_c_llc_lookup.any
856,896 Bytes unc_c_llc_lookup.any
808,832 Bytes unc_c_llc_lookup.any
684,864 Bytes unc_c_llc_lookup.any
710,464 Bytes unc_c_llc_lookup.any
538,304 Bytes unc_c_llc_lookup.any
1.002577660 seconds time elapsed
After:
% perf stat -a -e unc_c_llc_lookup.any sleep 1
Performance counter stats for 'system wide':
2,685,120 Bytes unc_c_llc_lookup.any
1.002648032 seconds time elapsed
v2: Split collect_aliases. Rename alias flag.
v3: Make sure unsupported/not counted is always printed.
v4: Factor out callback change into separate patch.
v5: Move check for bad results here
Move merged check into collect_data
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/20170320201711.14142-3-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2017-03-21 04:17:00 +08:00
|
|
|
--no-merge::
|
|
|
|
Do not merge results from same PMUs.
|
|
|
|
|
2018-03-06 22:04:44 +08:00
|
|
|
When multiple events are created from a single event specification,
|
|
|
|
stat will, by default, aggregate the event counts and show the result
|
|
|
|
in a single row. This option disables that behavior and shows
|
|
|
|
the individual events and counts.
|
|
|
|
|
|
|
|
Multiple events are created from a single event specification when:
|
|
|
|
1. Prefix or glob matching is used for the PMU name.
|
|
|
|
2. Aliases, which are listed immediately after the Kernel PMU events
|
|
|
|
by perf list, are used.
|
2018-03-06 22:04:42 +08:00
|
|
|
|
2017-05-27 03:05:38 +08:00
|
|
|
--smi-cost::
|
|
|
|
Measure SMI cost if msr/aperf/ and msr/smi/ events are supported.
|
|
|
|
|
|
|
|
During the measurement, the /sys/device/cpu/freeze_on_smi will be set to
|
|
|
|
freeze core counters on SMI.
|
|
|
|
The aperf counter will not be effected by the setting.
|
|
|
|
The cost of SMI can be measured by (aperf - unhalted core cycles).
|
|
|
|
|
|
|
|
In practice, the percentages of SMI cycles is very useful for performance
|
|
|
|
oriented analysis. --metric_only will be applied by default.
|
|
|
|
The output is SMI cycles%, equals to (aperf - unhalted core cycles) / aperf
|
|
|
|
|
|
|
|
Users who wants to get the actual value can apply --no-metric-only.
|
|
|
|
|
2019-10-11 13:05:45 +08:00
|
|
|
--all-kernel::
|
|
|
|
Configure all used events to run in kernel space.
|
|
|
|
|
|
|
|
--all-user::
|
|
|
|
Configure all used events to run in user space.
|
|
|
|
|
perf stat: Show percore counts in per CPU output
We have supported the event modifier "percore" which sums up the event
counts for all hardware threads in a core and show the counts per core.
For example,
# perf stat -e cpu/event=cpu-cycles,percore/ -a -A -- sleep 1
Performance counter stats for 'system wide':
S0-D0-C0 395,072 cpu/event=cpu-cycles,percore/
S0-D0-C1 851,248 cpu/event=cpu-cycles,percore/
S0-D0-C2 954,226 cpu/event=cpu-cycles,percore/
S0-D0-C3 1,233,659 cpu/event=cpu-cycles,percore/
This patch provides a new option "--percore-show-thread". It is used
with event modifier "percore" together to sum up the event counts for
all hardware threads in a core but show the counts per hardware thread.
This is essentially a replacement for the any bit (which is gone in
Icelake). Per core counts are useful for some formulas, e.g. CoreIPC.
The original percore version was inconvenient to post process. This
variant matches the output of the any bit.
With this patch, for example,
# perf stat -e cpu/event=cpu-cycles,percore/ -a -A --percore-show-thread -- sleep 1
Performance counter stats for 'system wide':
CPU0 2,453,061 cpu/event=cpu-cycles,percore/
CPU1 1,823,921 cpu/event=cpu-cycles,percore/
CPU2 1,383,166 cpu/event=cpu-cycles,percore/
CPU3 1,102,652 cpu/event=cpu-cycles,percore/
CPU4 2,453,061 cpu/event=cpu-cycles,percore/
CPU5 1,823,921 cpu/event=cpu-cycles,percore/
CPU6 1,383,166 cpu/event=cpu-cycles,percore/
CPU7 1,102,652 cpu/event=cpu-cycles,percore/
We can see counts are duplicated in CPU pairs (CPU0/CPU4, CPU1/CPU5,
CPU2/CPU6, CPU3/CPU7).
The interval mode also works. For example,
# perf stat -e cpu/event=cpu-cycles,percore/ -a -A --percore-show-thread -I 1000
# time CPU counts unit events
1.000425421 CPU0 925,032 cpu/event=cpu-cycles,percore/
1.000425421 CPU1 430,202 cpu/event=cpu-cycles,percore/
1.000425421 CPU2 436,843 cpu/event=cpu-cycles,percore/
1.000425421 CPU3 1,192,504 cpu/event=cpu-cycles,percore/
1.000425421 CPU4 925,032 cpu/event=cpu-cycles,percore/
1.000425421 CPU5 430,202 cpu/event=cpu-cycles,percore/
1.000425421 CPU6 436,843 cpu/event=cpu-cycles,percore/
1.000425421 CPU7 1,192,504 cpu/event=cpu-cycles,percore/
If we offline CPU5, the result is:
# perf stat -e cpu/event=cpu-cycles,percore/ -a -A --percore-show-thread -- sleep 1
Performance counter stats for 'system wide':
CPU0 2,752,148 cpu/event=cpu-cycles,percore/
CPU1 1,009,312 cpu/event=cpu-cycles,percore/
CPU2 2,784,072 cpu/event=cpu-cycles,percore/
CPU3 2,427,922 cpu/event=cpu-cycles,percore/
CPU4 2,752,148 cpu/event=cpu-cycles,percore/
CPU6 2,784,072 cpu/event=cpu-cycles,percore/
CPU7 2,427,922 cpu/event=cpu-cycles,percore/
1.001416041 seconds time elapsed
v4:
---
Ravi Bangoria reports an issue in v3. Once we offline a CPU,
the output is not correct. The issue is we should use the cpu
idx in print_percore_thread rather than using the cpu value.
v3:
---
1. Fix the interval mode output error
2. Use cpu value (not cpu index) in config->aggr_get_id().
3. Refine the code according to Jiri's comments.
v2:
---
Add the explanation in change log. This is essentially a replacement
for the any bit. No code change.
Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Tested-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20200214080452.26402-1-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-02-14 16:04:52 +08:00
|
|
|
--percore-show-thread::
|
|
|
|
The event modifier "percore" has supported to sum up the event counts
|
|
|
|
for all hardware threads in a core and show the counts per core.
|
|
|
|
|
|
|
|
This option with event modifier "percore" enabled also sums up the event
|
|
|
|
counts for all hardware threads in a core but show the sum counts per
|
|
|
|
hardware thread. This is essentially a replacement for the any bit and
|
|
|
|
convenient for post processing.
|
|
|
|
|
perf stat: Turn off summary for interval mode by default
There's a risk that outputting interval mode summaries by default breaks
CSV consumers. It already broke pmu-tools/toplev.
So now we turn off the summary by default but we create a new option
'--summary' to enable the summary. This is active even when not using
CSV mode.
Before:
root@kbl-ppc:~# perf stat -I1000 --interval-count 2
# time counts unit events
1.000265904 8,005.73 msec cpu-clock # 8.006 CPUs utilized
1.000265904 601 context-switches # 0.075 K/sec
1.000265904 10 cpu-migrations # 0.001 K/sec
1.000265904 0 page-faults # 0.000 K/sec
1.000265904 66,746,521 cycles # 0.008 GHz
1.000265904 71,874,398 instructions # 1.08 insn per cycle
1.000265904 13,356,781 branches # 1.668 M/sec
1.000265904 298,756 branch-misses # 2.24% of all branches
2.001857667 8,012.52 msec cpu-clock # 8.013 CPUs utilized
2.001857667 164 context-switches # 0.020 K/sec
2.001857667 10 cpu-migrations # 0.001 K/sec
2.001857667 2 page-faults # 0.000 K/sec
2.001857667 5,822,188 cycles # 0.001 GHz
2.001857667 2,186,170 instructions # 0.38 insn per cycle
2.001857667 442,378 branches # 0.055 M/sec
2.001857667 44,750 branch-misses # 10.12% of all branches
Performance counter stats for 'system wide':
16,018.25 msec cpu-clock # 7.993 CPUs utilized
765 context-switches # 0.048 K/sec
20 cpu-migrations # 0.001 K/sec
2 page-faults # 0.000 K/sec
72,568,709 cycles # 0.005 GHz
74,060,568 instructions # 1.02 insn per cycle
13,799,159 branches # 0.861 M/sec
343,506 branch-misses # 2.49% of all branches
2.004118489 seconds time elapsed
After:
root@kbl-ppc:~# perf stat -I1000 --interval-count 2
# time counts unit events
1.001336393 8,013.28 msec cpu-clock # 8.013 CPUs utilized
1.001336393 82 context-switches # 0.010 K/sec
1.001336393 8 cpu-migrations # 0.001 K/sec
1.001336393 0 page-faults # 0.000 K/sec
1.001336393 4,199,121 cycles # 0.001 GHz
1.001336393 1,373,991 instructions # 0.33 insn per cycle
1.001336393 270,681 branches # 0.034 M/sec
1.001336393 31,659 branch-misses # 11.70% of all branches
2.003905006 8,020.52 msec cpu-clock # 8.021 CPUs utilized
2.003905006 184 context-switches # 0.023 K/sec
2.003905006 8 cpu-migrations # 0.001 K/sec
2.003905006 2 page-faults # 0.000 K/sec
2.003905006 5,446,190 cycles # 0.001 GHz
2.003905006 2,312,547 instructions # 0.42 insn per cycle
2.003905006 451,691 branches # 0.056 M/sec
2.003905006 37,925 branch-misses # 8.40% of all branches
root@kbl-ppc:~# perf stat -I1000 --interval-count 2 --summary
# time counts unit events
1.001313128 8,013.20 msec cpu-clock # 8.013 CPUs utilized
1.001313128 83 context-switches # 0.010 K/sec
1.001313128 8 cpu-migrations # 0.001 K/sec
1.001313128 0 page-faults # 0.000 K/sec
1.001313128 4,470,950 cycles # 0.001 GHz
1.001313128 1,440,045 instructions # 0.32 insn per cycle
1.001313128 283,222 branches # 0.035 M/sec
1.001313128 33,576 branch-misses # 11.86% of all branches
2.003857385 8,020.34 msec cpu-clock # 8.020 CPUs utilized
2.003857385 154 context-switches # 0.019 K/sec
2.003857385 8 cpu-migrations # 0.001 K/sec
2.003857385 2 page-faults # 0.000 K/sec
2.003857385 4,515,676 cycles # 0.001 GHz
2.003857385 2,180,449 instructions # 0.48 insn per cycle
2.003857385 435,254 branches # 0.054 M/sec
2.003857385 31,179 branch-misses # 7.16% of all branches
Performance counter stats for 'system wide':
16,033.53 msec cpu-clock # 7.992 CPUs utilized
237 context-switches # 0.015 K/sec
16 cpu-migrations # 0.001 K/sec
2 page-faults # 0.000 K/sec
8,986,626 cycles # 0.001 GHz
3,620,494 instructions # 0.40 insn per cycle
718,476 branches # 0.045 M/sec
64,755 branch-misses # 9.01% of all branches
2.006124542 seconds time elapsed
Fixes: c7e5b328a8d4 ("perf stat: Report summary for interval mode")
Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20200903010113.32232-1-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-09-03 09:01:13 +08:00
|
|
|
--summary::
|
|
|
|
Print summary for interval mode (-I).
|
|
|
|
|
2009-04-20 21:52:29 +08:00
|
|
|
EXAMPLES
|
|
|
|
--------
|
|
|
|
|
2018-06-05 20:13:13 +08:00
|
|
|
$ perf stat -- make
|
2009-04-20 21:52:29 +08:00
|
|
|
|
2018-06-05 20:13:13 +08:00
|
|
|
Performance counter stats for 'make':
|
2009-04-20 21:52:29 +08:00
|
|
|
|
2018-06-05 20:13:13 +08:00
|
|
|
83723.452481 task-clock:u (msec) # 1.004 CPUs utilized
|
|
|
|
0 context-switches:u # 0.000 K/sec
|
|
|
|
0 cpu-migrations:u # 0.000 K/sec
|
|
|
|
3,228,188 page-faults:u # 0.039 M/sec
|
|
|
|
229,570,665,834 cycles:u # 2.742 GHz
|
|
|
|
313,163,853,778 instructions:u # 1.36 insn per cycle
|
|
|
|
69,704,684,856 branches:u # 832.559 M/sec
|
|
|
|
2,078,861,393 branch-misses:u # 2.98% of all branches
|
2009-04-20 21:52:29 +08:00
|
|
|
|
2018-06-05 20:13:13 +08:00
|
|
|
83.409183620 seconds time elapsed
|
|
|
|
|
|
|
|
74.684747000 seconds user
|
|
|
|
8.739217000 seconds sys
|
|
|
|
|
|
|
|
TIMINGS
|
|
|
|
-------
|
|
|
|
As displayed in the example above we can display 3 types of timings.
|
|
|
|
We always display the time the counters were enabled/alive:
|
|
|
|
|
|
|
|
83.409183620 seconds time elapsed
|
|
|
|
|
|
|
|
For workload sessions we also display time the workloads spent in
|
|
|
|
user/system lands:
|
|
|
|
|
|
|
|
74.684747000 seconds user
|
|
|
|
8.739217000 seconds sys
|
|
|
|
|
|
|
|
Those times are the very same as displayed by the 'time' tool.
|
2009-04-20 21:52:29 +08:00
|
|
|
|
2016-03-04 07:57:35 +08:00
|
|
|
CSV FORMAT
|
|
|
|
----------
|
|
|
|
|
|
|
|
With -x, perf stat is able to output a not-quite-CSV format output
|
|
|
|
Commas in the output are not put into "". To make it easy to parse
|
|
|
|
it is recommended to use a different character like -x \;
|
|
|
|
|
|
|
|
The fields are in this order:
|
|
|
|
|
|
|
|
- optional usec time stamp in fractions of second (with -I xxx)
|
|
|
|
- optional CPU, core, or socket identifier
|
|
|
|
- optional number of logical CPUs aggregated
|
|
|
|
- counter value
|
|
|
|
- unit of the counter value or empty
|
|
|
|
- event name
|
|
|
|
- run time of counter
|
|
|
|
- percentage of measurement time the counter was running
|
|
|
|
- optional variance if multiple values are collected with -r
|
|
|
|
- optional metric value
|
|
|
|
- optional unit of metric
|
|
|
|
|
|
|
|
Additional metrics may be printed with all earlier fields being empty.
|
|
|
|
|
2009-04-20 21:52:29 +08:00
|
|
|
SEE ALSO
|
|
|
|
--------
|
2009-06-06 20:56:33 +08:00
|
|
|
linkperf:perf-top[1], linkperf:perf-list[1]
|