aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2017-10-03 05:09:16 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2017-10-03 05:09:16 -0400
commit0d3c24e936feefeca854073ccb40613cd6eba9a9 (patch)
tree1f675397b924846740b0931b066ddce6f3d7eb3d /tools/perf
parent1af0838de60e723cb02253ecc9b555c30f8f6a6f (diff)
parentebec44a2456fbe5fe18aae88f6010f6878f0cb4a (diff)
Merge airlied/drm-next into drm-misc-next
Just catching up with upstream. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/Build2
-rw-r--r--tools/perf/Documentation/Makefile2
-rw-r--r--tools/perf/Documentation/intel-pt.txt8
-rw-r--r--tools/perf/Documentation/perf-annotate.txt6
-rw-r--r--tools/perf/Documentation/perf-buildid-cache.txt5
-rw-r--r--tools/perf/Documentation/perf-mem.txt4
-rw-r--r--tools/perf/Documentation/perf-probe.txt14
-rw-r--r--tools/perf/Documentation/perf-record.txt6
-rw-r--r--tools/perf/Documentation/perf-report.txt1
-rw-r--r--tools/perf/Documentation/perf-script.txt2
-rw-r--r--tools/perf/Documentation/perf-stat.txt4
-rw-r--r--tools/perf/Documentation/perf-top.txt4
-rw-r--r--tools/perf/Documentation/perf-trace.txt2
-rw-r--r--tools/perf/Documentation/perf.data-file-format.txt10
-rw-r--r--tools/perf/MANIFEST79
-rw-r--r--tools/perf/Makefile.config25
-rw-r--r--tools/perf/Makefile.perf101
-rw-r--r--tools/perf/arch/arm/util/cs-etm.c28
-rw-r--r--tools/perf/arch/powerpc/util/sym-handling.c2
-rw-r--r--tools/perf/arch/x86/Makefile2
-rw-r--r--tools/perf/arch/x86/annotate/instructions.c46
-rw-r--r--tools/perf/arch/x86/include/arch-tests.h11
-rw-r--r--tools/perf/arch/x86/tests/insn-x86.c2
-rw-r--r--tools/perf/arch/x86/tests/intel-cqm.c2
-rw-r--r--tools/perf/arch/x86/tests/perf-time-to-tsc.c2
-rw-r--r--tools/perf/arch/x86/tests/rdpmc.c2
-rw-r--r--tools/perf/arch/x86/util/intel-pt.c3
-rw-r--r--tools/perf/builtin-annotate.c23
-rw-r--r--tools/perf/builtin-buildid-cache.c54
-rw-r--r--tools/perf/builtin-config.c5
-rw-r--r--tools/perf/builtin-data.c2
-rw-r--r--tools/perf/builtin-ftrace.c2
-rw-r--r--tools/perf/builtin-help.c6
-rw-r--r--tools/perf/builtin-inject.c1
-rw-r--r--tools/perf/builtin-kmem.c1
-rw-r--r--tools/perf/builtin-mem.c97
-rw-r--r--tools/perf/builtin-probe.c45
-rw-r--r--tools/perf/builtin-record.c11
-rw-r--r--tools/perf/builtin-report.c63
-rw-r--r--tools/perf/builtin-script.c26
-rw-r--r--tools/perf/builtin-stat.c34
-rw-r--r--tools/perf/builtin-top.c22
-rw-r--r--tools/perf/builtin-trace.c781
-rwxr-xr-xtools/perf/check-headers.sh20
-rw-r--r--tools/perf/perf-sys.h28
-rw-r--r--tools/perf/perf.c30
-rw-r--r--tools/perf/perf.h2
-rw-r--r--tools/perf/pmu-events/README4
-rw-r--r--tools/perf/pmu-events/arch/powerpc/mapfile.csv16
-rw-r--r--tools/perf/pmu-events/arch/powerpc/power9/cache.json137
-rw-r--r--tools/perf/pmu-events/arch/powerpc/power9/floating-point.json32
-rw-r--r--tools/perf/pmu-events/arch/powerpc/power9/frontend.json372
-rw-r--r--tools/perf/pmu-events/arch/powerpc/power9/marked.json647
-rw-r--r--tools/perf/pmu-events/arch/powerpc/power9/memory.json132
-rw-r--r--tools/perf/pmu-events/arch/powerpc/power9/other.json2392
-rw-r--r--tools/perf/pmu-events/arch/powerpc/power9/pipeline.json552
-rw-r--r--tools/perf/pmu-events/arch/powerpc/power9/pmc.json122
-rw-r--r--tools/perf/pmu-events/arch/powerpc/power9/translation.json232
-rw-r--r--tools/perf/pmu-events/arch/x86/mapfile.csv1
-rw-r--r--tools/perf/pmu-events/arch/x86/skylakex/cache.json1672
-rw-r--r--tools/perf/pmu-events/arch/x86/skylakex/floating-point.json88
-rw-r--r--tools/perf/pmu-events/arch/x86/skylakex/frontend.json482
-rw-r--r--tools/perf/pmu-events/arch/x86/skylakex/memory.json1396
-rw-r--r--tools/perf/pmu-events/arch/x86/skylakex/other.json72
-rw-r--r--tools/perf/pmu-events/arch/x86/skylakex/pipeline.json950
-rw-r--r--tools/perf/pmu-events/arch/x86/skylakex/uncore-memory.json172
-rw-r--r--tools/perf/pmu-events/arch/x86/skylakex/uncore-other.json1156
-rw-r--r--tools/perf/pmu-events/arch/x86/skylakex/virtual-memory.json284
-rw-r--r--tools/perf/pmu-events/jevents.c23
-rw-r--r--tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py1
-rw-r--r--tools/perf/scripts/python/bin/export-to-sqlite-record8
-rw-r--r--tools/perf/scripts/python/bin/export-to-sqlite-report29
-rw-r--r--tools/perf/scripts/python/call-graph-from-sql.py (renamed from tools/perf/scripts/python/call-graph-from-postgresql.py)70
-rw-r--r--tools/perf/scripts/python/export-to-postgresql.py5
-rw-r--r--tools/perf/scripts/python/export-to-sqlite.py451
-rw-r--r--tools/perf/tests/Build1
-rw-r--r--tools/perf/tests/attr.c14
-rw-r--r--tools/perf/tests/attr.py50
-rw-r--r--tools/perf/tests/attr/base-record6
-rw-r--r--tools/perf/tests/attr/base-stat4
-rw-r--r--tools/perf/tests/attr/test-record-C01
-rw-r--r--tools/perf/tests/attr/test-record-basic1
-rw-r--r--tools/perf/tests/attr/test-record-branch-any2
-rw-r--r--tools/perf/tests/attr/test-record-branch-filter-any2
-rw-r--r--tools/perf/tests/attr/test-record-branch-filter-any_call2
-rw-r--r--tools/perf/tests/attr/test-record-branch-filter-any_ret2
-rw-r--r--tools/perf/tests/attr/test-record-branch-filter-hv2
-rw-r--r--tools/perf/tests/attr/test-record-branch-filter-ind_call2
-rw-r--r--tools/perf/tests/attr/test-record-branch-filter-k2
-rw-r--r--tools/perf/tests/attr/test-record-branch-filter-u2
-rw-r--r--tools/perf/tests/attr/test-record-count1
-rw-r--r--tools/perf/tests/attr/test-record-data3
-rw-r--r--tools/perf/tests/attr/test-record-freq1
-rw-r--r--tools/perf/tests/attr/test-record-graph-default1
-rw-r--r--tools/perf/tests/attr/test-record-graph-dwarf4
-rw-r--r--tools/perf/tests/attr/test-record-graph-fp1
-rw-r--r--tools/perf/tests/attr/test-record-group1
-rw-r--r--tools/perf/tests/attr/test-record-group-sampling1
-rw-r--r--tools/perf/tests/attr/test-record-group11
-rw-r--r--tools/perf/tests/attr/test-record-no-buffering (renamed from tools/perf/tests/attr/test-record-no-delay)4
-rw-r--r--tools/perf/tests/attr/test-record-no-inherit1
-rw-r--r--tools/perf/tests/attr/test-record-no-samples1
-rw-r--r--tools/perf/tests/attr/test-record-period1
-rw-r--r--tools/perf/tests/attr/test-record-raw2
-rw-r--r--tools/perf/tests/attr/test-stat-C04
-rw-r--r--tools/perf/tests/attr/test-stat-default2
-rw-r--r--tools/perf/tests/attr/test-stat-detailed-12
-rw-r--r--tools/perf/tests/attr/test-stat-detailed-23
-rw-r--r--tools/perf/tests/attr/test-stat-detailed-35
-rw-r--r--tools/perf/tests/backward-ring-buffer.c2
-rw-r--r--tools/perf/tests/bitmap.c2
-rw-r--r--tools/perf/tests/bp_signal.c2
-rw-r--r--tools/perf/tests/bp_signal_overflow.c2
-rw-r--r--tools/perf/tests/bpf-script-test-prologue.c4
-rw-r--r--tools/perf/tests/bpf.c20
-rw-r--r--tools/perf/tests/builtin-test.c188
-rw-r--r--tools/perf/tests/clang.c4
-rw-r--r--tools/perf/tests/code-reading.c7
-rw-r--r--tools/perf/tests/cpumap.c4
-rw-r--r--tools/perf/tests/dso-data.c6
-rw-r--r--tools/perf/tests/dwarf-unwind.c4
-rw-r--r--tools/perf/tests/event-times.c2
-rw-r--r--tools/perf/tests/event_update.c2
-rw-r--r--tools/perf/tests/evsel-roundtrip-name.c2
-rw-r--r--tools/perf/tests/evsel-tp-sched.c2
-rw-r--r--tools/perf/tests/expr.c7
-rw-r--r--tools/perf/tests/fdarray.c4
-rw-r--r--tools/perf/tests/hists_cumulate.c2
-rw-r--r--tools/perf/tests/hists_filter.c2
-rw-r--r--tools/perf/tests/hists_link.c2
-rw-r--r--tools/perf/tests/hists_output.c2
-rw-r--r--tools/perf/tests/is_printable_array.c2
-rw-r--r--tools/perf/tests/keep-tracking.c2
-rw-r--r--tools/perf/tests/kmod-path.c2
-rw-r--r--tools/perf/tests/llvm.c2
-rw-r--r--tools/perf/tests/mem.c56
-rw-r--r--tools/perf/tests/mmap-basic.c2
-rw-r--r--tools/perf/tests/mmap-thread-lookup.c2
-rw-r--r--tools/perf/tests/openat-syscall-all-cpus.c4
-rw-r--r--tools/perf/tests/openat-syscall-tp-fields.c2
-rw-r--r--tools/perf/tests/openat-syscall.c4
-rw-r--r--tools/perf/tests/parse-events.c2
-rw-r--r--tools/perf/tests/parse-no-sample-id-all.c2
-rw-r--r--tools/perf/tests/perf-hooks.c2
-rw-r--r--tools/perf/tests/perf-record.c2
-rw-r--r--tools/perf/tests/pmu.c2
-rw-r--r--tools/perf/tests/python-use.c2
-rw-r--r--tools/perf/tests/sample-parsing.c8
-rw-r--r--tools/perf/tests/sdt.c12
-rw-r--r--tools/perf/tests/shell/lib/probe.sh6
-rw-r--r--tools/perf/tests/shell/lib/probe_vfs_getname.sh23
-rwxr-xr-xtools/perf/tests/shell/probe_vfs_getname.sh14
-rwxr-xr-xtools/perf/tests/shell/record+script_probe_vfs_getname.sh41
-rwxr-xr-xtools/perf/tests/shell/trace+probe_libc_inet_pton.sh43
-rwxr-xr-xtools/perf/tests/shell/trace+probe_vfs_getname.sh35
-rw-r--r--tools/perf/tests/stat.c6
-rw-r--r--tools/perf/tests/sw-clock.c2
-rw-r--r--tools/perf/tests/switch-tracking.c2
-rw-r--r--tools/perf/tests/task-exit.c2
-rw-r--r--tools/perf/tests/tests.h114
-rw-r--r--tools/perf/tests/thread-map.c6
-rw-r--r--tools/perf/tests/thread-mg-share.c2
-rw-r--r--tools/perf/tests/topology.c2
-rw-r--r--tools/perf/tests/unit_number__scnprintf.c2
-rw-r--r--tools/perf/tests/vmlinux-kallsyms.c2
-rw-r--r--tools/perf/trace/beauty/Build6
-rw-r--r--tools/perf/trace/beauty/beauty.h74
-rw-r--r--tools/perf/trace/beauty/clone.c75
-rwxr-xr-xtools/perf/trace/beauty/drm_ioctl.sh13
-rw-r--r--tools/perf/trace/beauty/fcntl.c100
-rw-r--r--tools/perf/trace/beauty/ioctl.c162
-rwxr-xr-xtools/perf/trace/beauty/kvm_ioctl.sh11
-rw-r--r--tools/perf/trace/beauty/mmap.c3
-rw-r--r--tools/perf/trace/beauty/open_flags.c29
-rwxr-xr-xtools/perf/trace/beauty/perf_ioctl.sh10
-rw-r--r--tools/perf/trace/beauty/pid.c4
-rw-r--r--tools/perf/trace/beauty/pkey_alloc.c50
-rwxr-xr-xtools/perf/trace/beauty/pkey_alloc_access_rights.sh10
-rwxr-xr-xtools/perf/trace/beauty/sndrv_ctl_ioctl.sh8
-rwxr-xr-xtools/perf/trace/beauty/sndrv_pcm_ioctl.sh8
-rwxr-xr-xtools/perf/trace/beauty/vhost_virtio_ioctl.sh17
-rw-r--r--tools/perf/ui/browser.c32
-rw-r--r--tools/perf/ui/browser.h2
-rw-r--r--tools/perf/ui/browsers/annotate.c97
-rw-r--r--tools/perf/ui/browsers/hists.c11
-rw-r--r--tools/perf/ui/gtk/annotate.c6
-rw-r--r--tools/perf/ui/progress.c9
-rw-r--r--tools/perf/ui/stdio/hist.c16
-rw-r--r--tools/perf/util/Build6
-rw-r--r--tools/perf/util/annotate.c137
-rw-r--r--tools/perf/util/annotate.h22
-rw-r--r--tools/perf/util/bpf-loader.c2
-rw-r--r--tools/perf/util/bpf-prologue.c49
-rw-r--r--tools/perf/util/branch.c147
-rw-r--r--tools/perf/util/branch.h25
-rw-r--r--tools/perf/util/build-id.c129
-rw-r--r--tools/perf/util/build-id.h16
-rw-r--r--tools/perf/util/callchain.c311
-rw-r--r--tools/perf/util/callchain.h12
-rw-r--r--tools/perf/util/cgroup.c8
-rw-r--r--tools/perf/util/config.c13
-rw-r--r--tools/perf/util/counts.h1
-rw-r--r--tools/perf/util/data-convert-bt.c127
-rw-r--r--tools/perf/util/data.c13
-rw-r--r--tools/perf/util/dso.c21
-rw-r--r--tools/perf/util/dso.h3
-rw-r--r--tools/perf/util/event.c1
-rw-r--r--tools/perf/util/event.h12
-rw-r--r--tools/perf/util/evlist.c16
-rw-r--r--tools/perf/util/evlist.h14
-rw-r--r--tools/perf/util/evsel.c239
-rw-r--r--tools/perf/util/evsel.h13
-rw-r--r--tools/perf/util/expr.h2
-rw-r--r--tools/perf/util/expr.y76
-rw-r--r--tools/perf/util/header.c1018
-rw-r--r--tools/perf/util/header.h16
-rw-r--r--tools/perf/util/hist.c11
-rw-r--r--tools/perf/util/hist.h1
-rw-r--r--tools/perf/util/intel-pt-decoder/Build2
-rw-r--r--tools/perf/util/llvm-utils.c2
-rw-r--r--tools/perf/util/machine.c128
-rw-r--r--tools/perf/util/map.c23
-rw-r--r--tools/perf/util/map.h2
-rw-r--r--tools/perf/util/mem-events.c54
-rw-r--r--tools/perf/util/namespaces.c211
-rw-r--r--tools/perf/util/namespaces.h38
-rw-r--r--tools/perf/util/parse-branch-options.c1
-rw-r--r--tools/perf/util/parse-events.c116
-rw-r--r--tools/perf/util/parse-events.h19
-rw-r--r--tools/perf/util/parse-events.l23
-rw-r--r--tools/perf/util/parse-events.y94
-rw-r--r--tools/perf/util/probe-event.c88
-rw-r--r--tools/perf/util/probe-event.h10
-rw-r--r--tools/perf/util/probe-file.c19
-rw-r--r--tools/perf/util/probe-file.h4
-rw-r--r--tools/perf/util/python-ext-sources1
-rw-r--r--tools/perf/util/scripting-engines/trace-event-python.c246
-rw-r--r--tools/perf/util/session.c32
-rw-r--r--tools/perf/util/setns.c8
-rw-r--r--tools/perf/util/smt.c44
-rw-r--r--tools/perf/util/smt.h6
-rw-r--r--tools/perf/util/sort.c44
-rw-r--r--tools/perf/util/sort.h1
-rw-r--r--tools/perf/util/srcline.c6
-rw-r--r--tools/perf/util/stat-shadow.c6
-rw-r--r--tools/perf/util/stat.c4
-rw-r--r--tools/perf/util/stat.h5
-rw-r--r--tools/perf/util/symbol-elf.c31
-rw-r--r--tools/perf/util/symbol-minimal.c2
-rw-r--r--tools/perf/util/symbol.c113
-rw-r--r--tools/perf/util/symbol.h5
-rw-r--r--tools/perf/util/syscalltbl.c35
-rw-r--r--tools/perf/util/syscalltbl.h3
-rw-r--r--tools/perf/util/thread.c3
-rw-r--r--tools/perf/util/thread.h1
-rw-r--r--tools/perf/util/tool.h10
-rw-r--r--tools/perf/util/util.c40
-rw-r--r--tools/perf/util/util.h8
-rw-r--r--tools/perf/util/values.c17
-rw-r--r--tools/perf/util/xyarray.c2
-rw-r--r--tools/perf/util/xyarray.h12
261 files changed, 16709 insertions, 1966 deletions
diff --git a/tools/perf/Build b/tools/perf/Build
index bd8eeb60533c..b48ca40fccf9 100644
--- a/tools/perf/Build
+++ b/tools/perf/Build
@@ -50,6 +50,6 @@ libperf-y += util/
50libperf-y += arch/ 50libperf-y += arch/
51libperf-y += ui/ 51libperf-y += ui/
52libperf-y += scripts/ 52libperf-y += scripts/
53libperf-y += trace/beauty/ 53libperf-$(CONFIG_AUDIT) += trace/beauty/
54 54
55gtk-y += ui/gtk/ 55gtk-y += ui/gtk/
diff --git a/tools/perf/Documentation/Makefile b/tools/perf/Documentation/Makefile
index 098cfb9ca8f0..db11478e30b4 100644
--- a/tools/perf/Documentation/Makefile
+++ b/tools/perf/Documentation/Makefile
@@ -192,7 +192,7 @@ do-install-man: man
192# $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir); \ 192# $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir); \
193# $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir) 193# $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
194 194
195install-man: check-man-tools man 195install-man: check-man-tools man do-install-man
196 196
197ifdef missing_tools 197ifdef missing_tools
198 DO_INSTALL_MAN = $(warning Please install $(missing_tools) to have the man pages installed) 198 DO_INSTALL_MAN = $(warning Please install $(missing_tools) to have the man pages installed)
diff --git a/tools/perf/Documentation/intel-pt.txt b/tools/perf/Documentation/intel-pt.txt
index 4b6cdbf8f935..76971d2e4164 100644
--- a/tools/perf/Documentation/intel-pt.txt
+++ b/tools/perf/Documentation/intel-pt.txt
@@ -104,9 +104,9 @@ system, asynchronous, interrupt, transaction abort, trace begin, trace end, and
104in transaction, respectively. 104in transaction, respectively.
105 105
106While it is possible to create scripts to analyze the data, an alternative 106While it is possible to create scripts to analyze the data, an alternative
107approach is available to export the data to a postgresql database. Refer to 107approach is available to export the data to a sqlite or postgresql database.
108script export-to-postgresql.py for more details, and to script 108Refer to script export-to-sqlite.py or export-to-postgresql.py for more details,
109call-graph-from-postgresql.py for an example of using the database. 109and to script call-graph-from-sql.py for an example of using the database.
110 110
111There is also script intel-pt-events.py which provides an example of how to 111There is also script intel-pt-events.py which provides an example of how to
112unpack the raw data for power events and PTWRITE. 112unpack the raw data for power events and PTWRITE.
@@ -873,7 +873,7 @@ amended to take the number of elements as a parameter.
873 873
874 $ cat ~/.perfconfig 874 $ cat ~/.perfconfig
875 [intel-pt] 875 [intel-pt]
876 mispred-all 876 mispred-all = on
877 877
878 $ perf record -e intel_pt//u ./sort 3000 878 $ perf record -e intel_pt//u ./sort 3000
879 Bubble sorting array of 3000 elements 879 Bubble sorting array of 3000 elements
diff --git a/tools/perf/Documentation/perf-annotate.txt b/tools/perf/Documentation/perf-annotate.txt
index a89273d8e744..c635eab6af54 100644
--- a/tools/perf/Documentation/perf-annotate.txt
+++ b/tools/perf/Documentation/perf-annotate.txt
@@ -43,6 +43,10 @@ OPTIONS
43--quiet:: 43--quiet::
44 Do not show any message. (Suppress -v) 44 Do not show any message. (Suppress -v)
45 45
46-n::
47--show-nr-samples::
48 Show the number of samples for each symbol
49
46-D:: 50-D::
47--dump-raw-trace:: 51--dump-raw-trace::
48 Dump raw trace in ASCII. 52 Dump raw trace in ASCII.
@@ -88,6 +92,8 @@ OPTIONS
88--asm-raw:: 92--asm-raw::
89 Show raw instruction encoding of assembly instructions. 93 Show raw instruction encoding of assembly instructions.
90 94
95--show-total-period:: Show a column with the sum of periods.
96
91--source:: 97--source::
92 Interleave source code with assembly code. Enabled by default, 98 Interleave source code with assembly code. Enabled by default,
93 disable with --no-source. 99 disable with --no-source.
diff --git a/tools/perf/Documentation/perf-buildid-cache.txt b/tools/perf/Documentation/perf-buildid-cache.txt
index 058064db39d2..84681007f80f 100644
--- a/tools/perf/Documentation/perf-buildid-cache.txt
+++ b/tools/perf/Documentation/perf-buildid-cache.txt
@@ -61,6 +61,11 @@ OPTIONS
61--verbose:: 61--verbose::
62 Be more verbose. 62 Be more verbose.
63 63
64--target-ns=PID:
65 Obtain mount namespace information from the target pid. This is
66 used when creating a uprobe for a process that resides in a
67 different mount namespace from the perf(1) utility.
68
64SEE ALSO 69SEE ALSO
65-------- 70--------
66linkperf:perf-record[1], linkperf:perf-report[1], linkperf:perf-buildid-list[1] 71linkperf:perf-record[1], linkperf:perf-report[1], linkperf:perf-buildid-list[1]
diff --git a/tools/perf/Documentation/perf-mem.txt b/tools/perf/Documentation/perf-mem.txt
index 73496320fca3..4be08a1e3f8d 100644
--- a/tools/perf/Documentation/perf-mem.txt
+++ b/tools/perf/Documentation/perf-mem.txt
@@ -59,6 +59,10 @@ OPTIONS
59--ldload:: 59--ldload::
60 Specify desired latency for loads event. 60 Specify desired latency for loads event.
61 61
62-p::
63--phys-data::
64 Record/Report sample physical addresses
65
62SEE ALSO 66SEE ALSO
63-------- 67--------
64linkperf:perf-record[1], linkperf:perf-report[1] 68linkperf:perf-record[1], linkperf:perf-report[1]
diff --git a/tools/perf/Documentation/perf-probe.txt b/tools/perf/Documentation/perf-probe.txt
index 165c2b1d4317..d7e4869905f1 100644
--- a/tools/perf/Documentation/perf-probe.txt
+++ b/tools/perf/Documentation/perf-probe.txt
@@ -130,6 +130,11 @@ OPTIONS
130--max-probes=NUM:: 130--max-probes=NUM::
131 Set the maximum number of probe points for an event. Default is 128. 131 Set the maximum number of probe points for an event. Default is 128.
132 132
133--target-ns=PID:
134 Obtain mount namespace information from the target pid. This is
135 used when creating a uprobe for a process that resides in a
136 different mount namespace from the perf(1) utility.
137
133-x:: 138-x::
134--exec=PATH:: 139--exec=PATH::
135 Specify path to the executable or shared library file for user 140 Specify path to the executable or shared library file for user
@@ -264,6 +269,15 @@ Add probes at malloc() function on libc
264 269
265 ./perf probe -x /lib/libc.so.6 malloc or ./perf probe /lib/libc.so.6 malloc 270 ./perf probe -x /lib/libc.so.6 malloc or ./perf probe /lib/libc.so.6 malloc
266 271
272Add a uprobe to a target process running in a different mount namespace
273
274 ./perf probe --target-ns <target pid> -x /lib64/libc.so.6 malloc
275
276Add a USDT probe to a target process running in a different mount namespace
277
278 ./perf probe --target-ns <target pid> -x /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el7_3.x86_64/jre/lib/amd64/server/libjvm.so %sdt_hotspot:thread__sleep__end
279
280
267SEE ALSO 281SEE ALSO
268-------- 282--------
269linkperf:perf-trace[1], linkperf:perf-record[1], linkperf:perf-buildid-cache[1] 283linkperf:perf-trace[1], linkperf:perf-record[1], linkperf:perf-buildid-cache[1]
diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index b0e9e921d534..e397453e5a46 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -249,7 +249,10 @@ OPTIONS
249 249
250-d:: 250-d::
251--data:: 251--data::
252 Record the sample addresses. 252 Record the sample virtual addresses.
253
254--phys-data::
255 Record the sample physical addresses.
253 256
254-T:: 257-T::
255--timestamp:: 258--timestamp::
@@ -332,6 +335,7 @@ following filters are defined:
332 - no_tx: only when the target is not in a hardware transaction 335 - no_tx: only when the target is not in a hardware transaction
333 - abort_tx: only when the target is a hardware transaction abort 336 - abort_tx: only when the target is a hardware transaction abort
334 - cond: conditional branches 337 - cond: conditional branches
338 - save_type: save branch type during sampling in case binary is not available later
335 339
336+ 340+
337The option requires at least one branch type among any, any_call, any_ret, ind_call, cond. 341The option requires at least one branch type among any, any_call, any_ret, ind_call, cond.
diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index 9fa84617181e..383a98d992ed 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -137,6 +137,7 @@ OPTIONS
137 - mem: type of memory access for the data at the time of the sample 137 - mem: type of memory access for the data at the time of the sample
138 - snoop: type of snoop (if any) for the data at the time of the sample 138 - snoop: type of snoop (if any) for the data at the time of the sample
139 - dcacheline: the cacheline the data address is on at the time of the sample 139 - dcacheline: the cacheline the data address is on at the time of the sample
140 - phys_daddr: physical address of data being executed on at the time of sample
140 141
141 And the default sort keys are changed to local_weight, mem, sym, dso, 142 And the default sort keys are changed to local_weight, mem, sym, dso,
142 symbol_daddr, dso_daddr, snoop, tlb, locked, see '--mem-mode'. 143 symbol_daddr, dso_daddr, snoop, tlb, locked, see '--mem-mode'.
diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt
index 5ee8796be96e..18dfcfa38454 100644
--- a/tools/perf/Documentation/perf-script.txt
+++ b/tools/perf/Documentation/perf-script.txt
@@ -117,7 +117,7 @@ OPTIONS
117 Comma separated list of fields to print. Options are: 117 Comma separated list of fields to print. Options are:
118 comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff, 118 comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff,
119 srcline, period, iregs, brstack, brstacksym, flags, bpf-output, brstackinsn, brstackoff, 119 srcline, period, iregs, brstack, brstacksym, flags, bpf-output, brstackinsn, brstackoff,
120 callindent, insn, insnlen, synth. 120 callindent, insn, insnlen, synth, phys_addr.
121 Field list can be prepended with the type, trace, sw or hw, 121 Field list can be prepended with the type, trace, sw or hw,
122 to indicate to which event type the field list applies. 122 to indicate to which event type the field list applies.
123 e.g., -F sw:comm,tid,time,ip,sym and -F trace:time,cpu,trace 123 e.g., -F sw:comm,tid,time,ip,sym and -F trace:time,cpu,trace
diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt
index 698076313606..c37d61682dfb 100644
--- a/tools/perf/Documentation/perf-stat.txt
+++ b/tools/perf/Documentation/perf-stat.txt
@@ -41,13 +41,13 @@ report::
41 41
42 - a symbolically formed event like 'pmu/param1=0x3,param2/' where 42 - a symbolically formed event like 'pmu/param1=0x3,param2/' where
43 param1 and param2 are defined as formats for the PMU in 43 param1 and param2 are defined as formats for the PMU in
44 /sys/bus/event_sources/devices/<pmu>/format/* 44 /sys/bus/event_source/devices/<pmu>/format/*
45 45
46 - a symbolically formed event like 'pmu/config=M,config1=N,config2=K/' 46 - a symbolically formed event like 'pmu/config=M,config1=N,config2=K/'
47 where M, N, K are numbers (in decimal, hex, octal format). 47 where M, N, K are numbers (in decimal, hex, octal format).
48 Acceptable values for each of 'config', 'config1' and 'config2' 48 Acceptable values for each of 'config', 'config1' and 'config2'
49 parameters are defined by corresponding entries in 49 parameters are defined by corresponding entries in
50 /sys/bus/event_sources/devices/<pmu>/format/* 50 /sys/bus/event_source/devices/<pmu>/format/*
51 51
52-i:: 52-i::
53--no-inherit:: 53--no-inherit::
diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt
index e71d63843f45..d864ea6fd367 100644
--- a/tools/perf/Documentation/perf-top.txt
+++ b/tools/perf/Documentation/perf-top.txt
@@ -237,6 +237,10 @@ Default is to monitor all CPUS.
237--hierarchy:: 237--hierarchy::
238 Enable hierarchy output. 238 Enable hierarchy output.
239 239
240--force::
241 Don't do ownership validation.
242
243
240INTERACTIVE PROMPTING KEYS 244INTERACTIVE PROMPTING KEYS
241-------------------------- 245--------------------------
242 246
diff --git a/tools/perf/Documentation/perf-trace.txt b/tools/perf/Documentation/perf-trace.txt
index c1e3288a2dfb..d53bea6bd571 100644
--- a/tools/perf/Documentation/perf-trace.txt
+++ b/tools/perf/Documentation/perf-trace.txt
@@ -37,7 +37,7 @@ OPTIONS
37--expr:: 37--expr::
38--event:: 38--event::
39 List of syscalls and other perf events (tracepoints, HW cache events, 39 List of syscalls and other perf events (tracepoints, HW cache events,
40 etc) to show. 40 etc) to show. Globbing is supported, e.g.: "epoll_*", "*msg*", etc.
41 See 'perf list' for a complete list of events. 41 See 'perf list' for a complete list of events.
42 Prefixing with ! shows all syscalls but the ones specified. You may 42 Prefixing with ! shows all syscalls but the ones specified. You may
43 need to escape it. 43 need to escape it.
diff --git a/tools/perf/Documentation/perf.data-file-format.txt b/tools/perf/Documentation/perf.data-file-format.txt
index de8b39dda7b8..e90c59c6d815 100644
--- a/tools/perf/Documentation/perf.data-file-format.txt
+++ b/tools/perf/Documentation/perf.data-file-format.txt
@@ -398,6 +398,11 @@ struct auxtrace_error_event {
398 char msg[MAX_AUXTRACE_ERROR_MSG]; 398 char msg[MAX_AUXTRACE_ERROR_MSG];
399}; 399};
400 400
401 PERF_RECORD_HEADER_FEATURE = 80,
402
403Describes a header feature. These are records used in pipe-mode that
404contain information that otherwise would be in perf.data file's header.
405
401Event types 406Event types
402 407
403Define the event attributes with their IDs. 408Define the event attributes with their IDs.
@@ -422,8 +427,9 @@ struct perf_pipe_file_header {
422}; 427};
423 428
424The information about attrs, data, and event_types is instead in the 429The information about attrs, data, and event_types is instead in the
425synthesized events PERF_RECORD_ATTR, PERF_RECORD_HEADER_TRACING_DATA and 430synthesized events PERF_RECORD_ATTR, PERF_RECORD_HEADER_TRACING_DATA,
426PERF_RECORD_HEADER_EVENT_TYPE that are generated by perf record in pipe-mode. 431PERF_RECORD_HEADER_EVENT_TYPE, and PERF_RECORD_HEADER_FEATURE
432that are generated by perf record in pipe-mode.
427 433
428 434
429References: 435References:
diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST
index a29da46d180f..627b7cada144 100644
--- a/tools/perf/MANIFEST
+++ b/tools/perf/MANIFEST
@@ -1,34 +1,8 @@
1tools/perf 1tools/perf
2tools/arch/alpha/include/asm/barrier.h 2tools/arch
3tools/arch/arm/include/asm/barrier.h
4tools/arch/arm64/include/asm/barrier.h
5tools/arch/ia64/include/asm/barrier.h
6tools/arch/mips/include/asm/barrier.h
7tools/arch/powerpc/include/asm/barrier.h
8tools/arch/s390/include/asm/barrier.h
9tools/arch/sh/include/asm/barrier.h
10tools/arch/sparc/include/asm/barrier.h
11tools/arch/sparc/include/asm/barrier_32.h
12tools/arch/sparc/include/asm/barrier_64.h
13tools/arch/tile/include/asm/barrier.h
14tools/arch/x86/include/asm/barrier.h
15tools/arch/x86/include/asm/cmpxchg.h
16tools/arch/x86/include/asm/cpufeatures.h
17tools/arch/x86/include/asm/disabled-features.h
18tools/arch/x86/include/asm/required-features.h
19tools/arch/x86/include/uapi/asm/svm.h
20tools/arch/x86/include/uapi/asm/vmx.h
21tools/arch/x86/include/uapi/asm/kvm.h
22tools/arch/x86/include/uapi/asm/kvm_perf.h
23tools/arch/x86/lib/memcpy_64.S
24tools/arch/x86/lib/memset_64.S
25tools/arch/s390/include/uapi/asm/kvm_perf.h
26tools/arch/s390/include/uapi/asm/sie.h
27tools/arch/xtensa/include/asm/barrier.h
28tools/scripts 3tools/scripts
29tools/build 4tools/build
30tools/arch/x86/include/asm/atomic.h 5tools/include
31tools/arch/x86/include/asm/rmwcc.h
32tools/lib/traceevent 6tools/lib/traceevent
33tools/lib/api 7tools/lib/api
34tools/lib/bpf 8tools/lib/bpf
@@ -42,52 +16,3 @@ tools/lib/find_bit.c
42tools/lib/bitmap.c 16tools/lib/bitmap.c
43tools/lib/str_error_r.c 17tools/lib/str_error_r.c
44tools/lib/vsprintf.c 18tools/lib/vsprintf.c
45tools/include/asm/alternative-asm.h
46tools/include/asm/atomic.h
47tools/include/asm/barrier.h
48tools/include/asm/bug.h
49tools/include/asm-generic/atomic-gcc.h
50tools/include/asm-generic/barrier.h
51tools/include/asm-generic/bitops/arch_hweight.h
52tools/include/asm-generic/bitops/atomic.h
53tools/include/asm-generic/bitops/const_hweight.h
54tools/include/asm-generic/bitops/__ffs.h
55tools/include/asm-generic/bitops/__ffz.h
56tools/include/asm-generic/bitops/__fls.h
57tools/include/asm-generic/bitops/find.h
58tools/include/asm-generic/bitops/fls64.h
59tools/include/asm-generic/bitops/fls.h
60tools/include/asm-generic/bitops/hweight.h
61tools/include/asm-generic/bitops.h
62tools/include/linux/atomic.h
63tools/include/linux/bitops.h
64tools/include/linux/compiler.h
65tools/include/linux/compiler-gcc.h
66tools/include/linux/coresight-pmu.h
67tools/include/linux/bug.h
68tools/include/linux/filter.h
69tools/include/linux/hash.h
70tools/include/linux/kernel.h
71tools/include/linux/list.h
72tools/include/linux/log2.h
73tools/include/uapi/asm-generic/mman-common.h
74tools/include/uapi/asm-generic/mman.h
75tools/include/uapi/linux/bpf.h
76tools/include/uapi/linux/bpf_common.h
77tools/include/uapi/linux/fcntl.h
78tools/include/uapi/linux/hw_breakpoint.h
79tools/include/uapi/linux/mman.h
80tools/include/uapi/linux/perf_event.h
81tools/include/uapi/linux/stat.h
82tools/include/linux/poison.h
83tools/include/linux/rbtree.h
84tools/include/linux/rbtree_augmented.h
85tools/include/linux/refcount.h
86tools/include/linux/string.h
87tools/include/linux/stringify.h
88tools/include/linux/types.h
89tools/include/linux/err.h
90tools/include/linux/bitmap.h
91tools/include/linux/time64.h
92tools/arch/*/include/uapi/asm/mman.h
93tools/arch/*/include/uapi/asm/perf_regs.h
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index bdf0e87f9b29..63f534a0902f 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -35,7 +35,7 @@ ifeq ($(SRCARCH),x86)
35 ifeq (${IS_64_BIT}, 1) 35 ifeq (${IS_64_BIT}, 1)
36 CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT -DHAVE_SYSCALL_TABLE -I$(OUTPUT)arch/x86/include/generated 36 CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT -DHAVE_SYSCALL_TABLE -I$(OUTPUT)arch/x86/include/generated
37 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S 37 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
38 LIBUNWIND_LIBS = -lunwind -lunwind-x86_64 38 LIBUNWIND_LIBS = -lunwind-x86_64 -lunwind -llzma
39 $(call detected,CONFIG_X86_64) 39 $(call detected,CONFIG_X86_64)
40 else 40 else
41 LIBUNWIND_LIBS = -lunwind-x86 -llzma -lunwind 41 LIBUNWIND_LIBS = -lunwind-x86 -llzma -lunwind
@@ -103,8 +103,12 @@ ifdef LIBDW_DIR
103 LIBDW_CFLAGS := -I$(LIBDW_DIR)/include 103 LIBDW_CFLAGS := -I$(LIBDW_DIR)/include
104 LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib 104 LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib
105endif 105endif
106DWARFLIBS := -ldw
107ifeq ($(findstring -static,${LDFLAGS}),-static)
108 DWARFLIBS += -lelf -lebl -ldl -lz -llzma -lbz2
109endif
106FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS) 110FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS)
107FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) -ldw 111FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) $(DWARFLIBS)
108 112
109# for linking with debug library, run like: 113# for linking with debug library, run like:
110# make DEBUG=1 LIBBABELTRACE_DIR=/opt/libbabeltrace/ 114# make DEBUG=1 LIBBABELTRACE_DIR=/opt/libbabeltrace/
@@ -144,7 +148,7 @@ ifndef DEBUG
144endif 148endif
145 149
146ifeq ($(DEBUG),0) 150ifeq ($(DEBUG),0)
147ifeq ($(CC), clang) 151ifeq ($(CC_NO_CLANG), 0)
148 CFLAGS += -O3 152 CFLAGS += -O3
149else 153else
150 CFLAGS += -O6 154 CFLAGS += -O6
@@ -180,7 +184,7 @@ ifdef PYTHON_CONFIG
180 PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS)) 184 PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
181 PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil 185 PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
182 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null) 186 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
183 ifeq ($(CC), clang) 187 ifeq ($(CC_NO_CLANG), 1)
184 PYTHON_EMBED_CCOPTS := $(filter-out -specs=%,$(PYTHON_EMBED_CCOPTS)) 188 PYTHON_EMBED_CCOPTS := $(filter-out -specs=%,$(PYTHON_EMBED_CCOPTS))
185 endif 189 endif
186 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS) 190 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
@@ -330,6 +334,11 @@ ifeq ($(feature-sched_getcpu), 1)
330 CFLAGS += -DHAVE_SCHED_GETCPU_SUPPORT 334 CFLAGS += -DHAVE_SCHED_GETCPU_SUPPORT
331endif 335endif
332 336
337ifeq ($(feature-setns), 1)
338 CFLAGS += -DHAVE_SETNS_SUPPORT
339 $(call detected,CONFIG_SETNS)
340endif
341
333ifndef NO_LIBELF 342ifndef NO_LIBELF
334 CFLAGS += -DHAVE_LIBELF_SUPPORT 343 CFLAGS += -DHAVE_LIBELF_SUPPORT
335 EXTLIBS += -lelf 344 EXTLIBS += -lelf
@@ -360,10 +369,6 @@ ifndef NO_LIBELF
360 else 369 else
361 CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS) 370 CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
362 LDFLAGS += $(LIBDW_LDFLAGS) 371 LDFLAGS += $(LIBDW_LDFLAGS)
363 DWARFLIBS := -ldw
364 ifeq ($(findstring -static,${LDFLAGS}),-static)
365 DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
366 endif
367 EXTLIBS += ${DWARFLIBS} 372 EXTLIBS += ${DWARFLIBS}
368 $(call detected,CONFIG_DWARF) 373 $(call detected,CONFIG_DWARF)
369 endif # PERF_HAVE_DWARF_REGS 374 endif # PERF_HAVE_DWARF_REGS
@@ -500,6 +505,10 @@ ifndef NO_LOCAL_LIBUNWIND
500 EXTLIBS += $(LIBUNWIND_LIBS) 505 EXTLIBS += $(LIBUNWIND_LIBS)
501 LDFLAGS += $(LIBUNWIND_LIBS) 506 LDFLAGS += $(LIBUNWIND_LIBS)
502endif 507endif
508ifeq ($(findstring -static,${LDFLAGS}),-static)
509 # gcc -static links libgcc_eh which contans piece of libunwind
510 LIBUNWIND_LDFLAGS += -Wl,--allow-multiple-definition
511endif
503 512
504ifndef NO_LIBUNWIND 513ifndef NO_LIBUNWIND
505 CFLAGS += -DHAVE_LIBUNWIND_SUPPORT 514 CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 5008f51a08a2..91ef44bfaf3e 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -33,6 +33,11 @@ include ../scripts/utilities.mak
33# 33#
34# Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for cross-builds. 34# Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for cross-builds.
35# 35#
36# Define EXCLUDE_EXTLIBS=-lmylib to exclude libmylib from the auto-generated
37# EXTLIBS.
38#
39# Define EXTRA_PERFLIBS to pass extra libraries to PERFLIBS.
40#
36# Define NO_DWARF if you do not want debug-info analysis feature at all. 41# Define NO_DWARF if you do not want debug-info analysis feature at all.
37# 42#
38# Define WERROR=0 to disable treating any warnings as errors. 43# Define WERROR=0 to disable treating any warnings as errors.
@@ -159,8 +164,8 @@ LN = ln -f
159MKDIR = mkdir 164MKDIR = mkdir
160FIND = find 165FIND = find
161INSTALL = install 166INSTALL = install
162FLEX = flex 167FLEX ?= flex
163BISON = bison 168BISON ?= bison
164STRIP = strip 169STRIP = strip
165AWK = awk 170AWK = awk
166 171
@@ -235,7 +240,7 @@ endif
235ifeq ($(FEATURES_DUMP),) 240ifeq ($(FEATURES_DUMP),)
236FEATURE_DUMP_EXPORT := $(realpath $(OUTPUT)FEATURE-DUMP) 241FEATURE_DUMP_EXPORT := $(realpath $(OUTPUT)FEATURE-DUMP)
237else 242else
238FEATURE_DUMP_EXPORT := $(FEATURES_DUMP) 243FEATURE_DUMP_EXPORT := $(realpath $(FEATURES_DUMP))
239endif 244endif
240 245
241export prefix bindir sharedir sysconfdir DESTDIR 246export prefix bindir sharedir sysconfdir DESTDIR
@@ -274,7 +279,13 @@ LIBTRACEEVENT = $(TE_PATH)libtraceevent.a
274export LIBTRACEEVENT 279export LIBTRACEEVENT
275 280
276LIBTRACEEVENT_DYNAMIC_LIST = $(TE_PATH)libtraceevent-dynamic-list 281LIBTRACEEVENT_DYNAMIC_LIST = $(TE_PATH)libtraceevent-dynamic-list
277LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS = -Xlinker --dynamic-list=$(LIBTRACEEVENT_DYNAMIC_LIST) 282
283#
284# The static build has no dynsym table, so this does not work for
285# static build. Looks like linker starts to scream about that now
286# (in Fedora 26) so we need to switch it off for static build.
287DYNAMIC_LIST_LDFLAGS = -Xlinker --dynamic-list=$(LIBTRACEEVENT_DYNAMIC_LIST)
288LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS = $(if $(findstring -static,$(LDFLAGS)),,$(DYNAMIC_LIST_LDFLAGS))
278 289
279LIBAPI = $(API_PATH)libapi.a 290LIBAPI = $(API_PATH)libapi.a
280export LIBAPI 291export LIBAPI
@@ -352,7 +363,8 @@ ifdef ASCIIDOC8
352 export ASCIIDOC8 363 export ASCIIDOC8
353endif 364endif
354 365
355LIBS = -Wl,--whole-archive $(PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group 366EXTLIBS := $(call filter-out,$(EXCLUDE_EXTLIBS),$(EXTLIBS))
367LIBS = -Wl,--whole-archive $(PERFLIBS) $(EXTRA_PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group
356 368
357ifeq ($(USE_CLANG), 1) 369ifeq ($(USE_CLANG), 1)
358 CLANGLIBS_LIST = AST Basic CodeGen Driver Frontend Lex Tooling Edit Sema Analysis Parse Serialization 370 CLANGLIBS_LIST = AST Basic CodeGen Driver Frontend Lex Tooling Edit Sema Analysis Parse Serialization
@@ -375,6 +387,60 @@ export INSTALL SHELL_PATH
375 387
376SHELL = $(SHELL_PATH) 388SHELL = $(SHELL_PATH)
377 389
390beauty_outdir := $(OUTPUT)trace/beauty/generated
391beauty_ioctl_outdir := $(beauty_outdir)/ioctl
392drm_ioctl_array := $(beauty_ioctl_outdir)/drm_ioctl_array.c
393drm_hdr_dir := $(srctree)/tools/include/uapi/drm
394drm_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/drm_ioctl.sh
395
396# Create output directory if not already present
397_dummy := $(shell [ -d '$(beauty_ioctl_outdir)' ] || mkdir -p '$(beauty_ioctl_outdir)')
398
399$(drm_ioctl_array): $(drm_hdr_dir)/drm.h $(drm_hdr_dir)/i915_drm.h $(drm_ioctl_tbl)
400 $(Q)$(SHELL) '$(drm_ioctl_tbl)' $(drm_hdr_dir) > $@
401
402pkey_alloc_access_rights_array := $(beauty_outdir)/pkey_alloc_access_rights_array.c
403asm_generic_hdr_dir := $(srctree)/tools/include/uapi/asm-generic/
404pkey_alloc_access_rights_tbl := $(srctree)/tools/perf/trace/beauty/pkey_alloc_access_rights.sh
405
406$(pkey_alloc_access_rights_array): $(asm_generic_hdr_dir)/mman-common.h $(pkey_alloc_access_rights_tbl)
407 $(Q)$(SHELL) '$(pkey_alloc_access_rights_tbl)' $(asm_generic_hdr_dir) > $@
408
409sndrv_ctl_ioctl_array := $(beauty_ioctl_outdir)/sndrv_ctl_ioctl_array.c
410sndrv_ctl_hdr_dir := $(srctree)/tools/include/uapi/sound
411sndrv_ctl_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/sndrv_ctl_ioctl.sh
412
413$(sndrv_ctl_ioctl_array): $(sndrv_ctl_hdr_dir)/asound.h $(sndrv_ctl_ioctl_tbl)
414 $(Q)$(SHELL) '$(sndrv_ctl_ioctl_tbl)' $(sndrv_ctl_hdr_dir) > $@
415
416sndrv_pcm_ioctl_array := $(beauty_ioctl_outdir)/sndrv_pcm_ioctl_array.c
417sndrv_pcm_hdr_dir := $(srctree)/tools/include/uapi/sound
418sndrv_pcm_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/sndrv_pcm_ioctl.sh
419
420$(sndrv_pcm_ioctl_array): $(sndrv_pcm_hdr_dir)/asound.h $(sndrv_pcm_ioctl_tbl)
421 $(Q)$(SHELL) '$(sndrv_pcm_ioctl_tbl)' $(sndrv_pcm_hdr_dir) > $@
422
423kvm_ioctl_array := $(beauty_ioctl_outdir)/kvm_ioctl_array.c
424kvm_hdr_dir := $(srctree)/tools/include/uapi/linux
425kvm_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/kvm_ioctl.sh
426
427$(kvm_ioctl_array): $(kvm_hdr_dir)/kvm.h $(kvm_ioctl_tbl)
428 $(Q)$(SHELL) '$(kvm_ioctl_tbl)' $(kvm_hdr_dir) > $@
429
430vhost_virtio_ioctl_array := $(beauty_ioctl_outdir)/vhost_virtio_ioctl_array.c
431vhost_virtio_hdr_dir := $(srctree)/tools/include/uapi/linux
432vhost_virtio_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/vhost_virtio_ioctl.sh
433
434$(vhost_virtio_ioctl_array): $(vhost_virtio_hdr_dir)/vhost.h $(vhost_virtio_ioctl_tbl)
435 $(Q)$(SHELL) '$(vhost_virtio_ioctl_tbl)' $(vhost_virtio_hdr_dir) > $@
436
437perf_ioctl_array := $(beauty_ioctl_outdir)/perf_ioctl_array.c
438perf_hdr_dir := $(srctree)/tools/include/uapi/linux
439perf_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/perf_ioctl.sh
440
441$(perf_ioctl_array): $(perf_hdr_dir)/perf_event.h $(perf_ioctl_tbl)
442 $(Q)$(SHELL) '$(perf_ioctl_tbl)' $(perf_hdr_dir) > $@
443
378all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS) 444all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS)
379 445
380$(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBTRACEEVENT_DYNAMIC_LIST) 446$(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBTRACEEVENT_DYNAMIC_LIST)
@@ -469,7 +535,13 @@ endif
469__build-dir = $(subst $(OUTPUT),,$(dir $@)) 535__build-dir = $(subst $(OUTPUT),,$(dir $@))
470build-dir = $(if $(__build-dir),$(__build-dir),.) 536build-dir = $(if $(__build-dir),$(__build-dir),.)
471 537
472prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders 538prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders $(drm_ioctl_array) \
539 $(pkey_alloc_access_rights_array) \
540 $(sndrv_pcm_ioctl_array) \
541 $(sndrv_ctl_ioctl_array) \
542 $(kvm_ioctl_array) \
543 $(vhost_virtio_ioctl_array) \
544 $(perf_ioctl_array)
473 545
474$(OUTPUT)%.o: %.c prepare FORCE 546$(OUTPUT)%.o: %.c prepare FORCE
475 $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@ 547 $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
@@ -512,7 +584,7 @@ $(LIBJVMTI_IN): FORCE
512 $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=jvmti obj=jvmti 584 $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=jvmti obj=jvmti
513 585
514$(OUTPUT)$(LIBJVMTI): $(LIBJVMTI_IN) 586$(OUTPUT)$(LIBJVMTI): $(LIBJVMTI_IN)
515 $(QUIET_LINK)$(CC) -shared -Wl,-soname -Wl,$(LIBJVMTI) -o $@ $< -lelf -lrt 587 $(QUIET_LINK)$(CC) -shared -Wl,-soname -Wl,$(LIBJVMTI) -o $@ $<
516endif 588endif
517 589
518$(patsubst perf-%,%.o,$(PROGRAMS)): $(wildcard */*.h) 590$(patsubst perf-%,%.o,$(PROGRAMS)): $(wildcard */*.h)
@@ -703,7 +775,11 @@ install-tests: all install-gtk
703 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \ 775 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
704 $(INSTALL) tests/attr.py '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \ 776 $(INSTALL) tests/attr.py '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
705 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'; \ 777 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'; \
706 $(INSTALL) tests/attr/* '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr' 778 $(INSTALL) tests/attr/* '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'; \
779 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell'; \
780 $(INSTALL) tests/shell/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell'; \
781 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'; \
782 $(INSTALL) tests/shell/lib/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'
707 783
708install-bin: install-tools install-tests install-traceevent-plugins 784install-bin: install-tools install-tests install-traceevent-plugins
709 785
@@ -734,7 +810,14 @@ clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clea
734 $(call QUIET_CLEAN, core-gen) $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)FEATURE-DUMP $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex* \ 810 $(call QUIET_CLEAN, core-gen) $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)FEATURE-DUMP $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex* \
735 $(OUTPUT)util/intel-pt-decoder/inat-tables.c \ 811 $(OUTPUT)util/intel-pt-decoder/inat-tables.c \
736 $(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c \ 812 $(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c \
737 $(OUTPUT)pmu-events/pmu-events.c 813 $(OUTPUT)pmu-events/pmu-events.c \
814 $(OUTPUT)$(drm_ioctl_array) \
815 $(OUTPUT)$(pkey_alloc_access_rights_array) \
816 $(OUTPUT)$(sndrv_ctl_ioctl_array) \
817 $(OUTPUT)$(sndrv_pcm_ioctl_array) \
818 $(OUTPUT)$(kvm_ioctl_array) \
819 $(OUTPUT)$(vhost_virtio_ioctl_array) \
820 $(OUTPUT)$(perf_ioctl_array)
738 $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean 821 $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean
739 $(python-clean) 822 $(python-clean)
740 823
diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c
index 7ce3d1a25133..fbfc055d3f4d 100644
--- a/tools/perf/arch/arm/util/cs-etm.c
+++ b/tools/perf/arch/arm/util/cs-etm.c
@@ -266,6 +266,32 @@ static u64 cs_etm_get_config(struct auxtrace_record *itr)
266 return config; 266 return config;
267} 267}
268 268
269#ifndef BIT
270#define BIT(N) (1UL << (N))
271#endif
272
273static u64 cs_etmv4_get_config(struct auxtrace_record *itr)
274{
275 u64 config = 0;
276 u64 config_opts = 0;
277
278 /*
279 * The perf event variable config bits represent both
280 * the command line options and register programming
281 * bits in ETMv3/PTM. For ETMv4 we must remap options
282 * to real bits
283 */
284 config_opts = cs_etm_get_config(itr);
285 if (config_opts & BIT(ETM_OPT_CYCACC))
286 config |= BIT(ETM4_CFG_BIT_CYCACC);
287 if (config_opts & BIT(ETM_OPT_TS))
288 config |= BIT(ETM4_CFG_BIT_TS);
289 if (config_opts & BIT(ETM_OPT_RETSTK))
290 config |= BIT(ETM4_CFG_BIT_RETSTK);
291
292 return config;
293}
294
269static size_t 295static size_t
270cs_etm_info_priv_size(struct auxtrace_record *itr __maybe_unused, 296cs_etm_info_priv_size(struct auxtrace_record *itr __maybe_unused,
271 struct perf_evlist *evlist __maybe_unused) 297 struct perf_evlist *evlist __maybe_unused)
@@ -363,7 +389,7 @@ static void cs_etm_get_metadata(int cpu, u32 *offset,
363 magic = __perf_cs_etmv4_magic; 389 magic = __perf_cs_etmv4_magic;
364 /* Get trace configuration register */ 390 /* Get trace configuration register */
365 info->priv[*offset + CS_ETMV4_TRCCONFIGR] = 391 info->priv[*offset + CS_ETMV4_TRCCONFIGR] =
366 cs_etm_get_config(itr); 392 cs_etmv4_get_config(itr);
367 /* Get traceID from the framework */ 393 /* Get traceID from the framework */
368 info->priv[*offset + CS_ETMV4_TRCTRACEIDR] = 394 info->priv[*offset + CS_ETMV4_TRCTRACEIDR] =
369 coresight_get_trace_id(cpu); 395 coresight_get_trace_id(cpu);
diff --git a/tools/perf/arch/powerpc/util/sym-handling.c b/tools/perf/arch/powerpc/util/sym-handling.c
index bf9a2594572c..9c4e23d8c8ce 100644
--- a/tools/perf/arch/powerpc/util/sym-handling.c
+++ b/tools/perf/arch/powerpc/util/sym-handling.c
@@ -126,7 +126,7 @@ void arch__post_process_probe_trace_events(struct perf_probe_event *pev,
126 struct rb_node *tmp; 126 struct rb_node *tmp;
127 int i = 0; 127 int i = 0;
128 128
129 map = get_target_map(pev->target, pev->uprobes); 129 map = get_target_map(pev->target, pev->nsi, pev->uprobes);
130 if (!map || map__load(map) < 0) 130 if (!map || map__load(map) < 0)
131 return; 131 return;
132 132
diff --git a/tools/perf/arch/x86/Makefile b/tools/perf/arch/x86/Makefile
index 6c9211b18ec0..9a628a24c5c9 100644
--- a/tools/perf/arch/x86/Makefile
+++ b/tools/perf/arch/x86/Makefile
@@ -20,7 +20,7 @@ _dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)')
20$(header): $(sys)/syscall_64.tbl $(systbl) 20$(header): $(sys)/syscall_64.tbl $(systbl)
21 @(test -d ../../kernel -a -d ../../tools -a -d ../perf && ( \ 21 @(test -d ../../kernel -a -d ../../tools -a -d ../perf && ( \
22 (diff -B arch/x86/entry/syscalls/syscall_64.tbl ../../arch/x86/entry/syscalls/syscall_64.tbl >/dev/null) \ 22 (diff -B arch/x86/entry/syscalls/syscall_64.tbl ../../arch/x86/entry/syscalls/syscall_64.tbl >/dev/null) \
23 || echo "Warning: x86_64's syscall_64.tbl differs from kernel" >&2 )) || true 23 || echo "Warning: Kernel ABI header at 'tools/arch/x86/entry/syscalls/syscall_64.tbl' differs from latest version at 'arch/x86/entry/syscalls/syscall_64.tbl'" >&2 )) || true
24 $(Q)$(SHELL) '$(systbl)' $(sys)/syscall_64.tbl 'x86_64' > $@ 24 $(Q)$(SHELL) '$(systbl)' $(sys)/syscall_64.tbl 'x86_64' > $@
25 25
26clean:: 26clean::
diff --git a/tools/perf/arch/x86/annotate/instructions.c b/tools/perf/arch/x86/annotate/instructions.c
index c1625f256df3..d84b72063a30 100644
--- a/tools/perf/arch/x86/annotate/instructions.c
+++ b/tools/perf/arch/x86/annotate/instructions.c
@@ -76,3 +76,49 @@ static struct ins x86__instructions[] = {
76 { .name = "xbeginq", .ops = &jump_ops, }, 76 { .name = "xbeginq", .ops = &jump_ops, },
77 { .name = "retq", .ops = &ret_ops, }, 77 { .name = "retq", .ops = &ret_ops, },
78}; 78};
79
80static bool x86__ins_is_fused(struct arch *arch, const char *ins1,
81 const char *ins2)
82{
83 if (arch->family != 6 || arch->model < 0x1e || strstr(ins2, "jmp"))
84 return false;
85
86 if (arch->model == 0x1e) {
87 /* Nehalem */
88 if ((strstr(ins1, "cmp") && !strstr(ins1, "xchg")) ||
89 strstr(ins1, "test")) {
90 return true;
91 }
92 } else {
93 /* Newer platform */
94 if ((strstr(ins1, "cmp") && !strstr(ins1, "xchg")) ||
95 strstr(ins1, "test") ||
96 strstr(ins1, "add") ||
97 strstr(ins1, "sub") ||
98 strstr(ins1, "and") ||
99 strstr(ins1, "inc") ||
100 strstr(ins1, "dec")) {
101 return true;
102 }
103 }
104
105 return false;
106}
107
108static int x86__cpuid_parse(struct arch *arch, char *cpuid)
109{
110 unsigned int family, model, stepping;
111 int ret;
112
113 /*
114 * cpuid = "GenuineIntel,family,model,stepping"
115 */
116 ret = sscanf(cpuid, "%*[^,],%u,%u,%u", &family, &model, &stepping);
117 if (ret == 3) {
118 arch->family = family;
119 arch->model = model;
120 return 0;
121 }
122
123 return -1;
124}
diff --git a/tools/perf/arch/x86/include/arch-tests.h b/tools/perf/arch/x86/include/arch-tests.h
index b48de2f5813c..4e0b806a7a0f 100644
--- a/tools/perf/arch/x86/include/arch-tests.h
+++ b/tools/perf/arch/x86/include/arch-tests.h
@@ -1,11 +1,14 @@
1#ifndef ARCH_TESTS_H 1#ifndef ARCH_TESTS_H
2#define ARCH_TESTS_H 2#define ARCH_TESTS_H
3 3
4#include <linux/compiler.h>
5struct test;
6
4/* Tests */ 7/* Tests */
5int test__rdpmc(int subtest); 8int test__rdpmc(struct test *test __maybe_unused, int subtest);
6int test__perf_time_to_tsc(int subtest); 9int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest);
7int test__insn_x86(int subtest); 10int test__insn_x86(struct test *test __maybe_unused, int subtest);
8int test__intel_cqm_count_nmi_context(int subtest); 11int test__intel_cqm_count_nmi_context(struct test *test __maybe_unused, int subtest);
9 12
10#ifdef HAVE_DWARF_UNWIND_SUPPORT 13#ifdef HAVE_DWARF_UNWIND_SUPPORT
11struct thread; 14struct thread;
diff --git a/tools/perf/arch/x86/tests/insn-x86.c b/tools/perf/arch/x86/tests/insn-x86.c
index 08d9b2bc185c..b3860586a0c2 100644
--- a/tools/perf/arch/x86/tests/insn-x86.c
+++ b/tools/perf/arch/x86/tests/insn-x86.c
@@ -171,7 +171,7 @@ static int test_data_set(struct test_data *dat_set, int x86_64)
171 * verbose (-v) option to see all the instructions and whether or not they 171 * verbose (-v) option to see all the instructions and whether or not they
172 * decoded successfuly. 172 * decoded successfuly.
173 */ 173 */
174int test__insn_x86(int subtest __maybe_unused) 174int test__insn_x86(struct test *test __maybe_unused, int subtest __maybe_unused)
175{ 175{
176 int ret = 0; 176 int ret = 0;
177 177
diff --git a/tools/perf/arch/x86/tests/intel-cqm.c b/tools/perf/arch/x86/tests/intel-cqm.c
index f9713a71d77e..57f86b6e7d6f 100644
--- a/tools/perf/arch/x86/tests/intel-cqm.c
+++ b/tools/perf/arch/x86/tests/intel-cqm.c
@@ -36,7 +36,7 @@ static pid_t spawn(void)
36 * the last read counter value to avoid triggering a WARN_ON_ONCE() in 36 * the last read counter value to avoid triggering a WARN_ON_ONCE() in
37 * smp_call_function_many() caused by sending IPIs from NMI context. 37 * smp_call_function_many() caused by sending IPIs from NMI context.
38 */ 38 */
39int test__intel_cqm_count_nmi_context(int subtest __maybe_unused) 39int test__intel_cqm_count_nmi_context(struct test *test __maybe_unused, int subtest __maybe_unused)
40{ 40{
41 struct perf_evlist *evlist = NULL; 41 struct perf_evlist *evlist = NULL;
42 struct perf_evsel *evsel = NULL; 42 struct perf_evsel *evsel = NULL;
diff --git a/tools/perf/arch/x86/tests/perf-time-to-tsc.c b/tools/perf/arch/x86/tests/perf-time-to-tsc.c
index e3ae9cff2b67..5dd7efb192ce 100644
--- a/tools/perf/arch/x86/tests/perf-time-to-tsc.c
+++ b/tools/perf/arch/x86/tests/perf-time-to-tsc.c
@@ -37,7 +37,7 @@
37 * %0 is returned, otherwise %-1 is returned. If TSC conversion is not 37 * %0 is returned, otherwise %-1 is returned. If TSC conversion is not
38 * supported then then the test passes but " (not supported)" is printed. 38 * supported then then the test passes but " (not supported)" is printed.
39 */ 39 */
40int test__perf_time_to_tsc(int subtest __maybe_unused) 40int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe_unused)
41{ 41{
42 struct record_opts opts = { 42 struct record_opts opts = {
43 .mmap_pages = UINT_MAX, 43 .mmap_pages = UINT_MAX,
diff --git a/tools/perf/arch/x86/tests/rdpmc.c b/tools/perf/arch/x86/tests/rdpmc.c
index 500cf96db979..17fec30a0b31 100644
--- a/tools/perf/arch/x86/tests/rdpmc.c
+++ b/tools/perf/arch/x86/tests/rdpmc.c
@@ -154,7 +154,7 @@ out_close:
154 return 0; 154 return 0;
155} 155}
156 156
157int test__rdpmc(int subtest __maybe_unused) 157int test__rdpmc(struct test *test __maybe_unused, int subtest __maybe_unused)
158{ 158{
159 int status = 0; 159 int status = 0;
160 int wret = 0; 160 int wret = 0;
diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c
index 9535be57033f..db0ba8caf5a2 100644
--- a/tools/perf/arch/x86/util/intel-pt.c
+++ b/tools/perf/arch/x86/util/intel-pt.c
@@ -701,6 +701,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
701 perf_evsel__set_sample_bit(switch_evsel, TID); 701 perf_evsel__set_sample_bit(switch_evsel, TID);
702 perf_evsel__set_sample_bit(switch_evsel, TIME); 702 perf_evsel__set_sample_bit(switch_evsel, TIME);
703 perf_evsel__set_sample_bit(switch_evsel, CPU); 703 perf_evsel__set_sample_bit(switch_evsel, CPU);
704 perf_evsel__reset_sample_bit(switch_evsel, BRANCH_STACK);
704 705
705 opts->record_switch_events = false; 706 opts->record_switch_events = false;
706 ptr->have_sched_switch = 3; 707 ptr->have_sched_switch = 3;
@@ -752,6 +753,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
752 tracking_evsel->attr.freq = 0; 753 tracking_evsel->attr.freq = 0;
753 tracking_evsel->attr.sample_period = 1; 754 tracking_evsel->attr.sample_period = 1;
754 755
756 tracking_evsel->no_aux_samples = true;
755 if (need_immediate) 757 if (need_immediate)
756 tracking_evsel->immediate = true; 758 tracking_evsel->immediate = true;
757 759
@@ -761,6 +763,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
761 /* And the CPU for switch events */ 763 /* And the CPU for switch events */
762 perf_evsel__set_sample_bit(tracking_evsel, CPU); 764 perf_evsel__set_sample_bit(tracking_evsel, CPU);
763 } 765 }
766 perf_evsel__reset_sample_bit(tracking_evsel, BRANCH_STACK);
764 } 767 }
765 768
766 /* 769 /*
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 7a5dc7e5c577..c38373195c4a 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -177,14 +177,11 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,
177 */ 177 */
178 process_branch_stack(sample->branch_stack, al, sample); 178 process_branch_stack(sample->branch_stack, al, sample);
179 179
180 sample->period = 1;
181 sample->weight = 1;
182
183 he = hists__add_entry(hists, al, NULL, NULL, NULL, sample, true); 180 he = hists__add_entry(hists, al, NULL, NULL, NULL, sample, true);
184 if (he == NULL) 181 if (he == NULL)
185 return -ENOMEM; 182 return -ENOMEM;
186 183
187 ret = hist_entry__inc_addr_samples(he, evsel->idx, al->addr); 184 ret = hist_entry__inc_addr_samples(he, sample, evsel->idx, al->addr);
188 hists__inc_nr_samples(hists, true); 185 hists__inc_nr_samples(hists, true);
189 return ret; 186 return ret;
190} 187}
@@ -397,6 +394,8 @@ int cmd_annotate(int argc, const char **argv)
397 .namespaces = perf_event__process_namespaces, 394 .namespaces = perf_event__process_namespaces,
398 .attr = perf_event__process_attr, 395 .attr = perf_event__process_attr,
399 .build_id = perf_event__process_build_id, 396 .build_id = perf_event__process_build_id,
397 .tracing_data = perf_event__process_tracing_data,
398 .feature = perf_event__process_feature,
400 .ordered_events = true, 399 .ordered_events = true,
401 .ordering_requires_timestamps = true, 400 .ordering_requires_timestamps = true,
402 }, 401 },
@@ -404,7 +403,7 @@ int cmd_annotate(int argc, const char **argv)
404 struct perf_data_file file = { 403 struct perf_data_file file = {
405 .mode = PERF_DATA_MODE_READ, 404 .mode = PERF_DATA_MODE_READ,
406 }; 405 };
407 const struct option options[] = { 406 struct option options[] = {
408 OPT_STRING('i', "input", &input_name, "file", 407 OPT_STRING('i', "input", &input_name, "file",
409 "input file name"), 408 "input file name"),
410 OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]", 409 OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]",
@@ -446,13 +445,20 @@ int cmd_annotate(int argc, const char **argv)
446 "Show event group information together"), 445 "Show event group information together"),
447 OPT_BOOLEAN(0, "show-total-period", &symbol_conf.show_total_period, 446 OPT_BOOLEAN(0, "show-total-period", &symbol_conf.show_total_period,
448 "Show a column with the sum of periods"), 447 "Show a column with the sum of periods"),
448 OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples,
449 "Show a column with the number of samples"),
449 OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode", 450 OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode",
450 "'always' (default), 'never' or 'auto' only applicable to --stdio mode", 451 "'always' (default), 'never' or 'auto' only applicable to --stdio mode",
451 stdio__config_color, "always"), 452 stdio__config_color, "always"),
452 OPT_END() 453 OPT_END()
453 }; 454 };
454 int ret = hists__init(); 455 int ret;
456
457 set_option_flag(options, 0, "show-total-period", PARSE_OPT_EXCLUSIVE);
458 set_option_flag(options, 0, "show-nr-samples", PARSE_OPT_EXCLUSIVE);
459
455 460
461 ret = hists__init();
456 if (ret < 0) 462 if (ret < 0)
457 return ret; 463 return ret;
458 464
@@ -468,6 +474,11 @@ int cmd_annotate(int argc, const char **argv)
468 annotate.sym_hist_filter = argv[0]; 474 annotate.sym_hist_filter = argv[0];
469 } 475 }
470 476
477 if (symbol_conf.show_nr_samples && annotate.use_gtk) {
478 pr_err("--show-nr-samples is not available in --gtk mode at this time\n");
479 return ret;
480 }
481
471 if (quiet) 482 if (quiet)
472 perf_quiet_option(); 483 perf_quiet_option();
473 484
diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c
index 9eba7f1add1f..e3eb6240ced0 100644
--- a/tools/perf/builtin-buildid-cache.c
+++ b/tools/perf/builtin-buildid-cache.c
@@ -14,6 +14,7 @@
14#include <unistd.h> 14#include <unistd.h>
15#include "builtin.h" 15#include "builtin.h"
16#include "perf.h" 16#include "perf.h"
17#include "namespaces.h"
17#include "util/cache.h" 18#include "util/cache.h"
18#include "util/debug.h" 19#include "util/debug.h"
19#include "util/header.h" 20#include "util/header.h"
@@ -165,33 +166,41 @@ static int build_id_cache__add_kcore(const char *filename, bool force)
165 return 0; 166 return 0;
166} 167}
167 168
168static int build_id_cache__add_file(const char *filename) 169static int build_id_cache__add_file(const char *filename, struct nsinfo *nsi)
169{ 170{
170 char sbuild_id[SBUILD_ID_SIZE]; 171 char sbuild_id[SBUILD_ID_SIZE];
171 u8 build_id[BUILD_ID_SIZE]; 172 u8 build_id[BUILD_ID_SIZE];
172 int err; 173 int err;
174 struct nscookie nsc;
173 175
174 if (filename__read_build_id(filename, &build_id, sizeof(build_id)) < 0) { 176 nsinfo__mountns_enter(nsi, &nsc);
177 err = filename__read_build_id(filename, &build_id, sizeof(build_id));
178 nsinfo__mountns_exit(&nsc);
179 if (err < 0) {
175 pr_debug("Couldn't read a build-id in %s\n", filename); 180 pr_debug("Couldn't read a build-id in %s\n", filename);
176 return -1; 181 return -1;
177 } 182 }
178 183
179 build_id__sprintf(build_id, sizeof(build_id), sbuild_id); 184 build_id__sprintf(build_id, sizeof(build_id), sbuild_id);
180 err = build_id_cache__add_s(sbuild_id, filename, 185 err = build_id_cache__add_s(sbuild_id, filename, nsi,
181 false, false); 186 false, false);
182 pr_debug("Adding %s %s: %s\n", sbuild_id, filename, 187 pr_debug("Adding %s %s: %s\n", sbuild_id, filename,
183 err ? "FAIL" : "Ok"); 188 err ? "FAIL" : "Ok");
184 return err; 189 return err;
185} 190}
186 191
187static int build_id_cache__remove_file(const char *filename) 192static int build_id_cache__remove_file(const char *filename, struct nsinfo *nsi)
188{ 193{
189 u8 build_id[BUILD_ID_SIZE]; 194 u8 build_id[BUILD_ID_SIZE];
190 char sbuild_id[SBUILD_ID_SIZE]; 195 char sbuild_id[SBUILD_ID_SIZE];
196 struct nscookie nsc;
191 197
192 int err; 198 int err;
193 199
194 if (filename__read_build_id(filename, &build_id, sizeof(build_id)) < 0) { 200 nsinfo__mountns_enter(nsi, &nsc);
201 err = filename__read_build_id(filename, &build_id, sizeof(build_id));
202 nsinfo__mountns_exit(&nsc);
203 if (err < 0) {
195 pr_debug("Couldn't read a build-id in %s\n", filename); 204 pr_debug("Couldn't read a build-id in %s\n", filename);
196 return -1; 205 return -1;
197 } 206 }
@@ -204,13 +213,13 @@ static int build_id_cache__remove_file(const char *filename)
204 return err; 213 return err;
205} 214}
206 215
207static int build_id_cache__purge_path(const char *pathname) 216static int build_id_cache__purge_path(const char *pathname, struct nsinfo *nsi)
208{ 217{
209 struct strlist *list; 218 struct strlist *list;
210 struct str_node *pos; 219 struct str_node *pos;
211 int err; 220 int err;
212 221
213 err = build_id_cache__list_build_ids(pathname, &list); 222 err = build_id_cache__list_build_ids(pathname, nsi, &list);
214 if (err) 223 if (err)
215 goto out; 224 goto out;
216 225
@@ -234,7 +243,7 @@ static bool dso__missing_buildid_cache(struct dso *dso, int parm __maybe_unused)
234 char filename[PATH_MAX]; 243 char filename[PATH_MAX];
235 u8 build_id[BUILD_ID_SIZE]; 244 u8 build_id[BUILD_ID_SIZE];
236 245
237 if (dso__build_id_filename(dso, filename, sizeof(filename)) && 246 if (dso__build_id_filename(dso, filename, sizeof(filename), false) &&
238 filename__read_build_id(filename, build_id, 247 filename__read_build_id(filename, build_id,
239 sizeof(build_id)) != sizeof(build_id)) { 248 sizeof(build_id)) != sizeof(build_id)) {
240 if (errno == ENOENT) 249 if (errno == ENOENT)
@@ -256,24 +265,30 @@ static int build_id_cache__fprintf_missing(struct perf_session *session, FILE *f
256 return 0; 265 return 0;
257} 266}
258 267
259static int build_id_cache__update_file(const char *filename) 268static int build_id_cache__update_file(const char *filename, struct nsinfo *nsi)
260{ 269{
261 u8 build_id[BUILD_ID_SIZE]; 270 u8 build_id[BUILD_ID_SIZE];
262 char sbuild_id[SBUILD_ID_SIZE]; 271 char sbuild_id[SBUILD_ID_SIZE];
272 struct nscookie nsc;
263 273
264 int err = 0; 274 int err;
265 275
266 if (filename__read_build_id(filename, &build_id, sizeof(build_id)) < 0) { 276 nsinfo__mountns_enter(nsi, &nsc);
277 err = filename__read_build_id(filename, &build_id, sizeof(build_id));
278 nsinfo__mountns_exit(&nsc);
279 if (err < 0) {
267 pr_debug("Couldn't read a build-id in %s\n", filename); 280 pr_debug("Couldn't read a build-id in %s\n", filename);
268 return -1; 281 return -1;
269 } 282 }
283 err = 0;
270 284
271 build_id__sprintf(build_id, sizeof(build_id), sbuild_id); 285 build_id__sprintf(build_id, sizeof(build_id), sbuild_id);
272 if (build_id_cache__cached(sbuild_id)) 286 if (build_id_cache__cached(sbuild_id))
273 err = build_id_cache__remove_s(sbuild_id); 287 err = build_id_cache__remove_s(sbuild_id);
274 288
275 if (!err) 289 if (!err)
276 err = build_id_cache__add_s(sbuild_id, filename, false, false); 290 err = build_id_cache__add_s(sbuild_id, filename, nsi, false,
291 false);
277 292
278 pr_debug("Updating %s %s: %s\n", sbuild_id, filename, 293 pr_debug("Updating %s %s: %s\n", sbuild_id, filename,
279 err ? "FAIL" : "Ok"); 294 err ? "FAIL" : "Ok");
@@ -286,6 +301,7 @@ int cmd_buildid_cache(int argc, const char **argv)
286 struct strlist *list; 301 struct strlist *list;
287 struct str_node *pos; 302 struct str_node *pos;
288 int ret = 0; 303 int ret = 0;
304 int ns_id = -1;
289 bool force = false; 305 bool force = false;
290 char const *add_name_list_str = NULL, 306 char const *add_name_list_str = NULL,
291 *remove_name_list_str = NULL, 307 *remove_name_list_str = NULL,
@@ -299,6 +315,7 @@ int cmd_buildid_cache(int argc, const char **argv)
299 .mode = PERF_DATA_MODE_READ, 315 .mode = PERF_DATA_MODE_READ,
300 }; 316 };
301 struct perf_session *session = NULL; 317 struct perf_session *session = NULL;
318 struct nsinfo *nsi = NULL;
302 319
303 const struct option buildid_cache_options[] = { 320 const struct option buildid_cache_options[] = {
304 OPT_STRING('a', "add", &add_name_list_str, 321 OPT_STRING('a', "add", &add_name_list_str,
@@ -315,6 +332,7 @@ int cmd_buildid_cache(int argc, const char **argv)
315 OPT_STRING('u', "update", &update_name_list_str, "file list", 332 OPT_STRING('u', "update", &update_name_list_str, "file list",
316 "file(s) to update"), 333 "file(s) to update"),
317 OPT_INCR('v', "verbose", &verbose, "be more verbose"), 334 OPT_INCR('v', "verbose", &verbose, "be more verbose"),
335 OPT_INTEGER(0, "target-ns", &ns_id, "target pid for namespace context"),
318 OPT_END() 336 OPT_END()
319 }; 337 };
320 const char * const buildid_cache_usage[] = { 338 const char * const buildid_cache_usage[] = {
@@ -330,6 +348,9 @@ int cmd_buildid_cache(int argc, const char **argv)
330 !missing_filename && !update_name_list_str)) 348 !missing_filename && !update_name_list_str))
331 usage_with_options(buildid_cache_usage, buildid_cache_options); 349 usage_with_options(buildid_cache_usage, buildid_cache_options);
332 350
351 if (ns_id > 0)
352 nsi = nsinfo__new(ns_id);
353
333 if (missing_filename) { 354 if (missing_filename) {
334 file.path = missing_filename; 355 file.path = missing_filename;
335 file.force = force; 356 file.force = force;
@@ -348,7 +369,7 @@ int cmd_buildid_cache(int argc, const char **argv)
348 list = strlist__new(add_name_list_str, NULL); 369 list = strlist__new(add_name_list_str, NULL);
349 if (list) { 370 if (list) {
350 strlist__for_each_entry(pos, list) 371 strlist__for_each_entry(pos, list)
351 if (build_id_cache__add_file(pos->s)) { 372 if (build_id_cache__add_file(pos->s, nsi)) {
352 if (errno == EEXIST) { 373 if (errno == EEXIST) {
353 pr_debug("%s already in the cache\n", 374 pr_debug("%s already in the cache\n",
354 pos->s); 375 pos->s);
@@ -366,7 +387,7 @@ int cmd_buildid_cache(int argc, const char **argv)
366 list = strlist__new(remove_name_list_str, NULL); 387 list = strlist__new(remove_name_list_str, NULL);
367 if (list) { 388 if (list) {
368 strlist__for_each_entry(pos, list) 389 strlist__for_each_entry(pos, list)
369 if (build_id_cache__remove_file(pos->s)) { 390 if (build_id_cache__remove_file(pos->s, nsi)) {
370 if (errno == ENOENT) { 391 if (errno == ENOENT) {
371 pr_debug("%s wasn't in the cache\n", 392 pr_debug("%s wasn't in the cache\n",
372 pos->s); 393 pos->s);
@@ -384,7 +405,7 @@ int cmd_buildid_cache(int argc, const char **argv)
384 list = strlist__new(purge_name_list_str, NULL); 405 list = strlist__new(purge_name_list_str, NULL);
385 if (list) { 406 if (list) {
386 strlist__for_each_entry(pos, list) 407 strlist__for_each_entry(pos, list)
387 if (build_id_cache__purge_path(pos->s)) { 408 if (build_id_cache__purge_path(pos->s, nsi)) {
388 if (errno == ENOENT) { 409 if (errno == ENOENT) {
389 pr_debug("%s wasn't in the cache\n", 410 pr_debug("%s wasn't in the cache\n",
390 pos->s); 411 pos->s);
@@ -405,7 +426,7 @@ int cmd_buildid_cache(int argc, const char **argv)
405 list = strlist__new(update_name_list_str, NULL); 426 list = strlist__new(update_name_list_str, NULL);
406 if (list) { 427 if (list) {
407 strlist__for_each_entry(pos, list) 428 strlist__for_each_entry(pos, list)
408 if (build_id_cache__update_file(pos->s)) { 429 if (build_id_cache__update_file(pos->s, nsi)) {
409 if (errno == ENOENT) { 430 if (errno == ENOENT) {
410 pr_debug("%s wasn't in the cache\n", 431 pr_debug("%s wasn't in the cache\n",
411 pos->s); 432 pos->s);
@@ -424,6 +445,7 @@ int cmd_buildid_cache(int argc, const char **argv)
424 445
425out: 446out:
426 perf_session__delete(session); 447 perf_session__delete(session);
448 nsinfo__zput(nsi);
427 449
428 return ret; 450 return ret;
429} 451}
diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index ece45582a48d..a1d82e33282c 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -13,6 +13,7 @@
13#include "util/util.h" 13#include "util/util.h"
14#include "util/debug.h" 14#include "util/debug.h"
15#include "util/config.h" 15#include "util/config.h"
16#include <linux/string.h>
16 17
17static bool use_system_config, use_user_config; 18static bool use_system_config, use_user_config;
18 19
@@ -58,7 +59,7 @@ static int set_config(struct perf_config_set *set, const char *file_name,
58 fprintf(fp, "[%s]\n", section->name); 59 fprintf(fp, "[%s]\n", section->name);
59 60
60 perf_config_items__for_each_entry(&section->items, item) { 61 perf_config_items__for_each_entry(&section->items, item) {
61 if (!use_system_config && section->from_system_config) 62 if (!use_system_config && item->from_system_config)
62 continue; 63 continue;
63 if (item->value) 64 if (item->value)
64 fprintf(fp, "\t%s = %s\n", 65 fprintf(fp, "\t%s = %s\n",
@@ -79,7 +80,7 @@ static int show_spec_config(struct perf_config_set *set, const char *var)
79 return -1; 80 return -1;
80 81
81 perf_config_items__for_each_entry(&set->sections, section) { 82 perf_config_items__for_each_entry(&set->sections, section) {
82 if (prefixcmp(var, section->name) != 0) 83 if (!strstarts(var, section->name))
83 continue; 84 continue;
84 85
85 perf_config_items__for_each_entry(&section->items, item) { 86 perf_config_items__for_each_entry(&section->items, item) {
diff --git a/tools/perf/builtin-data.c b/tools/perf/builtin-data.c
index 0adb5f82335a..46cd8490baf4 100644
--- a/tools/perf/builtin-data.c
+++ b/tools/perf/builtin-data.c
@@ -69,7 +69,7 @@ static int cmd_data_convert(int argc, const char **argv)
69 }; 69 };
70 70
71#ifndef HAVE_LIBBABELTRACE_SUPPORT 71#ifndef HAVE_LIBBABELTRACE_SUPPORT
72 pr_err("No conversion support compiled in.\n"); 72 pr_err("No conversion support compiled in. perf should be compiled with environment variables LIBBABELTRACE=1 and LIBBABELTRACE_DIR=/path/to/libbabeltrace/\n");
73 return -1; 73 return -1;
74#endif 74#endif
75 75
diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index dd26c62c9893..25a42acabee1 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -381,7 +381,7 @@ static int perf_ftrace_config(const char *var, const char *value, void *cb)
381{ 381{
382 struct perf_ftrace *ftrace = cb; 382 struct perf_ftrace *ftrace = cb;
383 383
384 if (prefixcmp(var, "ftrace.")) 384 if (!strstarts(var, "ftrace."))
385 return 0; 385 return 0;
386 386
387 if (strcmp(var, "ftrace.tracer")) 387 if (strcmp(var, "ftrace.tracer"))
diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c
index 530a7f2fa0f3..dbe4e4153bcf 100644
--- a/tools/perf/builtin-help.c
+++ b/tools/perf/builtin-help.c
@@ -90,7 +90,7 @@ static int check_emacsclient_version(void)
90 */ 90 */
91 finish_command(&ec_process); 91 finish_command(&ec_process);
92 92
93 if (prefixcmp(buffer.buf, "emacsclient")) { 93 if (!strstarts(buffer.buf, "emacsclient")) {
94 fprintf(stderr, "Failed to parse emacsclient version.\n"); 94 fprintf(stderr, "Failed to parse emacsclient version.\n");
95 goto out; 95 goto out;
96 } 96 }
@@ -283,7 +283,7 @@ static int perf_help_config(const char *var, const char *value, void *cb)
283 add_man_viewer(value); 283 add_man_viewer(value);
284 return 0; 284 return 0;
285 } 285 }
286 if (!prefixcmp(var, "man.")) 286 if (!strstarts(var, "man."))
287 return add_man_viewer_info(var, value); 287 return add_man_viewer_info(var, value);
288 288
289 return 0; 289 return 0;
@@ -313,7 +313,7 @@ static const char *cmd_to_page(const char *perf_cmd)
313 313
314 if (!perf_cmd) 314 if (!perf_cmd)
315 return "perf"; 315 return "perf";
316 else if (!prefixcmp(perf_cmd, "perf")) 316 else if (!strstarts(perf_cmd, "perf"))
317 return perf_cmd; 317 return perf_cmd;
318 318
319 return asprintf(&s, "perf-%s", perf_cmd) < 0 ? NULL : s; 319 return asprintf(&s, "perf-%s", perf_cmd) < 0 ? NULL : s;
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index ea8db38eedd1..2b8032908fb2 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -770,6 +770,7 @@ int cmd_inject(int argc, const char **argv)
770 .finished_round = perf_event__repipe_oe_synth, 770 .finished_round = perf_event__repipe_oe_synth,
771 .build_id = perf_event__repipe_op2_synth, 771 .build_id = perf_event__repipe_op2_synth,
772 .id_index = perf_event__repipe_op2_synth, 772 .id_index = perf_event__repipe_op2_synth,
773 .feature = perf_event__repipe_op2_synth,
773 }, 774 },
774 .input_name = "-", 775 .input_name = "-",
775 .samples = LIST_HEAD_INIT(inject.samples), 776 .samples = LIST_HEAD_INIT(inject.samples),
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index a1497c516d85..24ee68ecdd42 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -627,7 +627,6 @@ static const struct {
627 { "GFP_HIGHUSER_MOVABLE", "HUM" }, 627 { "GFP_HIGHUSER_MOVABLE", "HUM" },
628 { "GFP_HIGHUSER", "HU" }, 628 { "GFP_HIGHUSER", "HU" },
629 { "GFP_USER", "U" }, 629 { "GFP_USER", "U" },
630 { "GFP_TEMPORARY", "TMP" },
631 { "GFP_KERNEL_ACCOUNT", "KAC" }, 630 { "GFP_KERNEL_ACCOUNT", "KAC" },
632 { "GFP_KERNEL", "K" }, 631 { "GFP_KERNEL", "K" },
633 { "GFP_NOFS", "NF" }, 632 { "GFP_NOFS", "NF" },
diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index e001c0290793..0f15634ef82c 100644
--- a/tools/perf/builtin-mem.c
+++ b/tools/perf/builtin-mem.c
@@ -23,6 +23,7 @@ struct perf_mem {
23 bool hide_unresolved; 23 bool hide_unresolved;
24 bool dump_raw; 24 bool dump_raw;
25 bool force; 25 bool force;
26 bool phys_addr;
26 int operation; 27 int operation;
27 const char *cpu_list; 28 const char *cpu_list;
28 DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); 29 DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
@@ -101,6 +102,9 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
101 102
102 rec_argv[i++] = "-d"; 103 rec_argv[i++] = "-d";
103 104
105 if (mem->phys_addr)
106 rec_argv[i++] = "--phys-data";
107
104 for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) { 108 for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) {
105 if (!perf_mem_events[j].record) 109 if (!perf_mem_events[j].record)
106 continue; 110 continue;
@@ -161,30 +165,60 @@ dump_raw_samples(struct perf_tool *tool,
161 if (al.map != NULL) 165 if (al.map != NULL)
162 al.map->dso->hit = 1; 166 al.map->dso->hit = 1;
163 167
164 if (symbol_conf.field_sep) { 168 if (mem->phys_addr) {
165 fmt = "%d%s%d%s0x%"PRIx64"%s0x%"PRIx64"%s%"PRIu64 169 if (symbol_conf.field_sep) {
166 "%s0x%"PRIx64"%s%s:%s\n"; 170 fmt = "%d%s%d%s0x%"PRIx64"%s0x%"PRIx64"%s0x%016"PRIx64
171 "%s%"PRIu64"%s0x%"PRIx64"%s%s:%s\n";
172 } else {
173 fmt = "%5d%s%5d%s0x%016"PRIx64"%s0x016%"PRIx64
174 "%s0x%016"PRIx64"%s%5"PRIu64"%s0x%06"PRIx64
175 "%s%s:%s\n";
176 symbol_conf.field_sep = " ";
177 }
178
179 printf(fmt,
180 sample->pid,
181 symbol_conf.field_sep,
182 sample->tid,
183 symbol_conf.field_sep,
184 sample->ip,
185 symbol_conf.field_sep,
186 sample->addr,
187 symbol_conf.field_sep,
188 sample->phys_addr,
189 symbol_conf.field_sep,
190 sample->weight,
191 symbol_conf.field_sep,
192 sample->data_src,
193 symbol_conf.field_sep,
194 al.map ? (al.map->dso ? al.map->dso->long_name : "???") : "???",
195 al.sym ? al.sym->name : "???");
167 } else { 196 } else {
168 fmt = "%5d%s%5d%s0x%016"PRIx64"%s0x016%"PRIx64 197 if (symbol_conf.field_sep) {
169 "%s%5"PRIu64"%s0x%06"PRIx64"%s%s:%s\n"; 198 fmt = "%d%s%d%s0x%"PRIx64"%s0x%"PRIx64"%s%"PRIu64
170 symbol_conf.field_sep = " "; 199 "%s0x%"PRIx64"%s%s:%s\n";
171 } 200 } else {
201 fmt = "%5d%s%5d%s0x%016"PRIx64"%s0x016%"PRIx64
202 "%s%5"PRIu64"%s0x%06"PRIx64"%s%s:%s\n";
203 symbol_conf.field_sep = " ";
204 }
172 205
173 printf(fmt, 206 printf(fmt,
174 sample->pid, 207 sample->pid,
175 symbol_conf.field_sep, 208 symbol_conf.field_sep,
176 sample->tid, 209 sample->tid,
177 symbol_conf.field_sep, 210 symbol_conf.field_sep,
178 sample->ip, 211 sample->ip,
179 symbol_conf.field_sep, 212 symbol_conf.field_sep,
180 sample->addr, 213 sample->addr,
181 symbol_conf.field_sep, 214 symbol_conf.field_sep,
182 sample->weight, 215 sample->weight,
183 symbol_conf.field_sep, 216 symbol_conf.field_sep,
184 sample->data_src, 217 sample->data_src,
185 symbol_conf.field_sep, 218 symbol_conf.field_sep,
186 al.map ? (al.map->dso ? al.map->dso->long_name : "???") : "???", 219 al.map ? (al.map->dso ? al.map->dso->long_name : "???") : "???",
187 al.sym ? al.sym->name : "???"); 220 al.sym ? al.sym->name : "???");
221 }
188out_put: 222out_put:
189 addr_location__put(&al); 223 addr_location__put(&al);
190 return 0; 224 return 0;
@@ -224,7 +258,10 @@ static int report_raw_events(struct perf_mem *mem)
224 if (ret < 0) 258 if (ret < 0)
225 goto out_delete; 259 goto out_delete;
226 260
227 printf("# PID, TID, IP, ADDR, LOCAL WEIGHT, DSRC, SYMBOL\n"); 261 if (mem->phys_addr)
262 printf("# PID, TID, IP, ADDR, PHYS ADDR, LOCAL WEIGHT, DSRC, SYMBOL\n");
263 else
264 printf("# PID, TID, IP, ADDR, LOCAL WEIGHT, DSRC, SYMBOL\n");
228 265
229 ret = perf_session__process_events(session); 266 ret = perf_session__process_events(session);
230 267
@@ -254,9 +291,16 @@ static int report_events(int argc, const char **argv, struct perf_mem *mem)
254 * there is no weight (cost) associated with stores, so don't print 291 * there is no weight (cost) associated with stores, so don't print
255 * the column 292 * the column
256 */ 293 */
257 if (!(mem->operation & MEM_OPERATION_LOAD)) 294 if (!(mem->operation & MEM_OPERATION_LOAD)) {
258 rep_argv[i++] = "--sort=mem,sym,dso,symbol_daddr," 295 if (mem->phys_addr)
259 "dso_daddr,tlb,locked"; 296 rep_argv[i++] = "--sort=mem,sym,dso,symbol_daddr,"
297 "dso_daddr,tlb,locked,phys_daddr";
298 else
299 rep_argv[i++] = "--sort=mem,sym,dso,symbol_daddr,"
300 "dso_daddr,tlb,locked";
301 } else if (mem->phys_addr)
302 rep_argv[i++] = "--sort=local_weight,mem,sym,dso,symbol_daddr,"
303 "dso_daddr,snoop,tlb,locked,phys_daddr";
260 304
261 for (j = 1; j < argc; j++, i++) 305 for (j = 1; j < argc; j++, i++)
262 rep_argv[i] = argv[j]; 306 rep_argv[i] = argv[j];
@@ -373,6 +417,7 @@ int cmd_mem(int argc, const char **argv)
373 "separator for columns, no spaces will be added" 417 "separator for columns, no spaces will be added"
374 " between columns '.' is reserved."), 418 " between columns '.' is reserved."),
375 OPT_BOOLEAN('f', "force", &mem.force, "don't complain, do it"), 419 OPT_BOOLEAN('f', "force", &mem.force, "don't complain, do it"),
420 OPT_BOOLEAN('p', "phys-data", &mem.phys_addr, "Record/Report sample physical addresses"),
376 OPT_END() 421 OPT_END()
377 }; 422 };
378 const char *const mem_subcommands[] = { "record", "report", NULL }; 423 const char *const mem_subcommands[] = { "record", "report", NULL };
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index cf9f9e9c2fc0..c0065923a525 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -58,6 +58,7 @@ static struct {
58 struct line_range line_range; 58 struct line_range line_range;
59 char *target; 59 char *target;
60 struct strfilter *filter; 60 struct strfilter *filter;
61 struct nsinfo *nsi;
61} params; 62} params;
62 63
63/* Parse an event definition. Note that any error must die. */ 64/* Parse an event definition. Note that any error must die. */
@@ -80,6 +81,9 @@ static int parse_probe_event(const char *str)
80 params.target_used = true; 81 params.target_used = true;
81 } 82 }
82 83
84 if (params.nsi)
85 pev->nsi = nsinfo__get(params.nsi);
86
83 /* Parse a perf-probe command into event */ 87 /* Parse a perf-probe command into event */
84 ret = parse_perf_probe_command(str, pev); 88 ret = parse_perf_probe_command(str, pev);
85 pr_debug("%d arguments\n", pev->nargs); 89 pr_debug("%d arguments\n", pev->nargs);
@@ -189,7 +193,7 @@ static int opt_set_target(const struct option *opt, const char *str,
189 193
190 /* Expand given path to absolute path, except for modulename */ 194 /* Expand given path to absolute path, except for modulename */
191 if (params.uprobes || strchr(str, '/')) { 195 if (params.uprobes || strchr(str, '/')) {
192 tmp = realpath(str, NULL); 196 tmp = nsinfo__realpath(str, params.nsi);
193 if (!tmp) { 197 if (!tmp) {
194 pr_warning("Failed to get the absolute path of %s: %m\n", str); 198 pr_warning("Failed to get the absolute path of %s: %m\n", str);
195 return ret; 199 return ret;
@@ -208,6 +212,34 @@ static int opt_set_target(const struct option *opt, const char *str,
208 return ret; 212 return ret;
209} 213}
210 214
215static int opt_set_target_ns(const struct option *opt __maybe_unused,
216 const char *str, int unset __maybe_unused)
217{
218 int ret = -ENOENT;
219 pid_t ns_pid;
220 struct nsinfo *nsip;
221
222 if (str) {
223 errno = 0;
224 ns_pid = (pid_t)strtol(str, NULL, 10);
225 if (errno != 0) {
226 ret = -errno;
227 pr_warning("Failed to parse %s as a pid: %s\n", str,
228 strerror(errno));
229 return ret;
230 }
231 nsip = nsinfo__new(ns_pid);
232 if (nsip && nsip->need_setns)
233 params.nsi = nsinfo__get(nsip);
234 nsinfo__put(nsip);
235
236 ret = 0;
237 }
238
239 return ret;
240}
241
242
211/* Command option callbacks */ 243/* Command option callbacks */
212 244
213#ifdef HAVE_DWARF_SUPPORT 245#ifdef HAVE_DWARF_SUPPORT
@@ -299,6 +331,7 @@ static void cleanup_params(void)
299 line_range__clear(&params.line_range); 331 line_range__clear(&params.line_range);
300 free(params.target); 332 free(params.target);
301 strfilter__delete(params.filter); 333 strfilter__delete(params.filter);
334 nsinfo__put(params.nsi);
302 memset(&params, 0, sizeof(params)); 335 memset(&params, 0, sizeof(params));
303} 336}
304 337
@@ -383,7 +416,7 @@ static int del_perf_probe_caches(struct strfilter *filter)
383 } 416 }
384 417
385 strlist__for_each_entry(nd, bidlist) { 418 strlist__for_each_entry(nd, bidlist) {
386 cache = probe_cache__new(nd->s); 419 cache = probe_cache__new(nd->s, NULL);
387 if (!cache) 420 if (!cache)
388 continue; 421 continue;
389 if (probe_cache__filter_purge(cache, filter) < 0 || 422 if (probe_cache__filter_purge(cache, filter) < 0 ||
@@ -554,6 +587,8 @@ __cmd_probe(int argc, const char **argv)
554 OPT_BOOLEAN(0, "cache", &probe_conf.cache, "Manipulate probe cache"), 587 OPT_BOOLEAN(0, "cache", &probe_conf.cache, "Manipulate probe cache"),
555 OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory", 588 OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
556 "Look for files with symbols relative to this directory"), 589 "Look for files with symbols relative to this directory"),
590 OPT_CALLBACK(0, "target-ns", NULL, "pid",
591 "target pid for namespace contexts", opt_set_target_ns),
557 OPT_END() 592 OPT_END()
558 }; 593 };
559 int ret; 594 int ret;
@@ -634,15 +669,15 @@ __cmd_probe(int argc, const char **argv)
634 pr_err_with_code(" Error: Failed to show event list.", ret); 669 pr_err_with_code(" Error: Failed to show event list.", ret);
635 return ret; 670 return ret;
636 case 'F': 671 case 'F':
637 ret = show_available_funcs(params.target, params.filter, 672 ret = show_available_funcs(params.target, params.nsi,
638 params.uprobes); 673 params.filter, params.uprobes);
639 if (ret < 0) 674 if (ret < 0)
640 pr_err_with_code(" Error: Failed to show functions.", ret); 675 pr_err_with_code(" Error: Failed to show functions.", ret);
641 return ret; 676 return ret;
642#ifdef HAVE_DWARF_SUPPORT 677#ifdef HAVE_DWARF_SUPPORT
643 case 'L': 678 case 'L':
644 ret = show_line_range(&params.line_range, params.target, 679 ret = show_line_range(&params.line_range, params.target,
645 params.uprobes); 680 params.nsi, params.uprobes);
646 if (ret < 0) 681 if (ret < 0)
647 pr_err_with_code(" Error: Failed to show lines.", ret); 682 pr_err_with_code(" Error: Failed to show lines.", ret);
648 return ret; 683 return ret;
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 17a14bcce34a..56f8142ff97f 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -799,6 +799,13 @@ static int record__synthesize(struct record *rec, bool tail)
799 return 0; 799 return 0;
800 800
801 if (file->is_pipe) { 801 if (file->is_pipe) {
802 err = perf_event__synthesize_features(
803 tool, session, rec->evlist, process_synthesized_event);
804 if (err < 0) {
805 pr_err("Couldn't synthesize features.\n");
806 return err;
807 }
808
802 err = perf_event__synthesize_attrs(tool, session, 809 err = perf_event__synthesize_attrs(tool, session,
803 process_synthesized_event); 810 process_synthesized_event);
804 if (err < 0) { 811 if (err < 0) {
@@ -1597,6 +1604,8 @@ static struct option __record_options[] = {
1597 OPT_BOOLEAN('s', "stat", &record.opts.inherit_stat, 1604 OPT_BOOLEAN('s', "stat", &record.opts.inherit_stat,
1598 "per thread counts"), 1605 "per thread counts"),
1599 OPT_BOOLEAN('d', "data", &record.opts.sample_address, "Record the sample addresses"), 1606 OPT_BOOLEAN('d', "data", &record.opts.sample_address, "Record the sample addresses"),
1607 OPT_BOOLEAN(0, "phys-data", &record.opts.sample_phys_addr,
1608 "Record the sample physical addresses"),
1600 OPT_BOOLEAN(0, "sample-cpu", &record.opts.sample_cpu, "Record the sample cpu"), 1609 OPT_BOOLEAN(0, "sample-cpu", &record.opts.sample_cpu, "Record the sample cpu"),
1601 OPT_BOOLEAN_SET('T', "timestamp", &record.opts.sample_time, 1610 OPT_BOOLEAN_SET('T', "timestamp", &record.opts.sample_time,
1602 &record.opts.sample_time_set, 1611 &record.opts.sample_time_set,
@@ -1821,7 +1830,7 @@ int cmd_record(int argc, const char **argv)
1821 record.opts.tail_synthesize = true; 1830 record.opts.tail_synthesize = true;
1822 1831
1823 if (rec->evlist->nr_entries == 0 && 1832 if (rec->evlist->nr_entries == 0 &&
1824 perf_evlist__add_default(rec->evlist) < 0) { 1833 __perf_evlist__add_default(rec->evlist, !record.opts.no_samples) < 0) {
1825 pr_err("Not enough memory for event selector list\n"); 1834 pr_err("Not enough memory for event selector list\n");
1826 goto out; 1835 goto out;
1827 } 1836 }
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 79a33eb1a10d..f9dff652dcbd 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -38,6 +38,7 @@
38#include "util/time-utils.h" 38#include "util/time-utils.h"
39#include "util/auxtrace.h" 39#include "util/auxtrace.h"
40#include "util/units.h" 40#include "util/units.h"
41#include "util/branch.h"
41 42
42#include <dlfcn.h> 43#include <dlfcn.h>
43#include <errno.h> 44#include <errno.h>
@@ -73,6 +74,7 @@ struct report {
73 u64 queue_size; 74 u64 queue_size;
74 int socket_filter; 75 int socket_filter;
75 DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); 76 DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
77 struct branch_type_stat brtype_stat;
76}; 78};
77 79
78static int report__config(const char *var, const char *value, void *cb) 80static int report__config(const char *var, const char *value, void *cb)
@@ -113,43 +115,60 @@ static int hist_iter__report_callback(struct hist_entry_iter *iter,
113 struct report *rep = arg; 115 struct report *rep = arg;
114 struct hist_entry *he = iter->he; 116 struct hist_entry *he = iter->he;
115 struct perf_evsel *evsel = iter->evsel; 117 struct perf_evsel *evsel = iter->evsel;
118 struct perf_sample *sample = iter->sample;
116 struct mem_info *mi; 119 struct mem_info *mi;
117 struct branch_info *bi; 120 struct branch_info *bi;
118 121
119 if (!ui__has_annotation()) 122 if (!ui__has_annotation())
120 return 0; 123 return 0;
121 124
122 hist__account_cycles(iter->sample->branch_stack, al, iter->sample, 125 hist__account_cycles(sample->branch_stack, al, sample,
123 rep->nonany_branch_mode); 126 rep->nonany_branch_mode);
124 127
125 if (sort__mode == SORT_MODE__BRANCH) { 128 if (sort__mode == SORT_MODE__BRANCH) {
126 bi = he->branch_info; 129 bi = he->branch_info;
127 err = addr_map_symbol__inc_samples(&bi->from, evsel->idx); 130 err = addr_map_symbol__inc_samples(&bi->from, sample, evsel->idx);
128 if (err) 131 if (err)
129 goto out; 132 goto out;
130 133
131 err = addr_map_symbol__inc_samples(&bi->to, evsel->idx); 134 err = addr_map_symbol__inc_samples(&bi->to, sample, evsel->idx);
132 135
133 } else if (rep->mem_mode) { 136 } else if (rep->mem_mode) {
134 mi = he->mem_info; 137 mi = he->mem_info;
135 err = addr_map_symbol__inc_samples(&mi->daddr, evsel->idx); 138 err = addr_map_symbol__inc_samples(&mi->daddr, sample, evsel->idx);
136 if (err) 139 if (err)
137 goto out; 140 goto out;
138 141
139 err = hist_entry__inc_addr_samples(he, evsel->idx, al->addr); 142 err = hist_entry__inc_addr_samples(he, sample, evsel->idx, al->addr);
140 143
141 } else if (symbol_conf.cumulate_callchain) { 144 } else if (symbol_conf.cumulate_callchain) {
142 if (single) 145 if (single)
143 err = hist_entry__inc_addr_samples(he, evsel->idx, 146 err = hist_entry__inc_addr_samples(he, sample, evsel->idx,
144 al->addr); 147 al->addr);
145 } else { 148 } else {
146 err = hist_entry__inc_addr_samples(he, evsel->idx, al->addr); 149 err = hist_entry__inc_addr_samples(he, sample, evsel->idx, al->addr);
147 } 150 }
148 151
149out: 152out:
150 return err; 153 return err;
151} 154}
152 155
156static int hist_iter__branch_callback(struct hist_entry_iter *iter,
157 struct addr_location *al __maybe_unused,
158 bool single __maybe_unused,
159 void *arg)
160{
161 struct hist_entry *he = iter->he;
162 struct report *rep = arg;
163 struct branch_info *bi;
164
165 bi = he->branch_info;
166 branch_type_count(&rep->brtype_stat, &bi->flags,
167 bi->from.addr, bi->to.addr);
168
169 return 0;
170}
171
153static int process_sample_event(struct perf_tool *tool, 172static int process_sample_event(struct perf_tool *tool,
154 union perf_event *event, 173 union perf_event *event,
155 struct perf_sample *sample, 174 struct perf_sample *sample,
@@ -188,6 +207,8 @@ static int process_sample_event(struct perf_tool *tool,
188 */ 207 */
189 if (!sample->branch_stack) 208 if (!sample->branch_stack)
190 goto out_put; 209 goto out_put;
210
211 iter.add_entry_cb = hist_iter__branch_callback;
191 iter.ops = &hist_iter_branch; 212 iter.ops = &hist_iter_branch;
192 } else if (rep->mem_mode) { 213 } else if (rep->mem_mode) {
193 iter.ops = &hist_iter_mem; 214 iter.ops = &hist_iter_mem;
@@ -220,7 +241,7 @@ static int process_read_event(struct perf_tool *tool,
220 const char *name = evsel ? perf_evsel__name(evsel) : "unknown"; 241 const char *name = evsel ? perf_evsel__name(evsel) : "unknown";
221 int err = perf_read_values_add_value(&rep->show_threads_values, 242 int err = perf_read_values_add_value(&rep->show_threads_values,
222 event->read.pid, event->read.tid, 243 event->read.pid, event->read.tid,
223 event->read.id, 244 evsel->idx,
224 name, 245 name,
225 event->read.value); 246 event->read.value);
226 247
@@ -228,10 +249,6 @@ static int process_read_event(struct perf_tool *tool,
228 return err; 249 return err;
229 } 250 }
230 251
231 dump_printf(": %d %d %s %" PRIu64 "\n", event->read.pid, event->read.tid,
232 evsel ? perf_evsel__name(evsel) : "FAIL",
233 event->read.value);
234
235 return 0; 252 return 0;
236} 253}
237 254
@@ -258,10 +275,11 @@ static int report__setup_sample_type(struct report *rep)
258 "'perf record' without -g?\n"); 275 "'perf record' without -g?\n");
259 return -EINVAL; 276 return -EINVAL;
260 } 277 }
261 if (symbol_conf.use_callchain) { 278 if (symbol_conf.use_callchain &&
262 ui__error("Selected -g or --branch-history but no " 279 !symbol_conf.show_branchflag_count) {
263 "callchain data. Did\n" 280 ui__error("Selected -g or --branch-history.\n"
264 "you call 'perf record' without -g?\n"); 281 "But no callchain or branch data.\n"
282 "Did you call 'perf record' without -g or -b?\n");
265 return -1; 283 return -1;
266 } 284 }
267 } else if (!callchain_param.enabled && 285 } else if (!callchain_param.enabled &&
@@ -396,7 +414,8 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist,
396 414
397 hists__fprintf_nr_sample_events(hists, rep, evname, stdout); 415 hists__fprintf_nr_sample_events(hists, rep, evname, stdout);
398 hists__fprintf(hists, !quiet, 0, 0, rep->min_percent, stdout, 416 hists__fprintf(hists, !quiet, 0, 0, rep->min_percent, stdout,
399 symbol_conf.use_callchain); 417 symbol_conf.use_callchain ||
418 symbol_conf.show_branchflag_count);
400 fprintf(stdout, "\n\n"); 419 fprintf(stdout, "\n\n");
401 } 420 }
402 421
@@ -410,6 +429,9 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist,
410 perf_read_values_destroy(&rep->show_threads_values); 429 perf_read_values_destroy(&rep->show_threads_values);
411 } 430 }
412 431
432 if (sort__mode == SORT_MODE__BRANCH)
433 branch_type_stat_display(stdout, &rep->brtype_stat);
434
413 return 0; 435 return 0;
414} 436}
415 437
@@ -718,6 +740,7 @@ int cmd_report(int argc, const char **argv)
718 .id_index = perf_event__process_id_index, 740 .id_index = perf_event__process_id_index,
719 .auxtrace_info = perf_event__process_auxtrace_info, 741 .auxtrace_info = perf_event__process_auxtrace_info,
720 .auxtrace = perf_event__process_auxtrace, 742 .auxtrace = perf_event__process_auxtrace,
743 .feature = perf_event__process_feature,
721 .ordered_events = true, 744 .ordered_events = true,
722 .ordering_requires_timestamps = true, 745 .ordering_requires_timestamps = true,
723 }, 746 },
@@ -943,6 +966,8 @@ repeat:
943 if (has_br_stack && branch_call_mode) 966 if (has_br_stack && branch_call_mode)
944 symbol_conf.show_branchflag_count = true; 967 symbol_conf.show_branchflag_count = true;
945 968
969 memset(&report.brtype_stat, 0, sizeof(struct branch_type_stat));
970
946 /* 971 /*
947 * Branch mode is a tristate: 972 * Branch mode is a tristate:
948 * -1 means default, so decide based on the file having branch data. 973 * -1 means default, so decide based on the file having branch data.
@@ -988,6 +1013,10 @@ repeat:
988 /* Force tty output for header output and per-thread stat. */ 1013 /* Force tty output for header output and per-thread stat. */
989 if (report.header || report.header_only || report.show_threads) 1014 if (report.header || report.header_only || report.show_threads)
990 use_browser = 0; 1015 use_browser = 0;
1016 if (report.header || report.header_only)
1017 report.tool.show_feat_hdr = SHOW_FEAT_HEADER;
1018 if (report.show_full_info)
1019 report.tool.show_feat_hdr = SHOW_FEAT_HEADER_FULL_INFO;
991 1020
992 if (strcmp(input_name, "-") != 0) 1021 if (strcmp(input_name, "-") != 0)
993 setup_browser(true); 1022 setup_browser(true);
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 83cdc0a61fd6..3d4c3b5e1868 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -87,6 +87,7 @@ enum perf_output_field {
87 PERF_OUTPUT_BRSTACKINSN = 1U << 23, 87 PERF_OUTPUT_BRSTACKINSN = 1U << 23,
88 PERF_OUTPUT_BRSTACKOFF = 1U << 24, 88 PERF_OUTPUT_BRSTACKOFF = 1U << 24,
89 PERF_OUTPUT_SYNTH = 1U << 25, 89 PERF_OUTPUT_SYNTH = 1U << 25,
90 PERF_OUTPUT_PHYS_ADDR = 1U << 26,
90}; 91};
91 92
92struct output_option { 93struct output_option {
@@ -119,6 +120,7 @@ struct output_option {
119 {.str = "brstackinsn", .field = PERF_OUTPUT_BRSTACKINSN}, 120 {.str = "brstackinsn", .field = PERF_OUTPUT_BRSTACKINSN},
120 {.str = "brstackoff", .field = PERF_OUTPUT_BRSTACKOFF}, 121 {.str = "brstackoff", .field = PERF_OUTPUT_BRSTACKOFF},
121 {.str = "synth", .field = PERF_OUTPUT_SYNTH}, 122 {.str = "synth", .field = PERF_OUTPUT_SYNTH},
123 {.str = "phys_addr", .field = PERF_OUTPUT_PHYS_ADDR},
122}; 124};
123 125
124enum { 126enum {
@@ -175,7 +177,8 @@ static struct {
175 PERF_OUTPUT_EVNAME | PERF_OUTPUT_IP | 177 PERF_OUTPUT_EVNAME | PERF_OUTPUT_IP |
176 PERF_OUTPUT_SYM | PERF_OUTPUT_DSO | 178 PERF_OUTPUT_SYM | PERF_OUTPUT_DSO |
177 PERF_OUTPUT_PERIOD | PERF_OUTPUT_ADDR | 179 PERF_OUTPUT_PERIOD | PERF_OUTPUT_ADDR |
178 PERF_OUTPUT_DATA_SRC | PERF_OUTPUT_WEIGHT, 180 PERF_OUTPUT_DATA_SRC | PERF_OUTPUT_WEIGHT |
181 PERF_OUTPUT_PHYS_ADDR,
179 182
180 .invalid_fields = PERF_OUTPUT_TRACE | PERF_OUTPUT_BPF_OUTPUT, 183 .invalid_fields = PERF_OUTPUT_TRACE | PERF_OUTPUT_BPF_OUTPUT,
181 }, 184 },
@@ -382,6 +385,11 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel,
382 PERF_OUTPUT_IREGS)) 385 PERF_OUTPUT_IREGS))
383 return -EINVAL; 386 return -EINVAL;
384 387
388 if (PRINT_FIELD(PHYS_ADDR) &&
389 perf_evsel__check_stype(evsel, PERF_SAMPLE_PHYS_ADDR, "PHYS_ADDR",
390 PERF_OUTPUT_PHYS_ADDR))
391 return -EINVAL;
392
385 return 0; 393 return 0;
386} 394}
387 395
@@ -1446,6 +1454,9 @@ static void process_event(struct perf_script *script,
1446 if (perf_evsel__is_bpf_output(evsel) && PRINT_FIELD(BPF_OUTPUT)) 1454 if (perf_evsel__is_bpf_output(evsel) && PRINT_FIELD(BPF_OUTPUT))
1447 print_sample_bpf_output(sample); 1455 print_sample_bpf_output(sample);
1448 print_insn(sample, attr, thread, machine); 1456 print_insn(sample, attr, thread, machine);
1457
1458 if (PRINT_FIELD(PHYS_ADDR))
1459 printf("%16" PRIx64, sample->phys_addr);
1449 printf("\n"); 1460 printf("\n");
1450} 1461}
1451 1462
@@ -2199,16 +2210,11 @@ static struct script_desc *script_desc__findnew(const char *name)
2199 2210
2200 s = script_desc__new(name); 2211 s = script_desc__new(name);
2201 if (!s) 2212 if (!s)
2202 goto out_delete_desc; 2213 return NULL;
2203 2214
2204 script_desc__add(s); 2215 script_desc__add(s);
2205 2216
2206 return s; 2217 return s;
2207
2208out_delete_desc:
2209 script_desc__delete(s);
2210
2211 return NULL;
2212} 2218}
2213 2219
2214static const char *ends_with(const char *str, const char *suffix) 2220static const char *ends_with(const char *str, const char *suffix)
@@ -2682,6 +2688,7 @@ int cmd_script(int argc, const char **argv)
2682 .attr = process_attr, 2688 .attr = process_attr,
2683 .event_update = perf_event__process_event_update, 2689 .event_update = perf_event__process_event_update,
2684 .tracing_data = perf_event__process_tracing_data, 2690 .tracing_data = perf_event__process_tracing_data,
2691 .feature = perf_event__process_feature,
2685 .build_id = perf_event__process_build_id, 2692 .build_id = perf_event__process_build_id,
2686 .id_index = perf_event__process_id_index, 2693 .id_index = perf_event__process_id_index,
2687 .auxtrace_info = perf_event__process_auxtrace_info, 2694 .auxtrace_info = perf_event__process_auxtrace_info,
@@ -2733,7 +2740,7 @@ int cmd_script(int argc, const char **argv)
2733 "Valid types: hw,sw,trace,raw,synth. " 2740 "Valid types: hw,sw,trace,raw,synth. "
2734 "Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso," 2741 "Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso,"
2735 "addr,symoff,period,iregs,brstack,brstacksym,flags," 2742 "addr,symoff,period,iregs,brstack,brstacksym,flags,"
2736 "bpf-output,callindent,insn,insnlen,brstackinsn,synth", 2743 "bpf-output,callindent,insn,insnlen,brstackinsn,synth,phys_addr",
2737 parse_output_fields), 2744 parse_output_fields),
2738 OPT_BOOLEAN('a', "all-cpus", &system_wide, 2745 OPT_BOOLEAN('a', "all-cpus", &system_wide,
2739 "system-wide collection from all CPUs"), 2746 "system-wide collection from all CPUs"),
@@ -2972,10 +2979,13 @@ int cmd_script(int argc, const char **argv)
2972 return -1; 2979 return -1;
2973 2980
2974 if (header || header_only) { 2981 if (header || header_only) {
2982 script.tool.show_feat_hdr = SHOW_FEAT_HEADER;
2975 perf_session__fprintf_info(session, stdout, show_full_info); 2983 perf_session__fprintf_info(session, stdout, show_full_info);
2976 if (header_only) 2984 if (header_only)
2977 goto out_delete; 2985 goto out_delete;
2978 } 2986 }
2987 if (show_full_info)
2988 script.tool.show_feat_hdr = SHOW_FEAT_HEADER_FULL_INFO;
2979 2989
2980 if (symbol__init(&session->header.env) < 0) 2990 if (symbol__init(&session->header.env) < 0)
2981 goto out_delete; 2991 goto out_delete;
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 48ac53b199fc..69523ed55894 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -213,10 +213,20 @@ static void perf_stat__reset_stats(void)
213static int create_perf_stat_counter(struct perf_evsel *evsel) 213static int create_perf_stat_counter(struct perf_evsel *evsel)
214{ 214{
215 struct perf_event_attr *attr = &evsel->attr; 215 struct perf_event_attr *attr = &evsel->attr;
216 struct perf_evsel *leader = evsel->leader;
216 217
217 if (stat_config.scale) 218 if (stat_config.scale) {
218 attr->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED | 219 attr->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED |
219 PERF_FORMAT_TOTAL_TIME_RUNNING; 220 PERF_FORMAT_TOTAL_TIME_RUNNING;
221 }
222
223 /*
224 * The event is part of non trivial group, let's enable
225 * the group read (for leader) and ID retrieval for all
226 * members.
227 */
228 if (leader->nr_members > 1)
229 attr->read_format |= PERF_FORMAT_ID|PERF_FORMAT_GROUP;
220 230
221 attr->inherit = !no_inherit; 231 attr->inherit = !no_inherit;
222 232
@@ -333,13 +343,21 @@ static int read_counter(struct perf_evsel *counter)
333 struct perf_counts_values *count; 343 struct perf_counts_values *count;
334 344
335 count = perf_counts(counter->counts, cpu, thread); 345 count = perf_counts(counter->counts, cpu, thread);
336 if (perf_evsel__read(counter, cpu, thread, count)) { 346
347 /*
348 * The leader's group read loads data into its group members
349 * (via perf_evsel__read_counter) and sets threir count->loaded.
350 */
351 if (!count->loaded &&
352 perf_evsel__read_counter(counter, cpu, thread)) {
337 counter->counts->scaled = -1; 353 counter->counts->scaled = -1;
338 perf_counts(counter->counts, cpu, thread)->ena = 0; 354 perf_counts(counter->counts, cpu, thread)->ena = 0;
339 perf_counts(counter->counts, cpu, thread)->run = 0; 355 perf_counts(counter->counts, cpu, thread)->run = 0;
340 return -1; 356 return -1;
341 } 357 }
342 358
359 count->loaded = false;
360
343 if (STAT_RECORD) { 361 if (STAT_RECORD) {
344 if (perf_evsel__write_stat_event(counter, cpu, thread, count)) { 362 if (perf_evsel__write_stat_event(counter, cpu, thread, count)) {
345 pr_err("failed to write stat event\n"); 363 pr_err("failed to write stat event\n");
@@ -559,6 +577,11 @@ static int store_counter_ids(struct perf_evsel *counter)
559 return __store_counter_ids(counter, cpus, threads); 577 return __store_counter_ids(counter, cpus, threads);
560} 578}
561 579
580static bool perf_evsel__should_store_id(struct perf_evsel *counter)
581{
582 return STAT_RECORD || counter->attr.read_format & PERF_FORMAT_ID;
583}
584
562static int __run_perf_stat(int argc, const char **argv) 585static int __run_perf_stat(int argc, const char **argv)
563{ 586{
564 int interval = stat_config.interval; 587 int interval = stat_config.interval;
@@ -631,7 +654,8 @@ try_again:
631 if (l > unit_width) 654 if (l > unit_width)
632 unit_width = l; 655 unit_width = l;
633 656
634 if (STAT_RECORD && store_counter_ids(counter)) 657 if (perf_evsel__should_store_id(counter) &&
658 store_counter_ids(counter))
635 return -1; 659 return -1;
636 } 660 }
637 661
@@ -683,7 +707,7 @@ try_again:
683 process_interval(); 707 process_interval();
684 } 708 }
685 } 709 }
686 wait(&status); 710 waitpid(child_pid, &status, 0);
687 711
688 if (workload_exec_errno) { 712 if (workload_exec_errno) {
689 const char *emsg = str_error_r(workload_exec_errno, msg, sizeof(msg)); 713 const char *emsg = str_error_r(workload_exec_errno, msg, sizeof(msg));
@@ -1233,7 +1257,7 @@ static bool collect_data(struct perf_evsel *counter,
1233 if (counter->merged_stat) 1257 if (counter->merged_stat)
1234 return false; 1258 return false;
1235 cb(counter, data, true); 1259 cb(counter, data, true);
1236 if (!no_merge) 1260 if (!no_merge && counter->auto_merge_stats)
1237 collect_all_aliases(counter, cb, data); 1261 collect_all_aliases(counter, cb, data);
1238 return true; 1262 return true;
1239} 1263}
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 6052376634c0..ee954bde7e3e 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -134,7 +134,7 @@ static int perf_top__parse_source(struct perf_top *top, struct hist_entry *he)
134 return err; 134 return err;
135 } 135 }
136 136
137 err = symbol__disassemble(sym, map, NULL, 0, NULL); 137 err = symbol__disassemble(sym, map, NULL, 0, NULL, NULL);
138 if (err == 0) { 138 if (err == 0) {
139out_assign: 139out_assign:
140 top->sym_filter_entry = he; 140 top->sym_filter_entry = he;
@@ -183,6 +183,7 @@ static void ui__warn_map_erange(struct map *map, struct symbol *sym, u64 ip)
183 183
184static void perf_top__record_precise_ip(struct perf_top *top, 184static void perf_top__record_precise_ip(struct perf_top *top,
185 struct hist_entry *he, 185 struct hist_entry *he,
186 struct perf_sample *sample,
186 int counter, u64 ip) 187 int counter, u64 ip)
187{ 188{
188 struct annotation *notes; 189 struct annotation *notes;
@@ -199,7 +200,7 @@ static void perf_top__record_precise_ip(struct perf_top *top,
199 if (pthread_mutex_trylock(&notes->lock)) 200 if (pthread_mutex_trylock(&notes->lock))
200 return; 201 return;
201 202
202 err = hist_entry__inc_addr_samples(he, counter, ip); 203 err = hist_entry__inc_addr_samples(he, sample, counter, ip);
203 204
204 pthread_mutex_unlock(&notes->lock); 205 pthread_mutex_unlock(&notes->lock);
205 206
@@ -586,6 +587,13 @@ static void *display_thread_tui(void *arg)
586 .refresh = top->delay_secs, 587 .refresh = top->delay_secs,
587 }; 588 };
588 589
590 /* In order to read symbols from other namespaces perf to needs to call
591 * setns(2). This isn't permitted if the struct_fs has multiple users.
592 * unshare(2) the fs so that we may continue to setns into namespaces
593 * that we're observing.
594 */
595 unshare(CLONE_FS);
596
589 perf_top__sort_new_samples(top); 597 perf_top__sort_new_samples(top);
590 598
591 /* 599 /*
@@ -627,6 +635,13 @@ static void *display_thread(void *arg)
627 struct perf_top *top = arg; 635 struct perf_top *top = arg;
628 int delay_msecs, c; 636 int delay_msecs, c;
629 637
638 /* In order to read symbols from other namespaces perf to needs to call
639 * setns(2). This isn't permitted if the struct_fs has multiple users.
640 * unshare(2) the fs so that we may continue to setns into namespaces
641 * that we're observing.
642 */
643 unshare(CLONE_FS);
644
630 display_setup_sig(); 645 display_setup_sig();
631 pthread__unblock_sigwinch(); 646 pthread__unblock_sigwinch();
632repeat: 647repeat:
@@ -671,7 +686,7 @@ static int hist_iter__top_callback(struct hist_entry_iter *iter,
671 struct perf_evsel *evsel = iter->evsel; 686 struct perf_evsel *evsel = iter->evsel;
672 687
673 if (perf_hpp_list.sym && single) 688 if (perf_hpp_list.sym && single)
674 perf_top__record_precise_ip(top, he, evsel->idx, al->addr); 689 perf_top__record_precise_ip(top, he, iter->sample, evsel->idx, al->addr);
675 690
676 hist__account_cycles(iter->sample->branch_stack, al, iter->sample, 691 hist__account_cycles(iter->sample->branch_stack, al, iter->sample,
677 !(top->record_opts.branch_stack & PERF_SAMPLE_BRANCH_ANY)); 692 !(top->record_opts.branch_stack & PERF_SAMPLE_BRANCH_ANY));
@@ -1205,6 +1220,7 @@ int cmd_top(int argc, const char **argv)
1205 "Show raw trace event output (do not use print fmt or plugins)"), 1220 "Show raw trace event output (do not use print fmt or plugins)"),
1206 OPT_BOOLEAN(0, "hierarchy", &symbol_conf.report_hierarchy, 1221 OPT_BOOLEAN(0, "hierarchy", &symbol_conf.report_hierarchy,
1207 "Show entries in a hierarchy"), 1222 "Show entries in a hierarchy"),
1223 OPT_BOOLEAN(0, "force", &symbol_conf.force, "don't complain, do it"),
1208 OPT_END() 1224 OPT_END()
1209 }; 1225 };
1210 const char * const top_usage[] = { 1226 const char * const top_usage[] = {
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 4b2a5d298197..771ddab94bb0 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -64,6 +64,10 @@
64# define O_CLOEXEC 02000000 64# define O_CLOEXEC 02000000
65#endif 65#endif
66 66
67#ifndef F_LINUX_SPECIFIC_BASE
68# define F_LINUX_SPECIFIC_BASE 1024
69#endif
70
67struct trace { 71struct trace {
68 struct perf_tool tool; 72 struct perf_tool tool;
69 struct syscalltbl *sctbl; 73 struct syscalltbl *sctbl;
@@ -279,34 +283,21 @@ out_delete:
279 ({ struct syscall_tp *fields = evsel->priv; \ 283 ({ struct syscall_tp *fields = evsel->priv; \
280 fields->name.pointer(&fields->name, sample); }) 284 fields->name.pointer(&fields->name, sample); })
281 285
282struct strarray { 286size_t strarray__scnprintf(struct strarray *sa, char *bf, size_t size, const char *intfmt, int val)
283 int offset; 287{
284 int nr_entries; 288 int idx = val - sa->offset;
285 const char **entries;
286};
287 289
288#define DEFINE_STRARRAY(array) struct strarray strarray__##array = { \ 290 if (idx < 0 || idx >= sa->nr_entries)
289 .nr_entries = ARRAY_SIZE(array), \ 291 return scnprintf(bf, size, intfmt, val);
290 .entries = array, \
291}
292 292
293#define DEFINE_STRARRAY_OFFSET(array, off) struct strarray strarray__##array = { \ 293 return scnprintf(bf, size, "%s", sa->entries[idx]);
294 .offset = off, \
295 .nr_entries = ARRAY_SIZE(array), \
296 .entries = array, \
297} 294}
298 295
299static size_t __syscall_arg__scnprintf_strarray(char *bf, size_t size, 296static size_t __syscall_arg__scnprintf_strarray(char *bf, size_t size,
300 const char *intfmt, 297 const char *intfmt,
301 struct syscall_arg *arg) 298 struct syscall_arg *arg)
302{ 299{
303 struct strarray *sa = arg->parm; 300 return strarray__scnprintf(arg->parm, bf, size, intfmt, arg->val);
304 int idx = arg->val - sa->offset;
305
306 if (idx < 0 || idx >= sa->nr_entries)
307 return scnprintf(bf, size, intfmt, arg->val);
308
309 return scnprintf(bf, size, "%s", sa->entries[idx]);
310} 301}
311 302
312static size_t syscall_arg__scnprintf_strarray(char *bf, size_t size, 303static size_t syscall_arg__scnprintf_strarray(char *bf, size_t size,
@@ -317,24 +308,35 @@ static size_t syscall_arg__scnprintf_strarray(char *bf, size_t size,
317 308
318#define SCA_STRARRAY syscall_arg__scnprintf_strarray 309#define SCA_STRARRAY syscall_arg__scnprintf_strarray
319 310
320#if defined(__i386__) || defined(__x86_64__) 311struct strarrays {
321/* 312 int nr_entries;
322 * FIXME: Make this available to all arches as soon as the ioctl beautifier 313 struct strarray **entries;
323 * gets rewritten to support all arches. 314};
324 */ 315
325static size_t syscall_arg__scnprintf_strhexarray(char *bf, size_t size, 316#define DEFINE_STRARRAYS(array) struct strarrays strarrays__##array = { \
326 struct syscall_arg *arg) 317 .nr_entries = ARRAY_SIZE(array), \
327{ 318 .entries = array, \
328 return __syscall_arg__scnprintf_strarray(bf, size, "%#x", arg);
329} 319}
330 320
331#define SCA_STRHEXARRAY syscall_arg__scnprintf_strhexarray 321size_t syscall_arg__scnprintf_strarrays(char *bf, size_t size,
332#endif /* defined(__i386__) || defined(__x86_64__) */ 322 struct syscall_arg *arg)
323{
324 struct strarrays *sas = arg->parm;
325 int i;
333 326
334static size_t syscall_arg__scnprintf_fd(char *bf, size_t size, 327 for (i = 0; i < sas->nr_entries; ++i) {
335 struct syscall_arg *arg); 328 struct strarray *sa = sas->entries[i];
329 int idx = arg->val - sa->offset;
336 330
337#define SCA_FD syscall_arg__scnprintf_fd 331 if (idx >= 0 && idx < sa->nr_entries) {
332 if (sa->entries[idx] == NULL)
333 break;
334 return scnprintf(bf, size, "%s", sa->entries[idx]);
335 }
336 }
337
338 return scnprintf(bf, size, "%d", arg->val);
339}
338 340
339#ifndef AT_FDCWD 341#ifndef AT_FDCWD
340#define AT_FDCWD -100 342#define AT_FDCWD -100
@@ -358,21 +360,20 @@ static size_t syscall_arg__scnprintf_close_fd(char *bf, size_t size,
358 360
359#define SCA_CLOSE_FD syscall_arg__scnprintf_close_fd 361#define SCA_CLOSE_FD syscall_arg__scnprintf_close_fd
360 362
361static size_t syscall_arg__scnprintf_hex(char *bf, size_t size, 363size_t syscall_arg__scnprintf_hex(char *bf, size_t size, struct syscall_arg *arg)
362 struct syscall_arg *arg)
363{ 364{
364 return scnprintf(bf, size, "%#lx", arg->val); 365 return scnprintf(bf, size, "%#lx", arg->val);
365} 366}
366 367
367#define SCA_HEX syscall_arg__scnprintf_hex 368size_t syscall_arg__scnprintf_int(char *bf, size_t size, struct syscall_arg *arg)
368
369static size_t syscall_arg__scnprintf_int(char *bf, size_t size,
370 struct syscall_arg *arg)
371{ 369{
372 return scnprintf(bf, size, "%d", arg->val); 370 return scnprintf(bf, size, "%d", arg->val);
373} 371}
374 372
375#define SCA_INT syscall_arg__scnprintf_int 373size_t syscall_arg__scnprintf_long(char *bf, size_t size, struct syscall_arg *arg)
374{
375 return scnprintf(bf, size, "%ld", arg->val);
376}
376 377
377static const char *bpf_cmd[] = { 378static const char *bpf_cmd[] = {
378 "MAP_CREATE", "MAP_LOOKUP_ELEM", "MAP_UPDATE_ELEM", "MAP_DELETE_ELEM", 379 "MAP_CREATE", "MAP_LOOKUP_ELEM", "MAP_UPDATE_ELEM", "MAP_DELETE_ELEM",
@@ -407,12 +408,27 @@ static DEFINE_STRARRAY(whences);
407 408
408static const char *fcntl_cmds[] = { 409static const char *fcntl_cmds[] = {
409 "DUPFD", "GETFD", "SETFD", "GETFL", "SETFL", "GETLK", "SETLK", 410 "DUPFD", "GETFD", "SETFD", "GETFL", "SETFL", "GETLK", "SETLK",
410 "SETLKW", "SETOWN", "GETOWN", "SETSIG", "GETSIG", "F_GETLK64", 411 "SETLKW", "SETOWN", "GETOWN", "SETSIG", "GETSIG", "GETLK64",
411 "F_SETLK64", "F_SETLKW64", "F_SETOWN_EX", "F_GETOWN_EX", 412 "SETLK64", "SETLKW64", "SETOWN_EX", "GETOWN_EX",
412 "F_GETOWNER_UIDS", 413 "GETOWNER_UIDS",
413}; 414};
414static DEFINE_STRARRAY(fcntl_cmds); 415static DEFINE_STRARRAY(fcntl_cmds);
415 416
417static const char *fcntl_linux_specific_cmds[] = {
418 "SETLEASE", "GETLEASE", "NOTIFY", [5] = "CANCELLK", "DUPFD_CLOEXEC",
419 "SETPIPE_SZ", "GETPIPE_SZ", "ADD_SEALS", "GET_SEALS",
420 "GET_RW_HINT", "SET_RW_HINT", "GET_FILE_RW_HINT", "SET_FILE_RW_HINT",
421};
422
423static DEFINE_STRARRAY_OFFSET(fcntl_linux_specific_cmds, F_LINUX_SPECIFIC_BASE);
424
425static struct strarray *fcntl_cmds_arrays[] = {
426 &strarray__fcntl_cmds,
427 &strarray__fcntl_linux_specific_cmds,
428};
429
430static DEFINE_STRARRAYS(fcntl_cmds_arrays);
431
416static const char *rlimit_resources[] = { 432static const char *rlimit_resources[] = {
417 "CPU", "FSIZE", "DATA", "STACK", "CORE", "RSS", "NPROC", "NOFILE", 433 "CPU", "FSIZE", "DATA", "STACK", "CORE", "RSS", "NPROC", "NOFILE",
418 "MEMLOCK", "AS", "LOCKS", "SIGPENDING", "MSGQUEUE", "NICE", "RTPRIO", 434 "MEMLOCK", "AS", "LOCKS", "SIGPENDING", "MSGQUEUE", "NICE", "RTPRIO",
@@ -495,33 +511,6 @@ static size_t syscall_arg__scnprintf_pipe_flags(char *bf, size_t size,
495 511
496#define SCA_PIPE_FLAGS syscall_arg__scnprintf_pipe_flags 512#define SCA_PIPE_FLAGS syscall_arg__scnprintf_pipe_flags
497 513
498#if defined(__i386__) || defined(__x86_64__)
499/*
500 * FIXME: Make this available to all arches.
501 */
502#define TCGETS 0x5401
503
504static const char *tioctls[] = {
505 "TCGETS", "TCSETS", "TCSETSW", "TCSETSF", "TCGETA", "TCSETA", "TCSETAW",
506 "TCSETAF", "TCSBRK", "TCXONC", "TCFLSH", "TIOCEXCL", "TIOCNXCL",
507 "TIOCSCTTY", "TIOCGPGRP", "TIOCSPGRP", "TIOCOUTQ", "TIOCSTI",
508 "TIOCGWINSZ", "TIOCSWINSZ", "TIOCMGET", "TIOCMBIS", "TIOCMBIC",
509 "TIOCMSET", "TIOCGSOFTCAR", "TIOCSSOFTCAR", "FIONREAD", "TIOCLINUX",
510 "TIOCCONS", "TIOCGSERIAL", "TIOCSSERIAL", "TIOCPKT", "FIONBIO",
511 "TIOCNOTTY", "TIOCSETD", "TIOCGETD", "TCSBRKP", [0x27] = "TIOCSBRK",
512 "TIOCCBRK", "TIOCGSID", "TCGETS2", "TCSETS2", "TCSETSW2", "TCSETSF2",
513 "TIOCGRS485", "TIOCSRS485", "TIOCGPTN", "TIOCSPTLCK",
514 "TIOCGDEV||TCGETX", "TCSETX", "TCSETXF", "TCSETXW", "TIOCSIG",
515 "TIOCVHANGUP", "TIOCGPKT", "TIOCGPTLCK", "TIOCGEXCL",
516 [0x50] = "FIONCLEX", "FIOCLEX", "FIOASYNC", "TIOCSERCONFIG",
517 "TIOCSERGWILD", "TIOCSERSWILD", "TIOCGLCKTRMIOS", "TIOCSLCKTRMIOS",
518 "TIOCSERGSTRUCT", "TIOCSERGETLSR", "TIOCSERGETMULTI", "TIOCSERSETMULTI",
519 "TIOCMIWAIT", "TIOCGICOUNT", [0x60] = "FIOQSIZE",
520};
521
522static DEFINE_STRARRAY_OFFSET(tioctls, 0x5401);
523#endif /* defined(__i386__) || defined(__x86_64__) */
524
525#ifndef GRND_NONBLOCK 514#ifndef GRND_NONBLOCK
526#define GRND_NONBLOCK 0x0001 515#define GRND_NONBLOCK 0x0001
527#endif 516#endif
@@ -552,9 +541,9 @@ static size_t syscall_arg__scnprintf_getrandom_flags(char *bf, size_t size,
552 541
553#define SCA_GETRANDOM_FLAGS syscall_arg__scnprintf_getrandom_flags 542#define SCA_GETRANDOM_FLAGS syscall_arg__scnprintf_getrandom_flags
554 543
555#define STRARRAY(arg, name, array) \ 544#define STRARRAY(name, array) \
556 .arg_scnprintf = { [arg] = SCA_STRARRAY, }, \ 545 { .scnprintf = SCA_STRARRAY, \
557 .arg_parm = { [arg] = &strarray__##array, } 546 .parm = &strarray__##array, }
558 547
559#include "trace/beauty/eventfd.c" 548#include "trace/beauty/eventfd.c"
560#include "trace/beauty/flock.c" 549#include "trace/beauty/flock.c"
@@ -571,242 +560,219 @@ static size_t syscall_arg__scnprintf_getrandom_flags(char *bf, size_t size,
571#include "trace/beauty/socket_type.c" 560#include "trace/beauty/socket_type.c"
572#include "trace/beauty/waitid_options.c" 561#include "trace/beauty/waitid_options.c"
573 562
563struct syscall_arg_fmt {
564 size_t (*scnprintf)(char *bf, size_t size, struct syscall_arg *arg);
565 void *parm;
566 const char *name;
567 bool show_zero;
568};
569
574static struct syscall_fmt { 570static struct syscall_fmt {
575 const char *name; 571 const char *name;
576 const char *alias; 572 const char *alias;
577 size_t (*arg_scnprintf[6])(char *bf, size_t size, struct syscall_arg *arg); 573 struct syscall_arg_fmt arg[6];
578 void *arg_parm[6]; 574 u8 nr_args;
579 bool errmsg;
580 bool errpid; 575 bool errpid;
581 bool timeout; 576 bool timeout;
582 bool hexret; 577 bool hexret;
583} syscall_fmts[] = { 578} syscall_fmts[] = {
584 { .name = "access", .errmsg = true, 579 { .name = "access",
585 .arg_scnprintf = { [1] = SCA_ACCMODE, /* mode */ }, }, 580 .arg = { [1] = { .scnprintf = SCA_ACCMODE, /* mode */ }, }, },
586 { .name = "arch_prctl", .errmsg = true, .alias = "prctl", }, 581 { .name = "arch_prctl", .alias = "prctl", },
587 { .name = "bpf", .errmsg = true, STRARRAY(0, cmd, bpf_cmd), }, 582 { .name = "bpf",
583 .arg = { [0] = STRARRAY(cmd, bpf_cmd), }, },
588 { .name = "brk", .hexret = true, 584 { .name = "brk", .hexret = true,
589 .arg_scnprintf = { [0] = SCA_HEX, /* brk */ }, }, 585 .arg = { [0] = { .scnprintf = SCA_HEX, /* brk */ }, }, },
590 { .name = "chdir", .errmsg = true, }, 586 { .name = "clock_gettime",
591 { .name = "chmod", .errmsg = true, }, 587 .arg = { [0] = STRARRAY(clk_id, clockid), }, },
592 { .name = "chroot", .errmsg = true, }, 588 { .name = "clone", .errpid = true, .nr_args = 5,
593 { .name = "clock_gettime", .errmsg = true, STRARRAY(0, clk_id, clockid), }, 589 .arg = { [0] = { .name = "flags", .scnprintf = SCA_CLONE_FLAGS, },
594 { .name = "clone", .errpid = true, }, 590 [1] = { .name = "child_stack", .scnprintf = SCA_HEX, },
595 { .name = "close", .errmsg = true, 591 [2] = { .name = "parent_tidptr", .scnprintf = SCA_HEX, },
596 .arg_scnprintf = { [0] = SCA_CLOSE_FD, /* fd */ }, }, 592 [3] = { .name = "child_tidptr", .scnprintf = SCA_HEX, },
597 { .name = "connect", .errmsg = true, }, 593 [4] = { .name = "tls", .scnprintf = SCA_HEX, }, }, },
598 { .name = "creat", .errmsg = true, }, 594 { .name = "close",
599 { .name = "dup", .errmsg = true, }, 595 .arg = { [0] = { .scnprintf = SCA_CLOSE_FD, /* fd */ }, }, },
600 { .name = "dup2", .errmsg = true, }, 596 { .name = "epoll_ctl",
601 { .name = "dup3", .errmsg = true, }, 597 .arg = { [1] = STRARRAY(op, epoll_ctl_ops), }, },
602 { .name = "epoll_ctl", .errmsg = true, STRARRAY(1, op, epoll_ctl_ops), }, 598 { .name = "eventfd2",
603 { .name = "eventfd2", .errmsg = true, 599 .arg = { [1] = { .scnprintf = SCA_EFD_FLAGS, /* flags */ }, }, },
604 .arg_scnprintf = { [1] = SCA_EFD_FLAGS, /* flags */ }, }, 600 { .name = "fchmodat",
605 { .name = "faccessat", .errmsg = true, }, 601 .arg = { [0] = { .scnprintf = SCA_FDAT, /* fd */ }, }, },
606 { .name = "fadvise64", .errmsg = true, }, 602 { .name = "fchownat",
607 { .name = "fallocate", .errmsg = true, }, 603 .arg = { [0] = { .scnprintf = SCA_FDAT, /* fd */ }, }, },
608 { .name = "fchdir", .errmsg = true, }, 604 { .name = "fcntl",
609 { .name = "fchmod", .errmsg = true, }, 605 .arg = { [1] = { .scnprintf = SCA_FCNTL_CMD, /* cmd */
610 { .name = "fchmodat", .errmsg = true, 606 .parm = &strarrays__fcntl_cmds_arrays,
611 .arg_scnprintf = { [0] = SCA_FDAT, /* fd */ }, }, 607 .show_zero = true, },
612 { .name = "fchown", .errmsg = true, }, 608 [2] = { .scnprintf = SCA_FCNTL_ARG, /* arg */ }, }, },
613 { .name = "fchownat", .errmsg = true, 609 { .name = "flock",
614 .arg_scnprintf = { [0] = SCA_FDAT, /* fd */ }, }, 610 .arg = { [1] = { .scnprintf = SCA_FLOCK, /* cmd */ }, }, },
615 { .name = "fcntl", .errmsg = true, 611 { .name = "fstat", .alias = "newfstat", },
616 .arg_scnprintf = { [1] = SCA_STRARRAY, /* cmd */ }, 612 { .name = "fstatat", .alias = "newfstatat", },
617 .arg_parm = { [1] = &strarray__fcntl_cmds, /* cmd */ }, }, 613 { .name = "futex",
618 { .name = "fdatasync", .errmsg = true, }, 614 .arg = { [1] = { .scnprintf = SCA_FUTEX_OP, /* op */ }, }, },
619 { .name = "flock", .errmsg = true, 615 { .name = "futimesat",
620 .arg_scnprintf = { [1] = SCA_FLOCK, /* cmd */ }, }, 616 .arg = { [0] = { .scnprintf = SCA_FDAT, /* fd */ }, }, },
621 { .name = "fsetxattr", .errmsg = true, }, 617 { .name = "getitimer",
622 { .name = "fstat", .errmsg = true, .alias = "newfstat", }, 618 .arg = { [0] = STRARRAY(which, itimers), }, },
623 { .name = "fstatat", .errmsg = true, .alias = "newfstatat", },
624 { .name = "fstatfs", .errmsg = true, },
625 { .name = "fsync", .errmsg = true, },
626 { .name = "ftruncate", .errmsg = true, },
627 { .name = "futex", .errmsg = true,
628 .arg_scnprintf = { [1] = SCA_FUTEX_OP, /* op */ }, },
629 { .name = "futimesat", .errmsg = true,
630 .arg_scnprintf = { [0] = SCA_FDAT, /* fd */ }, },
631 { .name = "getdents", .errmsg = true, },
632 { .name = "getdents64", .errmsg = true, },
633 { .name = "getitimer", .errmsg = true, STRARRAY(0, which, itimers), },
634 { .name = "getpid", .errpid = true, }, 619 { .name = "getpid", .errpid = true, },
635 { .name = "getpgid", .errpid = true, }, 620 { .name = "getpgid", .errpid = true, },
636 { .name = "getppid", .errpid = true, }, 621 { .name = "getppid", .errpid = true, },
637 { .name = "getrandom", .errmsg = true, 622 { .name = "getrandom",
638 .arg_scnprintf = { [2] = SCA_GETRANDOM_FLAGS, /* flags */ }, }, 623 .arg = { [2] = { .scnprintf = SCA_GETRANDOM_FLAGS, /* flags */ }, }, },
639 { .name = "getrlimit", .errmsg = true, STRARRAY(0, resource, rlimit_resources), }, 624 { .name = "getrlimit",
640 { .name = "getxattr", .errmsg = true, }, 625 .arg = { [0] = STRARRAY(resource, rlimit_resources), }, },
641 { .name = "inotify_add_watch", .errmsg = true, }, 626 { .name = "ioctl",
642 { .name = "ioctl", .errmsg = true, 627 .arg = {
643 .arg_scnprintf = {
644#if defined(__i386__) || defined(__x86_64__) 628#if defined(__i386__) || defined(__x86_64__)
645/* 629/*
646 * FIXME: Make this available to all arches. 630 * FIXME: Make this available to all arches.
647 */ 631 */
648 [1] = SCA_STRHEXARRAY, /* cmd */ 632 [1] = { .scnprintf = SCA_IOCTL_CMD, /* cmd */ },
649 [2] = SCA_HEX, /* arg */ }, 633 [2] = { .scnprintf = SCA_HEX, /* arg */ }, }, },
650 .arg_parm = { [1] = &strarray__tioctls, /* cmd */ }, },
651#else 634#else
652 [2] = SCA_HEX, /* arg */ }, }, 635 [2] = { .scnprintf = SCA_HEX, /* arg */ }, }, },
653#endif 636#endif
654 { .name = "keyctl", .errmsg = true, STRARRAY(0, option, keyctl_options), }, 637 { .name = "keyctl",
655 { .name = "kill", .errmsg = true, 638 .arg = { [0] = STRARRAY(option, keyctl_options), }, },
656 .arg_scnprintf = { [1] = SCA_SIGNUM, /* sig */ }, }, 639 { .name = "kill",
657 { .name = "lchown", .errmsg = true, }, 640 .arg = { [1] = { .scnprintf = SCA_SIGNUM, /* sig */ }, }, },
658 { .name = "lgetxattr", .errmsg = true, }, 641 { .name = "linkat",
659 { .name = "linkat", .errmsg = true, 642 .arg = { [0] = { .scnprintf = SCA_FDAT, /* fd */ }, }, },
660 .arg_scnprintf = { [0] = SCA_FDAT, /* fd */ }, }, 643 { .name = "lseek",
661 { .name = "listxattr", .errmsg = true, }, 644 .arg = { [2] = STRARRAY(whence, whences), }, },
662 { .name = "llistxattr", .errmsg = true, }, 645 { .name = "lstat", .alias = "newlstat", },
663 { .name = "lremovexattr", .errmsg = true, }, 646 { .name = "madvise",
664 { .name = "lseek", .errmsg = true, 647 .arg = { [0] = { .scnprintf = SCA_HEX, /* start */ },
665 .arg_scnprintf = { [2] = SCA_STRARRAY, /* whence */ }, 648 [2] = { .scnprintf = SCA_MADV_BHV, /* behavior */ }, }, },
666 .arg_parm = { [2] = &strarray__whences, /* whence */ }, }, 649 { .name = "mkdirat",
667 { .name = "lsetxattr", .errmsg = true, }, 650 .arg = { [0] = { .scnprintf = SCA_FDAT, /* fd */ }, }, },
668 { .name = "lstat", .errmsg = true, .alias = "newlstat", }, 651 { .name = "mknodat",
669 { .name = "lsxattr", .errmsg = true, }, 652 .arg = { [0] = { .scnprintf = SCA_FDAT, /* fd */ }, }, },
670 { .name = "madvise", .errmsg = true, 653 { .name = "mlock",
671 .arg_scnprintf = { [0] = SCA_HEX, /* start */ 654 .arg = { [0] = { .scnprintf = SCA_HEX, /* addr */ }, }, },
672 [2] = SCA_MADV_BHV, /* behavior */ }, }, 655 { .name = "mlockall",
673 { .name = "mkdir", .errmsg = true, }, 656 .arg = { [0] = { .scnprintf = SCA_HEX, /* addr */ }, }, },
674 { .name = "mkdirat", .errmsg = true,
675 .arg_scnprintf = { [0] = SCA_FDAT, /* fd */ }, },
676 { .name = "mknod", .errmsg = true, },
677 { .name = "mknodat", .errmsg = true,
678 .arg_scnprintf = { [0] = SCA_FDAT, /* fd */ }, },
679 { .name = "mlock", .errmsg = true,
680 .arg_scnprintf = { [0] = SCA_HEX, /* addr */ }, },
681 { .name = "mlockall", .errmsg = true,
682 .arg_scnprintf = { [0] = SCA_HEX, /* addr */ }, },
683 { .name = "mmap", .hexret = true, 657 { .name = "mmap", .hexret = true,
684/* The standard mmap maps to old_mmap on s390x */ 658/* The standard mmap maps to old_mmap on s390x */
685#if defined(__s390x__) 659#if defined(__s390x__)
686 .alias = "old_mmap", 660 .alias = "old_mmap",
687#endif 661#endif
688 .arg_scnprintf = { [0] = SCA_HEX, /* addr */ 662 .arg = { [0] = { .scnprintf = SCA_HEX, /* addr */ },
689 [2] = SCA_MMAP_PROT, /* prot */ 663 [2] = { .scnprintf = SCA_MMAP_PROT, /* prot */ },
690 [3] = SCA_MMAP_FLAGS, /* flags */ }, }, 664 [3] = { .scnprintf = SCA_MMAP_FLAGS, /* flags */ }, }, },
691 { .name = "mprotect", .errmsg = true, 665 { .name = "mprotect",
692 .arg_scnprintf = { [0] = SCA_HEX, /* start */ 666 .arg = { [0] = { .scnprintf = SCA_HEX, /* start */ },
693 [2] = SCA_MMAP_PROT, /* prot */ }, }, 667 [2] = { .scnprintf = SCA_MMAP_PROT, /* prot */ }, }, },
694 { .name = "mq_unlink", .errmsg = true, 668 { .name = "mq_unlink",
695 .arg_scnprintf = { [0] = SCA_FILENAME, /* u_name */ }, }, 669 .arg = { [0] = { .scnprintf = SCA_FILENAME, /* u_name */ }, }, },
696 { .name = "mremap", .hexret = true, 670 { .name = "mremap", .hexret = true,
697 .arg_scnprintf = { [0] = SCA_HEX, /* addr */ 671 .arg = { [0] = { .scnprintf = SCA_HEX, /* addr */ },
698 [3] = SCA_MREMAP_FLAGS, /* flags */ 672 [3] = { .scnprintf = SCA_MREMAP_FLAGS, /* flags */ },
699 [4] = SCA_HEX, /* new_addr */ }, }, 673 [4] = { .scnprintf = SCA_HEX, /* new_addr */ }, }, },
700 { .name = "munlock", .errmsg = true, 674 { .name = "munlock",
701 .arg_scnprintf = { [0] = SCA_HEX, /* addr */ }, }, 675 .arg = { [0] = { .scnprintf = SCA_HEX, /* addr */ }, }, },
702 { .name = "munmap", .errmsg = true, 676 { .name = "munmap",
703 .arg_scnprintf = { [0] = SCA_HEX, /* addr */ }, }, 677 .arg = { [0] = { .scnprintf = SCA_HEX, /* addr */ }, }, },
704 { .name = "name_to_handle_at", .errmsg = true, 678 { .name = "name_to_handle_at",
705 .arg_scnprintf = { [0] = SCA_FDAT, /* dfd */ }, }, 679 .arg = { [0] = { .scnprintf = SCA_FDAT, /* dfd */ }, }, },
706 { .name = "newfstatat", .errmsg = true, 680 { .name = "newfstatat",
707 .arg_scnprintf = { [0] = SCA_FDAT, /* dfd */ }, }, 681 .arg = { [0] = { .scnprintf = SCA_FDAT, /* dfd */ }, }, },
708 { .name = "open", .errmsg = true, 682 { .name = "open",
709 .arg_scnprintf = { [1] = SCA_OPEN_FLAGS, /* flags */ }, }, 683 .arg = { [1] = { .scnprintf = SCA_OPEN_FLAGS, /* flags */ }, }, },
710 { .name = "open_by_handle_at", .errmsg = true, 684 { .name = "open_by_handle_at",
711 .arg_scnprintf = { [0] = SCA_FDAT, /* dfd */ 685 .arg = { [0] = { .scnprintf = SCA_FDAT, /* dfd */ },
712 [2] = SCA_OPEN_FLAGS, /* flags */ }, }, 686 [2] = { .scnprintf = SCA_OPEN_FLAGS, /* flags */ }, }, },
713 { .name = "openat", .errmsg = true, 687 { .name = "openat",
714 .arg_scnprintf = { [0] = SCA_FDAT, /* dfd */ 688 .arg = { [0] = { .scnprintf = SCA_FDAT, /* dfd */ },
715 [2] = SCA_OPEN_FLAGS, /* flags */ }, }, 689 [2] = { .scnprintf = SCA_OPEN_FLAGS, /* flags */ }, }, },
716 { .name = "perf_event_open", .errmsg = true, 690 { .name = "perf_event_open",
717 .arg_scnprintf = { [2] = SCA_INT, /* cpu */ 691 .arg = { [2] = { .scnprintf = SCA_INT, /* cpu */ },
718 [3] = SCA_FD, /* group_fd */ 692 [3] = { .scnprintf = SCA_FD, /* group_fd */ },
719 [4] = SCA_PERF_FLAGS, /* flags */ }, }, 693 [4] = { .scnprintf = SCA_PERF_FLAGS, /* flags */ }, }, },
720 { .name = "pipe2", .errmsg = true, 694 { .name = "pipe2",
721 .arg_scnprintf = { [1] = SCA_PIPE_FLAGS, /* flags */ }, }, 695 .arg = { [1] = { .scnprintf = SCA_PIPE_FLAGS, /* flags */ }, }, },
722 { .name = "poll", .errmsg = true, .timeout = true, }, 696 { .name = "pkey_alloc",
723 { .name = "ppoll", .errmsg = true, .timeout = true, }, 697 .arg = { [1] = { .scnprintf = SCA_PKEY_ALLOC_ACCESS_RIGHTS, /* access_rights */ }, }, },
724 { .name = "pread", .errmsg = true, .alias = "pread64", }, 698 { .name = "pkey_free",
725 { .name = "preadv", .errmsg = true, .alias = "pread", }, 699 .arg = { [0] = { .scnprintf = SCA_INT, /* key */ }, }, },
726 { .name = "prlimit64", .errmsg = true, STRARRAY(1, resource, rlimit_resources), }, 700 { .name = "pkey_mprotect",
727 { .name = "pwrite", .errmsg = true, .alias = "pwrite64", }, 701 .arg = { [0] = { .scnprintf = SCA_HEX, /* start */ },
728 { .name = "pwritev", .errmsg = true, }, 702 [2] = { .scnprintf = SCA_MMAP_PROT, /* prot */ },
729 { .name = "read", .errmsg = true, }, 703 [3] = { .scnprintf = SCA_INT, /* pkey */ }, }, },
730 { .name = "readlink", .errmsg = true, }, 704 { .name = "poll", .timeout = true, },
731 { .name = "readlinkat", .errmsg = true, 705 { .name = "ppoll", .timeout = true, },
732 .arg_scnprintf = { [0] = SCA_FDAT, /* dfd */ }, }, 706 { .name = "pread", .alias = "pread64", },
733 { .name = "readv", .errmsg = true, }, 707 { .name = "preadv", .alias = "pread", },
734 { .name = "recvfrom", .errmsg = true, 708 { .name = "prlimit64",
735 .arg_scnprintf = { [3] = SCA_MSG_FLAGS, /* flags */ }, }, 709 .arg = { [1] = STRARRAY(resource, rlimit_resources), }, },
736 { .name = "recvmmsg", .errmsg = true, 710 { .name = "pwrite", .alias = "pwrite64", },
737 .arg_scnprintf = { [3] = SCA_MSG_FLAGS, /* flags */ }, }, 711 { .name = "readlinkat",
738 { .name = "recvmsg", .errmsg = true, 712 .arg = { [0] = { .scnprintf = SCA_FDAT, /* dfd */ }, }, },
739 .arg_scnprintf = { [2] = SCA_MSG_FLAGS, /* flags */ }, }, 713 { .name = "recvfrom",
740 { .name = "removexattr", .errmsg = true, }, 714 .arg = { [3] = { .scnprintf = SCA_MSG_FLAGS, /* flags */ }, }, },
741 { .name = "renameat", .errmsg = true, 715 { .name = "recvmmsg",
742 .arg_scnprintf = { [0] = SCA_FDAT, /* dfd */ }, }, 716 .arg = { [3] = { .scnprintf = SCA_MSG_FLAGS, /* flags */ }, }, },
743 { .name = "rmdir", .errmsg = true, }, 717 { .name = "recvmsg",
744 { .name = "rt_sigaction", .errmsg = true, 718 .arg = { [2] = { .scnprintf = SCA_MSG_FLAGS, /* flags */ }, }, },
745 .arg_scnprintf = { [0] = SCA_SIGNUM, /* sig */ }, }, 719 { .name = "renameat",
746 { .name = "rt_sigprocmask", .errmsg = true, STRARRAY(0, how, sighow), }, 720 .arg = { [0] = { .scnprintf = SCA_FDAT, /* dfd */ }, }, },
747 { .name = "rt_sigqueueinfo", .errmsg = true, 721 { .name = "rt_sigaction",
748 .arg_scnprintf = { [1] = SCA_SIGNUM, /* sig */ }, }, 722 .arg = { [0] = { .scnprintf = SCA_SIGNUM, /* sig */ }, }, },
749 { .name = "rt_tgsigqueueinfo", .errmsg = true, 723 { .name = "rt_sigprocmask",
750 .arg_scnprintf = { [2] = SCA_SIGNUM, /* sig */ }, }, 724 .arg = { [0] = STRARRAY(how, sighow), }, },
751 { .name = "sched_getattr", .errmsg = true, }, 725 { .name = "rt_sigqueueinfo",
752 { .name = "sched_setattr", .errmsg = true, }, 726 .arg = { [1] = { .scnprintf = SCA_SIGNUM, /* sig */ }, }, },
753 { .name = "sched_setscheduler", .errmsg = true, 727 { .name = "rt_tgsigqueueinfo",
754 .arg_scnprintf = { [1] = SCA_SCHED_POLICY, /* policy */ }, }, 728 .arg = { [2] = { .scnprintf = SCA_SIGNUM, /* sig */ }, }, },
755 { .name = "seccomp", .errmsg = true, 729 { .name = "sched_setscheduler",
756 .arg_scnprintf = { [0] = SCA_SECCOMP_OP, /* op */ 730 .arg = { [1] = { .scnprintf = SCA_SCHED_POLICY, /* policy */ }, }, },
757 [1] = SCA_SECCOMP_FLAGS, /* flags */ }, }, 731 { .name = "seccomp",
758 { .name = "select", .errmsg = true, .timeout = true, }, 732 .arg = { [0] = { .scnprintf = SCA_SECCOMP_OP, /* op */ },
759 { .name = "sendmmsg", .errmsg = true, 733 [1] = { .scnprintf = SCA_SECCOMP_FLAGS, /* flags */ }, }, },
760 .arg_scnprintf = { [3] = SCA_MSG_FLAGS, /* flags */ }, }, 734 { .name = "select", .timeout = true, },
761 { .name = "sendmsg", .errmsg = true, 735 { .name = "sendmmsg",
762 .arg_scnprintf = { [2] = SCA_MSG_FLAGS, /* flags */ }, }, 736 .arg = { [3] = { .scnprintf = SCA_MSG_FLAGS, /* flags */ }, }, },
763 { .name = "sendto", .errmsg = true, 737 { .name = "sendmsg",
764 .arg_scnprintf = { [3] = SCA_MSG_FLAGS, /* flags */ }, }, 738 .arg = { [2] = { .scnprintf = SCA_MSG_FLAGS, /* flags */ }, }, },
739 { .name = "sendto",
740 .arg = { [3] = { .scnprintf = SCA_MSG_FLAGS, /* flags */ }, }, },
765 { .name = "set_tid_address", .errpid = true, }, 741 { .name = "set_tid_address", .errpid = true, },
766 { .name = "setitimer", .errmsg = true, STRARRAY(0, which, itimers), }, 742 { .name = "setitimer",
767 { .name = "setpgid", .errmsg = true, }, 743 .arg = { [0] = STRARRAY(which, itimers), }, },
768 { .name = "setrlimit", .errmsg = true, STRARRAY(0, resource, rlimit_resources), }, 744 { .name = "setrlimit",
769 { .name = "setxattr", .errmsg = true, }, 745 .arg = { [0] = STRARRAY(resource, rlimit_resources), }, },
770 { .name = "shutdown", .errmsg = true, }, 746 { .name = "socket",
771 { .name = "socket", .errmsg = true, 747 .arg = { [0] = STRARRAY(family, socket_families),
772 .arg_scnprintf = { [0] = SCA_STRARRAY, /* family */ 748 [1] = { .scnprintf = SCA_SK_TYPE, /* type */ }, }, },
773 [1] = SCA_SK_TYPE, /* type */ }, 749 { .name = "socketpair",
774 .arg_parm = { [0] = &strarray__socket_families, /* family */ }, }, 750 .arg = { [0] = STRARRAY(family, socket_families),
775 { .name = "socketpair", .errmsg = true, 751 [1] = { .scnprintf = SCA_SK_TYPE, /* type */ }, }, },
776 .arg_scnprintf = { [0] = SCA_STRARRAY, /* family */ 752 { .name = "stat", .alias = "newstat", },
777 [1] = SCA_SK_TYPE, /* type */ }, 753 { .name = "statx",
778 .arg_parm = { [0] = &strarray__socket_families, /* family */ }, }, 754 .arg = { [0] = { .scnprintf = SCA_FDAT, /* fdat */ },
779 { .name = "stat", .errmsg = true, .alias = "newstat", }, 755 [2] = { .scnprintf = SCA_STATX_FLAGS, /* flags */ } ,
780 { .name = "statfs", .errmsg = true, }, 756 [3] = { .scnprintf = SCA_STATX_MASK, /* mask */ }, }, },
781 { .name = "statx", .errmsg = true, 757 { .name = "swapoff",
782 .arg_scnprintf = { [0] = SCA_FDAT, /* flags */ 758 .arg = { [0] = { .scnprintf = SCA_FILENAME, /* specialfile */ }, }, },
783 [2] = SCA_STATX_FLAGS, /* flags */ 759 { .name = "swapon",
784 [3] = SCA_STATX_MASK, /* mask */ }, }, 760 .arg = { [0] = { .scnprintf = SCA_FILENAME, /* specialfile */ }, }, },
785 { .name = "swapoff", .errmsg = true, 761 { .name = "symlinkat",
786 .arg_scnprintf = { [0] = SCA_FILENAME, /* specialfile */ }, }, 762 .arg = { [0] = { .scnprintf = SCA_FDAT, /* dfd */ }, }, },
787 { .name = "swapon", .errmsg = true, 763 { .name = "tgkill",
788 .arg_scnprintf = { [0] = SCA_FILENAME, /* specialfile */ }, }, 764 .arg = { [2] = { .scnprintf = SCA_SIGNUM, /* sig */ }, }, },
789 { .name = "symlinkat", .errmsg = true, 765 { .name = "tkill",
790 .arg_scnprintf = { [0] = SCA_FDAT, /* dfd */ }, }, 766 .arg = { [1] = { .scnprintf = SCA_SIGNUM, /* sig */ }, }, },
791 { .name = "tgkill", .errmsg = true, 767 { .name = "uname", .alias = "newuname", },
792 .arg_scnprintf = { [2] = SCA_SIGNUM, /* sig */ }, }, 768 { .name = "unlinkat",
793 { .name = "tkill", .errmsg = true, 769 .arg = { [0] = { .scnprintf = SCA_FDAT, /* dfd */ }, }, },
794 .arg_scnprintf = { [1] = SCA_SIGNUM, /* sig */ }, }, 770 { .name = "utimensat",
795 { .name = "truncate", .errmsg = true, }, 771 .arg = { [0] = { .scnprintf = SCA_FDAT, /* dirfd */ }, }, },
796 { .name = "uname", .errmsg = true, .alias = "newuname", },
797 { .name = "unlinkat", .errmsg = true,
798 .arg_scnprintf = { [0] = SCA_FDAT, /* dfd */ }, },
799 { .name = "utime", .errmsg = true, },
800 { .name = "utimensat", .errmsg = true,
801 .arg_scnprintf = { [0] = SCA_FDAT, /* dirfd */ }, },
802 { .name = "utimes", .errmsg = true, },
803 { .name = "vmsplice", .errmsg = true, },
804 { .name = "wait4", .errpid = true, 772 { .name = "wait4", .errpid = true,
805 .arg_scnprintf = { [2] = SCA_WAITID_OPTIONS, /* options */ }, }, 773 .arg = { [2] = { .scnprintf = SCA_WAITID_OPTIONS, /* options */ }, }, },
806 { .name = "waitid", .errpid = true, 774 { .name = "waitid", .errpid = true,
807 .arg_scnprintf = { [3] = SCA_WAITID_OPTIONS, /* options */ }, }, 775 .arg = { [3] = { .scnprintf = SCA_WAITID_OPTIONS, /* options */ }, }, },
808 { .name = "write", .errmsg = true, },
809 { .name = "writev", .errmsg = true, },
810}; 776};
811 777
812static int syscall_fmt__cmp(const void *name, const void *fmtp) 778static int syscall_fmt__cmp(const void *name, const void *fmtp)
@@ -828,8 +794,7 @@ struct syscall {
828 const char *name; 794 const char *name;
829 bool is_exit; 795 bool is_exit;
830 struct syscall_fmt *fmt; 796 struct syscall_fmt *fmt;
831 size_t (**arg_scnprintf)(char *bf, size_t size, struct syscall_arg *arg); 797 struct syscall_arg_fmt *arg_fmt;
832 void **arg_parm;
833}; 798};
834 799
835/* 800/*
@@ -859,6 +824,8 @@ static size_t fprintf_duration(unsigned long t, bool calculated, FILE *fp)
859 * filename.ptr: The filename char pointer that will be vfs_getname'd 824 * filename.ptr: The filename char pointer that will be vfs_getname'd
860 * filename.entry_str_pos: Where to insert the string translated from 825 * filename.entry_str_pos: Where to insert the string translated from
861 * filename.ptr by the vfs_getname tracepoint/kprobe. 826 * filename.ptr by the vfs_getname tracepoint/kprobe.
827 * ret_scnprintf: syscall args may set this to a different syscall return
828 * formatter, for instance, fcntl may return fds, file flags, etc.
862 */ 829 */
863struct thread_trace { 830struct thread_trace {
864 u64 entry_time; 831 u64 entry_time;
@@ -867,6 +834,7 @@ struct thread_trace {
867 unsigned long pfmaj, pfmin; 834 unsigned long pfmaj, pfmin;
868 char *entry_str; 835 char *entry_str;
869 double runtime_ms; 836 double runtime_ms;
837 size_t (*ret_scnprintf)(char *bf, size_t size, struct syscall_arg *arg);
870 struct { 838 struct {
871 unsigned long ptr; 839 unsigned long ptr;
872 short int entry_str_pos; 840 short int entry_str_pos;
@@ -917,6 +885,15 @@ fail:
917 return NULL; 885 return NULL;
918} 886}
919 887
888
889void syscall_arg__set_ret_scnprintf(struct syscall_arg *arg,
890 size_t (*ret_scnprintf)(char *bf, size_t size, struct syscall_arg *arg))
891{
892 struct thread_trace *ttrace = thread__priv(arg->thread);
893
894 ttrace->ret_scnprintf = ret_scnprintf;
895}
896
920#define TRACE_PFMAJ (1 << 0) 897#define TRACE_PFMAJ (1 << 0)
921#define TRACE_PFMIN (1 << 1) 898#define TRACE_PFMIN (1 << 1)
922 899
@@ -996,8 +973,7 @@ static const char *thread__fd_path(struct thread *thread, int fd,
996 return ttrace->paths.table[fd]; 973 return ttrace->paths.table[fd];
997} 974}
998 975
999static size_t syscall_arg__scnprintf_fd(char *bf, size_t size, 976size_t syscall_arg__scnprintf_fd(char *bf, size_t size, struct syscall_arg *arg)
1000 struct syscall_arg *arg)
1001{ 977{
1002 int fd = arg->val; 978 int fd = arg->val;
1003 size_t printed = scnprintf(bf, size, "%d", fd); 979 size_t printed = scnprintf(bf, size, "%d", fd);
@@ -1162,32 +1138,46 @@ static int trace__symbols_init(struct trace *trace, struct perf_evlist *evlist)
1162 return err; 1138 return err;
1163} 1139}
1164 1140
1141static int syscall__alloc_arg_fmts(struct syscall *sc, int nr_args)
1142{
1143 int idx;
1144
1145 if (nr_args == 6 && sc->fmt && sc->fmt->nr_args != 0)
1146 nr_args = sc->fmt->nr_args;
1147
1148 sc->arg_fmt = calloc(nr_args, sizeof(*sc->arg_fmt));
1149 if (sc->arg_fmt == NULL)
1150 return -1;
1151
1152 for (idx = 0; idx < nr_args; ++idx) {
1153 if (sc->fmt)
1154 sc->arg_fmt[idx] = sc->fmt->arg[idx];
1155 }
1156
1157 sc->nr_args = nr_args;
1158 return 0;
1159}
1160
1165static int syscall__set_arg_fmts(struct syscall *sc) 1161static int syscall__set_arg_fmts(struct syscall *sc)
1166{ 1162{
1167 struct format_field *field; 1163 struct format_field *field;
1168 int idx = 0, len; 1164 int idx = 0, len;
1169 1165
1170 sc->arg_scnprintf = calloc(sc->nr_args, sizeof(void *)); 1166 for (field = sc->args; field; field = field->next, ++idx) {
1171 if (sc->arg_scnprintf == NULL) 1167 if (sc->fmt && sc->fmt->arg[idx].scnprintf)
1172 return -1; 1168 continue;
1173
1174 if (sc->fmt)
1175 sc->arg_parm = sc->fmt->arg_parm;
1176 1169
1177 for (field = sc->args; field; field = field->next) { 1170 if (strcmp(field->type, "const char *") == 0 &&
1178 if (sc->fmt && sc->fmt->arg_scnprintf[idx])
1179 sc->arg_scnprintf[idx] = sc->fmt->arg_scnprintf[idx];
1180 else if (strcmp(field->type, "const char *") == 0 &&
1181 (strcmp(field->name, "filename") == 0 || 1171 (strcmp(field->name, "filename") == 0 ||
1182 strcmp(field->name, "path") == 0 || 1172 strcmp(field->name, "path") == 0 ||
1183 strcmp(field->name, "pathname") == 0)) 1173 strcmp(field->name, "pathname") == 0))
1184 sc->arg_scnprintf[idx] = SCA_FILENAME; 1174 sc->arg_fmt[idx].scnprintf = SCA_FILENAME;
1185 else if (field->flags & FIELD_IS_POINTER) 1175 else if (field->flags & FIELD_IS_POINTER)
1186 sc->arg_scnprintf[idx] = syscall_arg__scnprintf_hex; 1176 sc->arg_fmt[idx].scnprintf = syscall_arg__scnprintf_hex;
1187 else if (strcmp(field->type, "pid_t") == 0) 1177 else if (strcmp(field->type, "pid_t") == 0)
1188 sc->arg_scnprintf[idx] = SCA_PID; 1178 sc->arg_fmt[idx].scnprintf = SCA_PID;
1189 else if (strcmp(field->type, "umode_t") == 0) 1179 else if (strcmp(field->type, "umode_t") == 0)
1190 sc->arg_scnprintf[idx] = SCA_MODE_T; 1180 sc->arg_fmt[idx].scnprintf = SCA_MODE_T;
1191 else if ((strcmp(field->type, "int") == 0 || 1181 else if ((strcmp(field->type, "int") == 0 ||
1192 strcmp(field->type, "unsigned int") == 0 || 1182 strcmp(field->type, "unsigned int") == 0 ||
1193 strcmp(field->type, "long") == 0) && 1183 strcmp(field->type, "long") == 0) &&
@@ -1200,9 +1190,8 @@ static int syscall__set_arg_fmts(struct syscall *sc)
1200 * 23 unsigned int 1190 * 23 unsigned int
1201 * 7 unsigned long 1191 * 7 unsigned long
1202 */ 1192 */
1203 sc->arg_scnprintf[idx] = SCA_FD; 1193 sc->arg_fmt[idx].scnprintf = SCA_FD;
1204 } 1194 }
1205 ++idx;
1206 } 1195 }
1207 1196
1208 return 0; 1197 return 0;
@@ -1247,11 +1236,13 @@ static int trace__read_syscall_info(struct trace *trace, int id)
1247 sc->tp_format = trace_event__tp_format("syscalls", tp_name); 1236 sc->tp_format = trace_event__tp_format("syscalls", tp_name);
1248 } 1237 }
1249 1238
1239 if (syscall__alloc_arg_fmts(sc, IS_ERR(sc->tp_format) ? 6 : sc->tp_format->format.nr_fields))
1240 return -1;
1241
1250 if (IS_ERR(sc->tp_format)) 1242 if (IS_ERR(sc->tp_format))
1251 return -1; 1243 return -1;
1252 1244
1253 sc->args = sc->tp_format->format.fields; 1245 sc->args = sc->tp_format->format.fields;
1254 sc->nr_args = sc->tp_format->format.nr_fields;
1255 /* 1246 /*
1256 * We need to check and discard the first variable '__syscall_nr' 1247 * We need to check and discard the first variable '__syscall_nr'
1257 * or 'nr' that mean the syscall number. It is needless here. 1248 * or 'nr' that mean the syscall number. It is needless here.
@@ -1270,6 +1261,7 @@ static int trace__read_syscall_info(struct trace *trace, int id)
1270static int trace__validate_ev_qualifier(struct trace *trace) 1261static int trace__validate_ev_qualifier(struct trace *trace)
1271{ 1262{
1272 int err = 0, i; 1263 int err = 0, i;
1264 size_t nr_allocated;
1273 struct str_node *pos; 1265 struct str_node *pos;
1274 1266
1275 trace->ev_qualifier_ids.nr = strlist__nr_entries(trace->ev_qualifier); 1267 trace->ev_qualifier_ids.nr = strlist__nr_entries(trace->ev_qualifier);
@@ -1283,13 +1275,18 @@ static int trace__validate_ev_qualifier(struct trace *trace)
1283 goto out; 1275 goto out;
1284 } 1276 }
1285 1277
1278 nr_allocated = trace->ev_qualifier_ids.nr;
1286 i = 0; 1279 i = 0;
1287 1280
1288 strlist__for_each_entry(pos, trace->ev_qualifier) { 1281 strlist__for_each_entry(pos, trace->ev_qualifier) {
1289 const char *sc = pos->s; 1282 const char *sc = pos->s;
1290 int id = syscalltbl__id(trace->sctbl, sc); 1283 int id = syscalltbl__id(trace->sctbl, sc), match_next = -1;
1291 1284
1292 if (id < 0) { 1285 if (id < 0) {
1286 id = syscalltbl__strglobmatch_first(trace->sctbl, sc, &match_next);
1287 if (id >= 0)
1288 goto matches;
1289
1293 if (err == 0) { 1290 if (err == 0) {
1294 fputs("Error:\tInvalid syscall ", trace->output); 1291 fputs("Error:\tInvalid syscall ", trace->output);
1295 err = -EINVAL; 1292 err = -EINVAL;
@@ -1299,13 +1296,37 @@ static int trace__validate_ev_qualifier(struct trace *trace)
1299 1296
1300 fputs(sc, trace->output); 1297 fputs(sc, trace->output);
1301 } 1298 }
1302 1299matches:
1303 trace->ev_qualifier_ids.entries[i++] = id; 1300 trace->ev_qualifier_ids.entries[i++] = id;
1301 if (match_next == -1)
1302 continue;
1303
1304 while (1) {
1305 id = syscalltbl__strglobmatch_next(trace->sctbl, sc, &match_next);
1306 if (id < 0)
1307 break;
1308 if (nr_allocated == trace->ev_qualifier_ids.nr) {
1309 void *entries;
1310
1311 nr_allocated += 8;
1312 entries = realloc(trace->ev_qualifier_ids.entries,
1313 nr_allocated * sizeof(trace->ev_qualifier_ids.entries[0]));
1314 if (entries == NULL) {
1315 err = -ENOMEM;
1316 fputs("\nError:\t Not enough memory for parsing\n", trace->output);
1317 goto out_free;
1318 }
1319 trace->ev_qualifier_ids.entries = entries;
1320 }
1321 trace->ev_qualifier_ids.nr++;
1322 trace->ev_qualifier_ids.entries[i++] = id;
1323 }
1304 } 1324 }
1305 1325
1306 if (err < 0) { 1326 if (err < 0) {
1307 fputs("\nHint:\ttry 'perf list syscalls:sys_enter_*'" 1327 fputs("\nHint:\ttry 'perf list syscalls:sys_enter_*'"
1308 "\nHint:\tand: 'man syscalls'\n", trace->output); 1328 "\nHint:\tand: 'man syscalls'\n", trace->output);
1329out_free:
1309 zfree(&trace->ev_qualifier_ids.entries); 1330 zfree(&trace->ev_qualifier_ids.entries);
1310 trace->ev_qualifier_ids.nr = 0; 1331 trace->ev_qualifier_ids.nr = 0;
1311 } 1332 }
@@ -1321,33 +1342,68 @@ out:
1321 * variable to read it. Most notably this avoids extended load instructions 1342 * variable to read it. Most notably this avoids extended load instructions
1322 * on unaligned addresses 1343 * on unaligned addresses
1323 */ 1344 */
1345unsigned long syscall_arg__val(struct syscall_arg *arg, u8 idx)
1346{
1347 unsigned long val;
1348 unsigned char *p = arg->args + sizeof(unsigned long) * idx;
1349
1350 memcpy(&val, p, sizeof(val));
1351 return val;
1352}
1353
1354static size_t syscall__scnprintf_name(struct syscall *sc, char *bf, size_t size,
1355 struct syscall_arg *arg)
1356{
1357 if (sc->arg_fmt && sc->arg_fmt[arg->idx].name)
1358 return scnprintf(bf, size, "%s: ", sc->arg_fmt[arg->idx].name);
1359
1360 return scnprintf(bf, size, "arg%d: ", arg->idx);
1361}
1362
1363static size_t syscall__scnprintf_val(struct syscall *sc, char *bf, size_t size,
1364 struct syscall_arg *arg, unsigned long val)
1365{
1366 if (sc->arg_fmt && sc->arg_fmt[arg->idx].scnprintf) {
1367 arg->val = val;
1368 if (sc->arg_fmt[arg->idx].parm)
1369 arg->parm = sc->arg_fmt[arg->idx].parm;
1370 return sc->arg_fmt[arg->idx].scnprintf(bf, size, arg);
1371 }
1372 return scnprintf(bf, size, "%ld", val);
1373}
1324 1374
1325static size_t syscall__scnprintf_args(struct syscall *sc, char *bf, size_t size, 1375static size_t syscall__scnprintf_args(struct syscall *sc, char *bf, size_t size,
1326 unsigned char *args, struct trace *trace, 1376 unsigned char *args, struct trace *trace,
1327 struct thread *thread) 1377 struct thread *thread)
1328{ 1378{
1329 size_t printed = 0; 1379 size_t printed = 0;
1330 unsigned char *p;
1331 unsigned long val; 1380 unsigned long val;
1381 u8 bit = 1;
1382 struct syscall_arg arg = {
1383 .args = args,
1384 .idx = 0,
1385 .mask = 0,
1386 .trace = trace,
1387 .thread = thread,
1388 };
1389 struct thread_trace *ttrace = thread__priv(thread);
1390
1391 /*
1392 * Things like fcntl will set this in its 'cmd' formatter to pick the
1393 * right formatter for the return value (an fd? file flags?), which is
1394 * not needed for syscalls that always return a given type, say an fd.
1395 */
1396 ttrace->ret_scnprintf = NULL;
1332 1397
1333 if (sc->args != NULL) { 1398 if (sc->args != NULL) {
1334 struct format_field *field; 1399 struct format_field *field;
1335 u8 bit = 1;
1336 struct syscall_arg arg = {
1337 .idx = 0,
1338 .mask = 0,
1339 .trace = trace,
1340 .thread = thread,
1341 };
1342 1400
1343 for (field = sc->args; field; 1401 for (field = sc->args; field;
1344 field = field->next, ++arg.idx, bit <<= 1) { 1402 field = field->next, ++arg.idx, bit <<= 1) {
1345 if (arg.mask & bit) 1403 if (arg.mask & bit)
1346 continue; 1404 continue;
1347 1405
1348 /* special care for unaligned accesses */ 1406 val = syscall_arg__val(&arg, arg.idx);
1349 p = args + sizeof(unsigned long) * arg.idx;
1350 memcpy(&val, p, sizeof(val));
1351 1407
1352 /* 1408 /*
1353 * Suppress this argument if its value is zero and 1409 * Suppress this argument if its value is zero and
@@ -1355,23 +1411,16 @@ static size_t syscall__scnprintf_args(struct syscall *sc, char *bf, size_t size,
1355 * strarray for it. 1411 * strarray for it.
1356 */ 1412 */
1357 if (val == 0 && 1413 if (val == 0 &&
1358 !(sc->arg_scnprintf && 1414 !(sc->arg_fmt &&
1359 sc->arg_scnprintf[arg.idx] == SCA_STRARRAY && 1415 (sc->arg_fmt[arg.idx].show_zero ||
1360 sc->arg_parm[arg.idx])) 1416 sc->arg_fmt[arg.idx].scnprintf == SCA_STRARRAY ||
1417 sc->arg_fmt[arg.idx].scnprintf == SCA_STRARRAYS) &&
1418 sc->arg_fmt[arg.idx].parm))
1361 continue; 1419 continue;
1362 1420
1363 printed += scnprintf(bf + printed, size - printed, 1421 printed += scnprintf(bf + printed, size - printed,
1364 "%s%s: ", printed ? ", " : "", field->name); 1422 "%s%s: ", printed ? ", " : "", field->name);
1365 if (sc->arg_scnprintf && sc->arg_scnprintf[arg.idx]) { 1423 printed += syscall__scnprintf_val(sc, bf + printed, size - printed, &arg, val);
1366 arg.val = val;
1367 if (sc->arg_parm)
1368 arg.parm = sc->arg_parm[arg.idx];
1369 printed += sc->arg_scnprintf[arg.idx](bf + printed,
1370 size - printed, &arg);
1371 } else {
1372 printed += scnprintf(bf + printed, size - printed,
1373 "%ld", val);
1374 }
1375 } 1424 }
1376 } else if (IS_ERR(sc->tp_format)) { 1425 } else if (IS_ERR(sc->tp_format)) {
1377 /* 1426 /*
@@ -1379,16 +1428,17 @@ static size_t syscall__scnprintf_args(struct syscall *sc, char *bf, size_t size,
1379 * may end up not having any args, like with gettid(), so only 1428 * may end up not having any args, like with gettid(), so only
1380 * print the raw args when we didn't manage to read it. 1429 * print the raw args when we didn't manage to read it.
1381 */ 1430 */
1382 int i = 0; 1431 while (arg.idx < sc->nr_args) {
1383 1432 if (arg.mask & bit)
1384 while (i < 6) { 1433 goto next_arg;
1385 /* special care for unaligned accesses */ 1434 val = syscall_arg__val(&arg, arg.idx);
1386 p = args + sizeof(unsigned long) * i; 1435 if (printed)
1387 memcpy(&val, p, sizeof(val)); 1436 printed += scnprintf(bf + printed, size - printed, ", ");
1388 printed += scnprintf(bf + printed, size - printed, 1437 printed += syscall__scnprintf_name(sc, bf + printed, size - printed, &arg);
1389 "%sarg%d: %ld", 1438 printed += syscall__scnprintf_val(sc, bf + printed, size - printed, &arg, val);
1390 printed ? ", " : "", i, val); 1439next_arg:
1391 ++i; 1440 ++arg.idx;
1441 bit <<= 1;
1392 } 1442 }
1393 } 1443 }
1394 1444
@@ -1635,17 +1685,31 @@ static int trace__sys_exit(struct trace *trace, struct perf_evsel *evsel,
1635 } 1685 }
1636 1686
1637 if (sc->fmt == NULL) { 1687 if (sc->fmt == NULL) {
1688 if (ret < 0)
1689 goto errno_print;
1638signed_print: 1690signed_print:
1639 fprintf(trace->output, ") = %ld", ret); 1691 fprintf(trace->output, ") = %ld", ret);
1640 } else if (ret < 0 && (sc->fmt->errmsg || sc->fmt->errpid)) { 1692 } else if (ret < 0) {
1693errno_print: {
1641 char bf[STRERR_BUFSIZE]; 1694 char bf[STRERR_BUFSIZE];
1642 const char *emsg = str_error_r(-ret, bf, sizeof(bf)), 1695 const char *emsg = str_error_r(-ret, bf, sizeof(bf)),
1643 *e = audit_errno_to_name(-ret); 1696 *e = audit_errno_to_name(-ret);
1644 1697
1645 fprintf(trace->output, ") = -1 %s %s", e, emsg); 1698 fprintf(trace->output, ") = -1 %s %s", e, emsg);
1699 }
1646 } else if (ret == 0 && sc->fmt->timeout) 1700 } else if (ret == 0 && sc->fmt->timeout)
1647 fprintf(trace->output, ") = 0 Timeout"); 1701 fprintf(trace->output, ") = 0 Timeout");
1648 else if (sc->fmt->hexret) 1702 else if (ttrace->ret_scnprintf) {
1703 char bf[1024];
1704 struct syscall_arg arg = {
1705 .val = ret,
1706 .thread = thread,
1707 .trace = trace,
1708 };
1709 ttrace->ret_scnprintf(bf, sizeof(bf), &arg);
1710 ttrace->ret_scnprintf = NULL;
1711 fprintf(trace->output, ") = %s", bf);
1712 } else if (sc->fmt->hexret)
1649 fprintf(trace->output, ") = %#lx", ret); 1713 fprintf(trace->output, ") = %#lx", ret);
1650 else if (sc->fmt->errpid) { 1714 else if (sc->fmt->errpid) {
1651 struct thread *child = machine__find_thread(trace->host, ret, ret); 1715 struct thread *child = machine__find_thread(trace->host, ret, ret);
@@ -2171,6 +2235,30 @@ out_enomem:
2171 goto out; 2235 goto out;
2172} 2236}
2173 2237
2238static int trace__set_filter_loop_pids(struct trace *trace)
2239{
2240 unsigned int nr = 1;
2241 pid_t pids[32] = {
2242 getpid(),
2243 };
2244 struct thread *thread = machine__find_thread(trace->host, pids[0], pids[0]);
2245
2246 while (thread && nr < ARRAY_SIZE(pids)) {
2247 struct thread *parent = machine__find_thread(trace->host, thread->ppid, thread->ppid);
2248
2249 if (parent == NULL)
2250 break;
2251
2252 if (!strcmp(thread__comm_str(parent), "sshd")) {
2253 pids[nr++] = parent->tid;
2254 break;
2255 }
2256 thread = parent;
2257 }
2258
2259 return perf_evlist__set_filter_pids(trace->evlist, nr, pids);
2260}
2261
2174static int trace__run(struct trace *trace, int argc, const char **argv) 2262static int trace__run(struct trace *trace, int argc, const char **argv)
2175{ 2263{
2176 struct perf_evlist *evlist = trace->evlist; 2264 struct perf_evlist *evlist = trace->evlist;
@@ -2294,7 +2382,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
2294 if (trace->filter_pids.nr > 0) 2382 if (trace->filter_pids.nr > 0)
2295 err = perf_evlist__set_filter_pids(evlist, trace->filter_pids.nr, trace->filter_pids.entries); 2383 err = perf_evlist__set_filter_pids(evlist, trace->filter_pids.nr, trace->filter_pids.entries);
2296 else if (thread_map__pid(evlist->threads, 0) == -1) 2384 else if (thread_map__pid(evlist->threads, 0) == -1)
2297 err = perf_evlist__set_filter_pid(evlist, getpid()); 2385 err = trace__set_filter_loop_pids(trace);
2298 2386
2299 if (err < 0) 2387 if (err < 0)
2300 goto out_error_mem; 2388 goto out_error_mem;
@@ -2756,7 +2844,7 @@ static int trace__parse_events_option(const struct option *opt, const char *str,
2756 struct trace *trace = (struct trace *)opt->value; 2844 struct trace *trace = (struct trace *)opt->value;
2757 const char *s = str; 2845 const char *s = str;
2758 char *sep = NULL, *lists[2] = { NULL, NULL, }; 2846 char *sep = NULL, *lists[2] = { NULL, NULL, };
2759 int len = strlen(str), err = -1, list; 2847 int len = strlen(str) + 1, err = -1, list, idx;
2760 char *strace_groups_dir = system_path(STRACE_GROUPS_DIR); 2848 char *strace_groups_dir = system_path(STRACE_GROUPS_DIR);
2761 char group_name[PATH_MAX]; 2849 char group_name[PATH_MAX];
2762 2850
@@ -2773,7 +2861,8 @@ static int trace__parse_events_option(const struct option *opt, const char *str,
2773 *sep = '\0'; 2861 *sep = '\0';
2774 2862
2775 list = 0; 2863 list = 0;
2776 if (syscalltbl__id(trace->sctbl, s) >= 0) { 2864 if (syscalltbl__id(trace->sctbl, s) >= 0 ||
2865 syscalltbl__strglobmatch_first(trace->sctbl, s, &idx) >= 0) {
2777 list = 1; 2866 list = 1;
2778 } else { 2867 } else {
2779 path__join(group_name, sizeof(group_name), strace_groups_dir, s); 2868 path__join(group_name, sizeof(group_name), strace_groups_dir, s);
diff --git a/tools/perf/check-headers.sh b/tools/perf/check-headers.sh
index 83fe2202382e..932fda54b8a6 100755
--- a/tools/perf/check-headers.sh
+++ b/tools/perf/check-headers.sh
@@ -1,9 +1,15 @@
1#!/bin/sh 1#!/bin/sh
2 2
3HEADERS=' 3HEADERS='
4include/uapi/drm/drm.h
5include/uapi/drm/i915_drm.h
4include/uapi/linux/fcntl.h 6include/uapi/linux/fcntl.h
7include/uapi/linux/kvm.h
5include/uapi/linux/perf_event.h 8include/uapi/linux/perf_event.h
9include/uapi/linux/sched.h
6include/uapi/linux/stat.h 10include/uapi/linux/stat.h
11include/uapi/linux/vhost.h
12include/uapi/sound/asound.h
7include/linux/hash.h 13include/linux/hash.h
8include/uapi/linux/hw_breakpoint.h 14include/uapi/linux/hw_breakpoint.h
9arch/x86/include/asm/disabled-features.h 15arch/x86/include/asm/disabled-features.h
@@ -16,6 +22,7 @@ arch/x86/include/uapi/asm/perf_regs.h
16arch/x86/include/uapi/asm/kvm.h 22arch/x86/include/uapi/asm/kvm.h
17arch/x86/include/uapi/asm/kvm_perf.h 23arch/x86/include/uapi/asm/kvm_perf.h
18arch/x86/include/uapi/asm/svm.h 24arch/x86/include/uapi/asm/svm.h
25arch/x86/include/uapi/asm/unistd.h
19arch/x86/include/uapi/asm/vmx.h 26arch/x86/include/uapi/asm/vmx.h
20arch/powerpc/include/uapi/asm/kvm.h 27arch/powerpc/include/uapi/asm/kvm.h
21arch/s390/include/uapi/asm/kvm.h 28arch/s390/include/uapi/asm/kvm.h
@@ -29,12 +36,13 @@ include/asm-generic/bitops/__fls.h
29include/asm-generic/bitops/fls.h 36include/asm-generic/bitops/fls.h
30include/asm-generic/bitops/fls64.h 37include/asm-generic/bitops/fls64.h
31include/linux/coresight-pmu.h 38include/linux/coresight-pmu.h
39include/uapi/asm-generic/ioctls.h
32include/uapi/asm-generic/mman-common.h 40include/uapi/asm-generic/mman-common.h
33' 41'
34 42
35check () { 43check () {
36 file=$1 44 file=$1
37 opts= 45 opts="--ignore-blank-lines --ignore-space-change"
38 46
39 shift 47 shift
40 while [ -n "$*" ]; do 48 while [ -n "$*" ]; do
@@ -45,7 +53,7 @@ check () {
45 cmd="diff $opts ../$file ../../$file > /dev/null" 53 cmd="diff $opts ../$file ../../$file > /dev/null"
46 54
47 test -f ../../$file && 55 test -f ../../$file &&
48 eval $cmd || echo "Warning: $file differs from kernel" >&2 56 eval $cmd || echo "Warning: Kernel ABI header at 'tools/$file' differs from latest version at '$file'" >&2
49} 57}
50 58
51 59
@@ -55,7 +63,7 @@ for i in $HEADERS; do
55done 63done
56 64
57# diff with extra ignore lines 65# diff with extra ignore lines
58check arch/x86/lib/memcpy_64.S -B -I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>" 66check arch/x86/lib/memcpy_64.S -I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>"
59check arch/x86/lib/memset_64.S -B -I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>" 67check arch/x86/lib/memset_64.S -I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>"
60check include/uapi/asm-generic/mman.h -B -I "^#include <\(uapi/\)*asm-generic/mman-common.h>" 68check include/uapi/asm-generic/mman.h -I "^#include <\(uapi/\)*asm-generic/mman-common.h>"
61check include/uapi/linux/mman.h -B -I "^#include <\(uapi/\)*asm/mman.h>" 69check include/uapi/linux/mman.h -I "^#include <\(uapi/\)*asm/mman.h>"
diff --git a/tools/perf/perf-sys.h b/tools/perf/perf-sys.h
index e4b717e9eb6c..c11f0c76e90c 100644
--- a/tools/perf/perf-sys.h
+++ b/tools/perf/perf-sys.h
@@ -9,16 +9,6 @@
9#include <linux/perf_event.h> 9#include <linux/perf_event.h>
10#include <asm/barrier.h> 10#include <asm/barrier.h>
11 11
12#if defined(__i386__)
13#define cpu_relax() asm volatile("rep; nop" ::: "memory");
14#define CPUINFO_PROC {"model name"}
15#endif
16
17#if defined(__x86_64__)
18#define cpu_relax() asm volatile("rep; nop" ::: "memory");
19#define CPUINFO_PROC {"model name"}
20#endif
21
22#ifdef __powerpc__ 12#ifdef __powerpc__
23#define CPUINFO_PROC {"cpu"} 13#define CPUINFO_PROC {"cpu"}
24#endif 14#endif
@@ -43,19 +33,10 @@
43#define CPUINFO_PROC {"cpu model"} 33#define CPUINFO_PROC {"cpu model"}
44#endif 34#endif
45 35
46#ifdef __ia64__
47#define cpu_relax() asm volatile ("hint @pause" ::: "memory")
48#define CPUINFO_PROC {"model name"}
49#endif
50
51#ifdef __arm__ 36#ifdef __arm__
52#define CPUINFO_PROC {"model name", "Processor"} 37#define CPUINFO_PROC {"model name", "Processor"}
53#endif 38#endif
54 39
55#ifdef __aarch64__
56#define cpu_relax() asm volatile("yield" ::: "memory")
57#endif
58
59#ifdef __mips__ 40#ifdef __mips__
60#define CPUINFO_PROC {"cpu model"} 41#define CPUINFO_PROC {"cpu model"}
61#endif 42#endif
@@ -72,13 +53,8 @@
72#define CPUINFO_PROC {"core ID"} 53#define CPUINFO_PROC {"core ID"}
73#endif 54#endif
74 55
75#ifdef __tile__ 56#ifndef CPUINFO_PROC
76#define cpu_relax() asm volatile ("mfspr zero, PASS" ::: "memory") 57#define CPUINFO_PROC { "model name", }
77#define CPUINFO_PROC {"model name"}
78#endif
79
80#ifndef cpu_relax
81#define cpu_relax() barrier()
82#endif 58#endif
83 59
84static inline int 60static inline int
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 628a5e412cb1..2f19e03c5c40 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -89,7 +89,7 @@ struct pager_config {
89static int pager_command_config(const char *var, const char *value, void *data) 89static int pager_command_config(const char *var, const char *value, void *data)
90{ 90{
91 struct pager_config *c = data; 91 struct pager_config *c = data;
92 if (!prefixcmp(var, "pager.") && !strcmp(var + 6, c->cmd)) 92 if (strstarts(var, "pager.") && !strcmp(var + 6, c->cmd))
93 c->val = perf_config_bool(var, value); 93 c->val = perf_config_bool(var, value);
94 return 0; 94 return 0;
95} 95}
@@ -108,9 +108,9 @@ static int check_pager_config(const char *cmd)
108static int browser_command_config(const char *var, const char *value, void *data) 108static int browser_command_config(const char *var, const char *value, void *data)
109{ 109{
110 struct pager_config *c = data; 110 struct pager_config *c = data;
111 if (!prefixcmp(var, "tui.") && !strcmp(var + 4, c->cmd)) 111 if (strstarts(var, "tui.") && !strcmp(var + 4, c->cmd))
112 c->val = perf_config_bool(var, value); 112 c->val = perf_config_bool(var, value);
113 if (!prefixcmp(var, "gtk.") && !strcmp(var + 4, c->cmd)) 113 if (strstarts(var, "gtk.") && !strcmp(var + 4, c->cmd))
114 c->val = perf_config_bool(var, value) ? 2 : 0; 114 c->val = perf_config_bool(var, value) ? 2 : 0;
115 return 0; 115 return 0;
116} 116}
@@ -192,7 +192,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
192 /* 192 /*
193 * Check remaining flags. 193 * Check remaining flags.
194 */ 194 */
195 if (!prefixcmp(cmd, CMD_EXEC_PATH)) { 195 if (strstarts(cmd, CMD_EXEC_PATH)) {
196 cmd += strlen(CMD_EXEC_PATH); 196 cmd += strlen(CMD_EXEC_PATH);
197 if (*cmd == '=') 197 if (*cmd == '=')
198 set_argv_exec_path(cmd + 1); 198 set_argv_exec_path(cmd + 1);
@@ -229,7 +229,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
229 *envchanged = 1; 229 *envchanged = 1;
230 (*argv)++; 230 (*argv)++;
231 (*argc)--; 231 (*argc)--;
232 } else if (!prefixcmp(cmd, CMD_DEBUGFS_DIR)) { 232 } else if (strstarts(cmd, CMD_DEBUGFS_DIR)) {
233 tracing_path_set(cmd + strlen(CMD_DEBUGFS_DIR)); 233 tracing_path_set(cmd + strlen(CMD_DEBUGFS_DIR));
234 fprintf(stderr, "dir: %s\n", tracing_path); 234 fprintf(stderr, "dir: %s\n", tracing_path);
235 if (envchanged) 235 if (envchanged)
@@ -467,17 +467,23 @@ int main(int argc, const char **argv)
467 * - cannot execute it externally (since it would just do 467 * - cannot execute it externally (since it would just do
468 * the same thing over again) 468 * the same thing over again)
469 * 469 *
470 * So we just directly call the internal command handler, and 470 * So we just directly call the internal command handler. If that one
471 * die if that one cannot handle it. 471 * fails to handle this, then maybe we just run a renamed perf binary
472 * that contains a dash in its name. To handle this scenario, we just
473 * fall through and ignore the "xxxx" part of the command string.
472 */ 474 */
473 if (!prefixcmp(cmd, "perf-")) { 475 if (strstarts(cmd, "perf-")) {
474 cmd += 5; 476 cmd += 5;
475 argv[0] = cmd; 477 argv[0] = cmd;
476 handle_internal_command(argc, argv); 478 handle_internal_command(argc, argv);
477 fprintf(stderr, "cannot handle %s internally", cmd); 479 /*
478 goto out; 480 * If the command is handled, the above function does not
481 * return undo changes and fall through in such a case.
482 */
483 cmd -= 5;
484 argv[0] = cmd;
479 } 485 }
480 if (!prefixcmp(cmd, "trace")) { 486 if (strstarts(cmd, "trace")) {
481#ifdef HAVE_LIBAUDIT_SUPPORT 487#ifdef HAVE_LIBAUDIT_SUPPORT
482 setup_path(); 488 setup_path();
483 argv[0] = "trace"; 489 argv[0] = "trace";
@@ -495,7 +501,7 @@ int main(int argc, const char **argv)
495 commit_pager_choice(); 501 commit_pager_choice();
496 502
497 if (argc > 0) { 503 if (argc > 0) {
498 if (!prefixcmp(argv[0], "--")) 504 if (strstarts(argv[0], "--"))
499 argv[0] += 2; 505 argv[0] += 2;
500 } else { 506 } else {
501 /* The user didn't specify a command; give them help */ 507 /* The user didn't specify a command; give them help */
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 806c216a1078..dc442ba21bf6 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -7,6 +7,7 @@
7#include <linux/perf_event.h> 7#include <linux/perf_event.h>
8 8
9extern bool test_attr__enabled; 9extern bool test_attr__enabled;
10void test_attr__ready(void);
10void test_attr__init(void); 11void test_attr__init(void);
11void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu, 12void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu,
12 int fd, int group_fd, unsigned long flags); 13 int fd, int group_fd, unsigned long flags);
@@ -42,6 +43,7 @@ struct record_opts {
42 bool no_samples; 43 bool no_samples;
43 bool raw_samples; 44 bool raw_samples;
44 bool sample_address; 45 bool sample_address;
46 bool sample_phys_addr;
45 bool sample_weight; 47 bool sample_weight;
46 bool sample_time; 48 bool sample_time;
47 bool sample_time_set; 49 bool sample_time_set;
diff --git a/tools/perf/pmu-events/README b/tools/perf/pmu-events/README
index 1408ade0d773..c2ee3e4417fe 100644
--- a/tools/perf/pmu-events/README
+++ b/tools/perf/pmu-events/README
@@ -85,10 +85,6 @@ users to specify events by their name:
85 85
86where 'pm_1plus_ppc_cmpl' is a Power8 PMU event. 86where 'pm_1plus_ppc_cmpl' is a Power8 PMU event.
87 87
88In case of errors when processing files in the tools/perf/pmu-events/arch
89directory, 'jevents' tries to create an empty mapping file to allow the perf
90build to succeed even if the PMU event aliases cannot be used.
91
92However some errors in processing may cause the perf build to fail. 88However some errors in processing may cause the perf build to fail.
93 89
94Mapfile format 90Mapfile format
diff --git a/tools/perf/pmu-events/arch/powerpc/mapfile.csv b/tools/perf/pmu-events/arch/powerpc/mapfile.csv
index e925baa0c30b..a0f3a11ca19f 100644
--- a/tools/perf/pmu-events/arch/powerpc/mapfile.csv
+++ b/tools/perf/pmu-events/arch/powerpc/mapfile.csv
@@ -13,9 +13,13 @@
13# 13#
14 14
15# Power8 entries 15# Power8 entries
16004b0000,1,power8.json,core 16004b0000,1,power8,core
17004b0201,1,power8.json,core 17004b0201,1,power8,core
18004c0000,1,power8.json,core 18004c0000,1,power8,core
19004d0000,1,power8.json,core 19004d0000,1,power8,core
20004d0100,1,power8.json,core 20004d0100,1,power8,core
21004d0200,1,power8.json,core 21004d0200,1,power8,core
22004c0100,1,power8,core
23004e0100,1,power9,core
24004e0200,1,power9,core
25004e1200,1,power9,core
diff --git a/tools/perf/pmu-events/arch/powerpc/power9/cache.json b/tools/perf/pmu-events/arch/powerpc/power9/cache.json
new file mode 100644
index 000000000000..18f6645f2897
--- /dev/null
+++ b/tools/perf/pmu-events/arch/powerpc/power9/cache.json
@@ -0,0 +1,137 @@
1[
2 {,
3 "EventCode": "0x300F4",
4 "EventName": "PM_THRD_CONC_RUN_INST",
5 "BriefDescription": "PPC Instructions Finished by this thread when all threads in the core had the run-latch set"
6 },
7 {,
8 "EventCode": "0x1E056",
9 "EventName": "PM_CMPLU_STALL_FLUSH_ANY_THREAD",
10 "BriefDescription": "Cycles in which the NTC instruction is not allowed to complete because any of the 4 threads in the same core suffered a flush, which blocks completion"
11 },
12 {,
13 "EventCode": "0x4D016",
14 "EventName": "PM_CMPLU_STALL_FXLONG",
15 "BriefDescription": "Completion stall due to a long latency scalar fixed point instruction (division, square root)"
16 },
17 {,
18 "EventCode": "0x2D016",
19 "EventName": "PM_CMPLU_STALL_FXU",
20 "BriefDescription": "Finish stall due to a scalar fixed point or CR instruction in the execution pipeline. These instructions get routed to the ALU, ALU2, and DIV pipes"
21 },
22 {,
23 "EventCode": "0x1D15C",
24 "EventName": "PM_MRK_DTLB_MISS_1G",
25 "BriefDescription": "Marked Data TLB reload (after a miss) page size 2M. Implies radix translation was used"
26 },
27 {,
28 "EventCode": "0x4D12A",
29 "EventName": "PM_MRK_DATA_FROM_RL4_CYC",
30 "BriefDescription": "Duration in cycles to reload from another chip's L4 on the same Node or Group ( Remote) due to a marked load"
31 },
32 {,
33 "EventCode": "0x1003C",
34 "EventName": "PM_CMPLU_STALL_DMISS_L2L3",
35 "BriefDescription": "Completion stall by Dcache miss which resolved in L2/L3"
36 },
37 {,
38 "EventCode": "0x4C014",
39 "EventName": "PM_CMPLU_STALL_LMQ_FULL",
40 "BriefDescription": "Finish stall because the NTF instruction was a load that missed in the L1 and the LMQ was unable to accept this load miss request because it was full"
41 },
42 {,
43 "EventCode": "0x14048",
44 "EventName": "PM_INST_FROM_ON_CHIP_CACHE",
45 "BriefDescription": "The processor's Instruction cache was reloaded either shared or modified data from another core's L2/L3 on the same chip due to an instruction fetch (not prefetch)"
46 },
47 {,
48 "EventCode": "0x4D014",
49 "EventName": "PM_CMPLU_STALL_LOAD_FINISH",
50 "BriefDescription": "Finish stall because the NTF instruction was a load instruction with all its dependencies satisfied just going through the LSU pipe to finish"
51 },
52 {,
53 "EventCode": "0x2404A",
54 "EventName": "PM_INST_FROM_RL4",
55 "BriefDescription": "The processor's Instruction cache was reloaded from another chip's L4 on the same Node or Group ( Remote) due to an instruction fetch (not prefetch)"
56 },
57 {,
58 "EventCode": "0x1404A",
59 "EventName": "PM_INST_FROM_RL2L3_SHR",
60 "BriefDescription": "The processor's Instruction cache was reloaded with Shared (S) data from another chip's L2 or L3 on the same Node or Group (Remote), as this chip due to an instruction fetch (not prefetch)"
61 },
62 {,
63 "EventCode": "0x401EA",
64 "EventName": "PM_THRESH_EXC_128",
65 "BriefDescription": "Threshold counter exceeded a value of 128"
66 },
67 {,
68 "EventCode": "0x400F6",
69 "EventName": "PM_BR_MPRED_CMPL",
70 "BriefDescription": "Number of Branch Mispredicts"
71 },
72 {,
73 "EventCode": "0x2F140",
74 "EventName": "PM_MRK_DPTEG_FROM_L2_MEPF",
75 "BriefDescription": "A Page Table Entry was loaded into the TLB from local core's L2 hit without dispatch conflicts on Mepf state. due to a marked data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
76 },
77 {,
78 "EventCode": "0x101E6",
79 "EventName": "PM_THRESH_EXC_4096",
80 "BriefDescription": "Threshold counter exceed a count of 4096"
81 },
82 {,
83 "EventCode": "0x3D156",
84 "EventName": "PM_MRK_DTLB_MISS_64K",
85 "BriefDescription": "Marked Data TLB Miss page size 64K"
86 },
87 {,
88 "EventCode": "0x4C15E",
89 "EventName": "PM_MRK_DTLB_MISS_16M",
90 "BriefDescription": "Marked Data TLB Miss page size 16M"
91 },
92 {,
93 "EventCode": "0x2D15E",
94 "EventName": "PM_MRK_DTLB_MISS_16G",
95 "BriefDescription": "Marked Data TLB Miss page size 16G"
96 },
97 {,
98 "EventCode": "0x3F14A",
99 "EventName": "PM_MRK_DPTEG_FROM_RMEM",
100 "BriefDescription": "A Page Table Entry was loaded into the TLB from another chip's memory on the same Node or Group ( Remote) due to a marked data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
101 },
102 {,
103 "EventCode": "0x4C016",
104 "EventName": "PM_CMPLU_STALL_DMISS_L2L3_CONFLICT",
105 "BriefDescription": "Completion stall due to cache miss that resolves in the L2 or L3 with a conflict"
106 },
107 {,
108 "EventCode": "0x2C01A",
109 "EventName": "PM_CMPLU_STALL_LHS",
110 "BriefDescription": "Finish stall because the NTF instruction was a load that hit on an older store and it was waiting for store data"
111 },
112 {,
113 "EventCode": "0x401E4",
114 "EventName": "PM_MRK_DTLB_MISS",
115 "BriefDescription": "Marked dtlb miss"
116 },
117 {,
118 "EventCode": "0x24046",
119 "EventName": "PM_INST_FROM_RL2L3_MOD",
120 "BriefDescription": "The processor's Instruction cache was reloaded with Modified (M) data from another chip's L2 or L3 on the same Node or Group (Remote), as this chip due to an instruction fetch (not prefetch)"
121 },
122 {,
123 "EventCode": "0x1002A",
124 "EventName": "PM_CMPLU_STALL_LARX",
125 "BriefDescription": "Finish stall because the NTF instruction was a larx waiting to be satisfied"
126 },
127 {,
128 "EventCode": "0x3006C",
129 "EventName": "PM_RUN_CYC_SMT2_MODE",
130 "BriefDescription": "Cycles in which this thread's run latch is set and the core is in SMT2 mode"
131 },
132 {,
133 "EventCode": "0x1C058",
134 "EventName": "PM_DTLB_MISS_16G",
135 "BriefDescription": "Data TLB Miss page size 16G"
136 }
137] \ No newline at end of file
diff --git a/tools/perf/pmu-events/arch/powerpc/power9/floating-point.json b/tools/perf/pmu-events/arch/powerpc/power9/floating-point.json
new file mode 100644
index 000000000000..8a83bca26552
--- /dev/null
+++ b/tools/perf/pmu-events/arch/powerpc/power9/floating-point.json
@@ -0,0 +1,32 @@
1[
2 {,
3 "EventCode": "0x1415A",
4 "EventName": "PM_MRK_DATA_FROM_L2_DISP_CONFLICT_LDHITST_CYC",
5 "BriefDescription": "Duration in cycles to reload from local core's L2 with load hit store conflict due to a marked load"
6 },
7 {,
8 "EventCode": "0x10058",
9 "EventName": "PM_MEM_LOC_THRESH_IFU",
10 "BriefDescription": "Local Memory above threshold for IFU speculation control"
11 },
12 {,
13 "EventCode": "0x2D028",
14 "EventName": "PM_RADIX_PWC_L2_PDE_FROM_L2",
15 "BriefDescription": "A Page Directory Entry was reloaded to a level 2 page walk cache from the core's L2 data cache"
16 },
17 {,
18 "EventCode": "0x30012",
19 "EventName": "PM_FLUSH_COMPLETION",
20 "BriefDescription": "The instruction that was next to complete did not complete because it suffered a flush"
21 },
22 {,
23 "EventCode": "0x2D154",
24 "EventName": "PM_MRK_DERAT_MISS_64K",
25 "BriefDescription": "Marked Data ERAT Miss (Data TLB Access) page size 64K"
26 },
27 {,
28 "EventCode": "0x4016E",
29 "EventName": "PM_THRESH_NOT_MET",
30 "BriefDescription": "Threshold counter did not meet threshold"
31 }
32] \ No newline at end of file
diff --git a/tools/perf/pmu-events/arch/powerpc/power9/frontend.json b/tools/perf/pmu-events/arch/powerpc/power9/frontend.json
new file mode 100644
index 000000000000..c63a919eda98
--- /dev/null
+++ b/tools/perf/pmu-events/arch/powerpc/power9/frontend.json
@@ -0,0 +1,372 @@
1[
2 {,
3 "EventCode": "0x3E15C",
4 "EventName": "PM_MRK_L2_TM_ST_ABORT_SISTER",
5 "BriefDescription": "TM marked store abort for this thread"
6 },
7 {,
8 "EventCode": "0x25044",
9 "EventName": "PM_IPTEG_FROM_L31_MOD",
10 "BriefDescription": "A Page Table Entry was loaded into the TLB with Modified (M) data from another core's L3 on the same chip due to a instruction side request"
11 },
12 {,
13 "EventCode": "0x101E8",
14 "EventName": "PM_THRESH_EXC_256",
15 "BriefDescription": "Threshold counter exceed a count of 256"
16 },
17 {,
18 "EventCode": "0x4504E",
19 "EventName": "PM_IPTEG_FROM_L3MISS",
20 "BriefDescription": "A Page Table Entry was loaded into the TLB from a location other than the local core's L3 due to a instruction side request"
21 },
22 {,
23 "EventCode": "0x1006A",
24 "EventName": "PM_NTC_ISSUE_HELD_DARQ_FULL",
25 "BriefDescription": "The NTC instruction is being held at dispatch because there are no slots in the DARQ for it"
26 },
27 {,
28 "EventCode": "0x4E016",
29 "EventName": "PM_CMPLU_STALL_LSAQ_ARB",
30 "BriefDescription": "Finish stall because the NTF instruction was a load or store that was held in LSAQ because an older instruction from SRQ or LRQ won arbitration to the LSU pipe when this instruction tried to launch"
31 },
32 {,
33 "EventCode": "0x1001A",
34 "EventName": "PM_LSU_SRQ_FULL_CYC",
35 "BriefDescription": "Cycles in which the Store Queue is full on all 4 slices. This is event is not per thread. All the threads will see the same count for this core resource"
36 },
37 {,
38 "EventCode": "0x1E15E",
39 "EventName": "PM_MRK_L2_TM_REQ_ABORT",
40 "BriefDescription": "TM abort"
41 },
42 {,
43 "EventCode": "0x34052",
44 "EventName": "PM_INST_SYS_PUMP_MPRED",
45 "BriefDescription": "Final Pump Scope (system) mispredicted. Either the original scope was too small (Chip/Group) or the original scope was System and it should have been smaller. Counts for an instruction fetch"
46 },
47 {,
48 "EventCode": "0x20114",
49 "EventName": "PM_MRK_L2_RC_DISP",
50 "BriefDescription": "Marked Instruction RC dispatched in L2"
51 },
52 {,
53 "EventCode": "0x4C044",
54 "EventName": "PM_DATA_FROM_L31_ECO_MOD",
55 "BriefDescription": "The processor's data cache was reloaded with Modified (M) data from another core's ECO L3 on the same chip due to a demand load"
56 },
57 {,
58 "EventCode": "0x1C044",
59 "EventName": "PM_DATA_FROM_L3_NO_CONFLICT",
60 "BriefDescription": "The processor's data cache was reloaded from local core's L3 without conflict due to a demand load"
61 },
62 {,
63 "EventCode": "0x44050",
64 "EventName": "PM_INST_SYS_PUMP_MPRED_RTY",
65 "BriefDescription": "Final Pump Scope (system) ended up larger than Initial Pump Scope (Chip/Group) for an instruction fetch"
66 },
67 {,
68 "EventCode": "0x30154",
69 "EventName": "PM_MRK_FAB_RSP_DCLAIM",
70 "BriefDescription": "Marked store had to do a dclaim"
71 },
72 {,
73 "EventCode": "0x30014",
74 "EventName": "PM_CMPLU_STALL_STORE_FIN_ARB",
75 "BriefDescription": "Finish stall because the NTF instruction was a store waiting for a slot in the store finish pipe. This means the instruction is ready to finish but there are instructions ahead of it, using the finish pipe"
76 },
77 {,
78 "EventCode": "0x3E054",
79 "EventName": "PM_LD_MISS_L1",
80 "BriefDescription": "Load Missed L1, counted at execution time (can be greater than loads finished). LMQ merges are not included in this count. i.e. if a load instruction misses on an address that is already allocated on the LMQ, this event will not increment for that load). Note that this count is per slice, so if a load spans multiple slices this event will increment multiple times for a single load."
81 },
82 {,
83 "EventCode": "0x2E01A",
84 "EventName": "PM_CMPLU_STALL_LSU_FLUSH_NEXT",
85 "BriefDescription": "Completion stall of one cycle because the LSU requested to flush the next iop in the sequence. It takes 1 cycle for the ISU to process this request before the LSU instruction is allowed to complete"
86 },
87 {,
88 "EventCode": "0x2D01C",
89 "EventName": "PM_CMPLU_STALL_STCX",
90 "BriefDescription": "Finish stall because the NTF instruction was a stcx waiting for response from L2"
91 },
92 {,
93 "EventCode": "0x2C010",
94 "EventName": "PM_CMPLU_STALL_LSU",
95 "BriefDescription": "Completion stall by LSU instruction"
96 },
97 {,
98 "EventCode": "0x2C042",
99 "EventName": "PM_DATA_FROM_L3_MEPF",
100 "BriefDescription": "The processor's data cache was reloaded from local core's L3 without dispatch conflicts hit on Mepf state due to a demand load"
101 },
102 {,
103 "EventCode": "0x4E012",
104 "EventName": "PM_CMPLU_STALL_MTFPSCR",
105 "BriefDescription": "Completion stall because the ISU is updating the register and notifying the Effective Address Table (EAT)"
106 },
107 {,
108 "EventCode": "0x100F2",
109 "EventName": "PM_1PLUS_PPC_CMPL",
110 "BriefDescription": "1 or more ppc insts finished"
111 },
112 {,
113 "EventCode": "0x3001C",
114 "EventName": "PM_LSU_REJECT_LMQ_FULL",
115 "BriefDescription": "LSU Reject due to LMQ full (up to 4 per cycles)"
116 },
117 {,
118 "EventCode": "0x15046",
119 "EventName": "PM_IPTEG_FROM_L31_SHR",
120 "BriefDescription": "A Page Table Entry was loaded into the TLB with Shared (S) data from another core's L3 on the same chip due to a instruction side request"
121 },
122 {,
123 "EventCode": "0x1015E",
124 "EventName": "PM_MRK_FAB_RSP_RD_T_INTV",
125 "BriefDescription": "Sampled Read got a T intervention"
126 },
127 {,
128 "EventCode": "0x101EC",
129 "EventName": "PM_THRESH_MET",
130 "BriefDescription": "threshold exceeded"
131 },
132 {,
133 "EventCode": "0x10020",
134 "EventName": "PM_PMC4_REWIND",
135 "BriefDescription": "PMC4 Rewind Event"
136 },
137 {,
138 "EventCode": "0x301EA",
139 "EventName": "PM_THRESH_EXC_1024",
140 "BriefDescription": "Threshold counter exceeded a value of 1024"
141 },
142 {,
143 "EventCode": "0x34056",
144 "EventName": "PM_CMPLU_STALL_LSU_MFSPR",
145 "BriefDescription": "Finish stall because the NTF instruction was a mfspr instruction targeting an LSU SPR and it was waiting for the register data to be returned"
146 },
147 {,
148 "EventCode": "0x44056",
149 "EventName": "PM_VECTOR_ST_CMPL",
150 "BriefDescription": "Number of vector store instructions completed"
151 },
152 {,
153 "EventCode": "0x2C124",
154 "EventName": "PM_MRK_DATA_FROM_L2_DISP_CONFLICT_OTHER",
155 "BriefDescription": "The processor's data cache was reloaded from local core's L2 with dispatch conflict due to a marked load"
156 },
157 {,
158 "EventCode": "0x4C12A",
159 "EventName": "PM_MRK_DATA_FROM_RL2L3_SHR_CYC",
160 "BriefDescription": "Duration in cycles to reload with Shared (S) data from another chip's L2 or L3 on the same Node or Group (Remote), as this chip due to a marked load"
161 },
162 {,
163 "EventCode": "0x3C056",
164 "EventName": "PM_DTLB_MISS_64K",
165 "BriefDescription": "Data TLB Miss page size 64K"
166 },
167 {,
168 "EventCode": "0x30060",
169 "EventName": "PM_TM_TRANS_RUN_INST",
170 "BriefDescription": "Run instructions completed in transactional state (gated by the run latch)"
171 },
172 {,
173 "EventCode": "0x2C014",
174 "EventName": "PM_CMPLU_STALL_STORE_FINISH",
175 "BriefDescription": "Finish stall because the NTF instruction was a store with all its dependencies met, just waiting to go through the LSU pipe to finish"
176 },
177 {,
178 "EventCode": "0x3515A",
179 "EventName": "PM_MRK_DATA_FROM_ON_CHIP_CACHE_CYC",
180 "BriefDescription": "Duration in cycles to reload either shared or modified data from another core's L2/L3 on the same chip due to a marked load"
181 },
182 {,
183 "EventCode": "0x34050",
184 "EventName": "PM_INST_SYS_PUMP_CPRED",
185 "BriefDescription": "Initial and Final Pump Scope was system pump (prediction=correct) for an instruction fetch"
186 },
187 {,
188 "EventCode": "0x3015E",
189 "EventName": "PM_MRK_FAB_RSP_CLAIM_RTY",
190 "BriefDescription": "Sampled store did a rwitm and got a rty"
191 },
192 {,
193 "EventCode": "0x0",
194 "EventName": "PM_SUSPENDED",
195 "BriefDescription": "Counter OFF"
196 },
197 {,
198 "EventCode": "0x10010",
199 "EventName": "PM_PMC4_OVERFLOW",
200 "BriefDescription": "Overflow from counter 4"
201 },
202 {,
203 "EventCode": "0x3E04A",
204 "EventName": "PM_DPTEG_FROM_RMEM",
205 "BriefDescription": "A Page Table Entry was loaded into the TLB from another chip's memory on the same Node or Group ( Remote) due to a data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
206 },
207 {,
208 "EventCode": "0x2F152",
209 "EventName": "PM_MRK_FAB_RSP_DCLAIM_CYC",
210 "BriefDescription": "cycles L2 RC took for a dclaim"
211 },
212 {,
213 "EventCode": "0x10004",
214 "EventName": "PM_CMPLU_STALL_LRQ_OTHER",
215 "BriefDescription": "Finish stall due to LRQ miscellaneous reasons, lost arbitration to LMQ slot, bank collisions, set prediction cleanup, set prediction multihit and others"
216 },
217 {,
218 "EventCode": "0x4F150",
219 "EventName": "PM_MRK_FAB_RSP_RWITM_CYC",
220 "BriefDescription": "cycles L2 RC took for a rwitm"
221 },
222 {,
223 "EventCode": "0x4E042",
224 "EventName": "PM_DPTEG_FROM_L3",
225 "BriefDescription": "A Page Table Entry was loaded into the TLB from local core's L3 due to a data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
226 },
227 {,
228 "EventCode": "0x1F054",
229 "EventName": "PM_TLB_HIT",
230 "BriefDescription": "Number of times the TLB had the data required by the instruction. Applies to both HPT and RPT"
231 },
232 {,
233 "EventCode": "0x2C01E",
234 "EventName": "PM_CMPLU_STALL_SYNC_PMU_INT",
235 "BriefDescription": "Cycles in which the NTC instruction is waiting for a synchronous PMU interrupt"
236 },
237 {,
238 "EventCode": "0x24050",
239 "EventName": "PM_IOPS_CMPL",
240 "BriefDescription": "Internal Operations completed"
241 },
242 {,
243 "EventCode": "0x1515C",
244 "EventName": "PM_SYNC_MRK_BR_MPRED",
245 "BriefDescription": "Marked Branch mispredict that can cause a synchronous interrupt"
246 },
247 {,
248 "EventCode": "0x300FA",
249 "EventName": "PM_INST_FROM_L3MISS",
250 "BriefDescription": "Marked instruction was reloaded from a location beyond the local chiplet"
251 },
252 {,
253 "EventCode": "0x15044",
254 "EventName": "PM_IPTEG_FROM_L3_NO_CONFLICT",
255 "BriefDescription": "A Page Table Entry was loaded into the TLB from local core's L3 without conflict due to a instruction side request"
256 },
257 {,
258 "EventCode": "0x15152",
259 "EventName": "PM_SYNC_MRK_BR_LINK",
260 "BriefDescription": "Marked Branch and link branch that can cause a synchronous interrupt"
261 },
262 {,
263 "EventCode": "0x1E050",
264 "EventName": "PM_CMPLU_STALL_TEND",
265 "BriefDescription": "Finish stall because the NTF instruction was a tend instruction awaiting response from L2"
266 },
267 {,
268 "EventCode": "0x1013E",
269 "EventName": "PM_MRK_LD_MISS_EXPOSED_CYC",
270 "BriefDescription": "Marked Load exposed Miss (use edge detect to count #)"
271 },
272 {,
273 "EventCode": "0x25042",
274 "EventName": "PM_IPTEG_FROM_L3_MEPF",
275 "BriefDescription": "A Page Table Entry was loaded into the TLB from local core's L3 without dispatch conflicts hit on Mepf state. due to a instruction side request"
276 },
277 {,
278 "EventCode": "0x14054",
279 "EventName": "PM_INST_PUMP_CPRED",
280 "BriefDescription": "Pump prediction correct. Counts across all types of pumps for an instruction fetch"
281 },
282 {,
283 "EventCode": "0x4015E",
284 "EventName": "PM_MRK_FAB_RSP_RD_RTY",
285 "BriefDescription": "Sampled L2 reads retry count"
286 },
287 {,
288 "EventCode": "0x45048",
289 "EventName": "PM_IPTEG_FROM_DL2L3_MOD",
290 "BriefDescription": "A Page Table Entry was loaded into the TLB with Modified (M) data from another chip's L2 or L3 on a different Node or Group (Distant), as this chip due to a instruction side request"
291 },
292 {,
293 "EventCode": "0x44052",
294 "EventName": "PM_INST_PUMP_MPRED",
295 "BriefDescription": "Pump misprediction. Counts across all types of pumps for an instruction fetch"
296 },
297 {,
298 "EventCode": "0x30026",
299 "EventName": "PM_CMPLU_STALL_STORE_DATA",
300 "BriefDescription": "Finish stall because the next to finish instruction was a store waiting on data"
301 },
302 {,
303 "EventCode": "0x301E6",
304 "EventName": "PM_MRK_DERAT_MISS",
305 "BriefDescription": "Erat Miss (TLB Access) All page sizes"
306 },
307 {,
308 "EventCode": "0x24154",
309 "EventName": "PM_THRESH_ACC",
310 "BriefDescription": "This event increments every time the threshold event counter ticks. Thresholding must be enabled (via MMCRA) and the thresholding start event must occur for this counter to increment. It will stop incrementing when the thresholding stop event occurs or when thresholding is disabled, until the next time a configured thresholding start event occurs."
311 },
312 {,
313 "EventCode": "0x2015E",
314 "EventName": "PM_MRK_FAB_RSP_RWITM_RTY",
315 "BriefDescription": "Sampled store did a rwitm and got a rty"
316 },
317 {,
318 "EventCode": "0x200FA",
319 "EventName": "PM_BR_TAKEN_CMPL",
320 "BriefDescription": "New event for Branch Taken"
321 },
322 {,
323 "EventCode": "0x35044",
324 "EventName": "PM_IPTEG_FROM_L31_ECO_SHR",
325 "BriefDescription": "A Page Table Entry was loaded into the TLB with Shared (S) data from another core's ECO L3 on the same chip due to a instruction side request"
326 },
327 {,
328 "EventCode": "0x4C010",
329 "EventName": "PM_CMPLU_STALL_STORE_PIPE_ARB",
330 "BriefDescription": "Finish stall because the NTF instruction was a store waiting for the next relaunch opportunity after an internal reject. This means the instruction is ready to relaunch and tried once but lost arbitration"
331 },
332 {,
333 "EventCode": "0x4C01C",
334 "EventName": "PM_CMPLU_STALL_ST_FWD",
335 "BriefDescription": "Completion stall due to store forward"
336 },
337 {,
338 "EventCode": "0x3515C",
339 "EventName": "PM_MRK_DATA_FROM_RL4",
340 "BriefDescription": "The processor's data cache was reloaded from another chip's L4 on the same Node or Group ( Remote) due to a marked load"
341 },
342 {,
343 "EventCode": "0x2D14C",
344 "EventName": "PM_MRK_DATA_FROM_L31_ECO_SHR",
345 "BriefDescription": "The processor's data cache was reloaded with Shared (S) data from another core's ECO L3 on the same chip due to a marked load"
346 },
347 {,
348 "EventCode": "0x40116",
349 "EventName": "PM_MRK_LARX_FIN",
350 "BriefDescription": "Larx finished"
351 },
352 {,
353 "EventCode": "0x4C056",
354 "EventName": "PM_DTLB_MISS_16M",
355 "BriefDescription": "Data TLB Miss page size 16M"
356 },
357 {,
358 "EventCode": "0x1003A",
359 "EventName": "PM_CMPLU_STALL_LSU_FIN",
360 "BriefDescription": "Finish stall because the NTF instruction was an LSU op (other than a load or a store) with all its dependencies met and just going through the LSU pipe to finish"
361 },
362 {,
363 "EventCode": "0x3012A",
364 "EventName": "PM_MRK_L2_RC_DONE",
365 "BriefDescription": "Marked RC done"
366 },
367 {,
368 "EventCode": "0x45044",
369 "EventName": "PM_IPTEG_FROM_L31_ECO_MOD",
370 "BriefDescription": "A Page Table Entry was loaded into the TLB with Modified (M) data from another core's ECO L3 on the same chip due to a instruction side request"
371 }
372]
diff --git a/tools/perf/pmu-events/arch/powerpc/power9/marked.json b/tools/perf/pmu-events/arch/powerpc/power9/marked.json
new file mode 100644
index 000000000000..b9df54fb37e3
--- /dev/null
+++ b/tools/perf/pmu-events/arch/powerpc/power9/marked.json
@@ -0,0 +1,647 @@
1[
2 {,
3 "EventCode": "0x3C052",
4 "EventName": "PM_DATA_SYS_PUMP_MPRED",
5 "BriefDescription": "Final Pump Scope (system) mispredicted. Either the original scope was too small (Chip/Group) or the original scope was System and it should have been smaller. Counts for a demand load"
6 },
7 {,
8 "EventCode": "0x3013E",
9 "EventName": "PM_MRK_STALL_CMPLU_CYC",
10 "BriefDescription": "Number of cycles the marked instruction is experiencing a stall while it is next to complete (NTC)"
11 },
12 {,
13 "EventCode": "0x4F056",
14 "EventName": "PM_RADIX_PWC_L1_PDE_FROM_L3MISS",
15 "BriefDescription": "A Page Directory Entry was reloaded to a level 1 page walk cache from beyond the core's L3 data cache. The source could be local/remote/distant memory or another core's cache"
16 },
17 {,
18 "EventCode": "0x24158",
19 "EventName": "PM_MRK_INST",
20 "BriefDescription": "An instruction was marked. Includes both Random Instruction Sampling (RIS) at decode time and Random Event Sampling (RES) at the time the configured event happens"
21 },
22 {,
23 "EventCode": "0x1E046",
24 "EventName": "PM_DPTEG_FROM_L31_SHR",
25 "BriefDescription": "A Page Table Entry was loaded into the TLB with Shared (S) data from another core's L3 on the same chip due to a data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
26 },
27 {,
28 "EventCode": "0x3C04A",
29 "EventName": "PM_DATA_FROM_RMEM",
30 "BriefDescription": "The processor's data cache was reloaded from another chip's memory on the same Node or Group ( Remote) due to a demand load"
31 },
32 {,
33 "EventCode": "0x2C01C",
34 "EventName": "PM_CMPLU_STALL_DMISS_REMOTE",
35 "BriefDescription": "Completion stall by Dcache miss which resolved from remote chip (cache or memory)"
36 },
37 {,
38 "EventCode": "0x44040",
39 "EventName": "PM_INST_FROM_L2_DISP_CONFLICT_OTHER",
40 "BriefDescription": "The processor's Instruction cache was reloaded from local core's L2 with dispatch conflict due to an instruction fetch (not prefetch)"
41 },
42 {,
43 "EventCode": "0x2E050",
44 "EventName": "PM_DARQ0_7_9_ENTRIES",
45 "BriefDescription": "Cycles in which 7,8, or 9 DARQ entries (out of 12) are in use"
46 },
47 {,
48 "EventCode": "0x2D02E",
49 "EventName": "PM_RADIX_PWC_L3_PTE_FROM_L2",
50 "BriefDescription": "A Page Table Entry was reloaded to a level 3 page walk cache from the core's L2 data cache. This implies that a level 4 PWC access was not necessary for this translation"
51 },
52 {,
53 "EventCode": "0x3F05E",
54 "EventName": "PM_RADIX_PWC_L3_PTE_FROM_L3",
55 "BriefDescription": "A Page Table Entry was reloaded to a level 3 page walk cache from the core's L3 data cache. This implies that a level 4 PWC access was not necessary for this translation"
56 },
57 {,
58 "EventCode": "0x2E01E",
59 "EventName": "PM_CMPLU_STALL_NTC_FLUSH",
60 "BriefDescription": "Completion stall due to ntc flush"
61 },
62 {,
63 "EventCode": "0x1F14C",
64 "EventName": "PM_MRK_DPTEG_FROM_LL4",
65 "BriefDescription": "A Page Table Entry was loaded into the TLB from the local chip's L4 cache due to a marked data side request.. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
66 },
67 {,
68 "EventCode": "0x20130",
69 "EventName": "PM_MRK_INST_DECODED",
70 "BriefDescription": "An instruction was marked at decode time. Random Instruction Sampling (RIS) only"
71 },
72 {,
73 "EventCode": "0x3F144",
74 "EventName": "PM_MRK_DPTEG_FROM_L31_ECO_SHR",
75 "BriefDescription": "A Page Table Entry was loaded into the TLB with Shared (S) data from another core's ECO L3 on the same chip due to a marked data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
76 },
77 {,
78 "EventCode": "0x4D058",
79 "EventName": "PM_VECTOR_FLOP_CMPL",
80 "BriefDescription": "Vector FP instruction completed"
81 },
82 {,
83 "EventCode": "0x14040",
84 "EventName": "PM_INST_FROM_L2_NO_CONFLICT",
85 "BriefDescription": "The processor's Instruction cache was reloaded from local core's L2 without conflict due to an instruction fetch (not prefetch)"
86 },
87 {,
88 "EventCode": "0x4404E",
89 "EventName": "PM_INST_FROM_L3MISS_MOD",
90 "BriefDescription": "The processor's Instruction cache was reloaded from a location other than the local core's L3 due to a instruction fetch"
91 },
92 {,
93 "EventCode": "0x3003A",
94 "EventName": "PM_CMPLU_STALL_EXCEPTION",
95 "BriefDescription": "Cycles in which the NTC instruction is not allowed to complete because it was interrupted by ANY exception, which has to be serviced before the instruction can complete"
96 },
97 {,
98 "EventCode": "0x4F144",
99 "EventName": "PM_MRK_DPTEG_FROM_L31_ECO_MOD",
100 "BriefDescription": "A Page Table Entry was loaded into the TLB with Modified (M) data from another core's ECO L3 on the same chip due to a marked data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
101 },
102 {,
103 "EventCode": "0x3E044",
104 "EventName": "PM_DPTEG_FROM_L31_ECO_SHR",
105 "BriefDescription": "A Page Table Entry was loaded into the TLB with Shared (S) data from another core's ECO L3 on the same chip due to a data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
106 },
107 {,
108 "EventCode": "0x300F6",
109 "EventName": "PM_L1_DCACHE_RELOAD_VALID",
110 "BriefDescription": "DL1 reloaded due to Demand Load"
111 },
112 {,
113 "EventCode": "0x1415E",
114 "EventName": "PM_MRK_DATA_FROM_L3MISS_CYC",
115 "BriefDescription": "Duration in cycles to reload from a location other than the local core's L3 due to a marked load"
116 },
117 {,
118 "EventCode": "0x1E052",
119 "EventName": "PM_CMPLU_STALL_SLB",
120 "BriefDescription": "Finish stall because the NTF instruction was awaiting L2 response for an SLB"
121 },
122 {,
123 "EventCode": "0x4404C",
124 "EventName": "PM_INST_FROM_DMEM",
125 "BriefDescription": "The processor's Instruction cache was reloaded from another chip's memory on the same Node or Group (Distant) due to an instruction fetch (not prefetch)"
126 },
127 {,
128 "EventCode": "0x3000E",
129 "EventName": "PM_FXU_1PLUS_BUSY",
130 "BriefDescription": "At least one of the 4 FXU units is busy"
131 },
132 {,
133 "EventCode": "0x2C048",
134 "EventName": "PM_DATA_FROM_LMEM",
135 "BriefDescription": "The processor's data cache was reloaded from the local chip's Memory due to a demand load"
136 },
137 {,
138 "EventCode": "0x3000A",
139 "EventName": "PM_CMPLU_STALL_PM",
140 "BriefDescription": "Finish stall because the NTF instruction was issued to the Permute execution pipe and waiting to finish. Includes permute and decimal fixed point instructions (128 bit BCD arithmetic) + a few 128 bit fixpoint add/subtract instructions with carry. Not qualified by vector or multicycle"
141 },
142 {,
143 "EventCode": "0x1504E",
144 "EventName": "PM_IPTEG_FROM_L2MISS",
145 "BriefDescription": "A Page Table Entry was loaded into the TLB from a location other than the local core's L2 due to a instruction side request"
146 },
147 {,
148 "EventCode": "0x1C052",
149 "EventName": "PM_DATA_GRP_PUMP_MPRED_RTY",
150 "BriefDescription": "Final Pump Scope (Group) ended up larger than Initial Pump Scope (Chip) for a demand load"
151 },
152 {,
153 "EventCode": "0x30008",
154 "EventName": "PM_DISP_STARVED",
155 "BriefDescription": "Dispatched Starved"
156 },
157 {,
158 "EventCode": "0x14042",
159 "EventName": "PM_INST_FROM_L2",
160 "BriefDescription": "The processor's Instruction cache was reloaded from local core's L2 due to an instruction fetch (not prefetch)"
161 },
162 {,
163 "EventCode": "0x4000C",
164 "EventName": "PM_FREQ_UP",
165 "BriefDescription": "Power Management: Above Threshold A"
166 },
167 {,
168 "EventCode": "0x3C050",
169 "EventName": "PM_DATA_SYS_PUMP_CPRED",
170 "BriefDescription": "Initial and Final Pump Scope was system pump (prediction=correct) for a demand load"
171 },
172 {,
173 "EventCode": "0x25040",
174 "EventName": "PM_IPTEG_FROM_L2_MEPF",
175 "BriefDescription": "A Page Table Entry was loaded into the TLB from local core's L2 hit without dispatch conflicts on Mepf state. due to a instruction side request"
176 },
177 {,
178 "EventCode": "0x10132",
179 "EventName": "PM_MRK_INST_ISSUED",
180 "BriefDescription": "Marked instruction issued"
181 },
182 {,
183 "EventCode": "0x1C046",
184 "EventName": "PM_DATA_FROM_L31_SHR",
185 "BriefDescription": "The processor's data cache was reloaded with Shared (S) data from another core's L3 on the same chip due to a demand load"
186 },
187 {,
188 "EventCode": "0x2C044",
189 "EventName": "PM_DATA_FROM_L31_MOD",
190 "BriefDescription": "The processor's data cache was reloaded with Modified (M) data from another core's L3 on the same chip due to a demand load"
191 },
192 {,
193 "EventCode": "0x2C04A",
194 "EventName": "PM_DATA_FROM_RL4",
195 "BriefDescription": "The processor's data cache was reloaded from another chip's L4 on the same Node or Group ( Remote) due to a demand load"
196 },
197 {,
198 "EventCode": "0x24044",
199 "EventName": "PM_INST_FROM_L31_MOD",
200 "BriefDescription": "The processor's Instruction cache was reloaded with Modified (M) data from another core's L3 on the same chip due to an instruction fetch (not prefetch)"
201 },
202 {,
203 "EventCode": "0x4C050",
204 "EventName": "PM_DATA_SYS_PUMP_MPRED_RTY",
205 "BriefDescription": "Final Pump Scope (system) ended up larger than Initial Pump Scope (Chip/Group) for a demand load"
206 },
207 {,
208 "EventCode": "0x2C052",
209 "EventName": "PM_DATA_GRP_PUMP_MPRED",
210 "BriefDescription": "Final Pump Scope (Group) ended up either larger or smaller than Initial Pump Scope for a demand load"
211 },
212 {,
213 "EventCode": "0x2F148",
214 "EventName": "PM_MRK_DPTEG_FROM_LMEM",
215 "BriefDescription": "A Page Table Entry was loaded into the TLB from the local chip's Memory due to a marked data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
216 },
217 {,
218 "EventCode": "0x4D01A",
219 "EventName": "PM_CMPLU_STALL_EIEIO",
220 "BriefDescription": "Finish stall because the NTF instruction is an EIEIO waiting for response from L2"
221 },
222 {,
223 "EventCode": "0x4F14E",
224 "EventName": "PM_MRK_DPTEG_FROM_L3MISS",
225 "BriefDescription": "A Page Table Entry was loaded into the TLB from a location other than the local core's L3 due to a marked data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
226 },
227 {,
228 "EventCode": "0x4F05A",
229 "EventName": "PM_RADIX_PWC_L4_PTE_FROM_L3",
230 "BriefDescription": "A Page Table Entry was reloaded to a level 4 page walk cache from the core's L3 data cache. This is the deepest level of PWC possible for a translation"
231 },
232 {,
233 "EventCode": "0x1F05A",
234 "EventName": "PM_RADIX_PWC_L4_PTE_FROM_L2",
235 "BriefDescription": "A Page Table Entry was reloaded to a level 4 page walk cache from the core's L2 data cache. This is the deepest level of PWC possible for a translation"
236 },
237 {,
238 "EventCode": "0x30068",
239 "EventName": "PM_L1_ICACHE_RELOADED_PREF",
240 "BriefDescription": "Counts all Icache prefetch reloads ( includes demand turned into prefetch)"
241 },
242 {,
243 "EventCode": "0x4C04A",
244 "EventName": "PM_DATA_FROM_OFF_CHIP_CACHE",
245 "BriefDescription": "The processor's data cache was reloaded either shared or modified data from another core's L2/L3 on a different chip (remote or distant) due to a demand load"
246 },
247 {,
248 "EventCode": "0x400FE",
249 "EventName": "PM_DATA_FROM_MEMORY",
250 "BriefDescription": "The processor's data cache was reloaded from a memory location including L4 from local remote or distant due to a demand load"
251 },
252 {,
253 "EventCode": "0x3F058",
254 "EventName": "PM_RADIX_PWC_L1_PDE_FROM_L3",
255 "BriefDescription": "A Page Directory Entry was reloaded to a level 1 page walk cache from the core's L3 data cache"
256 },
257 {,
258 "EventCode": "0x4D142",
259 "EventName": "PM_MRK_DATA_FROM_L3",
260 "BriefDescription": "The processor's data cache was reloaded from local core's L3 due to a marked load"
261 },
262 {,
263 "EventCode": "0x30050",
264 "EventName": "PM_SYS_PUMP_CPRED",
265 "BriefDescription": "Initial and Final Pump Scope was system pump for all data types excluding data prefetch (demand load,inst prefetch,inst fetch,xlate)"
266 },
267 {,
268 "EventCode": "0x30028",
269 "EventName": "PM_CMPLU_STALL_SPEC_FINISH",
270 "BriefDescription": "Finish stall while waiting for the non-speculative finish of either a stcx waiting for its result or a load waiting for non-critical sectors of data and ECC"
271 },
272 {,
273 "EventCode": "0x400F4",
274 "EventName": "PM_RUN_PURR",
275 "BriefDescription": "Run_PURR"
276 },
277 {,
278 "EventCode": "0x3404C",
279 "EventName": "PM_INST_FROM_DL4",
280 "BriefDescription": "The processor's Instruction cache was reloaded from another chip's L4 on a different Node or Group (Distant) due to an instruction fetch (not prefetch)"
281 },
282 {,
283 "EventCode": "0x3D05A",
284 "EventName": "PM_NTC_ISSUE_HELD_OTHER",
285 "BriefDescription": "The NTC instruction is being held at dispatch during regular pipeline cycles, or because the VSU is busy with multi-cycle instructions, or because of a write-back collision with VSU"
286 },
287 {,
288 "EventCode": "0x2E048",
289 "EventName": "PM_DPTEG_FROM_LMEM",
290 "BriefDescription": "A Page Table Entry was loaded into the TLB from the local chip's Memory due to a data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
291 },
292 {,
293 "EventCode": "0x2D02A",
294 "EventName": "PM_RADIX_PWC_L3_PDE_FROM_L2",
295 "BriefDescription": "A Page Directory Entry was reloaded to a level 3 page walk cache from the core's L2 data cache"
296 },
297 {,
298 "EventCode": "0x1F05C",
299 "EventName": "PM_RADIX_PWC_L3_PDE_FROM_L3",
300 "BriefDescription": "A Page Directory Entry was reloaded to a level 3 page walk cache from the core's L3 data cache"
301 },
302 {,
303 "EventCode": "0x4D04A",
304 "EventName": "PM_DARQ0_0_3_ENTRIES",
305 "BriefDescription": "Cycles in which 3 or less DARQ entries (out of 12) are in use"
306 },
307 {,
308 "EventCode": "0x1404C",
309 "EventName": "PM_INST_FROM_LL4",
310 "BriefDescription": "The processor's Instruction cache was reloaded from the local chip's L4 cache due to an instruction fetch (not prefetch)"
311 },
312 {,
313 "EventCode": "0x200FD",
314 "EventName": "PM_L1_ICACHE_MISS",
315 "BriefDescription": "Demand iCache Miss"
316 },
317 {,
318 "EventCode": "0x34040",
319 "EventName": "PM_INST_FROM_L2_DISP_CONFLICT_LDHITST",
320 "BriefDescription": "The processor's Instruction cache was reloaded from local core's L2 with load hit store conflict due to an instruction fetch (not prefetch)"
321 },
322 {,
323 "EventCode": "0x20138",
324 "EventName": "PM_MRK_ST_NEST",
325 "BriefDescription": "Marked store sent to nest"
326 },
327 {,
328 "EventCode": "0x44048",
329 "EventName": "PM_INST_FROM_DL2L3_MOD",
330 "BriefDescription": "The processor's Instruction cache was reloaded with Modified (M) data from another chip's L2 or L3 on a different Node or Group (Distant), as this chip due to an instruction fetch (not prefetch)"
331 },
332 {,
333 "EventCode": "0x35046",
334 "EventName": "PM_IPTEG_FROM_L21_SHR",
335 "BriefDescription": "A Page Table Entry was loaded into the TLB with Shared (S) data from another core's L2 on the same chip due to a instruction side request"
336 },
337 {,
338 "EventCode": "0x4C04E",
339 "EventName": "PM_DATA_FROM_L3MISS_MOD",
340 "BriefDescription": "The processor's data cache was reloaded from a location other than the local core's L3 due to a demand load"
341 },
342 {,
343 "EventCode": "0x401E0",
344 "EventName": "PM_MRK_INST_CMPL",
345 "BriefDescription": "marked instruction completed"
346 },
347 {,
348 "EventCode": "0x2C128",
349 "EventName": "PM_MRK_DATA_FROM_DL2L3_SHR_CYC",
350 "BriefDescription": "Duration in cycles to reload with Shared (S) data from another chip's L2 or L3 on a different Node or Group (Distant), as this chip due to a marked load"
351 },
352 {,
353 "EventCode": "0x34044",
354 "EventName": "PM_INST_FROM_L31_ECO_SHR",
355 "BriefDescription": "The processor's Instruction cache was reloaded with Shared (S) data from another core's ECO L3 on the same chip due to an instruction fetch (not prefetch)"
356 },
357 {,
358 "EventCode": "0x4E018",
359 "EventName": "PM_CMPLU_STALL_NTC_DISP_FIN",
360 "BriefDescription": "Finish stall because the NTF instruction was one that must finish at dispatch."
361 },
362 {,
363 "EventCode": "0x2E05E",
364 "EventName": "PM_LMQ_EMPTY_CYC",
365 "BriefDescription": "Cycles in which the LMQ has no pending load misses for this thread"
366 },
367 {,
368 "EventCode": "0x4C122",
369 "EventName": "PM_DARQ1_0_3_ENTRIES",
370 "BriefDescription": "Cycles in which 3 or fewer DARQ1 entries (out of 12) are in use"
371 },
372 {,
373 "EventCode": "0x4F058",
374 "EventName": "PM_RADIX_PWC_L2_PTE_FROM_L3",
375 "BriefDescription": "A Page Table Entry was reloaded to a level 2 page walk cache from the core's L3 data cache. This implies that level 3 and level 4 PWC accesses were not necessary for this translation"
376 },
377 {,
378 "EventCode": "0x14046",
379 "EventName": "PM_INST_FROM_L31_SHR",
380 "BriefDescription": "The processor's Instruction cache was reloaded with Shared (S) data from another core's L3 on the same chip due to an instruction fetch (not prefetch)"
381 },
382 {,
383 "EventCode": "0x3012C",
384 "EventName": "PM_MRK_ST_FWD",
385 "BriefDescription": "Marked st forwards"
386 },
387 {,
388 "EventCode": "0x101E0",
389 "EventName": "PM_MRK_INST_DISP",
390 "BriefDescription": "The thread has dispatched a randomly sampled marked instruction"
391 },
392 {,
393 "EventCode": "0x1D058",
394 "EventName": "PM_DARQ0_10_12_ENTRIES",
395 "BriefDescription": "Cycles in which 10 or more DARQ entries (out of 12) are in use"
396 },
397 {,
398 "EventCode": "0x300FE",
399 "EventName": "PM_DATA_FROM_L3MISS",
400 "BriefDescription": "Demand LD - L3 Miss (not L2 hit and not L3 hit)"
401 },
402 {,
403 "EventCode": "0x30006",
404 "EventName": "PM_CMPLU_STALL_OTHER_CMPL",
405 "BriefDescription": "Instructions the core completed while this tread was stalled"
406 },
407 {,
408 "EventCode": "0x1005C",
409 "EventName": "PM_CMPLU_STALL_DP",
410 "BriefDescription": "Finish stall because the NTF instruction was a scalar instruction issued to the Double Precision execution pipe and waiting to finish. Includes binary floating point instructions in 32 and 64 bit binary floating point format. Not qualified multicycle. Qualified by NOT vector"
411 },
412 {,
413 "EventCode": "0x1E042",
414 "EventName": "PM_DPTEG_FROM_L2",
415 "BriefDescription": "A Page Table Entry was loaded into the TLB from local core's L2 due to a data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
416 },
417 {,
418 "EventCode": "0x1016E",
419 "EventName": "PM_MRK_BR_CMPL",
420 "BriefDescription": "Branch Instruction completed"
421 },
422 {,
423 "EventCode": "0x2013A",
424 "EventName": "PM_MRK_BRU_FIN",
425 "BriefDescription": "bru marked instr finish"
426 },
427 {,
428 "EventCode": "0x4F05E",
429 "EventName": "PM_RADIX_PWC_L3_PTE_FROM_L3MISS",
430 "BriefDescription": "A Page Table Entry was reloaded to a level 3 page walk cache from beyond the core's L3 data cache. This implies that a level 4 PWC access was not necessary for this translation. The source could be local/remote/distant memory or another core's cache"
431 },
432 {,
433 "EventCode": "0x400FC",
434 "EventName": "PM_ITLB_MISS",
435 "BriefDescription": "ITLB Reloaded. Counts 1 per ITLB miss for HPT but multiple for radix depending on number of levels traveresed"
436 },
437 {,
438 "EventCode": "0x2D024",
439 "EventName": "PM_RADIX_PWC_L2_HIT",
440 "BriefDescription": "A radix translation attempt missed in the TLB but hit on both the first and second levels of page walk cache."
441 },
442 {,
443 "EventCode": "0x3F056",
444 "EventName": "PM_RADIX_PWC_L3_HIT",
445 "BriefDescription": "A radix translation attempt missed in the TLB but hit on the first, second, and third levels of page walk cache."
446 },
447 {,
448 "EventCode": "0x4E014",
449 "EventName": "PM_TM_TX_PASS_RUN_INST",
450 "BriefDescription": "Run instructions spent in successful transactions"
451 },
452 {,
453 "EventCode": "0x1E044",
454 "EventName": "PM_DPTEG_FROM_L3_NO_CONFLICT",
455 "BriefDescription": "A Page Table Entry was loaded into the TLB from local core's L3 without conflict due to a data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
456 },
457 {,
458 "EventCode": "0x4D05A",
459 "EventName": "PM_NON_MATH_FLOP_CMPL",
460 "BriefDescription": "Non FLOP operation completed"
461 },
462 {,
463 "EventCode": "0x101E2",
464 "EventName": "PM_MRK_BR_TAKEN_CMPL",
465 "BriefDescription": "Marked Branch Taken completed"
466 },
467 {,
468 "EventCode": "0x3E158",
469 "EventName": "PM_MRK_STCX_FAIL",
470 "BriefDescription": "marked stcx failed"
471 },
472 {,
473 "EventCode": "0x1C048",
474 "EventName": "PM_DATA_FROM_ON_CHIP_CACHE",
475 "BriefDescription": "The processor's data cache was reloaded either shared or modified data from another core's L2/L3 on the same chip due to a demand load"
476 },
477 {,
478 "EventCode": "0x1C054",
479 "EventName": "PM_DATA_PUMP_CPRED",
480 "BriefDescription": "Pump prediction correct. Counts across all types of pumps for a demand load"
481 },
482 {,
483 "EventCode": "0x4405E",
484 "EventName": "PM_DARQ_STORE_REJECT",
485 "BriefDescription": "The DARQ attempted to transmit a store into an LSAQ or SRQ entry but It was rejected. Divide by PM_DARQ_STORE_XMIT to get reject ratio"
486 },
487 {,
488 "EventCode": "0x1C042",
489 "EventName": "PM_DATA_FROM_L2",
490 "BriefDescription": "The processor's data cache was reloaded from local core's L2 due to a demand load"
491 },
492 {,
493 "EventCode": "0x1D14C",
494 "EventName": "PM_MRK_DATA_FROM_LL4",
495 "BriefDescription": "The processor's data cache was reloaded from the local chip's L4 cache due to a marked load"
496 },
497 {,
498 "EventCode": "0x1006C",
499 "EventName": "PM_RUN_CYC_ST_MODE",
500 "BriefDescription": "Cycles run latch is set and core is in ST mode"
501 },
502 {,
503 "EventCode": "0x3C044",
504 "EventName": "PM_DATA_FROM_L31_ECO_SHR",
505 "BriefDescription": "The processor's data cache was reloaded with Shared (S) data from another core's ECO L3 on the same chip due to a demand load"
506 },
507 {,
508 "EventCode": "0x4C052",
509 "EventName": "PM_DATA_PUMP_MPRED",
510 "BriefDescription": "Pump misprediction. Counts across all types of pumps for a demand load"
511 },
512 {,
513 "EventCode": "0x20050",
514 "EventName": "PM_GRP_PUMP_CPRED",
515 "BriefDescription": "Initial and Final Pump Scope and data sourced across this scope was group pump for all data types excluding data prefetch (demand load,inst prefetch,inst fetch,xlate)"
516 },
517 {,
518 "EventCode": "0x1F150",
519 "EventName": "PM_MRK_ST_L2DISP_TO_CMPL_CYC",
520 "BriefDescription": "cycles from L2 rc disp to l2 rc completion"
521 },
522 {,
523 "EventCode": "0x4505A",
524 "EventName": "PM_SP_FLOP_CMPL",
525 "BriefDescription": "SP instruction completed"
526 },
527 {,
528 "EventCode": "0x4000A",
529 "EventName": "PM_ISQ_36_44_ENTRIES",
530 "BriefDescription": "Cycles in which 36 or more Issue Queue entries are in use. This is a shared event, not per thread. There are 44 issue queue entries across 4 slices in the whole core"
531 },
532 {,
533 "EventCode": "0x2C12E",
534 "EventName": "PM_MRK_DATA_FROM_LL4_CYC",
535 "BriefDescription": "Duration in cycles to reload from the local chip's L4 cache due to a marked load"
536 },
537 {,
538 "EventCode": "0x2C058",
539 "EventName": "PM_MEM_PREF",
540 "BriefDescription": "Memory prefetch for this thread. Includes L4"
541 },
542 {,
543 "EventCode": "0x40012",
544 "EventName": "PM_L1_ICACHE_RELOADED_ALL",
545 "BriefDescription": "Counts all Icache reloads includes demand, prefetch, prefetch turned into demand and demand turned into prefetch"
546 },
547 {,
548 "EventCode": "0x4003C",
549 "EventName": "PM_DISP_HELD_SYNC_HOLD",
550 "BriefDescription": "Cycles in which dispatch is held because of a synchronizing instruction in the pipeline"
551 },
552 {,
553 "EventCode": "0x3003C",
554 "EventName": "PM_CMPLU_STALL_NESTED_TEND",
555 "BriefDescription": "Completion stall because the ISU is updating the TEXASR to keep track of the nested tend and decrement the TEXASR nested level. This is a short delay"
556 },
557 {,
558 "EventCode": "0x3D05C",
559 "EventName": "PM_DISP_HELD_HB_FULL",
560 "BriefDescription": "Dispatch held due to History Buffer full. Could be GPR/VSR/VMR/FPR/CR/XVF; CR; XVF (XER/VSCR/FPSCR)"
561 },
562 {,
563 "EventCode": "0x30052",
564 "EventName": "PM_SYS_PUMP_MPRED",
565 "BriefDescription": "Final Pump Scope (system) mispredicted. Either the original scope was too small (Chip/Group) or the original scope was System and it should have been smaller. Counts for all data types excluding data prefetch (demand load,inst prefetch,inst fetch,xlate)"
566 },
567 {,
568 "EventCode": "0x2E044",
569 "EventName": "PM_DPTEG_FROM_L31_MOD",
570 "BriefDescription": "A Page Table Entry was loaded into the TLB with Modified (M) data from another core's L3 on the same chip due to a data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
571 },
572 {,
573 "EventCode": "0x34048",
574 "EventName": "PM_INST_FROM_DL2L3_SHR",
575 "BriefDescription": "The processor's Instruction cache was reloaded with Shared (S) data from another chip's L2 or L3 on a different Node or Group (Distant), as this chip due to an instruction fetch (not prefetch)"
576 },
577 {,
578 "EventCode": "0x45042",
579 "EventName": "PM_IPTEG_FROM_L3",
580 "BriefDescription": "A Page Table Entry was loaded into the TLB from local core's L3 due to a instruction side request"
581 },
582 {,
583 "EventCode": "0x15042",
584 "EventName": "PM_IPTEG_FROM_L2",
585 "BriefDescription": "A Page Table Entry was loaded into the TLB from local core's L2 due to a instruction side request"
586 },
587 {,
588 "EventCode": "0x1C05E",
589 "EventName": "PM_MEM_LOC_THRESH_LSU_MED",
590 "BriefDescription": "Local memory above threshold for data prefetch"
591 },
592 {,
593 "EventCode": "0x40134",
594 "EventName": "PM_MRK_INST_TIMEO",
595 "BriefDescription": "marked Instruction finish timeout (instruction lost)"
596 },
597 {,
598 "EventCode": "0x1002C",
599 "EventName": "PM_L1_DCACHE_RELOADED_ALL",
600 "BriefDescription": "L1 data cache reloaded for demand. If MMCR1[16] is 1, prefetches will be included as well"
601 },
602 {,
603 "EventCode": "0x30130",
604 "EventName": "PM_MRK_INST_FIN",
605 "BriefDescription": "marked instruction finished"
606 },
607 {,
608 "EventCode": "0x1F14A",
609 "EventName": "PM_MRK_DPTEG_FROM_RL2L3_SHR",
610 "BriefDescription": "A Page Table Entry was loaded into the TLB with Shared (S) data from another chip's L2 or L3 on the same Node or Group (Remote), as this chip due to a marked data side request.. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
611 },
612 {,
613 "EventCode": "0x3504E",
614 "EventName": "PM_DARQ0_4_6_ENTRIES",
615 "BriefDescription": "Cycles in which 4, 5, or 6 DARQ entries (out of 12) are in use"
616 },
617 {,
618 "EventCode": "0x30064",
619 "EventName": "PM_DARQ_STORE_XMIT",
620 "BriefDescription": "The DARQ attempted to transmit a store into an LSAQ or SRQ entry. Includes rejects. Not qualified by thread, so it includes counts for the whole core"
621 },
622 {,
623 "EventCode": "0x45046",
624 "EventName": "PM_IPTEG_FROM_L21_MOD",
625 "BriefDescription": "A Page Table Entry was loaded into the TLB with Modified (M) data from another core's L2 on the same chip due to a instruction side request"
626 },
627 {,
628 "EventCode": "0x2C016",
629 "EventName": "PM_CMPLU_STALL_PASTE",
630 "BriefDescription": "Finish stall because the NTF instruction was a paste waiting for response from L2"
631 },
632 {,
633 "EventCode": "0x24156",
634 "EventName": "PM_MRK_STCX_FIN",
635 "BriefDescription": "Number of marked stcx instructions finished. This includes instructions in the speculative path of a branch that may be flushed"
636 },
637 {,
638 "EventCode": "0x15150",
639 "EventName": "PM_SYNC_MRK_PROBE_NOP",
640 "BriefDescription": "Marked probeNops which can cause synchronous interrupts"
641 },
642 {,
643 "EventCode": "0x301E4",
644 "EventName": "PM_MRK_BR_MPRED_CMPL",
645 "BriefDescription": "Marked Branch Mispredicted"
646 }
647]
diff --git a/tools/perf/pmu-events/arch/powerpc/power9/memory.json b/tools/perf/pmu-events/arch/powerpc/power9/memory.json
new file mode 100644
index 000000000000..9960d1c0dd44
--- /dev/null
+++ b/tools/perf/pmu-events/arch/powerpc/power9/memory.json
@@ -0,0 +1,132 @@
1[
2 {,
3 "EventCode": "0x3006E",
4 "EventName": "PM_NEST_REF_CLK",
5 "BriefDescription": "Multiply by 4 to obtain the number of PB cycles"
6 },
7 {,
8 "EventCode": "0x20010",
9 "EventName": "PM_PMC1_OVERFLOW",
10 "BriefDescription": "Overflow from counter 1"
11 },
12 {,
13 "EventCode": "0x2005A",
14 "EventName": "PM_DARQ1_7_9_ENTRIES",
15 "BriefDescription": "Cycles in which 7 to 9 DARQ1 entries (out of 12) are in use"
16 },
17 {,
18 "EventCode": "0x3C048",
19 "EventName": "PM_DATA_FROM_DL2L3_SHR",
20 "BriefDescription": "The processor's data cache was reloaded with Shared (S) data from another chip's L2 or L3 on a different Node or Group (Distant), as this chip due to a demand load"
21 },
22 {,
23 "EventCode": "0x10008",
24 "EventName": "PM_RUN_SPURR",
25 "BriefDescription": "Run SPURR"
26 },
27 {,
28 "EventCode": "0x200F6",
29 "EventName": "PM_LSU_DERAT_MISS",
30 "BriefDescription": "DERAT Reloaded due to a DERAT miss"
31 },
32 {,
33 "EventCode": "0x4C048",
34 "EventName": "PM_DATA_FROM_DL2L3_MOD",
35 "BriefDescription": "The processor's data cache was reloaded with Modified (M) data from another chip's L2 or L3 on a different Node or Group (Distant), as this chip due to a demand load"
36 },
37 {,
38 "EventCode": "0x1D15E",
39 "EventName": "PM_MRK_RUN_CYC",
40 "BriefDescription": "Run cycles in which a marked instruction is in the pipeline"
41 },
42 {,
43 "EventCode": "0x4003E",
44 "EventName": "PM_LD_CMPL",
45 "BriefDescription": "count of Loads completed"
46 },
47 {,
48 "EventCode": "0x2D156",
49 "EventName": "PM_MRK_DTLB_MISS_4K",
50 "BriefDescription": "Marked Data TLB Miss page size 4k"
51 },
52 {,
53 "EventCode": "0x4C042",
54 "EventName": "PM_DATA_FROM_L3",
55 "BriefDescription": "The processor's data cache was reloaded from local core's L3 due to a demand load"
56 },
57 {,
58 "EventCode": "0x4D02C",
59 "EventName": "PM_PMC1_REWIND",
60 "BriefDescription": ""
61 },
62 {,
63 "EventCode": "0x15158",
64 "EventName": "PM_SYNC_MRK_L2HIT",
65 "BriefDescription": "Marked L2 Hits that can throw a synchronous interrupt"
66 },
67 {,
68 "EventCode": "0x3404A",
69 "EventName": "PM_INST_FROM_RMEM",
70 "BriefDescription": "The processor's Instruction cache was reloaded from another chip's memory on the same Node or Group ( Remote) due to an instruction fetch (not prefetch)"
71 },
72 {,
73 "EventCode": "0x301E2",
74 "EventName": "PM_MRK_ST_CMPL",
75 "BriefDescription": "Marked store completed and sent to nest"
76 },
77 {,
78 "EventCode": "0x1C050",
79 "EventName": "PM_DATA_CHIP_PUMP_CPRED",
80 "BriefDescription": "Initial and Final Pump Scope was chip pump (prediction=correct) for a demand load"
81 },
82 {,
83 "EventCode": "0x4C040",
84 "EventName": "PM_DATA_FROM_L2_DISP_CONFLICT_OTHER",
85 "BriefDescription": "The processor's data cache was reloaded from local core's L2 with dispatch conflict due to a demand load"
86 },
87 {,
88 "EventCode": "0x2E05C",
89 "EventName": "PM_LSU_REJECT_ERAT_MISS",
90 "BriefDescription": "LSU Reject due to ERAT (up to 4 per cycles)"
91 },
92 {,
93 "EventCode": "0x1000A",
94 "EventName": "PM_PMC3_REWIND",
95 "BriefDescription": "PMC3 rewind event. A rewind happens when a speculative event (such as latency or CPI stack) is selected on PMC3 and the stall reason or reload source did not match the one programmed in PMC3. When this occurs, the count in PMC3 will not change."
96 },
97 {,
98 "EventCode": "0x3C058",
99 "EventName": "PM_LARX_FIN",
100 "BriefDescription": "Larx finished"
101 },
102 {,
103 "EventCode": "0x1C040",
104 "EventName": "PM_DATA_FROM_L2_NO_CONFLICT",
105 "BriefDescription": "The processor's data cache was reloaded from local core's L2 without conflict due to a demand load"
106 },
107 {,
108 "EventCode": "0x2C040",
109 "EventName": "PM_DATA_FROM_L2_MEPF",
110 "BriefDescription": "The processor's data cache was reloaded from local core's L2 hit without dispatch conflicts on Mepf state due to a demand load"
111 },
112 {,
113 "EventCode": "0x2E05A",
114 "EventName": "PM_LRQ_REJECT",
115 "BriefDescription": "Internal LSU reject from LRQ. Rejects cause the load to go back to LRQ, but it stays contained within the LSU once it gets issued. This event counts the number of times the LRQ attempts to relaunch an instruction after a reject. Any load can suffer multiple rejects"
116 },
117 {,
118 "EventCode": "0x2C05C",
119 "EventName": "PM_INST_GRP_PUMP_CPRED",
120 "BriefDescription": "Initial and Final Pump Scope was group pump (prediction=correct) for an instruction fetch (demand only)"
121 },
122 {,
123 "EventCode": "0x4D056",
124 "EventName": "PM_NON_FMA_FLOP_CMPL",
125 "BriefDescription": "Non FMA instruction completed"
126 },
127 {,
128 "EventCode": "0x3E050",
129 "EventName": "PM_DARQ1_4_6_ENTRIES",
130 "BriefDescription": "Cycles in which 4, 5, or 6 DARQ1 entries (out of 12) are in use"
131 }
132] \ No newline at end of file
diff --git a/tools/perf/pmu-events/arch/powerpc/power9/other.json b/tools/perf/pmu-events/arch/powerpc/power9/other.json
new file mode 100644
index 000000000000..54cc3be00fc2
--- /dev/null
+++ b/tools/perf/pmu-events/arch/powerpc/power9/other.json
@@ -0,0 +1,2392 @@
1[
2 {,
3 "EventCode": "0x3084",
4 "EventName": "PM_ISU1_ISS_HOLD_ALL",
5 "BriefDescription": "All ISU rejects"
6 },
7 {,
8 "EventCode": "0xF880",
9 "EventName": "PM_SNOOP_TLBIE",
10 "BriefDescription": "TLBIE snoop"
11 },
12 {,
13 "EventCode": "0x4088",
14 "EventName": "PM_IC_DEMAND_REQ",
15 "BriefDescription": "Demand Instruction fetch request"
16 },
17 {,
18 "EventCode": "0x20A4",
19 "EventName": "PM_TM_TRESUME",
20 "BriefDescription": "TM resume instruction completed"
21 },
22 {,
23 "EventCode": "0x40008",
24 "EventName": "PM_SRQ_EMPTY_CYC",
25 "BriefDescription": "Cycles in which the SRQ has at least one (out of four) empty slice"
26 },
27 {,
28 "EventCode": "0x20064",
29 "EventName": "PM_IERAT_RELOAD_4K",
30 "BriefDescription": "IERAT reloaded (after a miss) for 4K pages"
31 },
32 {,
33 "EventCode": "0x260B4",
34 "EventName": "PM_L3_P2_LCO_RTY",
35 "BriefDescription": "L3 initiated LCO received retry on port 2 (can try 4 times)"
36 },
37 {,
38 "EventCode": "0x20006",
39 "EventName": "PM_DISP_HELD_ISSQ_FULL",
40 "BriefDescription": "Dispatch held due to Issue q full. Includes issue queue and branch queue"
41 },
42 {,
43 "EventCode": "0x201E4",
44 "EventName": "PM_MRK_DATA_FROM_L3MISS",
45 "BriefDescription": "The processor's data cache was reloaded from a location other than the local core's L3 due to a marked load"
46 },
47 {,
48 "EventCode": "0x4E044",
49 "EventName": "PM_DPTEG_FROM_L31_ECO_MOD",
50 "BriefDescription": "A Page Table Entry was loaded into the TLB with Modified (M) data from another core's ECO L3 on the same chip due to a data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
51 },
52 {,
53 "EventCode": "0x40B8",
54 "EventName": "PM_BR_MPRED_TAKEN_CR",
55 "BriefDescription": "A Conditional Branch that resolved to taken was mispredicted as not taken (due to the BHT Direction Prediction)."
56 },
57 {,
58 "EventCode": "0xF8AC",
59 "EventName": "PM_DC_DEALLOC_NO_CONF",
60 "BriefDescription": "A demand load referenced a line in an active fuzzy prefetch stream. The stream could have been allocated through the hardware prefetch mechanism or through software.Fuzzy stream confirm (out of order effects, or pf cant keep up)"
61 },
62 {,
63 "EventCode": "0xD090",
64 "EventName": "PM_LS0_DC_COLLISIONS",
65 "BriefDescription": "Read-write data cache collisions"
66 },
67 {,
68 "EventCode": "0x40BC",
69 "EventName": "PM_THRD_PRIO_0_1_CYC",
70 "BriefDescription": "Cycles thread running at priority level 0 or 1"
71 },
72 {,
73 "EventCode": "0x2084",
74 "EventName": "PM_FLUSH_HB_RESTORE_CYC",
75 "BriefDescription": "Cycles in which no new instructions can be dispatched to the ICT after a flush. History buffer recovery"
76 },
77 {,
78 "EventCode": "0x4F054",
79 "EventName": "PM_RADIX_PWC_MISS",
80 "BriefDescription": "A radix translation attempt missed in the TLB and all levels of page walk cache."
81 },
82 {,
83 "EventCode": "0x24048",
84 "EventName": "PM_INST_FROM_LMEM",
85 "BriefDescription": "The processor's Instruction cache was reloaded from the local chip's Memory due to an instruction fetch (not prefetch)"
86 },
87 {,
88 "EventCode": "0xD8B4",
89 "EventName": "PM_LSU0_LRQ_S0_VALID_CYC",
90 "BriefDescription": "Slot 0 of LRQ valid"
91 },
92 {,
93 "EventCode": "0x2E052",
94 "EventName": "PM_TM_PASSED",
95 "BriefDescription": "Number of TM transactions that passed"
96 },
97 {,
98 "EventCode": "0xD1A0",
99 "EventName": "PM_MRK_LSU_FLUSH_LHS",
100 "BriefDescription": "Effective Address alias flush : no EA match but Real Address match. If the data has not yet been returned for this load, the instruction will just be rejected, but if it has returned data, it will be flushed"
101 },
102 {,
103 "EventCode": "0xF088",
104 "EventName": "PM_LSU0_STORE_REJECT",
105 "BriefDescription": "All internal store rejects cause the instruction to go back to the SRQ and go to sleep until woken up to try again after the condition has been met"
106 },
107 {,
108 "EventCode": "0x360B2",
109 "EventName": "PM_L3_GRP_GUESS_WRONG_LOW",
110 "BriefDescription": "Initial scope=group (GS or NNS) but data from outside group (far or rem). Prediction too Low"
111 },
112 {,
113 "EventCode": "0x168A6",
114 "EventName": "PM_TM_CAM_OVERFLOW",
115 "BriefDescription": "L3 TM cam overflow during L2 co of SC"
116 },
117 {,
118 "EventCode": "0xE8B0",
119 "EventName": "PM_TEND_PEND_CYC",
120 "BriefDescription": "TEND latency per thread"
121 },
122 {,
123 "EventCode": "0x4884",
124 "EventName": "PM_IBUF_FULL_CYC",
125 "BriefDescription": "Cycles No room in ibuff"
126 },
127 {,
128 "EventCode": "0xD08C",
129 "EventName": "PM_LSU2_LDMX_FIN",
130 "BriefDescription": "New P9 instruction LDMX. The definition of this new PMU event is (from the ldmx RFC02491): The thread has executed an ldmx instruction that accessed a doubleword that contains an effective address within an enabled section of the Load Monitored region. This event, therefore, should not occur if the FSCR has disabled the load monitored facility (FSCR[52]) or disabled the EBB facility (FSCR[56])"
131 },
132 {,
133 "EventCode": "0x300F8",
134 "EventName": "PM_TB_BIT_TRANS",
135 "BriefDescription": "timebase event"
136 },
137 {,
138 "EventCode": "0x3C040",
139 "EventName": "PM_DATA_FROM_L2_DISP_CONFLICT_LDHITST",
140 "BriefDescription": "The processor's data cache was reloaded from local core's L2 with load hit store conflict due to a demand load"
141 },
142 {,
143 "EventCode": "0xE0BC",
144 "EventName": "PM_LS0_PTE_TABLEWALK_CYC",
145 "BriefDescription": "Cycles when a tablewalk is pending on this thread on table 0"
146 },
147 {,
148 "EventCode": "0x3884",
149 "EventName": "PM_ISU3_ISS_HOLD_ALL",
150 "BriefDescription": "All ISU rejects"
151 },
152 {,
153 "EventCode": "0x460A6",
154 "EventName": "PM_RD_FORMING_SC",
155 "BriefDescription": "Read forming SC"
156 },
157 {,
158 "EventCode": "0x468A0",
159 "EventName": "PM_L3_PF_OFF_CHIP_MEM",
160 "BriefDescription": "L3 PF from Off chip memory"
161 },
162 {,
163 "EventCode": "0x268AA",
164 "EventName": "PM_L3_P1_LCO_DATA",
165 "BriefDescription": "LCO sent with data port 1"
166 },
167 {,
168 "EventCode": "0xE894",
169 "EventName": "PM_LSU1_TM_L1_HIT",
170 "BriefDescription": "Load tm hit in L1"
171 },
172 {,
173 "EventCode": "0x5888",
174 "EventName": "PM_IC_INVALIDATE",
175 "BriefDescription": "Ic line invalidated"
176 },
177 {,
178 "EventCode": "0x2890",
179 "EventName": "PM_DISP_CLB_HELD_TLBIE",
180 "BriefDescription": "Dispatch Hold: Due to TLBIE"
181 },
182 {,
183 "EventCode": "0x1001C",
184 "EventName": "PM_CMPLU_STALL_THRD",
185 "BriefDescription": "Completion Stalled because the thread was blocked"
186 },
187 {,
188 "EventCode": "0x368A6",
189 "EventName": "PM_SNP_TM_HIT_T",
190 "BriefDescription": "Snp TM sthit T/Tn/Te"
191 },
192 {,
193 "EventCode": "0x3001A",
194 "EventName": "PM_DATA_TABLEWALK_CYC",
195 "BriefDescription": "Data Tablewalk Cycles. Could be 1 or 2 active tablewalks. Includes data prefetches."
196 },
197 {,
198 "EventCode": "0xD894",
199 "EventName": "PM_LS3_DC_COLLISIONS",
200 "BriefDescription": "Read-write data cache collisions"
201 },
202 {,
203 "EventCode": "0x35158",
204 "EventName": "PM_MRK_DATA_FROM_L31_ECO_MOD_CYC",
205 "BriefDescription": "Duration in cycles to reload with Modified (M) data from another core's ECO L3 on the same chip due to a marked load"
206 },
207 {,
208 "EventCode": "0xF0B4",
209 "EventName": "PM_DC_PREF_CONS_ALLOC",
210 "BriefDescription": "Prefetch stream allocated in the conservative phase by either the hardware prefetch mechanism or software prefetch"
211 },
212 {,
213 "EventCode": "0xF894",
214 "EventName": "PM_LSU3_L1_CAM_CANCEL",
215 "BriefDescription": "ls3 l1 tm cam cancel"
216 },
217 {,
218 "EventCode": "0x2888",
219 "EventName": "PM_FLUSH_DISP_TLBIE",
220 "BriefDescription": "Dispatch Flush: TLBIE"
221 },
222 {,
223 "EventCode": "0xD1A4",
224 "EventName": "PM_MRK_LSU_FLUSH_SAO",
225 "BriefDescription": "A load-hit-load condition with Strong Address Ordering will have address compare disabled and flush"
226 },
227 {,
228 "EventCode": "0x4E11E",
229 "EventName": "PM_MRK_DATA_FROM_DMEM_CYC",
230 "BriefDescription": "Duration in cycles to reload from another chip's memory on the same Node or Group (Distant) due to a marked load"
231 },
232 {,
233 "EventCode": "0x5894",
234 "EventName": "PM_LWSYNC",
235 "BriefDescription": "Lwsync instruction decoded and transferred"
236 },
237 {,
238 "EventCode": "0x14156",
239 "EventName": "PM_MRK_DATA_FROM_L2_CYC",
240 "BriefDescription": "Duration in cycles to reload from local core's L2 due to a marked load"
241 },
242 {,
243 "EventCode": "0x468A6",
244 "EventName": "PM_RD_CLEARING_SC",
245 "BriefDescription": "Read clearing SC"
246 },
247 {,
248 "EventCode": "0x50A0",
249 "EventName": "PM_HWSYNC",
250 "BriefDescription": "Hwsync instruction decoded and transferred"
251 },
252 {,
253 "EventCode": "0x168B0",
254 "EventName": "PM_L3_P1_NODE_PUMP",
255 "BriefDescription": "L3 PF sent with nodal scope port 1, counts even retried requests"
256 },
257 {,
258 "EventCode": "0xD0BC",
259 "EventName": "PM_LSU0_1_LRQF_FULL_CYC",
260 "BriefDescription": "Counts the number of cycles the LRQF is full. LRQF is the queue that holds loads between finish and completion. If it fills up, instructions stay in LRQ until completion, potentially backing up the LRQ"
261 },
262 {,
263 "EventCode": "0x2D148",
264 "EventName": "PM_MRK_DATA_FROM_L2_DISP_CONFLICT_LDHITST",
265 "BriefDescription": "The processor's data cache was reloaded from local core's L2 with load hit store conflict due to a marked load"
266 },
267 {,
268 "EventCode": "0x460A8",
269 "EventName": "PM_SN_HIT",
270 "BriefDescription": "Any port snooper hit L3. Up to 4 can happen in a cycle but we only count 1"
271 },
272 {,
273 "EventCode": "0x360AA",
274 "EventName": "PM_L3_P0_CO_MEM",
275 "BriefDescription": "L3 CO to memory port 0 with or without data"
276 },
277 {,
278 "EventCode": "0xF0A4",
279 "EventName": "PM_DC_PREF_HW_ALLOC",
280 "BriefDescription": "Prefetch stream allocated by the hardware prefetch mechanism"
281 },
282 {,
283 "EventCode": "0xF0BC",
284 "EventName": "PM_LS2_UNALIGNED_ST",
285 "BriefDescription": "Store instructions whose data crosses a double-word boundary, which causes it to require an additional slice than than what normally would be required of the Store of that size. If the Store wraps from slice 3 to slice 0, thee is an additional 3-cycle penalty"
286 },
287 {,
288 "EventCode": "0xD0AC",
289 "EventName": "PM_SRQ_SYNC_CYC",
290 "BriefDescription": "A sync is in the S2Q (edge detect to count)"
291 },
292 {,
293 "EventCode": "0x401E6",
294 "EventName": "PM_MRK_INST_FROM_L3MISS",
295 "BriefDescription": "Marked instruction was reloaded from a location beyond the local chiplet"
296 },
297 {,
298 "EventCode": "0x26082",
299 "EventName": "PM_L2_IC_INV",
300 "BriefDescription": "I-cache Invalidates sent over the realod bus to the core"
301 },
302 {,
303 "EventCode": "0xC8AC",
304 "EventName": "PM_LSU_FLUSH_RELAUNCH_MISS",
305 "BriefDescription": "If a load that has already returned data and has to relaunch for any reason then gets a miss (erat, setp, data cache), it will often be flushed at relaunch time because the data might be inconsistent"
306 },
307 {,
308 "EventCode": "0x260A4",
309 "EventName": "PM_L3_LD_HIT",
310 "BriefDescription": "L3 Hits for demand LDs"
311 },
312 {,
313 "EventCode": "0xF0A0",
314 "EventName": "PM_DATA_STORE",
315 "BriefDescription": "All ops that drain from s2q to L2 containing data"
316 },
317 {,
318 "EventCode": "0x1D148",
319 "EventName": "PM_MRK_DATA_FROM_RMEM",
320 "BriefDescription": "The processor's data cache was reloaded from another chip's memory on the same Node or Group ( Remote) due to a marked load"
321 },
322 {,
323 "EventCode": "0x16088",
324 "EventName": "PM_L2_LOC_GUESS_CORRECT",
325 "BriefDescription": "L2 guess local (LNS) and guess was correct (ie data local)"
326 },
327 {,
328 "EventCode": "0x160A4",
329 "EventName": "PM_L3_HIT",
330 "BriefDescription": "L3 Hits (L2 miss hitting L3, including data/instrn/xlate)"
331 },
332 {,
333 "EventCode": "0xE09C",
334 "EventName": "PM_LSU0_TM_L1_MISS",
335 "BriefDescription": "Load tm L1 miss"
336 },
337 {,
338 "EventCode": "0x168B4",
339 "EventName": "PM_L3_P1_LCO_RTY",
340 "BriefDescription": "L3 initiated LCO received retry on port 1 (can try 4 times)"
341 },
342 {,
343 "EventCode": "0x268AC",
344 "EventName": "PM_L3_RD_USAGE",
345 "BriefDescription": "Rotating sample of 16 RD actives"
346 },
347 {,
348 "EventCode": "0x1415C",
349 "EventName": "PM_MRK_DATA_FROM_L3_MEPF_CYC",
350 "BriefDescription": "Duration in cycles to reload from local core's L3 without dispatch conflicts hit on Mepf state due to a marked load"
351 },
352 {,
353 "EventCode": "0xE880",
354 "EventName": "PM_L1_SW_PREF",
355 "BriefDescription": "Software L1 Prefetches, including SW Transient Prefetches"
356 },
357 {,
358 "EventCode": "0x288C",
359 "EventName": "PM_DISP_CLB_HELD_BAL",
360 "BriefDescription": "Dispatch/CLB Hold: Balance Flush"
361 },
362 {,
363 "EventCode": "0x101EA",
364 "EventName": "PM_MRK_L1_RELOAD_VALID",
365 "BriefDescription": "Marked demand reload"
366 },
367 {,
368 "EventCode": "0x1D156",
369 "EventName": "PM_MRK_LD_MISS_L1_CYC",
370 "BriefDescription": "Marked ld latency"
371 },
372 {,
373 "EventCode": "0x4C01A",
374 "EventName": "PM_CMPLU_STALL_DMISS_L3MISS",
375 "BriefDescription": "Completion stall due to cache miss resolving missed the L3"
376 },
377 {,
378 "EventCode": "0x2006C",
379 "EventName": "PM_RUN_CYC_SMT4_MODE",
380 "BriefDescription": "Cycles in which this thread's run latch is set and the core is in SMT4 mode"
381 },
382 {,
383 "EventCode": "0x5088",
384 "EventName": "PM_DECODE_FUSION_OP_PRESERV",
385 "BriefDescription": "Destructive op operand preservation"
386 },
387 {,
388 "EventCode": "0x1D14E",
389 "EventName": "PM_MRK_DATA_FROM_OFF_CHIP_CACHE_CYC",
390 "BriefDescription": "Duration in cycles to reload either shared or modified data from another core's L2/L3 on a different chip (remote or distant) due to a marked load"
391 },
392 {,
393 "EventCode": "0x509C",
394 "EventName": "PM_FORCED_NOP",
395 "BriefDescription": "Instruction was forced to execute as a nop because it was found to behave like a nop (have no effect) at decode time"
396 },
397 {,
398 "EventCode": "0xC098",
399 "EventName": "PM_LS2_UNALIGNED_LD",
400 "BriefDescription": "Load instructions whose data crosses a double-word boundary, which causes it to require an additional slice than than what normally would be required of the load of that size. If the load wraps from slice 3 to slice 0, thee is an additional 3-cycle penalty"
401 },
402 {,
403 "EventCode": "0x20058",
404 "EventName": "PM_DARQ1_10_12_ENTRIES",
405 "BriefDescription": "Cycles in which 10 or more DARQ1 entries (out of 12) are in use"
406 },
407 {,
408 "EventCode": "0x360A6",
409 "EventName": "PM_SNP_TM_HIT_M",
410 "BriefDescription": "Snp TM st hit M/Mu"
411 },
412 {,
413 "EventCode": "0x5898",
414 "EventName": "PM_LINK_STACK_INVALID_PTR",
415 "BriefDescription": "It is most often caused by certain types of flush where the pointer is not available. Can result in the data in the link stack becoming unusable."
416 },
417 {,
418 "EventCode": "0x46088",
419 "EventName": "PM_L2_CHIP_PUMP",
420 "BriefDescription": "RC requests that were local (aka chip) pump attempts"
421 },
422 {,
423 "EventCode": "0x28A0",
424 "EventName": "PM_TM_TSUSPEND",
425 "BriefDescription": "TM suspend instruction completed"
426 },
427 {,
428 "EventCode": "0x20054",
429 "EventName": "PM_L1_PREF",
430 "BriefDescription": "A data line was written to the L1 due to a hardware or software prefetch"
431 },
432 {,
433 "EventCode": "0xF888",
434 "EventName": "PM_LSU1_STORE_REJECT",
435 "BriefDescription": "All internal store rejects cause the instruction to go back to the SRQ and go to sleep until woken up to try again after the condition has been met"
436 },
437 {,
438 "EventCode": "0x4505E",
439 "EventName": "PM_FLOP_CMPL",
440 "BriefDescription": "Floating Point Operation Finished"
441 },
442 {,
443 "EventCode": "0x1D144",
444 "EventName": "PM_MRK_DATA_FROM_L3_DISP_CONFLICT",
445 "BriefDescription": "The processor's data cache was reloaded from local core's L3 with dispatch conflict due to a marked load"
446 },
447 {,
448 "EventCode": "0x400FA",
449 "EventName": "PM_RUN_INST_CMPL",
450 "BriefDescription": "Run_Instructions"
451 },
452 {,
453 "EventCode": "0x15154",
454 "EventName": "PM_SYNC_MRK_L3MISS",
455 "BriefDescription": "Marked L3 misses that can throw a synchronous interrupt"
456 },
457 {,
458 "EventCode": "0xE0B4",
459 "EventName": "PM_LS0_TM_DISALLOW",
460 "BriefDescription": "A TM-ineligible instruction tries to execute inside a transaction and the LSU disallows it"
461 },
462 {,
463 "EventCode": "0x26884",
464 "EventName": "PM_DSIDE_MRU_TOUCH",
465 "BriefDescription": "D-side L2 MRU touch sent to L2"
466 },
467 {,
468 "EventCode": "0x30134",
469 "EventName": "PM_MRK_ST_CMPL_INT",
470 "BriefDescription": "marked store finished with intervention"
471 },
472 {,
473 "EventCode": "0xC0B8",
474 "EventName": "PM_LSU_FLUSH_SAO",
475 "BriefDescription": "A load-hit-load condition with Strong Address Ordering will have address compare disabled and flush"
476 },
477 {,
478 "EventCode": "0x50A8",
479 "EventName": "PM_EAT_FORCE_MISPRED",
480 "BriefDescription": "XL-form branch was mispredicted due to the predicted target address missing from EAT. The EAT forces a mispredict in this case since there is no predicated target to validate. This is a rare case that may occur when the EAT is full and a branch is issued"
481 },
482 {,
483 "EventCode": "0xC094",
484 "EventName": "PM_LS0_UNALIGNED_LD",
485 "BriefDescription": "Load instructions whose data crosses a double-word boundary, which causes it to require an additional slice than than what normally would be required of the load of that size. If the load wraps from slice 3 to slice 0, thee is an additional 3-cycle penalty"
486 },
487 {,
488 "EventCode": "0xF8BC",
489 "EventName": "PM_LS3_UNALIGNED_ST",
490 "BriefDescription": "Store instructions whose data crosses a double-word boundary, which causes it to require an additional slice than than what normally would be required of the Store of that size. If the Store wraps from slice 3 to slice 0, thee is an additional 3-cycle penalty"
491 },
492 {,
493 "EventCode": "0x58B0",
494 "EventName": "PM_BTAC_GOOD_RESULT",
495 "BriefDescription": "BTAC predicts a taken branch and the BHT agrees, and the target address is correct"
496 },
497 {,
498 "EventCode": "0x1C04C",
499 "EventName": "PM_DATA_FROM_LL4",
500 "BriefDescription": "The processor's data cache was reloaded from the local chip's L4 cache due to a demand load"
501 },
502 {,
503 "EventCode": "0x3608E",
504 "EventName": "PM_TM_ST_CONF",
505 "BriefDescription": "TM Store (fav or non-fav) ran into conflict (failed)"
506 },
507 {,
508 "EventCode": "0xD998",
509 "EventName": "PM_MRK_LSU_FLUSH_EMSH",
510 "BriefDescription": "An ERAT miss was detected after a set-p hit. Erat tracker indicates fail due to tlbmiss and the instruction gets flushed because the instruction was working on the wrong address"
511 },
512 {,
513 "EventCode": "0xF8A0",
514 "EventName": "PM_NON_DATA_STORE",
515 "BriefDescription": "All ops that drain from s2q to L2 and contain no data"
516 },
517 {,
518 "EventCode": "0x3F146",
519 "EventName": "PM_MRK_DPTEG_FROM_L21_SHR",
520 "BriefDescription": "A Page Table Entry was loaded into the TLB with Shared (S) data from another core's L2 on the same chip due to a marked data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
521 },
522 {,
523 "EventCode": "0x40A0",
524 "EventName": "PM_BR_UNCOND",
525 "BriefDescription": "Unconditional Branch Completed. HW branch prediction was not used for this branch. This can be an I-form branch, a B-form branch with BO-field set to branch always, or a B-form branch which was covenrted to a Resolve."
526 },
527 {,
528 "EventCode": "0x1F056",
529 "EventName": "PM_RADIX_PWC_L1_HIT",
530 "BriefDescription": "A radix translation attempt missed in the TLB and only the first level page walk cache was a hit."
531 },
532 {,
533 "EventCode": "0xF8A8",
534 "EventName": "PM_DC_PREF_FUZZY_CONF",
535 "BriefDescription": "A demand load referenced a line in an active fuzzy prefetch stream. The stream could have been allocated through the hardware prefetch mechanism or through software.Fuzzy stream confirm (out of order effects, or pf cant keep up)"
536 },
537 {,
538 "EventCode": "0xF8A4",
539 "EventName": "PM_DC_PREF_SW_ALLOC",
540 "BriefDescription": "Prefetch stream allocated by software prefetching"
541 },
542 {,
543 "EventCode": "0xE0A0",
544 "EventName": "PM_LSU2_TM_L1_MISS",
545 "BriefDescription": "Load tm L1 miss"
546 },
547 {,
548 "EventCode": "0x2894",
549 "EventName": "PM_TM_OUTER_TEND",
550 "BriefDescription": "Completion time outer tend"
551 },
552 {,
553 "EventCode": "0xF098",
554 "EventName": "PM_XLATE_HPT_MODE",
555 "BriefDescription": "LSU reports every cycle the thread is in HPT translation mode (as opposed to radix mode)"
556 },
557 {,
558 "EventCode": "0x2C04E",
559 "EventName": "PM_LD_MISS_L1_FIN",
560 "BriefDescription": "Number of load instructions that finished with an L1 miss. Note that even if a load spans multiple slices this event will increment only once per load op."
561 },
562 {,
563 "EventCode": "0x30162",
564 "EventName": "PM_MRK_LSU_DERAT_MISS",
565 "BriefDescription": "Marked derat reload (miss) for any page size"
566 },
567 {,
568 "EventCode": "0x160A0",
569 "EventName": "PM_L3_PF_MISS_L3",
570 "BriefDescription": "L3 PF missed in L3"
571 },
572 {,
573 "EventCode": "0x1C04A",
574 "EventName": "PM_DATA_FROM_RL2L3_SHR",
575 "BriefDescription": "The processor's data cache was reloaded with Shared (S) data from another chip's L2 or L3 on the same Node or Group (Remote), as this chip due to a demand load"
576 },
577 {,
578 "EventCode": "0xD99C",
579 "EventName": "PM_MRK_LSU_FLUSH_UE",
580 "BriefDescription": "Correctable ECC error on reload data, reported at critical data forward time"
581 },
582 {,
583 "EventCode": "0x268B0",
584 "EventName": "PM_L3_P1_GRP_PUMP",
585 "BriefDescription": "L3 PF sent with grp scope port 1, counts even retried requests"
586 },
587 {,
588 "EventCode": "0x30016",
589 "EventName": "PM_CMPLU_STALL_SRQ_FULL",
590 "BriefDescription": "Finish stall because the NTF instruction was a store that was held in LSAQ because the SRQ was full"
591 },
592 {,
593 "EventCode": "0x40B4",
594 "EventName": "PM_BR_PRED_TA",
595 "BriefDescription": "Conditional Branch Completed that had its target address predicted. Only XL-form branches set this event. This equal the sum of CCACHE, LSTACK, and PCACHE"
596 },
597 {,
598 "EventCode": "0x40AC",
599 "EventName": "PM_BR_MPRED_CCACHE",
600 "BriefDescription": "Conditional Branch Completed that was Mispredicted due to the Count Cache Target Prediction"
601 },
602 {,
603 "EventCode": "0x3688A",
604 "EventName": "PM_L2_RTY_LD",
605 "BriefDescription": "RC retries on PB for any load from core (excludes DCBFs)"
606 },
607 {,
608 "EventCode": "0xE08C",
609 "EventName": "PM_LSU0_ERAT_HIT",
610 "BriefDescription": "Primary ERAT hit. There is no secondary ERAT"
611 },
612 {,
613 "EventCode": "0xE088",
614 "EventName": "PM_LS2_ERAT_MISS_PREF",
615 "BriefDescription": "LS0 Erat miss due to prefetch"
616 },
617 {,
618 "EventCode": "0xF0A8",
619 "EventName": "PM_DC_PREF_CONF",
620 "BriefDescription": "A demand load referenced a line in an active prefetch stream. The stream could have been allocated through the hardware prefetch mechanism or through software. Includes forwards and backwards streams"
621 },
622 {,
623 "EventCode": "0x16888",
624 "EventName": "PM_L2_LOC_GUESS_WRONG",
625 "BriefDescription": "L2 guess local (LNS) and guess was not correct (ie data not on chip)"
626 },
627 {,
628 "EventCode": "0xE0A4",
629 "EventName": "PM_TMA_REQ_L2",
630 "BriefDescription": "addrs only req to L2 only on the first one,Indication that Load footprint is not expanding"
631 },
632 {,
633 "EventCode": "0x5884",
634 "EventName": "PM_DECODE_LANES_NOT_AVAIL",
635 "BriefDescription": "Decode has something to transmit but dispatch lanes are not available"
636 },
637 {,
638 "EventCode": "0x3C042",
639 "EventName": "PM_DATA_FROM_L3_DISP_CONFLICT",
640 "BriefDescription": "The processor's data cache was reloaded from local core's L3 with dispatch conflict due to a demand load"
641 },
642 {,
643 "EventCode": "0x168AA",
644 "EventName": "PM_L3_P1_LCO_NO_DATA",
645 "BriefDescription": "Dataless L3 LCO sent port 1"
646 },
647 {,
648 "EventCode": "0x3D140",
649 "EventName": "PM_MRK_DATA_FROM_L2_DISP_CONFLICT_OTHER_CYC",
650 "BriefDescription": "Duration in cycles to reload from local core's L2 with dispatch conflict due to a marked load"
651 },
652 {,
653 "EventCode": "0xC89C",
654 "EventName": "PM_LS1_LAUNCH_HELD_PREF",
655 "BriefDescription": "Number of times a load or store instruction was unable to launch/relaunch because a high priority prefetch used that relaunch cycle"
656 },
657 {,
658 "EventCode": "0x4894",
659 "EventName": "PM_IC_RELOAD_PRIVATE",
660 "BriefDescription": "Reloading line was brought in private for a specific thread. Most lines are brought in shared for all eight threads. If RA does not match then invalidates and then brings it shared to other thread. In P7 line brought in private , then line was invalidat"
661 },
662 {,
663 "EventCode": "0x1688E",
664 "EventName": "PM_TM_LD_CAUSED_FAIL",
665 "BriefDescription": "Non-TM Load caused any thread to fail"
666 },
667 {,
668 "EventCode": "0x26084",
669 "EventName": "PM_L2_RCLD_DISP_FAIL_OTHER",
670 "BriefDescription": "All I-or-D side load dispatch attempts for this thread that failed due to reason other than address collision (excludes i_l2mru_tch_reqs)"
671 },
672 {,
673 "EventCode": "0x101E4",
674 "EventName": "PM_MRK_L1_ICACHE_MISS",
675 "BriefDescription": "sampled Instruction suffered an icache Miss"
676 },
677 {,
678 "EventCode": "0x20A0",
679 "EventName": "PM_TM_NESTED_TBEGIN",
680 "BriefDescription": "Completion Tm nested tbegin"
681 },
682 {,
683 "EventCode": "0x368AA",
684 "EventName": "PM_L3_P1_CO_MEM",
685 "BriefDescription": "L3 CO to memory port 1 with or without data"
686 },
687 {,
688 "EventCode": "0xC8A4",
689 "EventName": "PM_LSU3_FALSE_LHS",
690 "BriefDescription": "False LHS match detected"
691 },
692 {,
693 "EventCode": "0xD9A4",
694 "EventName": "PM_MRK_LSU_FLUSH_LARX_STCX",
695 "BriefDescription": "A larx is flushed because an older larx has an LMQ reservation for the same thread. A stcx is flushed because an older stcx is in the LMQ. The flush happens when the older larx/stcx relaunches"
696 },
697 {,
698 "EventCode": "0x4D012",
699 "EventName": "PM_PMC3_SAVED",
700 "BriefDescription": "PMC3 Rewind Value saved"
701 },
702 {,
703 "EventCode": "0xE888",
704 "EventName": "PM_LS3_ERAT_MISS_PREF",
705 "BriefDescription": "LS1 Erat miss due to prefetch"
706 },
707 {,
708 "EventCode": "0x368B4",
709 "EventName": "PM_L3_RD0_BUSY",
710 "BriefDescription": "Lifetime, sample of RD machine 0 valid"
711 },
712 {,
713 "EventCode": "0x46080",
714 "EventName": "PM_L2_DISP_ALL_L2MISS",
715 "BriefDescription": "All successful Ld/St dispatches for this thread that were an L2 miss (excludes i_l2mru_tch_reqs)"
716 },
717 {,
718 "EventCode": "0xF8B8",
719 "EventName": "PM_LS1_UNALIGNED_ST",
720 "BriefDescription": "Store instructions whose data crosses a double-word boundary, which causes it to require an additional slice than than what normally would be required of the Store of that size. If the Store wraps from slice 3 to slice 0, thee is an additional 3-cycle penalty"
721 },
722 {,
723 "EventCode": "0x408C",
724 "EventName": "PM_L1_DEMAND_WRITE",
725 "BriefDescription": "Instruction Demand sectors written into IL1"
726 },
727 {,
728 "EventCode": "0x368A8",
729 "EventName": "PM_SN_INVL",
730 "BriefDescription": "Any port snooper detects a store to a line in the Sx state and invalidates the line. Up to 4 can happen in a cycle but we only count 1"
731 },
732 {,
733 "EventCode": "0x160B2",
734 "EventName": "PM_L3_LOC_GUESS_CORRECT",
735 "BriefDescription": "initial scope=node/chip (LNS) and data from local node (local) (pred successful) - always PFs only"
736 },
737 {,
738 "EventCode": "0x48B4",
739 "EventName": "PM_DECODE_FUSION_CONST_GEN",
740 "BriefDescription": "32-bit constant generation"
741 },
742 {,
743 "EventCode": "0x4D146",
744 "EventName": "PM_MRK_DATA_FROM_L21_MOD",
745 "BriefDescription": "The processor's data cache was reloaded with Modified (M) data from another core's L2 on the same chip due to a marked load"
746 },
747 {,
748 "EventCode": "0xE080",
749 "EventName": "PM_S2Q_FULL",
750 "BriefDescription": "Cycles during which the S2Q is full"
751 },
752 {,
753 "EventCode": "0x268B4",
754 "EventName": "PM_L3_P3_LCO_RTY",
755 "BriefDescription": "L3 initiated LCO received retry on port 3 (can try 4 times)"
756 },
757 {,
758 "EventCode": "0xD8B8",
759 "EventName": "PM_LSU0_LMQ_S0_VALID",
760 "BriefDescription": "Slot 0 of LMQ valid"
761 },
762 {,
763 "EventCode": "0x2098",
764 "EventName": "PM_TM_NESTED_TEND",
765 "BriefDescription": "Completion time nested tend"
766 },
767 {,
768 "EventCode": "0x36084",
769 "EventName": "PM_L2_RCST_DISP",
770 "BriefDescription": "All D-side store dispatch attempts for this thread"
771 },
772 {,
773 "EventCode": "0x368A0",
774 "EventName": "PM_L3_PF_OFF_CHIP_CACHE",
775 "BriefDescription": "L3 PF from Off chip cache"
776 },
777 {,
778 "EventCode": "0x20056",
779 "EventName": "PM_TAKEN_BR_MPRED_CMPL",
780 "BriefDescription": "Total number of taken branches that were incorrectly predicted as not-taken. This event counts branches completed and does not include speculative instructions"
781 },
782 {,
783 "EventCode": "0x4688A",
784 "EventName": "PM_L2_SYS_PUMP",
785 "BriefDescription": "RC requests that were system pump attempts"
786 },
787 {,
788 "EventCode": "0xE090",
789 "EventName": "PM_LSU2_ERAT_HIT",
790 "BriefDescription": "Primary ERAT hit. There is no secondary ERAT"
791 },
792 {,
793 "EventCode": "0x4001C",
794 "EventName": "PM_INST_IMC_MATCH_CMPL",
795 "BriefDescription": "IMC Match Count"
796 },
797 {,
798 "EventCode": "0x40A8",
799 "EventName": "PM_BR_PRED_LSTACK",
800 "BriefDescription": "Conditional Branch Completed that used the Link Stack for Target Prediction"
801 },
802 {,
803 "EventCode": "0x268A2",
804 "EventName": "PM_L3_CI_MISS",
805 "BriefDescription": "L3 castins miss (total count)"
806 },
807 {,
808 "EventCode": "0x289C",
809 "EventName": "PM_TM_NON_FAV_TBEGIN",
810 "BriefDescription": "Dispatch time non favored tbegin"
811 },
812 {,
813 "EventCode": "0xF08C",
814 "EventName": "PM_LSU2_STORE_REJECT",
815 "BriefDescription": "All internal store rejects cause the instruction to go back to the SRQ and go to sleep until woken up to try again after the condition has been met"
816 },
817 {,
818 "EventCode": "0x360A0",
819 "EventName": "PM_L3_PF_ON_CHIP_CACHE",
820 "BriefDescription": "L3 PF from On chip cache"
821 },
822 {,
823 "EventCode": "0x35152",
824 "EventName": "PM_MRK_DATA_FROM_L2MISS_CYC",
825 "BriefDescription": "Duration in cycles to reload from a location other than the local core's L2 due to a marked load"
826 },
827 {,
828 "EventCode": "0x160AC",
829 "EventName": "PM_L3_SN_USAGE",
830 "BriefDescription": "Rotating sample of 16 snoop valids"
831 },
832 {,
833 "EventCode": "0x16084",
834 "EventName": "PM_L2_RCLD_DISP",
835 "BriefDescription": "All I-or-D side load dispatch attempts for this thread (excludes i_l2mru_tch_reqs)"
836 },
837 {,
838 "EventCode": "0x1608C",
839 "EventName": "PM_RC0_BUSY",
840 "BriefDescription": "RC mach 0 Busy. Used by PMU to sample ave RC lifetime (mach0 used as sample point)"
841 },
842 {,
843 "EventCode": "0x36082",
844 "EventName": "PM_L2_LD_DISP",
845 "BriefDescription": "All successful I-or-D side load dispatches for this thread (excludes i_l2mru_tch_reqs)."
846 },
847 {,
848 "EventCode": "0xF8B0",
849 "EventName": "PM_L3_SW_PREF",
850 "BriefDescription": "L3 load prefetch, sourced from a software prefetch stream, was sent to the nest"
851 },
852 {,
853 "EventCode": "0xF884",
854 "EventName": "PM_TABLEWALK_CYC_PREF",
855 "BriefDescription": "tablewalk qualified for pte prefetches"
856 },
857 {,
858 "EventCode": "0x4D144",
859 "EventName": "PM_MRK_DATA_FROM_L31_ECO_MOD",
860 "BriefDescription": "The processor's data cache was reloaded with Modified (M) data from another core's ECO L3 on the same chip due to a marked load"
861 },
862 {,
863 "EventCode": "0x16884",
864 "EventName": "PM_L2_RCLD_DISP_FAIL_ADDR",
865 "BriefDescription": "All I-od-D side load dispatch attempts for this thread that failed due to address collision with RC/CO/SN/SQ machine (excludes i_l2mru_tch_reqs)"
866 },
867 {,
868 "EventCode": "0x460A0",
869 "EventName": "PM_L3_PF_ON_CHIP_MEM",
870 "BriefDescription": "L3 PF from On chip memory"
871 },
872 {,
873 "EventCode": "0xF084",
874 "EventName": "PM_PTE_PREFETCH",
875 "BriefDescription": "PTE prefetches"
876 },
877 {,
878 "EventCode": "0x2D026",
879 "EventName": "PM_RADIX_PWC_L1_PDE_FROM_L2",
880 "BriefDescription": "A Page Directory Entry was reloaded to a level 1 page walk cache from the core's L2 data cache"
881 },
882 {,
883 "EventCode": "0x48B0",
884 "EventName": "PM_BR_MPRED_PCACHE",
885 "BriefDescription": "Conditional Branch Completed that was Mispredicted due to pattern cache prediction"
886 },
887 {,
888 "EventCode": "0x2C126",
889 "EventName": "PM_MRK_DATA_FROM_L2",
890 "BriefDescription": "The processor's data cache was reloaded from local core's L2 due to a marked load"
891 },
892 {,
893 "EventCode": "0xE0AC",
894 "EventName": "PM_TM_FAIL_TLBIE",
895 "BriefDescription": "Transaction failed because there was a TLBIE hit in the bloom filter"
896 },
897 {,
898 "EventCode": "0x260AA",
899 "EventName": "PM_L3_P0_LCO_DATA",
900 "BriefDescription": "LCO sent with data port 0"
901 },
902 {,
903 "EventCode": "0x4888",
904 "EventName": "PM_IC_PREF_REQ",
905 "BriefDescription": "Instruction prefetch requests"
906 },
907 {,
908 "EventCode": "0xC898",
909 "EventName": "PM_LS3_UNALIGNED_LD",
910 "BriefDescription": "Load instructions whose data crosses a double-word boundary, which causes it to require an additional slice than than what normally would be required of the load of that size. If the load wraps from slice 3 to slice 0, thee is an additional 3-cycle penalty"
911 },
912 {,
913 "EventCode": "0x488C",
914 "EventName": "PM_IC_PREF_WRITE",
915 "BriefDescription": "Instruction prefetch written into IL1"
916 },
917 {,
918 "EventCode": "0xF89C",
919 "EventName": "PM_XLATE_MISS",
920 "BriefDescription": "The LSU requested a line from L2 for translation. It may be satisfied from any source beyond L2. Includes speculative instructions"
921 },
922 {,
923 "EventCode": "0x14158",
924 "EventName": "PM_MRK_DATA_FROM_L2_NO_CONFLICT_CYC",
925 "BriefDescription": "Duration in cycles to reload from local core's L2 without conflict due to a marked load"
926 },
927 {,
928 "EventCode": "0x35156",
929 "EventName": "PM_MRK_DATA_FROM_L31_SHR_CYC",
930 "BriefDescription": "Duration in cycles to reload with Shared (S) data from another core's L3 on the same chip due to a marked load"
931 },
932 {,
933 "EventCode": "0x268A6",
934 "EventName": "PM_TM_RST_SC",
935 "BriefDescription": "TM-snp rst RM SC"
936 },
937 {,
938 "EventCode": "0x468A4",
939 "EventName": "PM_L3_TRANS_PF",
940 "BriefDescription": "L3 Transient prefetch received from L2"
941 },
942 {,
943 "EventCode": "0x4094",
944 "EventName": "PM_IC_PREF_CANCEL_L2",
945 "BriefDescription": "L2 Squashed a demand or prefetch request"
946 },
947 {,
948 "EventCode": "0x48AC",
949 "EventName": "PM_BR_MPRED_LSTACK",
950 "BriefDescription": "Conditional Branch Completed that was Mispredicted due to the Link Stack Target Prediction"
951 },
952 {,
953 "EventCode": "0xE88C",
954 "EventName": "PM_LSU1_ERAT_HIT",
955 "BriefDescription": "Primary ERAT hit. There is no secondary ERAT"
956 },
957 {,
958 "EventCode": "0xC0B4",
959 "EventName": "PM_LSU_FLUSH_WRK_ARND",
960 "BriefDescription": "LSU workaround flush. These flushes are setup with programmable scan only latches to perform various actions when the flush macro receives a trigger from the dbg macros. These actions include things like flushing the next op encountered for a particular thread or flushing the next op that is NTC op that is encountered on a particular slice. The kind of flush that the workaround is setup to perform is highly variable."
961 },
962 {,
963 "EventCode": "0x34054",
964 "EventName": "PM_PARTIAL_ST_FIN",
965 "BriefDescription": "Any store finished by an LSU slice"
966 },
967 {,
968 "EventCode": "0x5880",
969 "EventName": "PM_THRD_PRIO_6_7_CYC",
970 "BriefDescription": "Cycles thread running at priority level 6 or 7"
971 },
972 {,
973 "EventCode": "0x4898",
974 "EventName": "PM_IC_DEMAND_L2_BR_REDIRECT",
975 "BriefDescription": "L2 I cache demand request due to branch Mispredict ( 15 cycle path)"
976 },
977 {,
978 "EventCode": "0x4880",
979 "EventName": "PM_BANK_CONFLICT",
980 "BriefDescription": "Read blocked due to interleave conflict. The ifar logic will detect an interleave conflict and kill the data that was read that cycle."
981 },
982 {,
983 "EventCode": "0x360B0",
984 "EventName": "PM_L3_P0_SYS_PUMP",
985 "BriefDescription": "L3 PF sent with sys scope port 0, counts even retried requests"
986 },
987 {,
988 "EventCode": "0x3006A",
989 "EventName": "PM_IERAT_RELOAD_64K",
990 "BriefDescription": "IERAT Reloaded (Miss) for a 64k page"
991 },
992 {,
993 "EventCode": "0xD8BC",
994 "EventName": "PM_LSU2_3_LRQF_FULL_CYC",
995 "BriefDescription": "Counts the number of cycles the LRQF is full. LRQF is the queue that holds loads between finish and completion. If it fills up, instructions stay in LRQ until completion, potentially backing up the LRQ"
996 },
997 {,
998 "EventCode": "0x46086",
999 "EventName": "PM_L2_SN_M_RD_DONE",
1000 "BriefDescription": "SNP dispatched for a read and was M (true M)"
1001 },
1002 {,
1003 "EventCode": "0x40154",
1004 "EventName": "PM_MRK_FAB_RSP_BKILL",
1005 "BriefDescription": "Marked store had to do a bkill"
1006 },
1007 {,
1008 "EventCode": "0xF094",
1009 "EventName": "PM_LSU2_L1_CAM_CANCEL",
1010 "BriefDescription": "ls2 l1 tm cam cancel"
1011 },
1012 {,
1013 "EventCode": "0x2D014",
1014 "EventName": "PM_CMPLU_STALL_LRQ_FULL",
1015 "BriefDescription": "Finish stall because the NTF instruction was a load that was held in LSAQ (load-store address queue) because the LRQ (load-reorder queue) was full"
1016 },
1017 {,
1018 "EventCode": "0x3E05E",
1019 "EventName": "PM_L3_CO_MEPF",
1020 "BriefDescription": "L3 castouts in Mepf state for this thread"
1021 },
1022 {,
1023 "EventCode": "0x460A2",
1024 "EventName": "PM_L3_LAT_CI_HIT",
1025 "BriefDescription": "L3 Lateral Castins Hit"
1026 },
1027 {,
1028 "EventCode": "0x3D14E",
1029 "EventName": "PM_MRK_DATA_FROM_DL2L3_MOD",
1030 "BriefDescription": "The processor's data cache was reloaded with Modified (M) data from another chip's L2 or L3 on a different Node or Group (Distant), as this chip due to a marked load"
1031 },
1032 {,
1033 "EventCode": "0x3D15E",
1034 "EventName": "PM_MULT_MRK",
1035 "BriefDescription": "mult marked instr"
1036 },
1037 {,
1038 "EventCode": "0x4084",
1039 "EventName": "PM_EAT_FULL_CYC",
1040 "BriefDescription": "Cycles No room in EAT"
1041 },
1042 {,
1043 "EventCode": "0x5098",
1044 "EventName": "PM_LINK_STACK_WRONG_ADD_PRED",
1045 "BriefDescription": "Link stack predicts wrong address, because of link stack design limitation or software violating the coding conventions"
1046 },
1047 {,
1048 "EventCode": "0x2C050",
1049 "EventName": "PM_DATA_GRP_PUMP_CPRED",
1050 "BriefDescription": "Initial and Final Pump Scope was group pump (prediction=correct) for a demand load"
1051 },
1052 {,
1053 "EventCode": "0xC0A4",
1054 "EventName": "PM_LSU2_FALSE_LHS",
1055 "BriefDescription": "False LHS match detected"
1056 },
1057 {,
1058 "EventCode": "0x58A0",
1059 "EventName": "PM_LINK_STACK_CORRECT",
1060 "BriefDescription": "Link stack predicts right address"
1061 },
1062 {,
1063 "EventCode": "0x4C05A",
1064 "EventName": "PM_DTLB_MISS_1G",
1065 "BriefDescription": "Data TLB reload (after a miss) page size 1G. Implies radix translation was used"
1066 },
1067 {,
1068 "EventCode": "0x36886",
1069 "EventName": "PM_L2_SN_SX_I_DONE",
1070 "BriefDescription": "SNP dispatched and went from Sx to Ix"
1071 },
1072 {,
1073 "EventCode": "0x4E04A",
1074 "EventName": "PM_DPTEG_FROM_OFF_CHIP_CACHE",
1075 "BriefDescription": "A Page Table Entry was loaded into the TLB either shared or modified data from another core's L2/L3 on a different chip (remote or distant) due to a data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
1076 },
1077 {,
1078 "EventCode": "0x2C12C",
1079 "EventName": "PM_MRK_DATA_FROM_DL4_CYC",
1080 "BriefDescription": "Duration in cycles to reload from another chip's L4 on a different Node or Group (Distant) due to a marked load"
1081 },
1082 {,
1083 "EventCode": "0x2608E",
1084 "EventName": "PM_TM_LD_CONF",
1085 "BriefDescription": "TM Load (fav or non-fav) ran into conflict (failed)"
1086 },
1087 {,
1088 "EventCode": "0x4080",
1089 "EventName": "PM_INST_FROM_L1",
1090 "BriefDescription": "Instruction fetches from L1. L1 instruction hit"
1091 },
1092 {,
1093 "EventCode": "0xE898",
1094 "EventName": "PM_LSU3_TM_L1_HIT",
1095 "BriefDescription": "Load tm hit in L1"
1096 },
1097 {,
1098 "EventCode": "0x260A0",
1099 "EventName": "PM_L3_CO_MEM",
1100 "BriefDescription": "L3 CO to memory OR of port 0 and 1 (lossy = may undercount if two cresp come in the same cyc)"
1101 },
1102 {,
1103 "EventCode": "0x16082",
1104 "EventName": "PM_L2_CASTOUT_MOD",
1105 "BriefDescription": "L2 Castouts - Modified (M,Mu,Me)"
1106 },
1107 {,
1108 "EventCode": "0xC09C",
1109 "EventName": "PM_LS0_LAUNCH_HELD_PREF",
1110 "BriefDescription": "Number of times a load or store instruction was unable to launch/relaunch because a high priority prefetch used that relaunch cycle"
1111 },
1112 {,
1113 "EventCode": "0xC8B8",
1114 "EventName": "PM_LSU_FLUSH_LARX_STCX",
1115 "BriefDescription": "A larx is flushed because an older larx has an LMQ reservation for the same thread. A stcx is flushed because an older stcx is in the LMQ. The flush happens when the older larx/stcx relaunches"
1116 },
1117 {,
1118 "EventCode": "0x260A6",
1119 "EventName": "PM_NON_TM_RST_SC",
1120 "BriefDescription": "Non-TM snp rst TM SC"
1121 },
1122 {,
1123 "EventCode": "0x3608A",
1124 "EventName": "PM_L2_RTY_ST",
1125 "BriefDescription": "RC retries on PB for any store from core (excludes DCBFs)"
1126 },
1127 {,
1128 "EventCode": "0x24040",
1129 "EventName": "PM_INST_FROM_L2_MEPF",
1130 "BriefDescription": "The processor's Instruction cache was reloaded from local core's L2 hit without dispatch conflicts on Mepf state. due to an instruction fetch (not prefetch)"
1131 },
1132 {,
1133 "EventCode": "0x209C",
1134 "EventName": "PM_TM_FAV_TBEGIN",
1135 "BriefDescription": "Dispatch time Favored tbegin"
1136 },
1137 {,
1138 "EventCode": "0x2D01E",
1139 "EventName": "PM_ICT_NOSLOT_DISP_HELD_ISSQ",
1140 "BriefDescription": "Ict empty for this thread due to dispatch hold on this thread due to Issue q full, BRQ full, XVCF Full, Count cache, Link, Tar full"
1141 },
1142 {,
1143 "EventCode": "0x50A4",
1144 "EventName": "PM_FLUSH_MPRED",
1145 "BriefDescription": "Branch mispredict flushes. Includes target and address misprecition"
1146 },
1147 {,
1148 "EventCode": "0x508C",
1149 "EventName": "PM_SHL_CREATED",
1150 "BriefDescription": "Store-Hit-Load Table Entry Created"
1151 },
1152 {,
1153 "EventCode": "0x1504C",
1154 "EventName": "PM_IPTEG_FROM_LL4",
1155 "BriefDescription": "A Page Table Entry was loaded into the TLB from the local chip's L4 cache due to a instruction side request"
1156 },
1157 {,
1158 "EventCode": "0x268A4",
1159 "EventName": "PM_L3_LD_MISS",
1160 "BriefDescription": "L3 Misses for demand LDs"
1161 },
1162 {,
1163 "EventCode": "0x26088",
1164 "EventName": "PM_L2_GRP_GUESS_CORRECT",
1165 "BriefDescription": "L2 guess grp (GS or NNS) and guess was correct (data intra-group AND ^on-chip)"
1166 },
1167 {,
1168 "EventCode": "0xD088",
1169 "EventName": "PM_LSU0_LDMX_FIN",
1170 "BriefDescription": "New P9 instruction LDMX. The definition of this new PMU event is (from the ldmx RFC02491): The thread has executed an ldmx instruction that accessed a doubleword that contains an effective address within an enabled section of the Load Monitored region. This event, therefore, should not occur if the FSCR has disabled the load monitored facility (FSCR[52]) or disabled the EBB facility (FSCR[56])."
1171 },
1172 {,
1173 "EventCode": "0xE8B4",
1174 "EventName": "PM_LS1_TM_DISALLOW",
1175 "BriefDescription": "A TM-ineligible instruction tries to execute inside a transaction and the LSU disallows it"
1176 },
1177 {,
1178 "EventCode": "0x1688C",
1179 "EventName": "PM_RC_USAGE",
1180 "BriefDescription": "Continuous 16 cycle (2to1) window where this signals rotates thru sampling each RC machine busy. PMU uses this wave to then do 16 cyc count to sample total number of machs running"
1181 },
1182 {,
1183 "EventCode": "0x3F054",
1184 "EventName": "PM_RADIX_PWC_L4_PTE_FROM_L3MISS",
1185 "BriefDescription": "A Page Table Entry was reloaded to a level 4 page walk cache from beyond the core's L3 data cache. This is the deepest level of PWC possible for a translation. The source could be local/remote/distant memory or another core's cache"
1186 },
1187 {,
1188 "EventCode": "0x2608A",
1189 "EventName": "PM_ISIDE_DISP_FAIL_ADDR",
1190 "BriefDescription": "All I-side dispatch attempts for this thread that failed due to a addr collision with another machine (excludes i_l2mru_tch_reqs)"
1191 },
1192 {,
1193 "EventCode": "0x50B4",
1194 "EventName": "PM_TAGE_CORRECT_TAKEN_CMPL",
1195 "BriefDescription": "The TAGE overrode BHT direction prediction and it was correct. Counted at completion for taken branches only"
1196 },
1197 {,
1198 "EventCode": "0x2090",
1199 "EventName": "PM_DISP_CLB_HELD_SB",
1200 "BriefDescription": "Dispatch/CLB Hold: Scoreboard"
1201 },
1202 {,
1203 "EventCode": "0xE0B0",
1204 "EventName": "PM_TM_FAIL_NON_TX_CONFLICT",
1205 "BriefDescription": "Non transactional conflict from LSU, gets reported to TEXASR"
1206 },
1207 {,
1208 "EventCode": "0xD198",
1209 "EventName": "PM_MRK_LSU_FLUSH_ATOMIC",
1210 "BriefDescription": "Quad-word loads (lq) are considered atomic because they always span at least 2 slices. If a snoop or store from another thread changes the data the load is accessing between the 2 or 3 pieces of the lq instruction, the lq will be flushed"
1211 },
1212 {,
1213 "EventCode": "0x201E0",
1214 "EventName": "PM_MRK_DATA_FROM_MEMORY",
1215 "BriefDescription": "The processor's data cache was reloaded from a memory location including L4 from local remote or distant due to a marked load"
1216 },
1217 {,
1218 "EventCode": "0x368A2",
1219 "EventName": "PM_L3_L2_CO_MISS",
1220 "BriefDescription": "L2 CO miss"
1221 },
1222 {,
1223 "EventCode": "0x3608C",
1224 "EventName": "PM_CO0_BUSY",
1225 "BriefDescription": "CO mach 0 Busy. Used by PMU to sample ave CO lifetime (mach0 used as sample point)"
1226 },
1227 {,
1228 "EventCode": "0x2C122",
1229 "EventName": "PM_MRK_DATA_FROM_L3_DISP_CONFLICT_CYC",
1230 "BriefDescription": "Duration in cycles to reload from local core's L3 with dispatch conflict due to a marked load"
1231 },
1232 {,
1233 "EventCode": "0x35154",
1234 "EventName": "PM_MRK_DATA_FROM_L3_CYC",
1235 "BriefDescription": "Duration in cycles to reload from local core's L3 due to a marked load"
1236 },
1237 {,
1238 "EventCode": "0x1D140",
1239 "EventName": "PM_MRK_DATA_FROM_L31_MOD_CYC",
1240 "BriefDescription": "Duration in cycles to reload with Modified (M) data from another core's L3 on the same chip due to a marked load"
1241 },
1242 {,
1243 "EventCode": "0x4404A",
1244 "EventName": "PM_INST_FROM_OFF_CHIP_CACHE",
1245 "BriefDescription": "The processor's Instruction cache was reloaded either shared or modified data from another core's L2/L3 on a different chip (remote or distant) due to an instruction fetch (not prefetch)"
1246 },
1247 {,
1248 "EventCode": "0x28AC",
1249 "EventName": "PM_TM_FAIL_SELF",
1250 "BriefDescription": "TM aborted because a self-induced conflict occurred in Suspended state, due to one of the following: a store to a storage location that was previously accessed transactionally; a dcbf, dcbi, or icbi specify- ing a block that was previously accessed transactionally; a dcbst specifying a block that was previously written transactionally; or a tlbie that specifies a translation that was pre- viously used transactionally"
1251 },
1252 {,
1253 "EventCode": "0x45056",
1254 "EventName": "PM_SCALAR_FLOP_CMPL",
1255 "BriefDescription": "Scalar flop operation completed"
1256 },
1257 {,
1258 "EventCode": "0x16092",
1259 "EventName": "PM_L2_LD_MISS_128B",
1260 "BriefDescription": "All successful D-side load dispatches that were an L2 miss (NOT Sx,Tx,Mx) for this thread and the RC calculated the request should be for 128B (i.e., M=0)"
1261 },
1262 {,
1263 "EventCode": "0x2E014",
1264 "EventName": "PM_STCX_FIN",
1265 "BriefDescription": "Number of stcx instructions finished. This includes instructions in the speculative path of a branch that may be flushed"
1266 },
1267 {,
1268 "EventCode": "0xE0B8",
1269 "EventName": "PM_LS2_TM_DISALLOW",
1270 "BriefDescription": "A TM-ineligible instruction tries to execute inside a transaction and the LSU disallows it"
1271 },
1272 {,
1273 "EventCode": "0x2094",
1274 "EventName": "PM_TM_OUTER_TBEGIN",
1275 "BriefDescription": "Completion time outer tbegin"
1276 },
1277 {,
1278 "EventCode": "0x160B4",
1279 "EventName": "PM_L3_P0_LCO_RTY",
1280 "BriefDescription": "L3 initiated LCO received retry on port 0 (can try 4 times)"
1281 },
1282 {,
1283 "EventCode": "0x36892",
1284 "EventName": "PM_DSIDE_OTHER_64B_L2MEMACC",
1285 "BriefDescription": "Valid when first beat of data comes in for an D-side fetch where data came EXCLUSIVELY from memory that was for hpc_read64, (RC had to fetch other 64B of a line from MC) i.e., number of times RC had to go to memory to get 'missing' 64B"
1286 },
1287 {,
1288 "EventCode": "0x20A8",
1289 "EventName": "PM_TM_FAIL_FOOTPRINT_OVERFLOW",
1290 "BriefDescription": "TM aborted because the tracking limit for transactional storage accesses was exceeded.. Asynchronous"
1291 },
1292 {,
1293 "EventCode": "0x30018",
1294 "EventName": "PM_ICT_NOSLOT_DISP_HELD_HB_FULL",
1295 "BriefDescription": "Ict empty for this thread due to dispatch holds because the History Buffer was full. Could be GPR/VSR/VMR/FPR/CR/XVF; CR; XVF (XER/VSCR/FPSCR)"
1296 },
1297 {,
1298 "EventCode": "0xC894",
1299 "EventName": "PM_LS1_UNALIGNED_LD",
1300 "BriefDescription": "Load instructions whose data crosses a double-word boundary, which causes it to require an additional slice than than what normally would be required of the load of that size. If the load wraps from slice 3 to slice 0, thee is an additional 3-cycle penalty"
1301 },
1302 {,
1303 "EventCode": "0x360A2",
1304 "EventName": "PM_L3_L2_CO_HIT",
1305 "BriefDescription": "L2 CO hits"
1306 },
1307 {,
1308 "EventCode": "0x36092",
1309 "EventName": "PM_DSIDE_L2MEMACC",
1310 "BriefDescription": "Valid when first beat of data comes in for an D-side fetch where data came EXCLUSIVELY from memory (excluding hpcread64 accesses), i.e., total memory accesses by RCs"
1311 },
1312 {,
1313 "EventCode": "0x10138",
1314 "EventName": "PM_MRK_BR_2PATH",
1315 "BriefDescription": "marked branches which are not strongly biased"
1316 },
1317 {,
1318 "EventCode": "0x2884",
1319 "EventName": "PM_ISYNC",
1320 "BriefDescription": "Isync completion count per thread"
1321 },
1322 {,
1323 "EventCode": "0x16882",
1324 "EventName": "PM_L2_CASTOUT_SHR",
1325 "BriefDescription": "L2 Castouts - Shared (Tx,Sx)"
1326 },
1327 {,
1328 "EventCode": "0xD884",
1329 "EventName": "PM_LSU3_SET_MPRED",
1330 "BriefDescription": "Set prediction(set-p) miss. The entry was not found in the Set prediction table"
1331 },
1332 {,
1333 "EventCode": "0x26092",
1334 "EventName": "PM_L2_LD_MISS_64B",
1335 "BriefDescription": "All successful D-side load dispatches that were an L2 miss (NOT Sx,Tx,Mx) for this thread and the RC calculated the request should be for 64B(i.e., M=1)"
1336 },
1337 {,
1338 "EventCode": "0x26080",
1339 "EventName": "PM_L2_LD_MISS",
1340 "BriefDescription": "All successful D-Side Load dispatches that were an L2 miss for this thread"
1341 },
1342 {,
1343 "EventCode": "0x3D14C",
1344 "EventName": "PM_MRK_DATA_FROM_DMEM",
1345 "BriefDescription": "The processor's data cache was reloaded from another chip's memory on the same Node or Group (Distant) due to a marked load"
1346 },
1347 {,
1348 "EventCode": "0x100FA",
1349 "EventName": "PM_ANY_THRD_RUN_CYC",
1350 "BriefDescription": "Cycles in which at least one thread has the run latch set"
1351 },
1352 {,
1353 "EventCode": "0x2C12A",
1354 "EventName": "PM_MRK_DATA_FROM_RMEM_CYC",
1355 "BriefDescription": "Duration in cycles to reload from another chip's memory on the same Node or Group ( Remote) due to a marked load"
1356 },
1357 {,
1358 "EventCode": "0x25048",
1359 "EventName": "PM_IPTEG_FROM_LMEM",
1360 "BriefDescription": "A Page Table Entry was loaded into the TLB from the local chip's Memory due to a instruction side request"
1361 },
1362 {,
1363 "EventCode": "0xD8A8",
1364 "EventName": "PM_ISLB_MISS",
1365 "BriefDescription": "Instruction SLB miss - Total of all segment sizes"
1366 },
1367 {,
1368 "EventCode": "0xD19C",
1369 "EventName": "PM_MRK_LSU_FLUSH_RELAUNCH_MISS",
1370 "BriefDescription": "If a load that has already returned data and has to relaunch for any reason then gets a miss (erat, setp, data cache), it will often be flushed at relaunch time because the data might be inconsistent"
1371 },
1372 {,
1373 "EventCode": "0x260A2",
1374 "EventName": "PM_L3_CI_HIT",
1375 "BriefDescription": "L3 Castins Hit (total count)"
1376 },
1377 {,
1378 "EventCode": "0x44054",
1379 "EventName": "PM_VECTOR_LD_CMPL",
1380 "BriefDescription": "Number of vector load instructions completed"
1381 },
1382 {,
1383 "EventCode": "0x1E05C",
1384 "EventName": "PM_CMPLU_STALL_NESTED_TBEGIN",
1385 "BriefDescription": "Completion stall because the ISU is updating the TEXASR to keep track of the nested tbegin. This is a short delay, and it includes ROT"
1386 },
1387 {,
1388 "EventCode": "0x1608E",
1389 "EventName": "PM_ST_CAUSED_FAIL",
1390 "BriefDescription": "Non-TM Store caused any thread to fail"
1391 },
1392 {,
1393 "EventCode": "0x3080",
1394 "EventName": "PM_ISU0_ISS_HOLD_ALL",
1395 "BriefDescription": "All ISU rejects"
1396 },
1397 {,
1398 "EventCode": "0x1515A",
1399 "EventName": "PM_SYNC_MRK_L2MISS",
1400 "BriefDescription": "Marked L2 Miss that can throw a synchronous interrupt"
1401 },
1402 {,
1403 "EventCode": "0x26892",
1404 "EventName": "PM_L2_ST_MISS_64B",
1405 "BriefDescription": "All successful D-side store dispatches that were an L2 miss (NOT Sx,Tx,Mx) for this thread and the RC calculated the request should be for 64B (i.e., M=1)"
1406 },
1407 {,
1408 "EventCode": "0x2688C",
1409 "EventName": "PM_CO_USAGE",
1410 "BriefDescription": "Continuous 16 cycle (2to1) window where this signals rotates thru sampling each CO machine busy. PMU uses this wave to then do 16 cyc count to sample total number of machs running"
1411 },
1412 {,
1413 "EventCode": "0xD084",
1414 "EventName": "PM_LSU2_SET_MPRED",
1415 "BriefDescription": "Set prediction(set-p) miss. The entry was not found in the Set prediction table"
1416 },
1417 {,
1418 "EventCode": "0x48B8",
1419 "EventName": "PM_BR_MPRED_TAKEN_TA",
1420 "BriefDescription": "Conditional Branch Completed that was Mispredicted due to the Target Address Prediction from the Count Cache or Link Stack. Only XL-form branches that resolved Taken set this event."
1421 },
1422 {,
1423 "EventCode": "0x50B0",
1424 "EventName": "PM_BTAC_BAD_RESULT",
1425 "BriefDescription": "BTAC thinks branch will be taken but it is either predicted not-taken by the BHT, or the target address is wrong (less common). In both cases, a redirect will happen"
1426 },
1427 {,
1428 "EventCode": "0xD888",
1429 "EventName": "PM_LSU1_LDMX_FIN",
1430 "BriefDescription": "New P9 instruction LDMX. The definition of this new PMU event is (from the ldmx RFC02491): The thread has executed an ldmx instruction that accessed a doubleword that contains an effective address within an enabled section of the Load Monitored region. This event, therefore, should not occur if the FSCR has disabled the load monitored facility (FSCR[52]) or disabled the EBB facility (FSCR[56])."
1431 },
1432 {,
1433 "EventCode": "0x58B4",
1434 "EventName": "PM_TAGE_CORRECT",
1435 "BriefDescription": "The TAGE overrode BHT direction prediction and it was correct. Includes taken and not taken and is counted at execution time"
1436 },
1437 {,
1438 "EventCode": "0x3688C",
1439 "EventName": "PM_SN_USAGE",
1440 "BriefDescription": "Continuous 16 cycle (2to1) window where this signals rotates thru sampling each SN machine busy. PMU uses this wave to then do 16 cyc count to sample total number of machs running"
1441 },
1442 {,
1443 "EventCode": "0x46084",
1444 "EventName": "PM_L2_RCST_DISP_FAIL_OTHER",
1445 "BriefDescription": "All D-side store dispatch attempts for this thread that failed due to reason other than address collision"
1446 },
1447 {,
1448 "EventCode": "0xF0AC",
1449 "EventName": "PM_DC_PREF_STRIDED_CONF",
1450 "BriefDescription": "A demand load referenced a line in an active strided prefetch stream. The stream could have been allocated through the hardware prefetch mechanism or through software."
1451 },
1452 {,
1453 "EventCode": "0x45054",
1454 "EventName": "PM_FMA_CMPL",
1455 "BriefDescription": "two flops operation completed (fmadd, fnmadd, fmsub, fnmsub) Scalar instructions only. "
1456 },
1457 {,
1458 "EventCode": "0x5090",
1459 "EventName": "PM_SHL_ST_DISABLE",
1460 "BriefDescription": "Store-Hit-Load Table Read Hit with entry Disabled (entry was disabled due to the entry shown to not prevent the flush)"
1461 },
1462 {,
1463 "EventCode": "0x201E8",
1464 "EventName": "PM_THRESH_EXC_512",
1465 "BriefDescription": "Threshold counter exceeded a value of 512"
1466 },
1467 {,
1468 "EventCode": "0x5084",
1469 "EventName": "PM_DECODE_FUSION_EXT_ADD",
1470 "BriefDescription": "32-bit extended addition"
1471 },
1472 {,
1473 "EventCode": "0x36080",
1474 "EventName": "PM_L2_INST",
1475 "BriefDescription": "All successful I-side dispatches for this thread (excludes i_l2mru_tch reqs)."
1476 },
1477 {,
1478 "EventCode": "0x3504C",
1479 "EventName": "PM_IPTEG_FROM_DL4",
1480 "BriefDescription": "A Page Table Entry was loaded into the TLB from another chip's L4 on a different Node or Group (Distant) due to a instruction side request"
1481 },
1482 {,
1483 "EventCode": "0xD890",
1484 "EventName": "PM_LS1_DC_COLLISIONS",
1485 "BriefDescription": "Read-write data cache collisions"
1486 },
1487 {,
1488 "EventCode": "0x1688A",
1489 "EventName": "PM_ISIDE_DISP",
1490 "BriefDescription": "All I-side dispatch attempts for this thread (excludes i_l2mru_tch_reqs)"
1491 },
1492 {,
1493 "EventCode": "0x468AA",
1494 "EventName": "PM_L3_P1_CO_L31",
1495 "BriefDescription": "L3 CO to L3.1 (LCO) port 1 with or without data"
1496 },
1497 {,
1498 "EventCode": "0x28B0",
1499 "EventName": "PM_DISP_HELD_TBEGIN",
1500 "BriefDescription": "This outer tbegin transaction cannot be dispatched until the previous tend instruction completes"
1501 },
1502 {,
1503 "EventCode": "0xE8A0",
1504 "EventName": "PM_LSU3_TM_L1_MISS",
1505 "BriefDescription": "Load tm L1 miss"
1506 },
1507 {,
1508 "EventCode": "0x2C05E",
1509 "EventName": "PM_INST_GRP_PUMP_MPRED",
1510 "BriefDescription": "Final Pump Scope (Group) ended up either larger or smaller than Initial Pump Scope for an instruction fetch (demand only)"
1511 },
1512 {,
1513 "EventCode": "0xC8BC",
1514 "EventName": "PM_STCX_SUCCESS_CMPL",
1515 "BriefDescription": "Number of stcx instructions that completed successfully"
1516 },
1517 {,
1518 "EventCode": "0xE098",
1519 "EventName": "PM_LSU2_TM_L1_HIT",
1520 "BriefDescription": "Load tm hit in L1"
1521 },
1522 {,
1523 "EventCode": "0x44044",
1524 "EventName": "PM_INST_FROM_L31_ECO_MOD",
1525 "BriefDescription": "The processor's Instruction cache was reloaded with Modified (M) data from another core's ECO L3 on the same chip due to an instruction fetch (not prefetch)"
1526 },
1527 {,
1528 "EventCode": "0x16886",
1529 "EventName": "PM_CO_DISP_FAIL",
1530 "BriefDescription": "CO dispatch failed due to all CO machines being busy"
1531 },
1532 {,
1533 "EventCode": "0x3D146",
1534 "EventName": "PM_MRK_DATA_FROM_L3_NO_CONFLICT",
1535 "BriefDescription": "The processor's data cache was reloaded from local core's L3 without conflict due to a marked load"
1536 },
1537 {,
1538 "EventCode": "0x16892",
1539 "EventName": "PM_L2_ST_MISS_128B",
1540 "BriefDescription": "All successful D-side store dispatches that were an L2 miss (NOT Sx,Tx,Mx) for this thread and the RC calculated the request should be for 128B (i.e., M=0)"
1541 },
1542 {,
1543 "EventCode": "0x26890",
1544 "EventName": "PM_ISIDE_L2MEMACC",
1545 "BriefDescription": "Valid when first beat of data comes in for an I-side fetch where data came from memory"
1546 },
1547 {,
1548 "EventCode": "0xD094",
1549 "EventName": "PM_LS2_DC_COLLISIONS",
1550 "BriefDescription": "Read-write data cache collisions"
1551 },
1552 {,
1553 "EventCode": "0x3C05E",
1554 "EventName": "PM_MEM_RWITM",
1555 "BriefDescription": "Memory Read With Intent to Modify for this thread"
1556 },
1557 {,
1558 "EventCode": "0x26882",
1559 "EventName": "PM_L2_DC_INV",
1560 "BriefDescription": "D-cache invalidates sent over the reload bus to the core"
1561 },
1562 {,
1563 "EventCode": "0xC090",
1564 "EventName": "PM_LSU_STCX",
1565 "BriefDescription": "STCX sent to nest, i.e. total"
1566 },
1567 {,
1568 "EventCode": "0xD080",
1569 "EventName": "PM_LSU0_SET_MPRED",
1570 "BriefDescription": "Set prediction(set-p) miss. The entry was not found in the Set prediction table"
1571 },
1572 {,
1573 "EventCode": "0x2C120",
1574 "EventName": "PM_MRK_DATA_FROM_L2_NO_CONFLICT",
1575 "BriefDescription": "The processor's data cache was reloaded from local core's L2 without conflict due to a marked load"
1576 },
1577 {,
1578 "EventCode": "0x36086",
1579 "EventName": "PM_L2_RC_ST_DONE",
1580 "BriefDescription": "RC did store to line that was Tx or Sx"
1581 },
1582 {,
1583 "EventCode": "0xE8AC",
1584 "EventName": "PM_TM_FAIL_TX_CONFLICT",
1585 "BriefDescription": "Transactional conflict from LSU, gets reported to TEXASR"
1586 },
1587 {,
1588 "EventCode": "0x48A8",
1589 "EventName": "PM_DECODE_FUSION_LD_ST_DISP",
1590 "BriefDescription": "32-bit displacement D-form and 16-bit displacement X-form"
1591 },
1592 {,
1593 "EventCode": "0x3D144",
1594 "EventName": "PM_MRK_DATA_FROM_L2_MEPF_CYC",
1595 "BriefDescription": "Duration in cycles to reload from local core's L2 hit without dispatch conflicts on Mepf state. due to a marked load"
1596 },
1597 {,
1598 "EventCode": "0x44046",
1599 "EventName": "PM_INST_FROM_L21_MOD",
1600 "BriefDescription": "The processor's Instruction cache was reloaded with Modified (M) data from another core's L2 on the same chip due to an instruction fetch (not prefetch)"
1601 },
1602 {,
1603 "EventCode": "0x40B0",
1604 "EventName": "PM_BR_PRED_TAKEN_CR",
1605 "BriefDescription": "Conditional Branch that had its direction predicted. I-form branches do not set this event. In addition, B-form branches which do not use the BHT do not set this event - these are branches with BO-field set to 'always taken' and branches"
1606 },
1607 {,
1608 "EventCode": "0x15040",
1609 "EventName": "PM_IPTEG_FROM_L2_NO_CONFLICT",
1610 "BriefDescription": "A Page Table Entry was loaded into the TLB from local core's L2 without conflict due to a instruction side request"
1611 },
1612 {,
1613 "EventCode": "0xD9A0",
1614 "EventName": "PM_MRK_LSU_FLUSH_LHL_SHL",
1615 "BriefDescription": "The instruction was flushed because of a sequential load/store consistency. If a load or store hits on an older load that has either been snooped (for loads) or has stale data (for stores)."
1616 },
1617 {,
1618 "EventCode": "0x35042",
1619 "EventName": "PM_IPTEG_FROM_L3_DISP_CONFLICT",
1620 "BriefDescription": "A Page Table Entry was loaded into the TLB from local core's L3 with dispatch conflict due to a instruction side request"
1621 },
1622 {,
1623 "EventCode": "0xF898",
1624 "EventName": "PM_XLATE_RADIX_MODE",
1625 "BriefDescription": "LSU reports every cycle the thread is in radix translation mode (as opposed to HPT mode)"
1626 },
1627 {,
1628 "EventCode": "0x2D142",
1629 "EventName": "PM_MRK_DATA_FROM_L3_MEPF",
1630 "BriefDescription": "The processor's data cache was reloaded from local core's L3 without dispatch conflicts hit on Mepf state. due to a marked load"
1631 },
1632 {,
1633 "EventCode": "0x160B0",
1634 "EventName": "PM_L3_P0_NODE_PUMP",
1635 "BriefDescription": "L3 PF sent with nodal scope port 0, counts even retried requests"
1636 },
1637 {,
1638 "EventCode": "0xD88C",
1639 "EventName": "PM_LSU3_LDMX_FIN",
1640 "BriefDescription": "New P9 instruction LDMX. The definition of this new PMU event is (from the ldmx RFC02491): The thread has executed an ldmx instruction that accessed a doubleword that contains an effective address within an enabled section of the Load Monitored region. This event, therefore, should not occur if the FSCR has disabled the load monitored facility (FSCR[52]) or disabled the EBB facility (FSCR[56])."
1641 },
1642 {,
1643 "EventCode": "0x36882",
1644 "EventName": "PM_L2_LD_HIT",
1645 "BriefDescription": "All successful I-or-D side load dispatches for this thread that were L2 hits (excludes i_l2mru_tch_reqs)"
1646 },
1647 {,
1648 "EventCode": "0x168AC",
1649 "EventName": "PM_L3_CI_USAGE",
1650 "BriefDescription": "Rotating sample of 16 CI or CO actives"
1651 },
1652 {,
1653 "EventCode": "0x20134",
1654 "EventName": "PM_MRK_FXU_FIN",
1655 "BriefDescription": "fxu marked instr finish"
1656 },
1657 {,
1658 "EventCode": "0x4608E",
1659 "EventName": "PM_TM_CAP_OVERFLOW",
1660 "BriefDescription": "TM Footprint Capacity Overflow"
1661 },
1662 {,
1663 "EventCode": "0x4F05C",
1664 "EventName": "PM_RADIX_PWC_L2_PTE_FROM_L3MISS",
1665 "BriefDescription": "A Page Table Entry was reloaded to a level 2 page walk cache from beyond the core's L3 data cache. This implies that level 3 and level 4 PWC accesses were not necessary for this translation. The source could be local/remote/distant memory or another core's cache"
1666 },
1667 {,
1668 "EventCode": "0x40014",
1669 "EventName": "PM_PROBE_NOP_DISP",
1670 "BriefDescription": "ProbeNops dispatched"
1671 },
1672 {,
1673 "EventCode": "0x58A8",
1674 "EventName": "PM_DECODE_HOLD_ICT_FULL",
1675 "BriefDescription": "Counts the number of cycles in which the IFU was not able to decode and transmit one or more instructions because all itags were in use. This means the ICT is full for this thread"
1676 },
1677 {,
1678 "EventCode": "0x10052",
1679 "EventName": "PM_GRP_PUMP_MPRED_RTY",
1680 "BriefDescription": "Final Pump Scope (Group) ended up larger than Initial Pump Scope (Chip) for all data types excluding data prefetch (demand load,inst prefetch,inst fetch,xlate)"
1681 },
1682 {,
1683 "EventCode": "0x2505E",
1684 "EventName": "PM_BACK_BR_CMPL",
1685 "BriefDescription": "Branch instruction completed with a target address less than current instruction address"
1686 },
1687 {,
1688 "EventCode": "0x2688A",
1689 "EventName": "PM_ISIDE_DISP_FAIL_OTHER",
1690 "BriefDescription": "All I-side dispatch attempts for this thread that failed due to a reason other than addrs collision (excludes i_l2mru_tch_reqs)"
1691 },
1692 {,
1693 "EventCode": "0x2001A",
1694 "EventName": "PM_NTC_ALL_FIN",
1695 "BriefDescription": "Cycles after all instructions have finished to group completed"
1696 },
1697 {,
1698 "EventCode": "0x3005A",
1699 "EventName": "PM_ISQ_0_8_ENTRIES",
1700 "BriefDescription": "Cycles in which 8 or less Issue Queue entries are in use. This is a shared event, not per thread"
1701 },
1702 {,
1703 "EventCode": "0x3515E",
1704 "EventName": "PM_MRK_BACK_BR_CMPL",
1705 "BriefDescription": "Marked branch instruction completed with a target address less than current instruction address"
1706 },
1707 {,
1708 "EventCode": "0xF890",
1709 "EventName": "PM_LSU1_L1_CAM_CANCEL",
1710 "BriefDescription": "ls1 l1 tm cam cancel"
1711 },
1712 {,
1713 "EventCode": "0xE884",
1714 "EventName": "PM_LS1_ERAT_MISS_PREF",
1715 "BriefDescription": "LS1 Erat miss due to prefetch"
1716 },
1717 {,
1718 "EventCode": "0xE89C",
1719 "EventName": "PM_LSU1_TM_L1_MISS",
1720 "BriefDescription": "Load tm L1 miss"
1721 },
1722 {,
1723 "EventCode": "0x28A8",
1724 "EventName": "PM_TM_FAIL_CONF_NON_TM",
1725 "BriefDescription": "TM aborted because a conflict occurred with a non-transactional access by another processor"
1726 },
1727 {,
1728 "EventCode": "0x16890",
1729 "EventName": "PM_L1PF_L2MEMACC",
1730 "BriefDescription": "Valid when first beat of data comes in for an L1PF where data came from memory"
1731 },
1732 {,
1733 "EventCode": "0x4504C",
1734 "EventName": "PM_IPTEG_FROM_DMEM",
1735 "BriefDescription": "A Page Table Entry was loaded into the TLB from another chip's memory on the same Node or Group (Distant) due to a instruction side request"
1736 },
1737 {,
1738 "EventCode": "0x1002E",
1739 "EventName": "PM_LMQ_MERGE",
1740 "BriefDescription": "A demand miss collides with a prefetch for the same line"
1741 },
1742 {,
1743 "EventCode": "0x160B6",
1744 "EventName": "PM_L3_WI0_BUSY",
1745 "BriefDescription": "Rotating sample of 8 WI valid"
1746 },
1747 {,
1748 "EventCode": "0x368AC",
1749 "EventName": "PM_L3_CO0_BUSY",
1750 "BriefDescription": "Lifetime, sample of CO machine 0 valid"
1751 },
1752 {,
1753 "EventCode": "0x2E040",
1754 "EventName": "PM_DPTEG_FROM_L2_MEPF",
1755 "BriefDescription": "A Page Table Entry was loaded into the TLB from local core's L2 hit without dispatch conflicts on Mepf state. due to a data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
1756 },
1757 {,
1758 "EventCode": "0x1D152",
1759 "EventName": "PM_MRK_DATA_FROM_DL4",
1760 "BriefDescription": "The processor's data cache was reloaded from another chip's L4 on a different Node or Group (Distant) due to a marked load"
1761 },
1762 {,
1763 "EventCode": "0x46880",
1764 "EventName": "PM_ISIDE_MRU_TOUCH",
1765 "BriefDescription": "I-side L2 MRU touch sent to L2 for this thread"
1766 },
1767 {,
1768 "EventCode": "0x1C05C",
1769 "EventName": "PM_DTLB_MISS_2M",
1770 "BriefDescription": "Data TLB reload (after a miss) page size 2M. Implies radix translation was used"
1771 },
1772 {,
1773 "EventCode": "0x50B8",
1774 "EventName": "PM_TAGE_OVERRIDE_WRONG",
1775 "BriefDescription": "The TAGE overrode BHT direction prediction but it was incorrect. Counted at completion for taken branches only"
1776 },
1777 {,
1778 "EventCode": "0x160AE",
1779 "EventName": "PM_L3_P0_PF_RTY",
1780 "BriefDescription": "L3 PF received retry port 0, every retry counted"
1781 },
1782 {,
1783 "EventCode": "0x268B2",
1784 "EventName": "PM_L3_LOC_GUESS_WRONG",
1785 "BriefDescription": "Initial scope=node (LNS) but data from out side local node (near or far or rem). Prediction too Low"
1786 },
1787 {,
1788 "EventCode": "0x36088",
1789 "EventName": "PM_L2_SYS_GUESS_CORRECT",
1790 "BriefDescription": "L2 guess system (VGS or RNS) and guess was correct (ie data beyond-group)"
1791 },
1792 {,
1793 "EventCode": "0x589C",
1794 "EventName": "PM_PTESYNC",
1795 "BriefDescription": "ptesync instruction counted when the instruction is decoded and transmitted"
1796 },
1797 {,
1798 "EventCode": "0x26086",
1799 "EventName": "PM_CO_TM_SC_FOOTPRINT",
1800 "BriefDescription": "L2 did a cleanifdirty CO to the L3 (ie created an SC line in the L3) OR L2 TM_store hit dirty HPC line and L3 indicated SC line formed in L3 on RDR bus"
1801 },
1802 {,
1803 "EventCode": "0x1E05A",
1804 "EventName": "PM_CMPLU_STALL_ANY_SYNC",
1805 "BriefDescription": "Cycles in which the NTC sync instruction (isync, lwsync or hwsync) is not allowed to complete"
1806 },
1807 {,
1808 "EventCode": "0xF090",
1809 "EventName": "PM_LSU0_L1_CAM_CANCEL",
1810 "BriefDescription": "ls0 l1 tm cam cancel"
1811 },
1812 {,
1813 "EventCode": "0xC0A8",
1814 "EventName": "PM_LSU_FLUSH_CI",
1815 "BriefDescription": "Load was not issued to LSU as a cache inhibited (non-cacheable) load but it was later determined to be cache inhibited"
1816 },
1817 {,
1818 "EventCode": "0x20AC",
1819 "EventName": "PM_TM_FAIL_CONF_TM",
1820 "BriefDescription": "TM aborted because a conflict occurred with another transaction."
1821 },
1822 {,
1823 "EventCode": "0x588C",
1824 "EventName": "PM_SHL_ST_DEP_CREATED",
1825 "BriefDescription": "Store-Hit-Load Table Read Hit with entry Enabled"
1826 },
1827 {,
1828 "EventCode": "0x360AC",
1829 "EventName": "PM_L3_SN0_BUSY",
1830 "BriefDescription": "Lifetime, sample of snooper machine 0 valid"
1831 },
1832 {,
1833 "EventCode": "0x3005C",
1834 "EventName": "PM_BFU_BUSY",
1835 "BriefDescription": "Cycles in which all 4 Binary Floating Point units are busy. The BFU is running at capacity"
1836 },
1837 {,
1838 "EventCode": "0x48A0",
1839 "EventName": "PM_BR_PRED_PCACHE",
1840 "BriefDescription": "Conditional branch completed that used pattern cache prediction"
1841 },
1842 {,
1843 "EventCode": "0x26880",
1844 "EventName": "PM_L2_ST_MISS",
1845 "BriefDescription": "All successful D-Side Store dispatches that were an L2 miss for this thread"
1846 },
1847 {,
1848 "EventCode": "0xF8B4",
1849 "EventName": "PM_DC_PREF_XCONS_ALLOC",
1850 "BriefDescription": "Prefetch stream allocated in the Ultra conservative phase by either the hardware prefetch mechanism or software prefetch"
1851 },
1852 {,
1853 "EventCode": "0x35048",
1854 "EventName": "PM_IPTEG_FROM_DL2L3_SHR",
1855 "BriefDescription": "A Page Table Entry was loaded into the TLB with Shared (S) data from another chip's L2 or L3 on a different Node or Group (Distant), as this chip due to a instruction side request"
1856 },
1857 {,
1858 "EventCode": "0x260A8",
1859 "EventName": "PM_L3_PF_HIT_L3",
1860 "BriefDescription": "L3 PF hit in L3 (abandoned)"
1861 },
1862 {,
1863 "EventCode": "0x360B4",
1864 "EventName": "PM_L3_PF0_BUSY",
1865 "BriefDescription": "Lifetime, sample of PF machine 0 valid"
1866 },
1867 {,
1868 "EventCode": "0xC0B0",
1869 "EventName": "PM_LSU_FLUSH_UE",
1870 "BriefDescription": "Correctable ECC error on reload data, reported at critical data forward time"
1871 },
1872 {,
1873 "EventCode": "0x4013A",
1874 "EventName": "PM_MRK_IC_MISS",
1875 "BriefDescription": "Marked instruction experienced I cache miss"
1876 },
1877 {,
1878 "EventCode": "0x2088",
1879 "EventName": "PM_FLUSH_DISP_SB",
1880 "BriefDescription": "Dispatch Flush: Scoreboard"
1881 },
1882 {,
1883 "EventCode": "0x401E8",
1884 "EventName": "PM_MRK_DATA_FROM_L2MISS",
1885 "BriefDescription": "The processor's data cache was reloaded from a location other than the local core's L2 due to a marked load"
1886 },
1887 {,
1888 "EventCode": "0x3688E",
1889 "EventName": "PM_TM_ST_CAUSED_FAIL",
1890 "BriefDescription": "TM Store (fav or non-fav) caused another thread to fail"
1891 },
1892 {,
1893 "EventCode": "0x460B2",
1894 "EventName": "PM_L3_SYS_GUESS_WRONG",
1895 "BriefDescription": "Initial scope=system (VGS or RNS) but data from local or near. Prediction too high"
1896 },
1897 {,
1898 "EventCode": "0x58B8",
1899 "EventName": "PM_TAGE_OVERRIDE_WRONG_SPEC",
1900 "BriefDescription": "The TAGE overrode BHT direction prediction and it was correct. Includes taken and not taken and is counted at execution time"
1901 },
1902 {,
1903 "EventCode": "0xE890",
1904 "EventName": "PM_LSU3_ERAT_HIT",
1905 "BriefDescription": "Primary ERAT hit. There is no secondary ERAT"
1906 },
1907 {,
1908 "EventCode": "0x2898",
1909 "EventName": "PM_TM_TABORT_TRECLAIM",
1910 "BriefDescription": "Completion time tabortnoncd, tabortcd, treclaim"
1911 },
1912 {,
1913 "EventCode": "0x4C054",
1914 "EventName": "PM_DERAT_MISS_16G",
1915 "BriefDescription": "Data ERAT Miss (Data TLB Access) page size 16G"
1916 },
1917 {,
1918 "EventCode": "0x268A0",
1919 "EventName": "PM_L3_CO_L31",
1920 "BriefDescription": "L3 CO to L3.1 OR of port 0 and 1 (lossy = may undercount if two cresps come in the same cyc)"
1921 },
1922 {,
1923 "EventCode": "0x5080",
1924 "EventName": "PM_THRD_PRIO_4_5_CYC",
1925 "BriefDescription": "Cycles thread running at priority level 4 or 5"
1926 },
1927 {,
1928 "EventCode": "0x2505C",
1929 "EventName": "PM_VSU_FIN",
1930 "BriefDescription": "VSU instruction finished. Up to 4 per cycle"
1931 },
1932 {,
1933 "EventCode": "0x40A4",
1934 "EventName": "PM_BR_PRED_CCACHE",
1935 "BriefDescription": "Conditional Branch Completed that used the Count Cache for Target Prediction"
1936 },
1937 {,
1938 "EventCode": "0x2E04A",
1939 "EventName": "PM_DPTEG_FROM_RL4",
1940 "BriefDescription": "A Page Table Entry was loaded into the TLB from another chip's L4 on the same Node or Group ( Remote) due to a data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
1941 },
1942 {,
1943 "EventCode": "0x4D12E",
1944 "EventName": "PM_MRK_DATA_FROM_DL2L3_MOD_CYC",
1945 "BriefDescription": "Duration in cycles to reload with Modified (M) data from another chip's L2 or L3 on a different Node or Group (Distant), as this chip due to a marked load"
1946 },
1947 {,
1948 "EventCode": "0xC8B4",
1949 "EventName": "PM_LSU_FLUSH_LHL_SHL",
1950 "BriefDescription": "The instruction was flushed because of a sequential load/store consistency. If a load or store hits on an older load that has either been snooped (for loads) or has stale data (for stores)."
1951 },
1952 {,
1953 "EventCode": "0x58A4",
1954 "EventName": "PM_FLUSH_LSU",
1955 "BriefDescription": "LSU flushes. Includes all lsu flushes"
1956 },
1957 {,
1958 "EventCode": "0x1D150",
1959 "EventName": "PM_MRK_DATA_FROM_DL2L3_SHR",
1960 "BriefDescription": "The processor's data cache was reloaded with Shared (S) data from another chip's L2 or L3 on a different Node or Group (Distant), as this chip due to a marked load"
1961 },
1962 {,
1963 "EventCode": "0xC8A0",
1964 "EventName": "PM_LSU1_FALSE_LHS",
1965 "BriefDescription": "False LHS match detected"
1966 },
1967 {,
1968 "EventCode": "0x48BC",
1969 "EventName": "PM_THRD_PRIO_2_3_CYC",
1970 "BriefDescription": "Cycles thread running at priority level 2 or 3"
1971 },
1972 {,
1973 "EventCode": "0x10134",
1974 "EventName": "PM_MRK_ST_DONE_L2",
1975 "BriefDescription": "marked store completed in L2 ( RC machine done)"
1976 },
1977 {,
1978 "EventCode": "0x368B2",
1979 "EventName": "PM_L3_GRP_GUESS_WRONG_HIGH",
1980 "BriefDescription": "Initial scope=group (GS or NNS) but data from local node. Prediction too high"
1981 },
1982 {,
1983 "EventCode": "0xE8BC",
1984 "EventName": "PM_LS1_PTE_TABLEWALK_CYC",
1985 "BriefDescription": "Cycles when a tablewalk is pending on this thread on table 1"
1986 },
1987 {,
1988 "EventCode": "0x1F152",
1989 "EventName": "PM_MRK_FAB_RSP_BKILL_CYC",
1990 "BriefDescription": "cycles L2 RC took for a bkill"
1991 },
1992 {,
1993 "EventCode": "0x4C124",
1994 "EventName": "PM_MRK_DATA_FROM_L3_NO_CONFLICT_CYC",
1995 "BriefDescription": "Duration in cycles to reload from local core's L3 without conflict due to a marked load"
1996 },
1997 {,
1998 "EventCode": "0x2F14A",
1999 "EventName": "PM_MRK_DPTEG_FROM_RL4",
2000 "BriefDescription": "A Page Table Entry was loaded into the TLB from another chip's L4 on the same Node or Group ( Remote) due to a marked data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
2001 },
2002 {,
2003 "EventCode": "0x26888",
2004 "EventName": "PM_L2_GRP_GUESS_WRONG",
2005 "BriefDescription": "L2 guess grp (GS or NNS) and guess was not correct (ie data on-chip OR beyond-group)"
2006 },
2007 {,
2008 "EventCode": "0x368AE",
2009 "EventName": "PM_L3_P1_CO_RTY",
2010 "BriefDescription": "L3 CO received retry port 1 (memory only), every retry counted"
2011 },
2012 {,
2013 "EventCode": "0xC0AC",
2014 "EventName": "PM_LSU_FLUSH_EMSH",
2015 "BriefDescription": "An ERAT miss was detected after a set-p hit. Erat tracker indicates fail due to tlbmiss and the instruction gets flushed because the instruction was working on the wrong address"
2016 },
2017 {,
2018 "EventCode": "0x260B2",
2019 "EventName": "PM_L3_SYS_GUESS_CORRECT",
2020 "BriefDescription": "Initial scope=system (VGS or RNS) and data from outside group (far or rem)(pred successful)"
2021 },
2022 {,
2023 "EventCode": "0x1D146",
2024 "EventName": "PM_MRK_DATA_FROM_MEMORY_CYC",
2025 "BriefDescription": "Duration in cycles to reload from a memory location including L4 from local remote or distant due to a marked load"
2026 },
2027 {,
2028 "EventCode": "0xE094",
2029 "EventName": "PM_LSU0_TM_L1_HIT",
2030 "BriefDescription": "Load tm hit in L1"
2031 },
2032 {,
2033 "EventCode": "0x46888",
2034 "EventName": "PM_L2_GROUP_PUMP",
2035 "BriefDescription": "RC requests that were on group (aka nodel) pump attempts"
2036 },
2037 {,
2038 "EventCode": "0xF0B0",
2039 "EventName": "PM_L3_LD_PREF",
2040 "BriefDescription": "L3 load prefetch, sourced from a hardware or software stream, was sent to the nest"
2041 },
2042 {,
2043 "EventCode": "0x16080",
2044 "EventName": "PM_L2_LD",
2045 "BriefDescription": "All successful D-side Load dispatches for this thread (L2 miss + L2 hits)"
2046 },
2047 {,
2048 "EventCode": "0x4505C",
2049 "EventName": "PM_MATH_FLOP_CMPL",
2050 "BriefDescription": "Math flop instruction completed"
2051 },
2052 {,
2053 "EventCode": "0x368B0",
2054 "EventName": "PM_L3_P1_SYS_PUMP",
2055 "BriefDescription": "L3 PF sent with sys scope port 1, counts even retried requests"
2056 },
2057 {,
2058 "EventCode": "0x1F146",
2059 "EventName": "PM_MRK_DPTEG_FROM_L31_SHR",
2060 "BriefDescription": "A Page Table Entry was loaded into the TLB with Shared (S) data from another core's L3 on the same chip due to a marked data side request.. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
2061 },
2062 {,
2063 "EventCode": "0x2000C",
2064 "EventName": "PM_THRD_ALL_RUN_CYC",
2065 "BriefDescription": "Cycles in which all the threads have the run latch set"
2066 },
2067 {,
2068 "EventCode": "0xC0BC",
2069 "EventName": "PM_LSU_FLUSH_OTHER",
2070 "BriefDescription": "Other LSU flushes including: Sync (sync ack from L2 caused search of LRQ for oldest snooped load, This will either signal a Precise Flush of the oldest snooped loa or a Flush Next PPC); Data Valid Flush Next (several cases of this, one example is store and reload are lined up such that a store-hit-reload scenario exists and the CDF has already launched and has gotten bad/stale data); Bad Data Valid Flush Next (might be a few cases of this, one example is a larxa (D$ hit) return data and dval but can't allocate to LMQ (LMQ full or other reason). Already gave dval but can't watch it for snoop_hit_larx. Need to take the “bad dval” back and flush all younger ops)"
2071 },
2072 {,
2073 "EventCode": "0x5094",
2074 "EventName": "PM_IC_MISS_ICBI",
2075 "BriefDescription": "threaded version, IC Misses where we got EA dir hit but no sector valids were on. ICBI took line out"
2076 },
2077 {,
2078 "EventCode": "0xC8A8",
2079 "EventName": "PM_LSU_FLUSH_ATOMIC",
2080 "BriefDescription": "Quad-word loads (lq) are considered atomic because they always span at least 2 slices. If a snoop or store from another thread changes the data the load is accessing between the 2 or 3 pieces of the lq instruction, the lq will be flushed"
2081 },
2082 {,
2083 "EventCode": "0x1E04E",
2084 "EventName": "PM_DPTEG_FROM_L2MISS",
2085 "BriefDescription": "A Page Table Entry was loaded into the TLB from a location other than the local core's L2 due to a data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
2086 },
2087 {,
2088 "EventCode": "0x4D05E",
2089 "EventName": "PM_BR_CMPL",
2090 "BriefDescription": "Any Branch instruction completed"
2091 },
2092 {,
2093 "EventCode": "0x260B0",
2094 "EventName": "PM_L3_P0_GRP_PUMP",
2095 "BriefDescription": "L3 PF sent with grp scope port 0, counts even retried requests"
2096 },
2097 {,
2098 "EventCode": "0x30132",
2099 "EventName": "PM_MRK_VSU_FIN",
2100 "BriefDescription": "VSU marked instr finish"
2101 },
2102 {,
2103 "EventCode": "0x2D120",
2104 "EventName": "PM_MRK_DATA_FROM_OFF_CHIP_CACHE",
2105 "BriefDescription": "The processor's data cache was reloaded either shared or modified data from another core's L2/L3 on a different chip (remote or distant) due to a marked load"
2106 },
2107 {,
2108 "EventCode": "0x1E048",
2109 "EventName": "PM_DPTEG_FROM_ON_CHIP_CACHE",
2110 "BriefDescription": "A Page Table Entry was loaded into the TLB either shared or modified data from another core's L2/L3 on the same chip due to a data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
2111 },
2112 {,
2113 "EventCode": "0x16086",
2114 "EventName": "PM_L2_SN_M_WR_DONE",
2115 "BriefDescription": "SNP dispatched for a write and was M (true M); for DMA cacheinj this will pulse if rty/push is required (won't pulse if cacheinj is accepted)"
2116 },
2117 {,
2118 "EventCode": "0x489C",
2119 "EventName": "PM_BR_CORECT_PRED_TAKEN_CMPL",
2120 "BriefDescription": "Conditional Branch Completed in which the HW correctly predicted the direction as taken. Counted at completion time"
2121 },
2122 {,
2123 "EventCode": "0xF0B8",
2124 "EventName": "PM_LS0_UNALIGNED_ST",
2125 "BriefDescription": "Store instructions whose data crosses a double-word boundary, which causes it to require an additional slice than than what normally would be required of the Store of that size. If the Store wraps from slice 3 to slice 0, thee is an additional 3-cycle penalty"
2126 },
2127 {,
2128 "EventCode": "0x20132",
2129 "EventName": "PM_MRK_DFU_FIN",
2130 "BriefDescription": "Decimal Unit marked Instruction Finish"
2131 },
2132 {,
2133 "EventCode": "0x160A6",
2134 "EventName": "PM_TM_SC_CO",
2135 "BriefDescription": "L3 castout TM SC line"
2136 },
2137 {,
2138 "EventCode": "0xC8B0",
2139 "EventName": "PM_LSU_FLUSH_LHS",
2140 "BriefDescription": "Effective Address alias flush : no EA match but Real Address match. If the data has not yet been returned for this load, the instruction will just be rejected, but if it has returned data, it will be flushed"
2141 },
2142 {,
2143 "EventCode": "0x3F150",
2144 "EventName": "PM_MRK_ST_DRAIN_TO_L2DISP_CYC",
2145 "BriefDescription": "cycles to drain st from core to L2"
2146 },
2147 {,
2148 "EventCode": "0x168A4",
2149 "EventName": "PM_L3_MISS",
2150 "BriefDescription": "L3 Misses (L2 miss also missing L3, including data/instrn/xlate)"
2151 },
2152 {,
2153 "EventCode": "0xF080",
2154 "EventName": "PM_LSU_STCX_FAIL",
2155 "BriefDescription": ""
2156 },
2157 {,
2158 "EventCode": "0x30038",
2159 "EventName": "PM_CMPLU_STALL_DMISS_LMEM",
2160 "BriefDescription": "Completion stall due to cache miss that resolves in local memory"
2161 },
2162 {,
2163 "EventCode": "0x28A4",
2164 "EventName": "PM_MRK_TEND_FAIL",
2165 "BriefDescription": "Nested or not nested tend failed for a marked tend instruction"
2166 },
2167 {,
2168 "EventCode": "0x100FC",
2169 "EventName": "PM_LD_REF_L1",
2170 "BriefDescription": "All L1 D cache load references counted at finish, gated by reject"
2171 },
2172 {,
2173 "EventCode": "0xC0A0",
2174 "EventName": "PM_LSU0_FALSE_LHS",
2175 "BriefDescription": "False LHS match detected"
2176 },
2177 {,
2178 "EventCode": "0x468A8",
2179 "EventName": "PM_SN_MISS",
2180 "BriefDescription": "Any port snooper L3 miss or collision. Up to 4 can happen in a cycle but we only count 1"
2181 },
2182 {,
2183 "EventCode": "0x36888",
2184 "EventName": "PM_L2_SYS_GUESS_WRONG",
2185 "BriefDescription": "L2 guess system (VGS or RNS) and guess was not correct (ie data ^beyond-group)"
2186 },
2187 {,
2188 "EventCode": "0x2080",
2189 "EventName": "PM_EE_OFF_EXT_INT",
2190 "BriefDescription": "CyclesMSR[EE] is off and external interrupts are active"
2191 },
2192 {,
2193 "EventCode": "0xE8B8",
2194 "EventName": "PM_LS3_TM_DISALLOW",
2195 "BriefDescription": "A TM-ineligible instruction tries to execute inside a transaction and the LSU disallows it"
2196 },
2197 {,
2198 "EventCode": "0x2688E",
2199 "EventName": "PM_TM_FAV_CAUSED_FAIL",
2200 "BriefDescription": "TM Load (fav) caused another thread to fail"
2201 },
2202 {,
2203 "EventCode": "0x16090",
2204 "EventName": "PM_SN0_BUSY",
2205 "BriefDescription": "SN mach 0 Busy. Used by PMU to sample ave SN lifetime (mach0 used as sample point)"
2206 },
2207 {,
2208 "EventCode": "0x360AE",
2209 "EventName": "PM_L3_P0_CO_RTY",
2210 "BriefDescription": "L3 CO received retry port 0 (memory only), every retry counted"
2211 },
2212 {,
2213 "EventCode": "0x168A8",
2214 "EventName": "PM_L3_WI_USAGE",
2215 "BriefDescription": "Lifetime, sample of Write Inject machine 0 valid"
2216 },
2217 {,
2218 "EventCode": "0x468A2",
2219 "EventName": "PM_L3_LAT_CI_MISS",
2220 "BriefDescription": "L3 Lateral Castins Miss"
2221 },
2222 {,
2223 "EventCode": "0x4090",
2224 "EventName": "PM_IC_PREF_CANCEL_PAGE",
2225 "BriefDescription": "Prefetch Canceled due to page boundary"
2226 },
2227 {,
2228 "EventCode": "0xF09C",
2229 "EventName": "PM_SLB_TABLEWALK_CYC",
2230 "BriefDescription": "Cycles when a tablewalk is pending on this thread on the SLB table"
2231 },
2232 {,
2233 "EventCode": "0x460AA",
2234 "EventName": "PM_L3_P0_CO_L31",
2235 "BriefDescription": "L3 CO to L3.1 (LCO) port 0 with or without data"
2236 },
2237 {,
2238 "EventCode": "0x2880",
2239 "EventName": "PM_FLUSH_DISP",
2240 "BriefDescription": "Dispatch flush"
2241 },
2242 {,
2243 "EventCode": "0x168AE",
2244 "EventName": "PM_L3_P1_PF_RTY",
2245 "BriefDescription": "L3 PF received retry port 1, every retry counted"
2246 },
2247 {,
2248 "EventCode": "0x46082",
2249 "EventName": "PM_L2_ST_DISP",
2250 "BriefDescription": "All successful D-side store dispatches for this thread "
2251 },
2252 {,
2253 "EventCode": "0x4609E",
2254 "EventName": "PM_L2_INST_MISS",
2255 "BriefDescription": "All successful I-side dispatches that were an L2 miss for this thread (excludes i_l2mru_tch reqs)"
2256 },
2257 {,
2258 "EventCode": "0xE084",
2259 "EventName": "PM_LS0_ERAT_MISS_PREF",
2260 "BriefDescription": "LS0 Erat miss due to prefetch"
2261 },
2262 {,
2263 "EventCode": "0x409C",
2264 "EventName": "PM_BR_PRED",
2265 "BriefDescription": "Conditional Branch Executed in which the HW predicted the Direction or Target. Includes taken and not taken and is counted at execution time"
2266 },
2267 {,
2268 "EventCode": "0x2D144",
2269 "EventName": "PM_MRK_DATA_FROM_L31_MOD",
2270 "BriefDescription": "The processor's data cache was reloaded with Modified (M) data from another core's L3 on the same chip due to a marked load"
2271 },
2272 {,
2273 "EventCode": "0x360A4",
2274 "EventName": "PM_L3_CO_LCO",
2275 "BriefDescription": "Total L3 COs occurred on LCO L3.1 (good cresp, may end up in mem on a retry)"
2276 },
2277 {,
2278 "EventCode": "0x4890",
2279 "EventName": "PM_IC_PREF_CANCEL_HIT",
2280 "BriefDescription": "Prefetch Canceled due to icache hit"
2281 },
2282 {,
2283 "EventCode": "0x268A8",
2284 "EventName": "PM_RD_HIT_PF",
2285 "BriefDescription": "RD machine hit L3 PF machine"
2286 },
2287 {,
2288 "EventCode": "0x16880",
2289 "EventName": "PM_L2_ST",
2290 "BriefDescription": "All successful D-side store dispatches for this thread (L2 miss + L2 hits)"
2291 },
2292 {,
2293 "EventCode": "0x4098",
2294 "EventName": "PM_IC_DEMAND_L2_BHT_REDIRECT",
2295 "BriefDescription": "L2 I cache demand request due to BHT redirect, branch redirect ( 2 bubbles 3 cycles)"
2296 },
2297 {,
2298 "EventCode": "0xD0B4",
2299 "EventName": "PM_LSU0_SRQ_S0_VALID_CYC",
2300 "BriefDescription": "Slot 0 of SRQ valid"
2301 },
2302 {,
2303 "EventCode": "0x160AA",
2304 "EventName": "PM_L3_P0_LCO_NO_DATA",
2305 "BriefDescription": "Dataless L3 LCO sent port 0"
2306 },
2307 {,
2308 "EventCode": "0x208C",
2309 "EventName": "PM_CLB_HELD",
2310 "BriefDescription": "CLB (control logic block - indicates quadword fetch block) Hold: Any Reason"
2311 },
2312 {,
2313 "EventCode": "0xF88C",
2314 "EventName": "PM_LSU3_STORE_REJECT",
2315 "BriefDescription": "All internal store rejects cause the instruction to go back to the SRQ and go to sleep until woken up to try again after the condition has been met"
2316 },
2317 {,
2318 "EventCode": "0x200F2",
2319 "EventName": "PM_INST_DISP",
2320 "BriefDescription": "# PPC Dispatched"
2321 },
2322 {,
2323 "EventCode": "0x4E05E",
2324 "EventName": "PM_TM_OUTER_TBEGIN_DISP",
2325 "BriefDescription": "Number of outer tbegin instructions dispatched. The dispatch unit determines whether the tbegin instruction is outer or nested. This is a speculative count, which includes flushed instructions"
2326 },
2327 {,
2328 "EventCode": "0x2D018",
2329 "EventName": "PM_CMPLU_STALL_EXEC_UNIT",
2330 "BriefDescription": "Completion stall due to execution units (FXU/VSU/CRU)"
2331 },
2332 {,
2333 "EventCode": "0x20B0",
2334 "EventName": "PM_LSU_FLUSH_NEXT",
2335 "BriefDescription": "LSU flush next reported at flush time. Sometimes these also come with an exception"
2336 },
2337 {,
2338 "EventCode": "0x3880",
2339 "EventName": "PM_ISU2_ISS_HOLD_ALL",
2340 "BriefDescription": "All ISU rejects"
2341 },
2342 {,
2343 "EventCode": "0x46882",
2344 "EventName": "PM_L2_ST_HIT",
2345 "BriefDescription": "All successful D-side store dispatches for this thread that were L2 hits"
2346 },
2347 {,
2348 "EventCode": "0x360A8",
2349 "EventName": "PM_L3_CO",
2350 "BriefDescription": "L3 castout occurring (does not include casthrough or log writes (cinj/dmaw))"
2351 },
2352 {,
2353 "EventCode": "0x368A4",
2354 "EventName": "PM_L3_CINJ",
2355 "BriefDescription": "L3 castin of cache inject"
2356 },
2357 {,
2358 "EventCode": "0xC890",
2359 "EventName": "PM_LSU_NCST",
2360 "BriefDescription": "Asserts when a i=1 store op is sent to the nest. No record of issue pipe (LS0/LS1) is maintained so this is for both pipes. Probably don't need separate LS0 and LS1"
2361 },
2362 {,
2363 "EventCode": "0xD880",
2364 "EventName": "PM_LSU1_SET_MPRED",
2365 "BriefDescription": "Set prediction(set-p) miss. The entry was not found in the Set prediction table"
2366 },
2367 {,
2368 "EventCode": "0xD0B8",
2369 "EventName": "PM_LSU_LMQ_FULL_CYC",
2370 "BriefDescription": "Counts the number of cycles the LMQ is full"
2371 },
2372 {,
2373 "EventCode": "0x168B2",
2374 "EventName": "PM_L3_GRP_GUESS_CORRECT",
2375 "BriefDescription": "Initial scope=group (GS or NNS) and data from same group (near) (pred successful)"
2376 },
2377 {,
2378 "EventCode": "0x48A4",
2379 "EventName": "PM_STOP_FETCH_PENDING_CYC",
2380 "BriefDescription": "Fetching is stopped due to an incoming instruction that will result in a flush"
2381 },
2382 {,
2383 "EventCode": "0x36884",
2384 "EventName": "PM_L2_RCST_DISP_FAIL_ADDR",
2385 "BriefDescription": "All D-side store dispatch attempts for this thread that failed due to address collision with RC/CO/SN/SQ"
2386 },
2387 {,
2388 "EventCode": "0x260AC",
2389 "EventName": "PM_L3_PF_USAGE",
2390 "BriefDescription": "Rotating sample of 32 PF actives"
2391 }
2392]
diff --git a/tools/perf/pmu-events/arch/powerpc/power9/pipeline.json b/tools/perf/pmu-events/arch/powerpc/power9/pipeline.json
new file mode 100644
index 000000000000..bc2db636dabf
--- /dev/null
+++ b/tools/perf/pmu-events/arch/powerpc/power9/pipeline.json
@@ -0,0 +1,552 @@
1[
2 {,
3 "EventCode": "0x4D04C",
4 "EventName": "PM_DFU_BUSY",
5 "BriefDescription": "Cycles in which all 4 Decimal Floating Point units are busy. The DFU is running at capacity"
6 },
7 {,
8 "EventCode": "0x100F6",
9 "EventName": "PM_IERAT_RELOAD",
10 "BriefDescription": "Number of I-ERAT reloads"
11 },
12 {,
13 "EventCode": "0x201E2",
14 "EventName": "PM_MRK_LD_MISS_L1",
15 "BriefDescription": "Marked DL1 Demand Miss counted at exec time. Note that this count is per slice, so if a load spans multiple slices this event will increment multiple times for a single load."
16 },
17 {,
18 "EventCode": "0x40010",
19 "EventName": "PM_PMC3_OVERFLOW",
20 "BriefDescription": "Overflow from counter 3"
21 },
22 {,
23 "EventCode": "0x1005A",
24 "EventName": "PM_CMPLU_STALL_DFLONG",
25 "BriefDescription": "Finish stall because the NTF instruction was a multi-cycle instruction issued to the Decimal Floating Point execution pipe and waiting to finish. Includes decimal floating point instructions + 128 bit binary floating point instructions. Qualified by multicycle"
26 },
27 {,
28 "EventCode": "0x4D140",
29 "EventName": "PM_MRK_DATA_FROM_ON_CHIP_CACHE",
30 "BriefDescription": "The processor's data cache was reloaded either shared or modified data from another core's L2/L3 on the same chip due to a marked load"
31 },
32 {,
33 "EventCode": "0x3F14C",
34 "EventName": "PM_MRK_DPTEG_FROM_DL4",
35 "BriefDescription": "A Page Table Entry was loaded into the TLB from another chip's L4 on a different Node or Group (Distant) due to a marked data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
36 },
37 {,
38 "EventCode": "0x1E040",
39 "EventName": "PM_DPTEG_FROM_L2_NO_CONFLICT",
40 "BriefDescription": "A Page Table Entry was loaded into the TLB from local core's L2 without conflict due to a data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
41 },
42 {,
43 "EventCode": "0x24052",
44 "EventName": "PM_FXU_IDLE",
45 "BriefDescription": "Cycles in which FXU0, FXU1, FXU2, and FXU3 are all idle"
46 },
47 {,
48 "EventCode": "0x1E054",
49 "EventName": "PM_CMPLU_STALL",
50 "BriefDescription": "Nothing completed and ICT not empty"
51 },
52 {,
53 "EventCode": "0x2",
54 "EventName": "PM_INST_CMPL",
55 "BriefDescription": "Number of PowerPC Instructions that completed."
56 },
57 {,
58 "EventCode": "0x3D058",
59 "EventName": "PM_VSU_DP_FSQRT_FDIV",
60 "BriefDescription": "vector versions of fdiv,fsqrt"
61 },
62 {,
63 "EventCode": "0x10006",
64 "EventName": "PM_DISP_HELD",
65 "BriefDescription": "Dispatch Held"
66 },
67 {,
68 "EventCode": "0x3D154",
69 "EventName": "PM_MRK_DERAT_MISS_16M",
70 "BriefDescription": "Marked Data ERAT Miss (Data TLB Access) page size 16M"
71 },
72 {,
73 "EventCode": "0x200F8",
74 "EventName": "PM_EXT_INT",
75 "BriefDescription": "external interrupt"
76 },
77 {,
78 "EventCode": "0x20008",
79 "EventName": "PM_ICT_EMPTY_CYC",
80 "BriefDescription": "Cycles in which the ICT is completely empty. No itags are assigned to any thread"
81 },
82 {,
83 "EventCode": "0x4F146",
84 "EventName": "PM_MRK_DPTEG_FROM_L21_MOD",
85 "BriefDescription": "A Page Table Entry was loaded into the TLB with Modified (M) data from another core's L2 on the same chip due to a marked data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
86 },
87 {,
88 "EventCode": "0x10056",
89 "EventName": "PM_MEM_READ",
90 "BriefDescription": "Reads from Memory from this thread (includes data/inst/xlate/l1prefetch/inst prefetch). Includes L4"
91 },
92 {,
93 "EventCode": "0x3C04C",
94 "EventName": "PM_DATA_FROM_DL4",
95 "BriefDescription": "The processor's data cache was reloaded from another chip's L4 on a different Node or Group (Distant) due to a demand load"
96 },
97 {,
98 "EventCode": "0x4E046",
99 "EventName": "PM_DPTEG_FROM_L21_MOD",
100 "BriefDescription": "A Page Table Entry was loaded into the TLB with Modified (M) data from another core's L2 on the same chip due to a data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
101 },
102 {,
103 "EventCode": "0x2E016",
104 "EventName": "PM_NTC_ISSUE_HELD_ARB",
105 "BriefDescription": "The NTC instruction is being held at dispatch because it lost arbitration onto the issue pipe to another instruction (from the same thread or a different thread)"
106 },
107 {,
108 "EventCode": "0x15156",
109 "EventName": "PM_SYNC_MRK_FX_DIVIDE",
110 "BriefDescription": "Marked fixed point divide that can cause a synchronous interrupt"
111 },
112 {,
113 "EventCode": "0x1C056",
114 "EventName": "PM_DERAT_MISS_4K",
115 "BriefDescription": "Data ERAT Miss (Data TLB Access) page size 4K"
116 },
117 {,
118 "EventCode": "0x2F142",
119 "EventName": "PM_MRK_DPTEG_FROM_L3_MEPF",
120 "BriefDescription": "A Page Table Entry was loaded into the TLB from local core's L3 without dispatch conflicts hit on Mepf state. due to a marked data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
121 },
122 {,
123 "EventCode": "0x10024",
124 "EventName": "PM_PMC5_OVERFLOW",
125 "BriefDescription": "Overflow from counter 5"
126 },
127 {,
128 "EventCode": "0x2C018",
129 "EventName": "PM_CMPLU_STALL_DMISS_L21_L31",
130 "BriefDescription": "Completion stall by Dcache miss which resolved on chip ( excluding local L2/L3)"
131 },
132 {,
133 "EventCode": "0x4006A",
134 "EventName": "PM_IERAT_RELOAD_16M",
135 "BriefDescription": "IERAT Reloaded (Miss) for a 16M page"
136 },
137 {,
138 "EventCode": "0x4E010",
139 "EventName": "PM_ICT_NOSLOT_IC_L3MISS",
140 "BriefDescription": "Ict empty for this thread due to icache misses that were sourced from beyond the local L3. The source could be local/remote/distant memory or another core's cache"
141 },
142 {,
143 "EventCode": "0x4D01C",
144 "EventName": "PM_ICT_NOSLOT_DISP_HELD_SYNC",
145 "BriefDescription": "Dispatch held due to a synchronizing instruction at dispatch"
146 },
147 {,
148 "EventCode": "0x2D01A",
149 "EventName": "PM_ICT_NOSLOT_IC_MISS",
150 "BriefDescription": "Ict empty for this thread due to Icache Miss"
151 },
152 {,
153 "EventCode": "0x3D152",
154 "EventName": "PM_MRK_DERAT_MISS_1G",
155 "BriefDescription": "Marked Data ERAT Miss (Data TLB Access) page size 1G. Implies radix translation"
156 },
157 {,
158 "EventCode": "0x4F14A",
159 "EventName": "PM_MRK_DPTEG_FROM_OFF_CHIP_CACHE",
160 "BriefDescription": "A Page Table Entry was loaded into the TLB either shared or modified data from another core's L2/L3 on a different chip (remote or distant) due to a marked data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
161 },
162 {,
163 "EventCode": "0x30058",
164 "EventName": "PM_TLBIE_FIN",
165 "BriefDescription": "tlbie finished"
166 },
167 {,
168 "EventCode": "0x100F8",
169 "EventName": "PM_ICT_NOSLOT_CYC",
170 "BriefDescription": "Number of cycles the ICT has no itags assigned to this thread"
171 },
172 {,
173 "EventCode": "0x3E042",
174 "EventName": "PM_DPTEG_FROM_L3_DISP_CONFLICT",
175 "BriefDescription": "A Page Table Entry was loaded into the TLB from local core's L3 with dispatch conflict due to a data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
176 },
177 {,
178 "EventCode": "0x1F140",
179 "EventName": "PM_MRK_DPTEG_FROM_L2_NO_CONFLICT",
180 "BriefDescription": "A Page Table Entry was loaded into the TLB from local core's L2 without conflict due to a marked data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
181 },
182 {,
183 "EventCode": "0x2C05A",
184 "EventName": "PM_DERAT_MISS_1G",
185 "BriefDescription": "Data ERAT Miss (Data TLB Access) page size 1G. Implies radix translation"
186 },
187 {,
188 "EventCode": "0x1F058",
189 "EventName": "PM_RADIX_PWC_L2_PTE_FROM_L2",
190 "BriefDescription": "A Page Table Entry was reloaded to a level 2 page walk cache from the core's L2 data cache. This implies that level 3 and level 4 PWC accesses were not necessary for this translation"
191 },
192 {,
193 "EventCode": "0x1D14A",
194 "EventName": "PM_MRK_DATA_FROM_RL2L3_MOD",
195 "BriefDescription": "The processor's data cache was reloaded with Modified (M) data from another chip's L2 or L3 on the same Node or Group (Remote), as this chip due to a marked load"
196 },
197 {,
198 "EventCode": "0x10050",
199 "EventName": "PM_CHIP_PUMP_CPRED",
200 "BriefDescription": "Initial and Final Pump Scope was chip pump (prediction=correct) for all data types excluding data prefetch (demand load,inst prefetch,inst fetch,xlate)"
201 },
202 {,
203 "EventCode": "0x45058",
204 "EventName": "PM_IC_MISS_CMPL",
205 "BriefDescription": "Non-speculative icache miss, counted at completion"
206 },
207 {,
208 "EventCode": "0x2D150",
209 "EventName": "PM_MRK_DERAT_MISS_4K",
210 "BriefDescription": "Marked Data ERAT Miss (Data TLB Access) page size 4K"
211 },
212 {,
213 "EventCode": "0x34058",
214 "EventName": "PM_ICT_NOSLOT_BR_MPRED_ICMISS",
215 "BriefDescription": "Ict empty for this thread due to Icache Miss and branch mispred"
216 },
217 {,
218 "EventCode": "0x10022",
219 "EventName": "PM_PMC2_SAVED",
220 "BriefDescription": "PMC2 Rewind Value saved"
221 },
222 {,
223 "EventCode": "0x2000A",
224 "EventName": "PM_HV_CYC",
225 "BriefDescription": "Cycles in which msr_hv is high. Note that this event does not take msr_pr into consideration"
226 },
227 {,
228 "EventCode": "0x1F144",
229 "EventName": "PM_MRK_DPTEG_FROM_L3_NO_CONFLICT",
230 "BriefDescription": "A Page Table Entry was loaded into the TLB from local core's L3 without conflict due to a marked data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
231 },
232 {,
233 "EventCode": "0x300FC",
234 "EventName": "PM_DTLB_MISS",
235 "BriefDescription": "Data PTEG reload"
236 },
237 {,
238 "EventCode": "0x2D152",
239 "EventName": "PM_MRK_DERAT_MISS_2M",
240 "BriefDescription": "Marked Data ERAT Miss (Data TLB Access) page size 2M. Implies radix translation"
241 },
242 {,
243 "EventCode": "0x2C046",
244 "EventName": "PM_DATA_FROM_RL2L3_MOD",
245 "BriefDescription": "The processor's data cache was reloaded with Modified (M) data from another chip's L2 or L3 on the same Node or Group (Remote), as this chip due to a demand load"
246 },
247 {,
248 "EventCode": "0x20052",
249 "EventName": "PM_GRP_PUMP_MPRED",
250 "BriefDescription": "Final Pump Scope (Group) ended up either larger or smaller than Initial Pump Scope for all data types excluding data prefetch (demand load,inst prefetch,inst fetch,xlate)"
251 },
252 {,
253 "EventCode": "0x3F05A",
254 "EventName": "PM_RADIX_PWC_L2_PDE_FROM_L3",
255 "BriefDescription": "A Page Directory Entry was reloaded to a level 2 page walk cache from the core's L3 data cache"
256 },
257 {,
258 "EventCode": "0x1E04A",
259 "EventName": "PM_DPTEG_FROM_RL2L3_SHR",
260 "BriefDescription": "A Page Table Entry was loaded into the TLB with Shared (S) data from another chip's L2 or L3 on the same Node or Group (Remote), as this chip due to a data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
261 },
262 {,
263 "EventCode": "0x10064",
264 "EventName": "PM_ICT_NOSLOT_DISP_HELD_TBEGIN",
265 "BriefDescription": "the NTC instruction is being held at dispatch because it is a tbegin instruction and there is an older tbegin in the pipeline that must complete before the younger tbegin can dispatch"
266 },
267 {,
268 "EventCode": "0x2E046",
269 "EventName": "PM_DPTEG_FROM_RL2L3_MOD",
270 "BriefDescription": "A Page Table Entry was loaded into the TLB with Modified (M) data from another chip's L2 or L3 on the same Node or Group (Remote), as this chip due to a data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
271 },
272 {,
273 "EventCode": "0x4F14C",
274 "EventName": "PM_MRK_DPTEG_FROM_DMEM",
275 "BriefDescription": "A Page Table Entry was loaded into the TLB from another chip's memory on the same Node or Group (Distant) due to a marked data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
276 },
277 {,
278 "EventCode": "0x2E042",
279 "EventName": "PM_DPTEG_FROM_L3_MEPF",
280 "BriefDescription": "A Page Table Entry was loaded into the TLB from local core's L3 without dispatch conflicts hit on Mepf state. due to a data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
281 },
282 {,
283 "EventCode": "0x2D012",
284 "EventName": "PM_CMPLU_STALL_DFU",
285 "BriefDescription": "Finish stall because the NTF instruction was issued to the Decimal Floating Point execution pipe and waiting to finish. Includes decimal floating point instructions + 128 bit binary floating point instructions. Not qualified by multicycle"
286 },
287 {,
288 "EventCode": "0x4C04C",
289 "EventName": "PM_DATA_FROM_DMEM",
290 "BriefDescription": "The processor's data cache was reloaded from another chip's memory on the same Node or Group (Distant) due to a demand load"
291 },
292 {,
293 "EventCode": "0x30022",
294 "EventName": "PM_PMC4_SAVED",
295 "BriefDescription": "PMC4 Rewind Value saved (matched condition)"
296 },
297 {,
298 "EventCode": "0x200F4",
299 "EventName": "PM_RUN_CYC",
300 "BriefDescription": "Run_cycles"
301 },
302 {,
303 "EventCode": "0x400F2",
304 "EventName": "PM_1PLUS_PPC_DISP",
305 "BriefDescription": "Cycles at least one Instr Dispatched"
306 },
307 {,
308 "EventCode": "0x3D148",
309 "EventName": "PM_MRK_DATA_FROM_L21_MOD_CYC",
310 "BriefDescription": "Duration in cycles to reload with Modified (M) data from another core's L2 on the same chip due to a marked load"
311 },
312 {,
313 "EventCode": "0x2F146",
314 "EventName": "PM_MRK_DPTEG_FROM_RL2L3_MOD",
315 "BriefDescription": "A Page Table Entry was loaded into the TLB with Modified (M) data from another chip's L2 or L3 on the same Node or Group (Remote), as this chip due to a marked data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
316 },
317 {,
318 "EventCode": "0x4E01A",
319 "EventName": "PM_ICT_NOSLOT_DISP_HELD",
320 "BriefDescription": "Cycles in which the NTC instruction is held at dispatch for any reason"
321 },
322 {,
323 "EventCode": "0x401EC",
324 "EventName": "PM_THRESH_EXC_2048",
325 "BriefDescription": "Threshold counter exceeded a value of 2048"
326 },
327 {,
328 "EventCode": "0x35150",
329 "EventName": "PM_MRK_DATA_FROM_RL2L3_SHR",
330 "BriefDescription": "The processor's data cache was reloaded with Shared (S) data from another chip's L2 or L3 on the same Node or Group (Remote), as this chip due to a marked load"
331 },
332 {,
333 "EventCode": "0x3E052",
334 "EventName": "PM_ICT_NOSLOT_IC_L3",
335 "BriefDescription": "Ict empty for this thread due to icache misses that were sourced from the local L3"
336 },
337 {,
338 "EventCode": "0x2405A",
339 "EventName": "PM_NTC_FIN",
340 "BriefDescription": "Cycles in which the oldest instruction in the pipeline (NTC) finishes. This event is used to account for cycles in which work is being completed in the CPI stack"
341 },
342 {,
343 "EventCode": "0x40052",
344 "EventName": "PM_PUMP_MPRED",
345 "BriefDescription": "Pump misprediction. Counts across all types of pumps for all data types excluding data prefetch (demand load,inst prefetch,inst fetch,xlate)"
346 },
347 {,
348 "EventCode": "0x30056",
349 "EventName": "PM_TM_ABORTS",
350 "BriefDescription": "Number of TM transactions aborted"
351 },
352 {,
353 "EventCode": "0x2404C",
354 "EventName": "PM_INST_FROM_MEMORY",
355 "BriefDescription": "The processor's Instruction cache was reloaded from a memory location including L4 from local remote or distant due to an instruction fetch (not prefetch)"
356 },
357 {,
358 "EventCode": "0x1C05A",
359 "EventName": "PM_DERAT_MISS_2M",
360 "BriefDescription": "Data ERAT Miss (Data TLB Access) page size 2M. Implies radix translation"
361 },
362 {,
363 "EventCode": "0x30024",
364 "EventName": "PM_PMC6_OVERFLOW",
365 "BriefDescription": "Overflow from counter 6"
366 },
367 {,
368 "EventCode": "0x10068",
369 "EventName": "PM_BRU_FIN",
370 "BriefDescription": "Branch Instruction Finished"
371 },
372 {,
373 "EventCode": "0x30020",
374 "EventName": "PM_PMC2_REWIND",
375 "BriefDescription": "PMC2 Rewind Event (did not match condition)"
376 },
377 {,
378 "EventCode": "0x40064",
379 "EventName": "PM_DUMMY2_REMOVE_ME",
380 "BriefDescription": "Space holder for LS_PC_RELOAD_RA"
381 },
382 {,
383 "EventCode": "0x3F148",
384 "EventName": "PM_MRK_DPTEG_FROM_DL2L3_SHR",
385 "BriefDescription": "A Page Table Entry was loaded into the TLB with Shared (S) data from another chip's L2 or L3 on a different Node or Group (Distant), as this chip due to a marked data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
386 },
387 {,
388 "EventCode": "0x4D01E",
389 "EventName": "PM_ICT_NOSLOT_BR_MPRED",
390 "BriefDescription": "Ict empty for this thread due to branch mispred"
391 },
392 {,
393 "EventCode": "0x3405E",
394 "EventName": "PM_IFETCH_THROTTLE",
395 "BriefDescription": "Cycles in which Instruction fetch throttle was active."
396 },
397 {,
398 "EventCode": "0x1F148",
399 "EventName": "PM_MRK_DPTEG_FROM_ON_CHIP_CACHE",
400 "BriefDescription": "A Page Table Entry was loaded into the TLB either shared or modified data from another core's L2/L3 on the same chip due to a marked data side request.. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
401 },
402 {,
403 "EventCode": "0x3E046",
404 "EventName": "PM_DPTEG_FROM_L21_SHR",
405 "BriefDescription": "A Page Table Entry was loaded into the TLB with Shared (S) data from another core's L2 on the same chip due to a data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
406 },
407 {,
408 "EventCode": "0x2F144",
409 "EventName": "PM_MRK_DPTEG_FROM_L31_MOD",
410 "BriefDescription": "A Page Table Entry was loaded into the TLB with Modified (M) data from another core's L3 on the same chip due to a marked data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
411 },
412 {,
413 "EventCode": "0x4C15C",
414 "EventName": "PM_MRK_DERAT_MISS_16G",
415 "BriefDescription": "Marked Data ERAT Miss (Data TLB Access) page size 16G"
416 },
417 {,
418 "EventCode": "0x14052",
419 "EventName": "PM_INST_GRP_PUMP_MPRED_RTY",
420 "BriefDescription": "Final Pump Scope (Group) ended up larger than Initial Pump Scope (Chip) for an instruction fetch"
421 },
422 {,
423 "EventCode": "0xD0A8",
424 "EventName": "PM_DSLB_MISS",
425 "BriefDescription": "Data SLB Miss - Total of all segment sizes"
426 },
427 {,
428 "EventCode": "0x4C058",
429 "EventName": "PM_MEM_CO",
430 "BriefDescription": "Memory castouts from this thread"
431 },
432 {,
433 "EventCode": "0x40004",
434 "EventName": "PM_FXU_FIN",
435 "BriefDescription": "The fixed point unit Unit finished an instruction. Instructions that finish may not necessary complete."
436 },
437 {,
438 "EventCode": "0x2C054",
439 "EventName": "PM_DERAT_MISS_64K",
440 "BriefDescription": "Data ERAT Miss (Data TLB Access) page size 64K"
441 },
442 {,
443 "EventCode": "0x10018",
444 "EventName": "PM_IC_DEMAND_CYC",
445 "BriefDescription": "Icache miss demand cycles"
446 },
447 {,
448 "EventCode": "0x3C054",
449 "EventName": "PM_DERAT_MISS_16M",
450 "BriefDescription": "Data ERAT Miss (Data TLB Access) page size 16M"
451 },
452 {,
453 "EventCode": "0x2D14E",
454 "EventName": "PM_MRK_DATA_FROM_L21_SHR",
455 "BriefDescription": "The processor's data cache was reloaded with Shared (S) data from another core's L2 on the same chip due to a marked load"
456 },
457 {,
458 "EventCode": "0x3405C",
459 "EventName": "PM_CMPLU_STALL_DPLONG",
460 "BriefDescription": "Finish stall because the NTF instruction was a scalar multi-cycle instruction issued to the Double Precision execution pipe and waiting to finish. Includes binary floating point instructions in 32 and 64 bit binary floating point format. Qualified by NOT vector AND multicycle"
461 },
462 {,
463 "EventCode": "0x4D052",
464 "EventName": "PM_2FLOP_CMPL",
465 "BriefDescription": "DP vector version of fmul, fsub, fcmp, fsel, fabs, fnabs, fres ,fsqrte, fneg "
466 },
467 {,
468 "EventCode": "0x1F142",
469 "EventName": "PM_MRK_DPTEG_FROM_L2",
470 "BriefDescription": "A Page Table Entry was loaded into the TLB from local core's L2 due to a marked data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
471 },
472 {,
473 "EventCode": "0x40062",
474 "EventName": "PM_DUMMY1_REMOVE_ME",
475 "BriefDescription": "Space holder for L2_PC_PM_MK_LDST_SCOPE_PRED_STATUS"
476 },
477 {,
478 "EventCode": "0x4C012",
479 "EventName": "PM_CMPLU_STALL_ERAT_MISS",
480 "BriefDescription": "Finish stall because the NTF instruction was a load or store that suffered a translation miss"
481 },
482 {,
483 "EventCode": "0x4D050",
484 "EventName": "PM_VSU_NON_FLOP_CMPL",
485 "BriefDescription": "Non FLOP operation completed"
486 },
487 {,
488 "EventCode": "0x2E012",
489 "EventName": "PM_TM_TX_PASS_RUN_CYC",
490 "BriefDescription": "cycles spent in successful transactions"
491 },
492 {,
493 "EventCode": "0x4D04E",
494 "EventName": "PM_VSU_FSQRT_FDIV",
495 "BriefDescription": "four flops operation (fdiv,fsqrt) Scalar Instructions only"
496 },
497 {,
498 "EventCode": "0x4C120",
499 "EventName": "PM_MRK_DATA_FROM_L2_MEPF",
500 "BriefDescription": "The processor's data cache was reloaded from local core's L2 hit without dispatch conflicts on Mepf state. due to a marked load"
501 },
502 {,
503 "EventCode": "0x10062",
504 "EventName": "PM_LD_L3MISS_PEND_CYC",
505 "BriefDescription": "Cycles L3 miss was pending for this thread"
506 },
507 {,
508 "EventCode": "0x2F14C",
509 "EventName": "PM_MRK_DPTEG_FROM_MEMORY",
510 "BriefDescription": "A Page Table Entry was loaded into the TLB from a memory location including L4 from local remote or distant due to a marked data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
511 },
512 {,
513 "EventCode": "0x14050",
514 "EventName": "PM_INST_CHIP_PUMP_CPRED",
515 "BriefDescription": "Initial and Final Pump Scope was chip pump (prediction=correct) for an instruction fetch"
516 },
517 {,
518 "EventCode": "0x2000E",
519 "EventName": "PM_FXU_BUSY",
520 "BriefDescription": "Cycles in which all 4 FXUs are busy. The FXU is running at capacity"
521 },
522 {,
523 "EventCode": "0x20066",
524 "EventName": "PM_TLB_MISS",
525 "BriefDescription": "TLB Miss (I + D)"
526 },
527 {,
528 "EventCode": "0x10054",
529 "EventName": "PM_PUMP_CPRED",
530 "BriefDescription": "Pump prediction correct. Counts across all types of pumps for all data types excluding data prefetch (demand load,inst prefetch,inst fetch,xlate)"
531 },
532 {,
533 "EventCode": "0x4D124",
534 "EventName": "PM_MRK_DATA_FROM_L31_SHR",
535 "BriefDescription": "The processor's data cache was reloaded with Shared (S) data from another core's L3 on the same chip due to a marked load"
536 },
537 {,
538 "EventCode": "0x400F8",
539 "EventName": "PM_FLUSH",
540 "BriefDescription": "Flush (any type)"
541 },
542 {,
543 "EventCode": "0x30004",
544 "EventName": "PM_CMPLU_STALL_EMQ_FULL",
545 "BriefDescription": "Finish stall because the next to finish instruction suffered an ERAT miss and the EMQ was full"
546 },
547 {,
548 "EventCode": "0x1D154",
549 "EventName": "PM_MRK_DATA_FROM_L21_SHR_CYC",
550 "BriefDescription": "Duration in cycles to reload with Shared (S) data from another core's L2 on the same chip due to a marked load"
551 }
552]
diff --git a/tools/perf/pmu-events/arch/powerpc/power9/pmc.json b/tools/perf/pmu-events/arch/powerpc/power9/pmc.json
new file mode 100644
index 000000000000..3ef8a10aac86
--- /dev/null
+++ b/tools/perf/pmu-events/arch/powerpc/power9/pmc.json
@@ -0,0 +1,122 @@
1[
2 {,
3 "EventCode": "0x20036",
4 "EventName": "PM_BR_2PATH",
5 "BriefDescription": "Branches that are not strongly biased"
6 },
7 {,
8 "EventCode": "0x40056",
9 "EventName": "PM_MEM_LOC_THRESH_LSU_HIGH",
10 "BriefDescription": "Local memory above threshold for LSU medium"
11 },
12 {,
13 "EventCode": "0x2C056",
14 "EventName": "PM_DTLB_MISS_4K",
15 "BriefDescription": "Data TLB Miss page size 4k"
16 },
17 {,
18 "EventCode": "0x40118",
19 "EventName": "PM_MRK_DCACHE_RELOAD_INTV",
20 "BriefDescription": "Combined Intervention event"
21 },
22 {,
23 "EventCode": "0x4F148",
24 "EventName": "PM_MRK_DPTEG_FROM_DL2L3_MOD",
25 "BriefDescription": "A Page Table Entry was loaded into the TLB with Modified (M) data from another chip's L2 or L3 on a different Node or Group (Distant), as this chip due to a marked data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
26 },
27 {,
28 "EventCode": "0x301E8",
29 "EventName": "PM_THRESH_EXC_64",
30 "BriefDescription": "Threshold counter exceeded a value of 64"
31 },
32 {,
33 "EventCode": "0x4E04E",
34 "EventName": "PM_DPTEG_FROM_L3MISS",
35 "BriefDescription": "A Page Table Entry was loaded into the TLB from a location other than the local core's L3 due to a data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
36 },
37 {,
38 "EventCode": "0x40050",
39 "EventName": "PM_SYS_PUMP_MPRED_RTY",
40 "BriefDescription": "Final Pump Scope (system) ended up larger than Initial Pump Scope (Chip/Group) for all data types excluding data prefetch (demand load,inst prefetch,inst fetch,xlate)"
41 },
42 {,
43 "EventCode": "0x1F14E",
44 "EventName": "PM_MRK_DPTEG_FROM_L2MISS",
45 "BriefDescription": "A Page Table Entry was loaded into the TLB from a location other than the local core's L2 due to a marked data side request.. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
46 },
47 {,
48 "EventCode": "0x4D018",
49 "EventName": "PM_CMPLU_STALL_BRU",
50 "BriefDescription": "Completion stall due to a Branch Unit"
51 },
52 {,
53 "EventCode": "0x45052",
54 "EventName": "PM_4FLOP_CMPL",
55 "BriefDescription": "4 FLOP instruction completed"
56 },
57 {,
58 "EventCode": "0x3D142",
59 "EventName": "PM_MRK_DATA_FROM_LMEM",
60 "BriefDescription": "The processor's data cache was reloaded from the local chip's Memory due to a marked load"
61 },
62 {,
63 "EventCode": "0x4C01E",
64 "EventName": "PM_CMPLU_STALL_CRYPTO",
65 "BriefDescription": "Finish stall because the NTF instruction was routed to the crypto execution pipe and was waiting to finish"
66 },
67 {,
68 "EventCode": "0x3000C",
69 "EventName": "PM_FREQ_DOWN",
70 "BriefDescription": "Power Management: Below Threshold B"
71 },
72 {,
73 "EventCode": "0x4D128",
74 "EventName": "PM_MRK_DATA_FROM_LMEM_CYC",
75 "BriefDescription": "Duration in cycles to reload from the local chip's Memory due to a marked load"
76 },
77 {,
78 "EventCode": "0x4D054",
79 "EventName": "PM_8FLOP_CMPL",
80 "BriefDescription": "8 FLOP instruction completed"
81 },
82 {,
83 "EventCode": "0x10026",
84 "EventName": "PM_TABLEWALK_CYC",
85 "BriefDescription": "Cycles when an instruction tablewalk is active"
86 },
87 {,
88 "EventCode": "0x2C012",
89 "EventName": "PM_CMPLU_STALL_DCACHE_MISS",
90 "BriefDescription": "Finish stall because the NTF instruction was a load that missed the L1 and was waiting for the data to return from the nest"
91 },
92 {,
93 "EventCode": "0x2E04C",
94 "EventName": "PM_DPTEG_FROM_MEMORY",
95 "BriefDescription": "A Page Table Entry was loaded into the TLB from a memory location including L4 from local remote or distant due to a data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
96 },
97 {,
98 "EventCode": "0x3F142",
99 "EventName": "PM_MRK_DPTEG_FROM_L3_DISP_CONFLICT",
100 "BriefDescription": "A Page Table Entry was loaded into the TLB from local core's L3 with dispatch conflict due to a marked data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
101 },
102 {,
103 "EventCode": "0x4F142",
104 "EventName": "PM_MRK_DPTEG_FROM_L3",
105 "BriefDescription": "A Page Table Entry was loaded into the TLB from local core's L3 due to a marked data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
106 },
107 {,
108 "EventCode": "0x10060",
109 "EventName": "PM_TM_TRANS_RUN_CYC",
110 "BriefDescription": "run cycles in transactional state"
111 },
112 {,
113 "EventCode": "0x1E04C",
114 "EventName": "PM_DPTEG_FROM_LL4",
115 "BriefDescription": "A Page Table Entry was loaded into the TLB from the local chip's L4 cache due to a data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
116 },
117 {,
118 "EventCode": "0x45050",
119 "EventName": "PM_1FLOP_CMPL",
120 "BriefDescription": "one flop (fadd, fmul, fsub, fcmp, fsel, fabs, fnabs, fres, fsqrte, fneg) operation completed"
121 }
122]
diff --git a/tools/perf/pmu-events/arch/powerpc/power9/translation.json b/tools/perf/pmu-events/arch/powerpc/power9/translation.json
new file mode 100644
index 000000000000..8c0f12024afa
--- /dev/null
+++ b/tools/perf/pmu-events/arch/powerpc/power9/translation.json
@@ -0,0 +1,232 @@
1[
2 {,
3 "EventCode": "0x1E",
4 "EventName": "PM_CYC",
5 "BriefDescription": "Processor cycles"
6 },
7 {,
8 "EventCode": "0x30010",
9 "EventName": "PM_PMC2_OVERFLOW",
10 "BriefDescription": "Overflow from counter 2"
11 },
12 {,
13 "EventCode": "0x3C046",
14 "EventName": "PM_DATA_FROM_L21_SHR",
15 "BriefDescription": "The processor's data cache was reloaded with Shared (S) data from another core's L2 on the same chip due to a demand load"
16 },
17 {,
18 "EventCode": "0x4D05C",
19 "EventName": "PM_DP_QP_FLOP_CMPL",
20 "BriefDescription": "Double-Precion or Quad-Precision instruction completed"
21 },
22 {,
23 "EventCode": "0x4E04C",
24 "EventName": "PM_DPTEG_FROM_DMEM",
25 "BriefDescription": "A Page Table Entry was loaded into the TLB from another chip's memory on the same Node or Group (Distant) due to a data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
26 },
27 {,
28 "EventCode": "0x20016",
29 "EventName": "PM_ST_FIN",
30 "BriefDescription": "Store finish count. Includes speculative activity"
31 },
32 {,
33 "EventCode": "0x44042",
34 "EventName": "PM_INST_FROM_L3",
35 "BriefDescription": "The processor's Instruction cache was reloaded from local core's L3 due to an instruction fetch (not prefetch)"
36 },
37 {,
38 "EventCode": "0x1504A",
39 "EventName": "PM_IPTEG_FROM_RL2L3_SHR",
40 "BriefDescription": "A Page Table Entry was loaded into the TLB with Shared (S) data from another chip's L2 or L3 on the same Node or Group (Remote), as this chip due to a instruction side request"
41 },
42 {,
43 "EventCode": "0x40132",
44 "EventName": "PM_MRK_LSU_FIN",
45 "BriefDescription": "lsu marked instr PPC finish"
46 },
47 {,
48 "EventCode": "0x3C05C",
49 "EventName": "PM_CMPLU_STALL_VFXU",
50 "BriefDescription": "Finish stall due to a vector fixed point instruction in the execution pipeline. These instructions get routed to the ALU, ALU2, and DIV pipes"
51 },
52 {,
53 "EventCode": "0x30066",
54 "EventName": "PM_LSU_FIN",
55 "BriefDescription": "LSU Finished a PPC instruction (up to 4 per cycle)"
56 },
57 {,
58 "EventCode": "0x2011C",
59 "EventName": "PM_MRK_NTC_CYC",
60 "BriefDescription": "Cycles during which the marked instruction is next to complete (completion is held up because the marked instruction hasn't completed yet)"
61 },
62 {,
63 "EventCode": "0x3E048",
64 "EventName": "PM_DPTEG_FROM_DL2L3_SHR",
65 "BriefDescription": "A Page Table Entry was loaded into the TLB with Shared (S) data from another chip's L2 or L3 on a different Node or Group (Distant), as this chip due to a data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
66 },
67 {,
68 "EventCode": "0x2E018",
69 "EventName": "PM_CMPLU_STALL_VFXLONG",
70 "BriefDescription": "Completion stall due to a long latency vector fixed point instruction (division, square root)"
71 },
72 {,
73 "EventCode": "0x1C04E",
74 "EventName": "PM_DATA_FROM_L2MISS_MOD",
75 "BriefDescription": "The processor's data cache was reloaded from a location other than the local core's L2 due to a demand load"
76 },
77 {,
78 "EventCode": "0x15048",
79 "EventName": "PM_IPTEG_FROM_ON_CHIP_CACHE",
80 "BriefDescription": "A Page Table Entry was loaded into the TLB either shared or modified data from another core's L2/L3 on the same chip due to a instruction side request"
81 },
82 {,
83 "EventCode": "0x34046",
84 "EventName": "PM_INST_FROM_L21_SHR",
85 "BriefDescription": "The processor's Instruction cache was reloaded with Shared (S) data from another core's L2 on the same chip due to an instruction fetch (not prefetch)"
86 },
87 {,
88 "EventCode": "0x1E058",
89 "EventName": "PM_STCX_FAIL",
90 "BriefDescription": "stcx failed"
91 },
92 {,
93 "EventCode": "0x20112",
94 "EventName": "PM_MRK_NTF_FIN",
95 "BriefDescription": "Marked next to finish instruction finished"
96 },
97 {,
98 "EventCode": "0x300F0",
99 "EventName": "PM_ST_MISS_L1",
100 "BriefDescription": "Store Missed L1"
101 },
102 {,
103 "EventCode": "0x4C046",
104 "EventName": "PM_DATA_FROM_L21_MOD",
105 "BriefDescription": "The processor's data cache was reloaded with Modified (M) data from another core's L2 on the same chip due to a demand load"
106 },
107 {,
108 "EventCode": "0x2504A",
109 "EventName": "PM_IPTEG_FROM_RL4",
110 "BriefDescription": "A Page Table Entry was loaded into the TLB from another chip's L4 on the same Node or Group ( Remote) due to a instruction side request"
111 },
112 {,
113 "EventCode": "0x2003E",
114 "EventName": "PM_LSU_LMQ_SRQ_EMPTY_CYC",
115 "BriefDescription": "Cycles in which the LSU is empty for all threads (lmq and srq are completely empty)"
116 },
117 {,
118 "EventCode": "0x201E6",
119 "EventName": "PM_THRESH_EXC_32",
120 "BriefDescription": "Threshold counter exceeded a value of 32"
121 },
122 {,
123 "EventCode": "0x4405C",
124 "EventName": "PM_CMPLU_STALL_VDP",
125 "BriefDescription": "Finish stall because the NTF instruction was a vector instruction issued to the Double Precision execution pipe and waiting to finish. Includes binary floating point instructions in 32 and 64 bit binary floating point format. Not qualified multicycle. Qualified by vector"
126 },
127 {,
128 "EventCode": "0x4D010",
129 "EventName": "PM_PMC1_SAVED",
130 "BriefDescription": "PMC1 Rewind Value saved"
131 },
132 {,
133 "EventCode": "0x200FE",
134 "EventName": "PM_DATA_FROM_L2MISS",
135 "BriefDescription": "Demand LD - L2 Miss (not L2 hit)"
136 },
137 {,
138 "EventCode": "0x2D14A",
139 "EventName": "PM_MRK_DATA_FROM_RL2L3_MOD_CYC",
140 "BriefDescription": "Duration in cycles to reload with Modified (M) data from another chip's L2 or L3 on the same Node or Group (Remote), as this chip due to a marked load"
141 },
142 {,
143 "EventCode": "0x10028",
144 "EventName": "PM_STALL_END_ICT_EMPTY",
145 "BriefDescription": "The number a times the core transitioned from a stall to ICT-empty for this thread"
146 },
147 {,
148 "EventCode": "0x2504C",
149 "EventName": "PM_IPTEG_FROM_MEMORY",
150 "BriefDescription": "A Page Table Entry was loaded into the TLB from a memory location including L4 from local remote or distant due to a instruction side request"
151 },
152 {,
153 "EventCode": "0x4504A",
154 "EventName": "PM_IPTEG_FROM_OFF_CHIP_CACHE",
155 "BriefDescription": "A Page Table Entry was loaded into the TLB either shared or modified data from another core's L2/L3 on a different chip (remote or distant) due to a instruction side request"
156 },
157 {,
158 "EventCode": "0x1404E",
159 "EventName": "PM_INST_FROM_L2MISS",
160 "BriefDescription": "The processor's Instruction cache was reloaded from a location other than the local core's L2 due to an instruction fetch (not prefetch)"
161 },
162 {,
163 "EventCode": "0x34042",
164 "EventName": "PM_INST_FROM_L3_DISP_CONFLICT",
165 "BriefDescription": "The processor's Instruction cache was reloaded from local core's L3 with dispatch conflict due to an instruction fetch (not prefetch)"
166 },
167 {,
168 "EventCode": "0x4E048",
169 "EventName": "PM_DPTEG_FROM_DL2L3_MOD",
170 "BriefDescription": "A Page Table Entry was loaded into the TLB with Modified (M) data from another chip's L2 or L3 on a different Node or Group (Distant), as this chip due to a data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
171 },
172 {,
173 "EventCode": "0x200F0",
174 "EventName": "PM_ST_CMPL",
175 "BriefDescription": "Stores completed from S2Q (2nd-level store queue)."
176 },
177 {,
178 "EventCode": "0x4E05C",
179 "EventName": "PM_LSU_REJECT_LHS",
180 "BriefDescription": "LSU Reject due to LHS (up to 4 per cycle)"
181 },
182 {,
183 "EventCode": "0x14044",
184 "EventName": "PM_INST_FROM_L3_NO_CONFLICT",
185 "BriefDescription": "The processor's Instruction cache was reloaded from local core's L3 without conflict due to an instruction fetch (not prefetch)"
186 },
187 {,
188 "EventCode": "0x3E04C",
189 "EventName": "PM_DPTEG_FROM_DL4",
190 "BriefDescription": "A Page Table Entry was loaded into the TLB from another chip's L4 on a different Node or Group (Distant) due to a data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
191 },
192 {,
193 "EventCode": "0x1F15E",
194 "EventName": "PM_MRK_PROBE_NOP_CMPL",
195 "BriefDescription": "Marked probeNops completed"
196 },
197 {,
198 "EventCode": "0x20018",
199 "EventName": "PM_ST_FWD",
200 "BriefDescription": "Store forwards that finished"
201 },
202 {,
203 "EventCode": "0x1D142",
204 "EventName": "PM_MRK_DATA_FROM_L31_ECO_SHR_CYC",
205 "BriefDescription": "Duration in cycles to reload with Shared (S) data from another core's ECO L3 on the same chip due to a marked load"
206 },
207 {,
208 "EventCode": "0x24042",
209 "EventName": "PM_INST_FROM_L3_MEPF",
210 "BriefDescription": "The processor's Instruction cache was reloaded from local core's L3 without dispatch conflicts hit on Mepf state. due to an instruction fetch (not prefetch)"
211 },
212 {,
213 "EventCode": "0x25046",
214 "EventName": "PM_IPTEG_FROM_RL2L3_MOD",
215 "BriefDescription": "A Page Table Entry was loaded into the TLB with Modified (M) data from another chip's L2 or L3 on the same Node or Group (Remote), as this chip due to a instruction side request"
216 },
217 {,
218 "EventCode": "0x3504A",
219 "EventName": "PM_IPTEG_FROM_RMEM",
220 "BriefDescription": "A Page Table Entry was loaded into the TLB from another chip's memory on the same Node or Group ( Remote) due to a instruction side request"
221 },
222 {,
223 "EventCode": "0x3C05A",
224 "EventName": "PM_CMPLU_STALL_VDPLONG",
225 "BriefDescription": "Finish stall because the NTF instruction was a scalar multi-cycle instruction issued to the Double Precision execution pipe and waiting to finish. Includes binary floating point instructions in 32 and 64 bit binary floating point format. Qualified by NOT vector AND multicycle"
226 },
227 {,
228 "EventCode": "0x2E01C",
229 "EventName": "PM_CMPLU_STALL_TLBIE",
230 "BriefDescription": "Finish stall because the NTF instruction was a tlbie waiting for response from L2"
231 }
232] \ No newline at end of file
diff --git a/tools/perf/pmu-events/arch/x86/mapfile.csv b/tools/perf/pmu-events/arch/x86/mapfile.csv
index d1a12e584c1b..4ea068366c3e 100644
--- a/tools/perf/pmu-events/arch/x86/mapfile.csv
+++ b/tools/perf/pmu-events/arch/x86/mapfile.csv
@@ -34,3 +34,4 @@ GenuineIntel-6-2C,v2,westmereep-dp,core
34GenuineIntel-6-2C,v2,westmereep-dp,core 34GenuineIntel-6-2C,v2,westmereep-dp,core
35GenuineIntel-6-25,v2,westmereep-sp,core 35GenuineIntel-6-25,v2,westmereep-sp,core
36GenuineIntel-6-2F,v2,westmereex,core 36GenuineIntel-6-2F,v2,westmereex,core
37GenuineIntel-6-55,v1,skylakex,core
diff --git a/tools/perf/pmu-events/arch/x86/skylakex/cache.json b/tools/perf/pmu-events/arch/x86/skylakex/cache.json
new file mode 100644
index 000000000000..b5bc742b6fbc
--- /dev/null
+++ b/tools/perf/pmu-events/arch/x86/skylakex/cache.json
@@ -0,0 +1,1672 @@
1[
2 {
3 "EventCode": "0x24",
4 "UMask": "0x21",
5 "BriefDescription": "Demand Data Read miss L2, no rejects",
6 "Counter": "0,1,2,3",
7 "EventName": "L2_RQSTS.DEMAND_DATA_RD_MISS",
8 "PublicDescription": "Counts the number of demand Data Read requests that miss L2 cache. Only not rejected loads are counted.",
9 "SampleAfterValue": "200003",
10 "CounterHTOff": "0,1,2,3,4,5,6,7"
11 },
12 {
13 "EventCode": "0x24",
14 "UMask": "0x22",
15 "BriefDescription": "RFO requests that miss L2 cache",
16 "Counter": "0,1,2,3",
17 "EventName": "L2_RQSTS.RFO_MISS",
18 "PublicDescription": "Counts the RFO (Read-for-Ownership) requests that miss L2 cache.",
19 "SampleAfterValue": "200003",
20 "CounterHTOff": "0,1,2,3,4,5,6,7"
21 },
22 {
23 "EventCode": "0x24",
24 "UMask": "0x24",
25 "BriefDescription": "L2 cache misses when fetching instructions",
26 "Counter": "0,1,2,3",
27 "EventName": "L2_RQSTS.CODE_RD_MISS",
28 "PublicDescription": "Counts L2 cache misses when fetching instructions.",
29 "SampleAfterValue": "200003",
30 "CounterHTOff": "0,1,2,3,4,5,6,7"
31 },
32 {
33 "EventCode": "0x24",
34 "UMask": "0x27",
35 "BriefDescription": "Demand requests that miss L2 cache",
36 "Counter": "0,1,2,3",
37 "EventName": "L2_RQSTS.ALL_DEMAND_MISS",
38 "PublicDescription": "Demand requests that miss L2 cache.",
39 "SampleAfterValue": "200003",
40 "CounterHTOff": "0,1,2,3,4,5,6,7"
41 },
42 {
43 "EventCode": "0x24",
44 "UMask": "0x38",
45 "BriefDescription": "Requests from the L1/L2/L3 hardware prefetchers or Load software prefetches that miss L2 cache",
46 "Counter": "0,1,2,3",
47 "EventName": "L2_RQSTS.PF_MISS",
48 "PublicDescription": "Counts requests from the L1/L2/L3 hardware prefetchers or Load software prefetches that miss L2 cache.",
49 "SampleAfterValue": "200003",
50 "CounterHTOff": "0,1,2,3,4,5,6,7"
51 },
52 {
53 "EventCode": "0x24",
54 "UMask": "0x3f",
55 "BriefDescription": "All requests that miss L2 cache",
56 "Counter": "0,1,2,3",
57 "EventName": "L2_RQSTS.MISS",
58 "PublicDescription": "All requests that miss L2 cache.",
59 "SampleAfterValue": "200003",
60 "CounterHTOff": "0,1,2,3,4,5,6,7"
61 },
62 {
63 "EventCode": "0x24",
64 "UMask": "0x41",
65 "BriefDescription": "Demand Data Read requests that hit L2 cache",
66 "Counter": "0,1,2,3",
67 "EventName": "L2_RQSTS.DEMAND_DATA_RD_HIT",
68 "PublicDescription": "Counts the number of demand Data Read requests that hit L2 cache. Only non rejected loads are counted.",
69 "SampleAfterValue": "200003",
70 "CounterHTOff": "0,1,2,3,4,5,6,7"
71 },
72 {
73 "EventCode": "0x24",
74 "UMask": "0x42",
75 "BriefDescription": "RFO requests that hit L2 cache",
76 "Counter": "0,1,2,3",
77 "EventName": "L2_RQSTS.RFO_HIT",
78 "PublicDescription": "Counts the RFO (Read-for-Ownership) requests that hit L2 cache.",
79 "SampleAfterValue": "200003",
80 "CounterHTOff": "0,1,2,3,4,5,6,7"
81 },
82 {
83 "EventCode": "0x24",
84 "UMask": "0x44",
85 "BriefDescription": "L2 cache hits when fetching instructions, code reads.",
86 "Counter": "0,1,2,3",
87 "EventName": "L2_RQSTS.CODE_RD_HIT",
88 "PublicDescription": "Counts L2 cache hits when fetching instructions, code reads.",
89 "SampleAfterValue": "200003",
90 "CounterHTOff": "0,1,2,3,4,5,6,7"
91 },
92 {
93 "EventCode": "0x24",
94 "UMask": "0xd8",
95 "BriefDescription": "Requests from the L1/L2/L3 hardware prefetchers or Load software prefetches that hit L2 cache",
96 "Counter": "0,1,2,3",
97 "EventName": "L2_RQSTS.PF_HIT",
98 "PublicDescription": "Counts requests from the L1/L2/L3 hardware prefetchers or Load software prefetches that hit L2 cache.",
99 "SampleAfterValue": "200003",
100 "CounterHTOff": "0,1,2,3,4,5,6,7"
101 },
102 {
103 "EventCode": "0x24",
104 "UMask": "0xe1",
105 "BriefDescription": "Demand Data Read requests",
106 "Counter": "0,1,2,3",
107 "EventName": "L2_RQSTS.ALL_DEMAND_DATA_RD",
108 "PublicDescription": "Counts the number of demand Data Read requests (including requests from L1D hardware prefetchers). These loads may hit or miss L2 cache. Only non rejected loads are counted.",
109 "SampleAfterValue": "200003",
110 "CounterHTOff": "0,1,2,3,4,5,6,7"
111 },
112 {
113 "EventCode": "0x24",
114 "UMask": "0xe2",
115 "BriefDescription": "RFO requests to L2 cache",
116 "Counter": "0,1,2,3",
117 "EventName": "L2_RQSTS.ALL_RFO",
118 "PublicDescription": "Counts the total number of RFO (read for ownership) requests to L2 cache. L2 RFO requests include both L1D demand RFO misses as well as L1D RFO prefetches.",
119 "SampleAfterValue": "200003",
120 "CounterHTOff": "0,1,2,3,4,5,6,7"
121 },
122 {
123 "EventCode": "0x24",
124 "UMask": "0xe4",
125 "BriefDescription": "L2 code requests",
126 "Counter": "0,1,2,3",
127 "EventName": "L2_RQSTS.ALL_CODE_RD",
128 "PublicDescription": "Counts the total number of L2 code requests.",
129 "SampleAfterValue": "200003",
130 "CounterHTOff": "0,1,2,3,4,5,6,7"
131 },
132 {
133 "EventCode": "0x24",
134 "UMask": "0xe7",
135 "BriefDescription": "Demand requests to L2 cache",
136 "Counter": "0,1,2,3",
137 "EventName": "L2_RQSTS.ALL_DEMAND_REFERENCES",
138 "PublicDescription": "Demand requests to L2 cache.",
139 "SampleAfterValue": "200003",
140 "CounterHTOff": "0,1,2,3,4,5,6,7"
141 },
142 {
143 "EventCode": "0x24",
144 "UMask": "0xf8",
145 "BriefDescription": "Requests from the L1/L2/L3 hardware prefetchers or Load software prefetches",
146 "Counter": "0,1,2,3",
147 "EventName": "L2_RQSTS.ALL_PF",
148 "PublicDescription": "Counts the total number of requests from the L2 hardware prefetchers.",
149 "SampleAfterValue": "200003",
150 "CounterHTOff": "0,1,2,3,4,5,6,7"
151 },
152 {
153 "EventCode": "0x24",
154 "UMask": "0xff",
155 "BriefDescription": "All L2 requests",
156 "Counter": "0,1,2,3",
157 "EventName": "L2_RQSTS.REFERENCES",
158 "PublicDescription": "All L2 requests.",
159 "SampleAfterValue": "200003",
160 "CounterHTOff": "0,1,2,3,4,5,6,7"
161 },
162 {
163 "EventCode": "0x2E",
164 "UMask": "0x41",
165 "BriefDescription": "Core-originated cacheable demand requests missed L3",
166 "Counter": "0,1,2,3",
167 "EventName": "LONGEST_LAT_CACHE.MISS",
168 "PublicDescription": "Counts core-originated cacheable requests that miss the L3 cache (Longest Latency cache). Requests include data and code reads, Reads-for-Ownership (RFOs), speculative accesses and hardware prefetches from L1 and L2. It does not include all misses to the L3.",
169 "SampleAfterValue": "100003",
170 "CounterHTOff": "0,1,2,3,4,5,6,7"
171 },
172 {
173 "EventCode": "0x2E",
174 "UMask": "0x4f",
175 "BriefDescription": "Core-originated cacheable demand requests that refer to L3",
176 "Counter": "0,1,2,3",
177 "EventName": "LONGEST_LAT_CACHE.REFERENCE",
178 "PublicDescription": "Counts core-originated cacheable requests to the L3 cache (Longest Latency cache). Requests include data and code reads, Reads-for-Ownership (RFOs), speculative accesses and hardware prefetches from L1 and L2. It does not include all accesses to the L3.",
179 "SampleAfterValue": "100003",
180 "CounterHTOff": "0,1,2,3,4,5,6,7"
181 },
182 {
183 "EventCode": "0x48",
184 "UMask": "0x1",
185 "BriefDescription": "L1D miss outstandings duration in cycles",
186 "Counter": "0,1,2,3",
187 "EventName": "L1D_PEND_MISS.PENDING",
188 "PublicDescription": "Counts duration of L1D miss outstanding, that is each cycle number of Fill Buffers (FB) outstanding required by Demand Reads. FB either is held by demand loads, or it is held by non-demand loads and gets hit at least once by demand. The valid outstanding interval is defined until the FB deallocation by one of the following ways: from FB allocation, if FB is allocated by demand from the demand Hit FB, if it is allocated by hardware or software prefetch.Note: In the L1D, a Demand Read contains cacheable or noncacheable demand loads, including ones causing cache-line splits and reads due to page walks resulted from any request type.",
189 "SampleAfterValue": "2000003",
190 "CounterHTOff": "0,1,2,3,4,5,6,7"
191 },
192 {
193 "EventCode": "0x48",
194 "UMask": "0x1",
195 "BriefDescription": "Cycles with L1D load Misses outstanding.",
196 "Counter": "0,1,2,3",
197 "EventName": "L1D_PEND_MISS.PENDING_CYCLES",
198 "CounterMask": "1",
199 "PublicDescription": "Counts duration of L1D miss outstanding in cycles.",
200 "SampleAfterValue": "2000003",
201 "CounterHTOff": "0,1,2,3,4,5,6,7"
202 },
203 {
204 "EventCode": "0x48",
205 "UMask": "0x1",
206 "BriefDescription": "Cycles with L1D load Misses outstanding from any thread on physical core.",
207 "Counter": "0,1,2,3",
208 "EventName": "L1D_PEND_MISS.PENDING_CYCLES_ANY",
209 "AnyThread": "1",
210 "CounterMask": "1",
211 "SampleAfterValue": "2000003",
212 "CounterHTOff": "0,1,2,3,4,5,6,7"
213 },
214 {
215 "EventCode": "0x48",
216 "UMask": "0x2",
217 "BriefDescription": "Number of times a request needed a FB entry but there was no entry available for it. That is the FB unavailability was dominant reason for blocking the request. A request includes cacheable/uncacheable demands that is load, store or SW prefetch.",
218 "Counter": "0,1,2,3",
219 "EventName": "L1D_PEND_MISS.FB_FULL",
220 "PublicDescription": "Number of times a request needed a FB (Fill Buffer) entry but there was no entry available for it. A request includes cacheable/uncacheable demands that are load, store or SW prefetch instructions.",
221 "SampleAfterValue": "2000003",
222 "CounterHTOff": "0,1,2,3,4,5,6,7"
223 },
224 {
225 "EventCode": "0x51",
226 "UMask": "0x1",
227 "BriefDescription": "L1D data line replacements",
228 "Counter": "0,1,2,3",
229 "EventName": "L1D.REPLACEMENT",
230 "PublicDescription": "Counts L1D data line replacements including opportunistic replacements, and replacements that require stall-for-replace or block-for-replace.",
231 "SampleAfterValue": "2000003",
232 "CounterHTOff": "0,1,2,3,4,5,6,7"
233 },
234 {
235 "EventCode": "0x60",
236 "UMask": "0x1",
237 "BriefDescription": "Offcore outstanding Demand Data Read transactions in uncore queue.",
238 "Counter": "0,1,2,3",
239 "EventName": "OFFCORE_REQUESTS_OUTSTANDING.DEMAND_DATA_RD",
240 "PublicDescription": "Counts the number of offcore outstanding Demand Data Read transactions in the super queue (SQ) every cycle. A transaction is considered to be in the Offcore outstanding state between L2 miss and transaction completion sent to requestor. See the corresponding Umask under OFFCORE_REQUESTS.Note: A prefetch promoted to Demand is counted from the promotion point.",
241 "SampleAfterValue": "2000003",
242 "CounterHTOff": "0,1,2,3,4,5,6,7"
243 },
244 {
245 "EventCode": "0x60",
246 "UMask": "0x1",
247 "BriefDescription": "Cycles when offcore outstanding Demand Data Read transactions are present in SuperQueue (SQ), queue to uncore",
248 "Counter": "0,1,2,3",
249 "EventName": "OFFCORE_REQUESTS_OUTSTANDING.CYCLES_WITH_DEMAND_DATA_RD",
250 "CounterMask": "1",
251 "PublicDescription": "Counts cycles when offcore outstanding Demand Data Read transactions are present in the super queue (SQ). A transaction is considered to be in the Offcore outstanding state between L2 miss and transaction completion sent to requestor (SQ de-allocation).",
252 "SampleAfterValue": "2000003",
253 "CounterHTOff": "0,1,2,3,4,5,6,7"
254 },
255 {
256 "EventCode": "0x60",
257 "UMask": "0x1",
258 "BriefDescription": "Cycles with at least 6 offcore outstanding Demand Data Read transactions in uncore queue.",
259 "Counter": "0,1,2,3",
260 "EventName": "OFFCORE_REQUESTS_OUTSTANDING.DEMAND_DATA_RD_GE_6",
261 "CounterMask": "6",
262 "SampleAfterValue": "2000003",
263 "CounterHTOff": "0,1,2,3,4,5,6,7"
264 },
265 {
266 "EventCode": "0x60",
267 "UMask": "0x2",
268 "BriefDescription": "Offcore outstanding Code Reads transactions in the SuperQueue (SQ), queue to uncore, every cycle. ",
269 "Counter": "0,1,2,3",
270 "EventName": "OFFCORE_REQUESTS_OUTSTANDING.DEMAND_CODE_RD",
271 "PublicDescription": "Counts the number of offcore outstanding Code Reads transactions in the super queue every cycle. The 'Offcore outstanding' state of the transaction lasts from the L2 miss until the sending transaction completion to requestor (SQ deallocation). See the corresponding Umask under OFFCORE_REQUESTS.",
272 "SampleAfterValue": "2000003",
273 "CounterHTOff": "0,1,2,3,4,5,6,7"
274 },
275 {
276 "EventCode": "0x60",
277 "UMask": "0x2",
278 "BriefDescription": "Cycles with offcore outstanding Code Reads transactions in the SuperQueue (SQ), queue to uncore.",
279 "Counter": "0,1,2,3",
280 "EventName": "OFFCORE_REQUESTS_OUTSTANDING.CYCLES_WITH_DEMAND_CODE_RD",
281 "CounterMask": "1",
282 "PublicDescription": "Counts the number of offcore outstanding Code Reads transactions in the super queue every cycle. The 'Offcore outstanding' state of the transaction lasts from the L2 miss until the sending transaction completion to requestor (SQ deallocation). See the corresponding Umask under OFFCORE_REQUESTS.",
283 "SampleAfterValue": "2000003",
284 "CounterHTOff": "0,1,2,3,4,5,6,7"
285 },
286 {
287 "EventCode": "0x60",
288 "UMask": "0x4",
289 "BriefDescription": "Offcore outstanding demand rfo reads transactions in SuperQueue (SQ), queue to uncore, every cycle",
290 "Counter": "0,1,2,3",
291 "EventName": "OFFCORE_REQUESTS_OUTSTANDING.DEMAND_RFO",
292 "PublicDescription": "Counts the number of offcore outstanding RFO (store) transactions in the super queue (SQ) every cycle. A transaction is considered to be in the Offcore outstanding state between L2 miss and transaction completion sent to requestor (SQ de-allocation). See corresponding Umask under OFFCORE_REQUESTS.",
293 "SampleAfterValue": "2000003",
294 "CounterHTOff": "0,1,2,3,4,5,6,7"
295 },
296 {
297 "EventCode": "0x60",
298 "UMask": "0x4",
299 "BriefDescription": "Cycles with offcore outstanding demand rfo reads transactions in SuperQueue (SQ), queue to uncore.",
300 "Counter": "0,1,2,3",
301 "EventName": "OFFCORE_REQUESTS_OUTSTANDING.CYCLES_WITH_DEMAND_RFO",
302 "CounterMask": "1",
303 "PublicDescription": "Counts the number of offcore outstanding demand rfo Reads transactions in the super queue every cycle. The 'Offcore outstanding' state of the transaction lasts from the L2 miss until the sending transaction completion to requestor (SQ deallocation). See the corresponding Umask under OFFCORE_REQUESTS.",
304 "SampleAfterValue": "2000003",
305 "CounterHTOff": "0,1,2,3,4,5,6,7"
306 },
307 {
308 "EventCode": "0x60",
309 "UMask": "0x8",
310 "BriefDescription": "Offcore outstanding cacheable Core Data Read transactions in SuperQueue (SQ), queue to uncore",
311 "Counter": "0,1,2,3",
312 "EventName": "OFFCORE_REQUESTS_OUTSTANDING.ALL_DATA_RD",
313 "PublicDescription": "Counts the number of offcore outstanding cacheable Core Data Read transactions in the super queue every cycle. A transaction is considered to be in the Offcore outstanding state between L2 miss and transaction completion sent to requestor (SQ de-allocation). See corresponding Umask under OFFCORE_REQUESTS.",
314 "SampleAfterValue": "2000003",
315 "CounterHTOff": "0,1,2,3,4,5,6,7"
316 },
317 {
318 "EventCode": "0x60",
319 "UMask": "0x8",
320 "BriefDescription": "Cycles when offcore outstanding cacheable Core Data Read transactions are present in SuperQueue (SQ), queue to uncore.",
321 "Counter": "0,1,2,3",
322 "EventName": "OFFCORE_REQUESTS_OUTSTANDING.CYCLES_WITH_DATA_RD",
323 "CounterMask": "1",
324 "PublicDescription": "Counts cycles when offcore outstanding cacheable Core Data Read transactions are present in the super queue. A transaction is considered to be in the Offcore outstanding state between L2 miss and transaction completion sent to requestor (SQ de-allocation). See corresponding Umask under OFFCORE_REQUESTS.",
325 "SampleAfterValue": "2000003",
326 "CounterHTOff": "0,1,2,3,4,5,6,7"
327 },
328 {
329 "EventCode": "0xB0",
330 "UMask": "0x1",
331 "BriefDescription": "Demand Data Read requests sent to uncore",
332 "Counter": "0,1,2,3",
333 "EventName": "OFFCORE_REQUESTS.DEMAND_DATA_RD",
334 "PublicDescription": "Counts the Demand Data Read requests sent to uncore. Use it in conjunction with OFFCORE_REQUESTS_OUTSTANDING to determine average latency in the uncore.",
335 "SampleAfterValue": "100003",
336 "CounterHTOff": "0,1,2,3,4,5,6,7"
337 },
338 {
339 "EventCode": "0xB0",
340 "UMask": "0x2",
341 "BriefDescription": "Cacheable and noncachaeble code read requests",
342 "Counter": "0,1,2,3",
343 "EventName": "OFFCORE_REQUESTS.DEMAND_CODE_RD",
344 "PublicDescription": "Counts both cacheable and non-cacheable code read requests.",
345 "SampleAfterValue": "100003",
346 "CounterHTOff": "0,1,2,3,4,5,6,7"
347 },
348 {
349 "EventCode": "0xB0",
350 "UMask": "0x4",
351 "BriefDescription": "Demand RFO requests including regular RFOs, locks, ItoM",
352 "Counter": "0,1,2,3",
353 "EventName": "OFFCORE_REQUESTS.DEMAND_RFO",
354 "PublicDescription": "Counts the demand RFO (read for ownership) requests including regular RFOs, locks, ItoM.",
355 "SampleAfterValue": "100003",
356 "CounterHTOff": "0,1,2,3,4,5,6,7"
357 },
358 {
359 "EventCode": "0xB0",
360 "UMask": "0x8",
361 "BriefDescription": "Demand and prefetch data reads",
362 "Counter": "0,1,2,3",
363 "EventName": "OFFCORE_REQUESTS.ALL_DATA_RD",
364 "PublicDescription": "Counts the demand and prefetch data reads. All Core Data Reads include cacheable 'Demands' and L2 prefetchers (not L3 prefetchers). Counting also covers reads due to page walks resulted from any request type.",
365 "SampleAfterValue": "100003",
366 "CounterHTOff": "0,1,2,3,4,5,6,7"
367 },
368 {
369 "EventCode": "0xB0",
370 "UMask": "0x80",
371 "BriefDescription": "Any memory transaction that reached the SQ.",
372 "Counter": "0,1,2,3",
373 "EventName": "OFFCORE_REQUESTS.ALL_REQUESTS",
374 "PublicDescription": "Counts memory transactions reached the super queue including requests initiated by the core, all L3 prefetches, page walks, etc..",
375 "SampleAfterValue": "100003",
376 "CounterHTOff": "0,1,2,3,4,5,6,7"
377 },
378 {
379 "EventCode": "0xB2",
380 "UMask": "0x1",
381 "BriefDescription": "Offcore requests buffer cannot take more entries for this thread core.",
382 "Counter": "0,1,2,3",
383 "EventName": "OFFCORE_REQUESTS_BUFFER.SQ_FULL",
384 "PublicDescription": "Counts the number of cases when the offcore requests buffer cannot take more entries for the core. This can happen when the superqueue does not contain eligible entries, or when L1D writeback pending FIFO requests is full.Note: Writeback pending FIFO has six entries.",
385 "SampleAfterValue": "2000003",
386 "CounterHTOff": "0,1,2,3,4,5,6,7"
387 },
388 {
389 "EventCode": "0xB7, 0xBB",
390 "UMask": "0x1",
391 "BriefDescription": "Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction",
392 "Counter": "0,1,2,3",
393 "EventName": "OFFCORE_RESPONSE",
394 "PublicDescription": "Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
395 "SampleAfterValue": "100003",
396 "CounterHTOff": "0,1,2,3"
397 },
398 {
399 "EventCode": "0xD0",
400 "UMask": "0x11",
401 "BriefDescription": "Retired load instructions that miss the STLB.",
402 "Data_LA": "1",
403 "PEBS": "1",
404 "Counter": "0,1,2,3",
405 "EventName": "MEM_INST_RETIRED.STLB_MISS_LOADS",
406 "SampleAfterValue": "100003",
407 "CounterHTOff": "0,1,2,3"
408 },
409 {
410 "EventCode": "0xD0",
411 "UMask": "0x12",
412 "BriefDescription": "Retired store instructions that miss the STLB.",
413 "Data_LA": "1",
414 "PEBS": "1",
415 "Counter": "0,1,2,3",
416 "EventName": "MEM_INST_RETIRED.STLB_MISS_STORES",
417 "SampleAfterValue": "100003",
418 "L1_Hit_Indication": "1",
419 "CounterHTOff": "0,1,2,3"
420 },
421 {
422 "EventCode": "0xD0",
423 "UMask": "0x21",
424 "BriefDescription": "Retired load instructions with locked access.",
425 "Data_LA": "1",
426 "PEBS": "1",
427 "Counter": "0,1,2,3",
428 "EventName": "MEM_INST_RETIRED.LOCK_LOADS",
429 "SampleAfterValue": "100007",
430 "CounterHTOff": "0,1,2,3"
431 },
432 {
433 "EventCode": "0xD0",
434 "UMask": "0x41",
435 "BriefDescription": "Retired load instructions that split across a cacheline boundary.",
436 "Data_LA": "1",
437 "PEBS": "1",
438 "Counter": "0,1,2,3",
439 "EventName": "MEM_INST_RETIRED.SPLIT_LOADS",
440 "PublicDescription": "Counts retired load instructions that split across a cacheline boundary.",
441 "SampleAfterValue": "100003",
442 "CounterHTOff": "0,1,2,3"
443 },
444 {
445 "EventCode": "0xD0",
446 "UMask": "0x42",
447 "BriefDescription": "Retired store instructions that split across a cacheline boundary.",
448 "Data_LA": "1",
449 "PEBS": "1",
450 "Counter": "0,1,2,3",
451 "EventName": "MEM_INST_RETIRED.SPLIT_STORES",
452 "PublicDescription": "Counts retired store instructions that split across a cacheline boundary.",
453 "SampleAfterValue": "100003",
454 "L1_Hit_Indication": "1",
455 "CounterHTOff": "0,1,2,3"
456 },
457 {
458 "EventCode": "0xD0",
459 "UMask": "0x81",
460 "BriefDescription": "All retired load instructions.",
461 "Data_LA": "1",
462 "PEBS": "1",
463 "Counter": "0,1,2,3",
464 "EventName": "MEM_INST_RETIRED.ALL_LOADS",
465 "SampleAfterValue": "2000003",
466 "CounterHTOff": "0,1,2,3"
467 },
468 {
469 "EventCode": "0xD0",
470 "UMask": "0x82",
471 "BriefDescription": "All retired store instructions.",
472 "Data_LA": "1",
473 "PEBS": "1",
474 "Counter": "0,1,2,3",
475 "EventName": "MEM_INST_RETIRED.ALL_STORES",
476 "SampleAfterValue": "2000003",
477 "L1_Hit_Indication": "1",
478 "CounterHTOff": "0,1,2,3"
479 },
480 {
481 "EventCode": "0xD1",
482 "UMask": "0x1",
483 "BriefDescription": "Retired load instructions with L1 cache hits as data sources",
484 "Data_LA": "1",
485 "PEBS": "1",
486 "Counter": "0,1,2,3",
487 "EventName": "MEM_LOAD_RETIRED.L1_HIT",
488 "PublicDescription": "Counts retired load instructions with at least one uop that hit in the L1 data cache. This event includes all SW prefetches and lock instructions regardless of the data source.",
489 "SampleAfterValue": "2000003",
490 "CounterHTOff": "0,1,2,3"
491 },
492 {
493 "EventCode": "0xD1",
494 "UMask": "0x2",
495 "BriefDescription": "Retired load instructions with L2 cache hits as data sources",
496 "Data_LA": "1",
497 "PEBS": "1",
498 "Counter": "0,1,2,3",
499 "EventName": "MEM_LOAD_RETIRED.L2_HIT",
500 "PublicDescription": "Retired load instructions with L2 cache hits as data sources.",
501 "SampleAfterValue": "100003",
502 "CounterHTOff": "0,1,2,3"
503 },
504 {
505 "EventCode": "0xD1",
506 "UMask": "0x4",
507 "BriefDescription": "Retired load instructions with L3 cache hits as data sources",
508 "Data_LA": "1",
509 "PEBS": "1",
510 "Counter": "0,1,2,3",
511 "EventName": "MEM_LOAD_RETIRED.L3_HIT",
512 "PublicDescription": "Counts retired load instructions with at least one uop that hit in the L3 cache. ",
513 "SampleAfterValue": "50021",
514 "CounterHTOff": "0,1,2,3"
515 },
516 {
517 "EventCode": "0xD1",
518 "UMask": "0x8",
519 "BriefDescription": "Retired load instructions missed L1 cache as data sources",
520 "Data_LA": "1",
521 "PEBS": "1",
522 "Counter": "0,1,2,3",
523 "EventName": "MEM_LOAD_RETIRED.L1_MISS",
524 "PublicDescription": "Counts retired load instructions with at least one uop that missed in the L1 cache.",
525 "SampleAfterValue": "100003",
526 "CounterHTOff": "0,1,2,3"
527 },
528 {
529 "EventCode": "0xD1",
530 "UMask": "0x10",
531 "BriefDescription": "Retired load instructions missed L2 cache as data sources",
532 "Data_LA": "1",
533 "PEBS": "1",
534 "Counter": "0,1,2,3",
535 "EventName": "MEM_LOAD_RETIRED.L2_MISS",
536 "PublicDescription": "Retired load instructions missed L2 cache as data sources.",
537 "SampleAfterValue": "50021",
538 "CounterHTOff": "0,1,2,3"
539 },
540 {
541 "EventCode": "0xD1",
542 "UMask": "0x20",
543 "BriefDescription": "Retired load instructions missed L3 cache as data sources",
544 "Data_LA": "1",
545 "PEBS": "1",
546 "Counter": "0,1,2,3",
547 "EventName": "MEM_LOAD_RETIRED.L3_MISS",
548 "PublicDescription": "Counts retired load instructions with at least one uop that missed in the L3 cache. ",
549 "SampleAfterValue": "100007",
550 "CounterHTOff": "0,1,2,3"
551 },
552 {
553 "EventCode": "0xD1",
554 "UMask": "0x40",
555 "BriefDescription": "Retired load instructions which data sources were load missed L1 but hit FB due to preceding miss to the same cache line with data not ready",
556 "Data_LA": "1",
557 "PEBS": "1",
558 "Counter": "0,1,2,3",
559 "EventName": "MEM_LOAD_RETIRED.FB_HIT",
560 "PublicDescription": "Counts retired load instructions with at least one uop was load missed in L1 but hit FB (Fill Buffers) due to preceding miss to the same cache line with data not ready. ",
561 "SampleAfterValue": "100007",
562 "CounterHTOff": "0,1,2,3"
563 },
564 {
565 "EventCode": "0xD2",
566 "UMask": "0x1",
567 "BriefDescription": "Retired load instructions which data sources were L3 hit and cross-core snoop missed in on-pkg core cache.",
568 "Data_LA": "1",
569 "PEBS": "1",
570 "Counter": "0,1,2,3",
571 "EventName": "MEM_LOAD_L3_HIT_RETIRED.XSNP_MISS",
572 "SampleAfterValue": "20011",
573 "CounterHTOff": "0,1,2,3"
574 },
575 {
576 "EventCode": "0xD2",
577 "UMask": "0x2",
578 "BriefDescription": "Retired load instructions which data sources were L3 and cross-core snoop hits in on-pkg core cache",
579 "Data_LA": "1",
580 "PEBS": "1",
581 "Counter": "0,1,2,3",
582 "EventName": "MEM_LOAD_L3_HIT_RETIRED.XSNP_HIT",
583 "PublicDescription": "Retired load instructions which data sources were L3 and cross-core snoop hits in on-pkg core cache.",
584 "SampleAfterValue": "20011",
585 "CounterHTOff": "0,1,2,3"
586 },
587 {
588 "EventCode": "0xD2",
589 "UMask": "0x4",
590 "BriefDescription": "Retired load instructions which data sources were HitM responses from shared L3",
591 "Data_LA": "1",
592 "PEBS": "1",
593 "Counter": "0,1,2,3",
594 "EventName": "MEM_LOAD_L3_HIT_RETIRED.XSNP_HITM",
595 "PublicDescription": "Retired load instructions which data sources were HitM responses from shared L3.",
596 "SampleAfterValue": "20011",
597 "CounterHTOff": "0,1,2,3"
598 },
599 {
600 "EventCode": "0xD2",
601 "UMask": "0x8",
602 "BriefDescription": "Retired load instructions which data sources were hits in L3 without snoops required",
603 "Data_LA": "1",
604 "PEBS": "1",
605 "Counter": "0,1,2,3",
606 "EventName": "MEM_LOAD_L3_HIT_RETIRED.XSNP_NONE",
607 "PublicDescription": "Retired load instructions which data sources were hits in L3 without snoops required.",
608 "SampleAfterValue": "100003",
609 "CounterHTOff": "0,1,2,3"
610 },
611 {
612 "EventCode": "0xD3",
613 "UMask": "0x1",
614 "BriefDescription": "Retired load instructions which data sources missed L3 but serviced from local dram",
615 "Data_LA": "1",
616 "PEBS": "1",
617 "Counter": "0,1,2,3",
618 "EventName": "MEM_LOAD_L3_MISS_RETIRED.LOCAL_DRAM",
619 "PublicDescription": "Retired load instructions which data sources missed L3 but serviced from local DRAM.",
620 "SampleAfterValue": "100007",
621 "CounterHTOff": "0,1,2,3"
622 },
623 {
624 "EventCode": "0xD3",
625 "UMask": "0x2",
626 "BriefDescription": "Retired load instructions which data sources missed L3 but serviced from remote dram",
627 "Data_LA": "1",
628 "PEBS": "1",
629 "Counter": "0,1,2,3",
630 "EventName": "MEM_LOAD_L3_MISS_RETIRED.REMOTE_DRAM",
631 "SampleAfterValue": "100007",
632 "CounterHTOff": "0,1,2,3"
633 },
634 {
635 "EventCode": "0xD3",
636 "UMask": "0x4",
637 "BriefDescription": "Retired load instructions whose data sources was remote HITM",
638 "Data_LA": "1",
639 "PEBS": "1",
640 "Counter": "0,1,2,3",
641 "EventName": "MEM_LOAD_L3_MISS_RETIRED.REMOTE_HITM",
642 "PublicDescription": "Retired load instructions whose data sources was remote HITM.",
643 "SampleAfterValue": "100007",
644 "CounterHTOff": "0,1,2,3"
645 },
646 {
647 "EventCode": "0xD3",
648 "UMask": "0x8",
649 "BriefDescription": "Retired load instructions whose data sources was forwarded from a remote cache",
650 "Data_LA": "1",
651 "Counter": "0,1,2,3",
652 "EventName": "MEM_LOAD_L3_MISS_RETIRED.REMOTE_FWD",
653 "PublicDescription": "Retired load instructions whose data sources was forwarded from a remote cache.",
654 "SampleAfterValue": "100007",
655 "CounterHTOff": "0,1,2,3"
656 },
657 {
658 "EventCode": "0xD4",
659 "UMask": "0x4",
660 "BriefDescription": "Retired instructions with at least 1 uncacheable load or lock.",
661 "Data_LA": "1",
662 "PEBS": "1",
663 "Counter": "0,1,2,3",
664 "EventName": "MEM_LOAD_MISC_RETIRED.UC",
665 "SampleAfterValue": "100007",
666 "CounterHTOff": "0,1,2,3"
667 },
668 {
669 "EventCode": "0xF0",
670 "UMask": "0x40",
671 "BriefDescription": "L2 writebacks that access L2 cache",
672 "Counter": "0,1,2,3",
673 "EventName": "L2_TRANS.L2_WB",
674 "PublicDescription": "Counts L2 writebacks that access L2 cache.",
675 "SampleAfterValue": "200003",
676 "CounterHTOff": "0,1,2,3,4,5,6,7"
677 },
678 {
679 "EventCode": "0xF1",
680 "UMask": "0x1f",
681 "BriefDescription": "L2 cache lines filling L2",
682 "Counter": "0,1,2,3",
683 "EventName": "L2_LINES_IN.ALL",
684 "PublicDescription": "Counts the number of L2 cache lines filling the L2. Counting does not cover rejects.",
685 "SampleAfterValue": "100003",
686 "CounterHTOff": "0,1,2,3,4,5,6,7"
687 },
688 {
689 "EventCode": "0xF2",
690 "UMask": "0x1",
691 "BriefDescription": "Counts the number of lines that are silently dropped by L2 cache when triggered by an L2 cache fill. These lines are typically in Shared state. A non-threaded event.",
692 "Counter": "0,1,2,3",
693 "EventName": "L2_LINES_OUT.SILENT",
694 "SampleAfterValue": "200003",
695 "CounterHTOff": "0,1,2,3,4,5,6,7"
696 },
697 {
698 "EventCode": "0xF2",
699 "UMask": "0x2",
700 "BriefDescription": "Counts the number of lines that are evicted by L2 cache when triggered by an L2 cache fill. Those lines can be either in modified state or clean state. Modified lines may either be written back to L3 or directly written to memory and not allocated in L3. Clean lines may either be allocated in L3 or dropped ",
701 "Counter": "0,1,2,3",
702 "EventName": "L2_LINES_OUT.NON_SILENT",
703 "PublicDescription": "Counts the number of lines that are evicted by L2 cache when triggered by an L2 cache fill. Those lines can be either in modified state or clean state. Modified lines may either be written back to L3 or directly written to memory and not allocated in L3. Clean lines may either be allocated in L3 or dropped.",
704 "SampleAfterValue": "200003",
705 "CounterHTOff": "0,1,2,3,4,5,6,7"
706 },
707 {
708 "EventCode": "0xF2",
709 "UMask": "0x4",
710 "BriefDescription": "Counts the number of lines that have been hardware prefetched but not used and now evicted by L2 cache",
711 "Counter": "0,1,2,3",
712 "EventName": "L2_LINES_OUT.USELESS_PREF",
713 "PublicDescription": "Counts the number of lines that have been hardware prefetched but not used and now evicted by L2 cache.",
714 "SampleAfterValue": "200003",
715 "CounterHTOff": "0,1,2,3,4,5,6,7"
716 },
717 {
718 "EventCode": "0xF2",
719 "UMask": "0x4",
720 "BriefDescription": "Counts the number of lines that have been hardware prefetched but not used and now evicted by L2 cache",
721 "Counter": "0,1,2,3",
722 "EventName": "L2_LINES_OUT.USELESS_HWPF",
723 "SampleAfterValue": "200003",
724 "CounterHTOff": "0,1,2,3,4,5,6,7"
725 },
726 {
727 "EventCode": "0xF4",
728 "UMask": "0x10",
729 "BriefDescription": "Number of cache line split locks sent to uncore.",
730 "Counter": "0,1,2,3",
731 "EventName": "SQ_MISC.SPLIT_LOCK",
732 "PublicDescription": "Counts the number of cache line split locks sent to the uncore.",
733 "SampleAfterValue": "100003",
734 "CounterHTOff": "0,1,2,3,4,5,6,7"
735 },
736 {
737 "Offcore": "1",
738 "EventCode": "0xB7, 0xBB",
739 "UMask": "0x1",
740 "BriefDescription": "Counts demand data reads that have any response type.",
741 "MSRValue": "0x0000010001 ",
742 "Counter": "0,1,2,3",
743 "EventName": "OFFCORE_RESPONSE.DEMAND_DATA_RD.ANY_RESPONSE",
744 "MSRIndex": "0x1a6,0x1a7",
745 "PublicDescription": "Counts demand data reads that have any response type.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
746 "SampleAfterValue": "100003",
747 "CounterHTOff": "0,1,2,3"
748 },
749 {
750 "Offcore": "1",
751 "EventCode": "0xB7, 0xBB",
752 "UMask": "0x1",
753 "BriefDescription": "Counts demand data reads that hit in the L3 and sibling core snoops are not needed as either the core-valid bit is not set or the shared line is present in multiple cores.",
754 "MSRValue": "0x01003c0001 ",
755 "Counter": "0,1,2,3",
756 "EventName": "OFFCORE_RESPONSE.DEMAND_DATA_RD.L3_HIT.NO_SNOOP_NEEDED",
757 "MSRIndex": "0x1a6,0x1a7",
758 "PublicDescription": "Counts demand data reads that hit in the L3 and sibling core snoops are not needed as either the core-valid bit is not set or the shared line is present in multiple cores.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
759 "SampleAfterValue": "100003",
760 "CounterHTOff": "0,1,2,3"
761 },
762 {
763 "Offcore": "1",
764 "EventCode": "0xB7, 0xBB",
765 "UMask": "0x1",
766 "BriefDescription": "Counts demand data reads that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.",
767 "MSRValue": "0x04003c0001 ",
768 "Counter": "0,1,2,3",
769 "EventName": "OFFCORE_RESPONSE.DEMAND_DATA_RD.L3_HIT.HIT_OTHER_CORE_NO_FWD",
770 "MSRIndex": "0x1a6,0x1a7",
771 "PublicDescription": "Counts demand data reads that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
772 "SampleAfterValue": "100003",
773 "CounterHTOff": "0,1,2,3"
774 },
775 {
776 "Offcore": "1",
777 "EventCode": "0xB7, 0xBB",
778 "UMask": "0x1",
779 "BriefDescription": "DEMAND_DATA_RD & L3_HIT & SNOOP_HIT_WITH_FWD",
780 "MSRValue": "0x08003c0001 ",
781 "Counter": "0,1,2,3",
782 "EventName": "OFFCORE_RESPONSE.DEMAND_DATA_RD.L3_HIT.SNOOP_HIT_WITH_FWD",
783 "MSRIndex": "0x1a6,0x1a7",
784 "PublicDescription": "tbd; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
785 "SampleAfterValue": "100003",
786 "CounterHTOff": "0,1,2,3"
787 },
788 {
789 "Offcore": "1",
790 "EventCode": "0xB7, 0xBB",
791 "UMask": "0x1",
792 "BriefDescription": "Counts demand data reads that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.",
793 "MSRValue": "0x10003c0001 ",
794 "Counter": "0,1,2,3",
795 "EventName": "OFFCORE_RESPONSE.DEMAND_DATA_RD.L3_HIT.HITM_OTHER_CORE",
796 "MSRIndex": "0x1a6,0x1a7",
797 "PublicDescription": "Counts demand data reads that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
798 "SampleAfterValue": "100003",
799 "CounterHTOff": "0,1,2,3"
800 },
801 {
802 "Offcore": "1",
803 "EventCode": "0xB7, 0xBB",
804 "UMask": "0x1",
805 "BriefDescription": "Counts demand data reads that hit in the L3.",
806 "MSRValue": "0x3f803c0001 ",
807 "Counter": "0,1,2,3",
808 "EventName": "OFFCORE_RESPONSE.DEMAND_DATA_RD.L3_HIT.ANY_SNOOP",
809 "MSRIndex": "0x1a6,0x1a7",
810 "PublicDescription": "Counts demand data reads that hit in the L3.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
811 "SampleAfterValue": "100003",
812 "CounterHTOff": "0,1,2,3"
813 },
814 {
815 "Offcore": "1",
816 "EventCode": "0xB7, 0xBB",
817 "UMask": "0x1",
818 "BriefDescription": "Counts all demand data writes (RFOs) that have any response type.",
819 "MSRValue": "0x0000010002 ",
820 "Counter": "0,1,2,3",
821 "EventName": "OFFCORE_RESPONSE.DEMAND_RFO.ANY_RESPONSE",
822 "MSRIndex": "0x1a6,0x1a7",
823 "PublicDescription": "Counts all demand data writes (RFOs) that have any response type.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
824 "SampleAfterValue": "100003",
825 "CounterHTOff": "0,1,2,3"
826 },
827 {
828 "Offcore": "1",
829 "EventCode": "0xB7, 0xBB",
830 "UMask": "0x1",
831 "BriefDescription": "Counts all demand data writes (RFOs) that hit in the L3 and sibling core snoops are not needed as either the core-valid bit is not set or the shared line is present in multiple cores.",
832 "MSRValue": "0x01003c0002 ",
833 "Counter": "0,1,2,3",
834 "EventName": "OFFCORE_RESPONSE.DEMAND_RFO.L3_HIT.NO_SNOOP_NEEDED",
835 "MSRIndex": "0x1a6,0x1a7",
836 "PublicDescription": "Counts all demand data writes (RFOs) that hit in the L3 and sibling core snoops are not needed as either the core-valid bit is not set or the shared line is present in multiple cores.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
837 "SampleAfterValue": "100003",
838 "CounterHTOff": "0,1,2,3"
839 },
840 {
841 "Offcore": "1",
842 "EventCode": "0xB7, 0xBB",
843 "UMask": "0x1",
844 "BriefDescription": "Counts all demand data writes (RFOs) that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.",
845 "MSRValue": "0x04003c0002 ",
846 "Counter": "0,1,2,3",
847 "EventName": "OFFCORE_RESPONSE.DEMAND_RFO.L3_HIT.HIT_OTHER_CORE_NO_FWD",
848 "MSRIndex": "0x1a6,0x1a7",
849 "PublicDescription": "Counts all demand data writes (RFOs) that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
850 "SampleAfterValue": "100003",
851 "CounterHTOff": "0,1,2,3"
852 },
853 {
854 "Offcore": "1",
855 "EventCode": "0xB7, 0xBB",
856 "UMask": "0x1",
857 "BriefDescription": "DEMAND_RFO & L3_HIT & SNOOP_HIT_WITH_FWD",
858 "MSRValue": "0x08003c0002 ",
859 "Counter": "0,1,2,3",
860 "EventName": "OFFCORE_RESPONSE.DEMAND_RFO.L3_HIT.SNOOP_HIT_WITH_FWD",
861 "MSRIndex": "0x1a6,0x1a7",
862 "PublicDescription": "tbd; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
863 "SampleAfterValue": "100003",
864 "CounterHTOff": "0,1,2,3"
865 },
866 {
867 "Offcore": "1",
868 "EventCode": "0xB7, 0xBB",
869 "UMask": "0x1",
870 "BriefDescription": "Counts all demand data writes (RFOs) that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.",
871 "MSRValue": "0x10003c0002 ",
872 "Counter": "0,1,2,3",
873 "EventName": "OFFCORE_RESPONSE.DEMAND_RFO.L3_HIT.HITM_OTHER_CORE",
874 "MSRIndex": "0x1a6,0x1a7",
875 "PublicDescription": "Counts all demand data writes (RFOs) that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
876 "SampleAfterValue": "100003",
877 "CounterHTOff": "0,1,2,3"
878 },
879 {
880 "Offcore": "1",
881 "EventCode": "0xB7, 0xBB",
882 "UMask": "0x1",
883 "BriefDescription": "Counts all demand data writes (RFOs) that hit in the L3.",
884 "MSRValue": "0x3f803c0002 ",
885 "Counter": "0,1,2,3",
886 "EventName": "OFFCORE_RESPONSE.DEMAND_RFO.L3_HIT.ANY_SNOOP",
887 "MSRIndex": "0x1a6,0x1a7",
888 "PublicDescription": "Counts all demand data writes (RFOs) that hit in the L3.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
889 "SampleAfterValue": "100003",
890 "CounterHTOff": "0,1,2,3"
891 },
892 {
893 "Offcore": "1",
894 "EventCode": "0xB7, 0xBB",
895 "UMask": "0x1",
896 "BriefDescription": "Counts all demand code reads that have any response type.",
897 "MSRValue": "0x0000010004 ",
898 "Counter": "0,1,2,3",
899 "EventName": "OFFCORE_RESPONSE.DEMAND_CODE_RD.ANY_RESPONSE",
900 "MSRIndex": "0x1a6,0x1a7",
901 "PublicDescription": "Counts all demand code reads that have any response type.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
902 "SampleAfterValue": "100003",
903 "CounterHTOff": "0,1,2,3"
904 },
905 {
906 "Offcore": "1",
907 "EventCode": "0xB7, 0xBB",
908 "UMask": "0x1",
909 "BriefDescription": "Counts all demand code reads that hit in the L3 and sibling core snoops are not needed as either the core-valid bit is not set or the shared line is present in multiple cores.",
910 "MSRValue": "0x01003c0004 ",
911 "Counter": "0,1,2,3",
912 "EventName": "OFFCORE_RESPONSE.DEMAND_CODE_RD.L3_HIT.NO_SNOOP_NEEDED",
913 "MSRIndex": "0x1a6,0x1a7",
914 "PublicDescription": "Counts all demand code reads that hit in the L3 and sibling core snoops are not needed as either the core-valid bit is not set or the shared line is present in multiple cores.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
915 "SampleAfterValue": "100003",
916 "CounterHTOff": "0,1,2,3"
917 },
918 {
919 "Offcore": "1",
920 "EventCode": "0xB7, 0xBB",
921 "UMask": "0x1",
922 "BriefDescription": "Counts all demand code reads that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.",
923 "MSRValue": "0x04003c0004 ",
924 "Counter": "0,1,2,3",
925 "EventName": "OFFCORE_RESPONSE.DEMAND_CODE_RD.L3_HIT.HIT_OTHER_CORE_NO_FWD",
926 "MSRIndex": "0x1a6,0x1a7",
927 "PublicDescription": "Counts all demand code reads that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
928 "SampleAfterValue": "100003",
929 "CounterHTOff": "0,1,2,3"
930 },
931 {
932 "Offcore": "1",
933 "EventCode": "0xB7, 0xBB",
934 "UMask": "0x1",
935 "BriefDescription": "DEMAND_CODE_RD & L3_HIT & SNOOP_HIT_WITH_FWD",
936 "MSRValue": "0x08003c0004 ",
937 "Counter": "0,1,2,3",
938 "EventName": "OFFCORE_RESPONSE.DEMAND_CODE_RD.L3_HIT.SNOOP_HIT_WITH_FWD",
939 "MSRIndex": "0x1a6,0x1a7",
940 "PublicDescription": "tbd; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
941 "SampleAfterValue": "100003",
942 "CounterHTOff": "0,1,2,3"
943 },
944 {
945 "Offcore": "1",
946 "EventCode": "0xB7, 0xBB",
947 "UMask": "0x1",
948 "BriefDescription": "Counts all demand code reads that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.",
949 "MSRValue": "0x10003c0004 ",
950 "Counter": "0,1,2,3",
951 "EventName": "OFFCORE_RESPONSE.DEMAND_CODE_RD.L3_HIT.HITM_OTHER_CORE",
952 "MSRIndex": "0x1a6,0x1a7",
953 "PublicDescription": "Counts all demand code reads that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
954 "SampleAfterValue": "100003",
955 "CounterHTOff": "0,1,2,3"
956 },
957 {
958 "Offcore": "1",
959 "EventCode": "0xB7, 0xBB",
960 "UMask": "0x1",
961 "BriefDescription": "Counts all demand code reads that hit in the L3.",
962 "MSRValue": "0x3f803c0004 ",
963 "Counter": "0,1,2,3",
964 "EventName": "OFFCORE_RESPONSE.DEMAND_CODE_RD.L3_HIT.ANY_SNOOP",
965 "MSRIndex": "0x1a6,0x1a7",
966 "PublicDescription": "Counts all demand code reads that hit in the L3.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
967 "SampleAfterValue": "100003",
968 "CounterHTOff": "0,1,2,3"
969 },
970 {
971 "Offcore": "1",
972 "EventCode": "0xB7, 0xBB",
973 "UMask": "0x1",
974 "BriefDescription": "Counts prefetch (that bring data to L2) data reads that have any response type.",
975 "MSRValue": "0x0000010010 ",
976 "Counter": "0,1,2,3",
977 "EventName": "OFFCORE_RESPONSE.PF_L2_DATA_RD.ANY_RESPONSE",
978 "MSRIndex": "0x1a6,0x1a7",
979 "PublicDescription": "Counts prefetch (that bring data to L2) data reads that have any response type.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
980 "SampleAfterValue": "100003",
981 "CounterHTOff": "0,1,2,3"
982 },
983 {
984 "Offcore": "1",
985 "EventCode": "0xB7, 0xBB",
986 "UMask": "0x1",
987 "BriefDescription": "Counts prefetch (that bring data to L2) data reads that hit in the L3 and sibling core snoops are not needed as either the core-valid bit is not set or the shared line is present in multiple cores.",
988 "MSRValue": "0x01003c0010 ",
989 "Counter": "0,1,2,3",
990 "EventName": "OFFCORE_RESPONSE.PF_L2_DATA_RD.L3_HIT.NO_SNOOP_NEEDED",
991 "MSRIndex": "0x1a6,0x1a7",
992 "PublicDescription": "Counts prefetch (that bring data to L2) data reads that hit in the L3 and sibling core snoops are not needed as either the core-valid bit is not set or the shared line is present in multiple cores.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
993 "SampleAfterValue": "100003",
994 "CounterHTOff": "0,1,2,3"
995 },
996 {
997 "Offcore": "1",
998 "EventCode": "0xB7, 0xBB",
999 "UMask": "0x1",
1000 "BriefDescription": "Counts prefetch (that bring data to L2) data reads that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.",
1001 "MSRValue": "0x04003c0010 ",
1002 "Counter": "0,1,2,3",
1003 "EventName": "OFFCORE_RESPONSE.PF_L2_DATA_RD.L3_HIT.HIT_OTHER_CORE_NO_FWD",
1004 "MSRIndex": "0x1a6,0x1a7",
1005 "PublicDescription": "Counts prefetch (that bring data to L2) data reads that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1006 "SampleAfterValue": "100003",
1007 "CounterHTOff": "0,1,2,3"
1008 },
1009 {
1010 "Offcore": "1",
1011 "EventCode": "0xB7, 0xBB",
1012 "UMask": "0x1",
1013 "BriefDescription": "PF_L2_DATA_RD & L3_HIT & SNOOP_HIT_WITH_FWD",
1014 "MSRValue": "0x08003c0010 ",
1015 "Counter": "0,1,2,3",
1016 "EventName": "OFFCORE_RESPONSE.PF_L2_DATA_RD.L3_HIT.SNOOP_HIT_WITH_FWD",
1017 "MSRIndex": "0x1a6,0x1a7",
1018 "PublicDescription": "tbd; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1019 "SampleAfterValue": "100003",
1020 "CounterHTOff": "0,1,2,3"
1021 },
1022 {
1023 "Offcore": "1",
1024 "EventCode": "0xB7, 0xBB",
1025 "UMask": "0x1",
1026 "BriefDescription": "Counts prefetch (that bring data to L2) data reads that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.",
1027 "MSRValue": "0x10003c0010 ",
1028 "Counter": "0,1,2,3",
1029 "EventName": "OFFCORE_RESPONSE.PF_L2_DATA_RD.L3_HIT.HITM_OTHER_CORE",
1030 "MSRIndex": "0x1a6,0x1a7",
1031 "PublicDescription": "Counts prefetch (that bring data to L2) data reads that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1032 "SampleAfterValue": "100003",
1033 "CounterHTOff": "0,1,2,3"
1034 },
1035 {
1036 "Offcore": "1",
1037 "EventCode": "0xB7, 0xBB",
1038 "UMask": "0x1",
1039 "BriefDescription": "Counts prefetch (that bring data to L2) data reads that hit in the L3.",
1040 "MSRValue": "0x3f803c0010 ",
1041 "Counter": "0,1,2,3",
1042 "EventName": "OFFCORE_RESPONSE.PF_L2_DATA_RD.L3_HIT.ANY_SNOOP",
1043 "MSRIndex": "0x1a6,0x1a7",
1044 "PublicDescription": "Counts prefetch (that bring data to L2) data reads that hit in the L3.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1045 "SampleAfterValue": "100003",
1046 "CounterHTOff": "0,1,2,3"
1047 },
1048 {
1049 "Offcore": "1",
1050 "EventCode": "0xB7, 0xBB",
1051 "UMask": "0x1",
1052 "BriefDescription": "Counts all prefetch (that bring data to L2) RFOs that have any response type.",
1053 "MSRValue": "0x0000010020 ",
1054 "Counter": "0,1,2,3",
1055 "EventName": "OFFCORE_RESPONSE.PF_L2_RFO.ANY_RESPONSE",
1056 "MSRIndex": "0x1a6,0x1a7",
1057 "PublicDescription": "Counts all prefetch (that bring data to L2) RFOs that have any response type.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1058 "SampleAfterValue": "100003",
1059 "CounterHTOff": "0,1,2,3"
1060 },
1061 {
1062 "Offcore": "1",
1063 "EventCode": "0xB7, 0xBB",
1064 "UMask": "0x1",
1065 "BriefDescription": "Counts all prefetch (that bring data to L2) RFOs that hit in the L3 and sibling core snoops are not needed as either the core-valid bit is not set or the shared line is present in multiple cores.",
1066 "MSRValue": "0x01003c0020 ",
1067 "Counter": "0,1,2,3",
1068 "EventName": "OFFCORE_RESPONSE.PF_L2_RFO.L3_HIT.NO_SNOOP_NEEDED",
1069 "MSRIndex": "0x1a6,0x1a7",
1070 "PublicDescription": "Counts all prefetch (that bring data to L2) RFOs that hit in the L3 and sibling core snoops are not needed as either the core-valid bit is not set or the shared line is present in multiple cores.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1071 "SampleAfterValue": "100003",
1072 "CounterHTOff": "0,1,2,3"
1073 },
1074 {
1075 "Offcore": "1",
1076 "EventCode": "0xB7, 0xBB",
1077 "UMask": "0x1",
1078 "BriefDescription": "Counts all prefetch (that bring data to L2) RFOs that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.",
1079 "MSRValue": "0x04003c0020 ",
1080 "Counter": "0,1,2,3",
1081 "EventName": "OFFCORE_RESPONSE.PF_L2_RFO.L3_HIT.HIT_OTHER_CORE_NO_FWD",
1082 "MSRIndex": "0x1a6,0x1a7",
1083 "PublicDescription": "Counts all prefetch (that bring data to L2) RFOs that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1084 "SampleAfterValue": "100003",
1085 "CounterHTOff": "0,1,2,3"
1086 },
1087 {
1088 "Offcore": "1",
1089 "EventCode": "0xB7, 0xBB",
1090 "UMask": "0x1",
1091 "BriefDescription": "PF_L2_RFO & L3_HIT & SNOOP_HIT_WITH_FWD",
1092 "MSRValue": "0x08003c0020 ",
1093 "Counter": "0,1,2,3",
1094 "EventName": "OFFCORE_RESPONSE.PF_L2_RFO.L3_HIT.SNOOP_HIT_WITH_FWD",
1095 "MSRIndex": "0x1a6,0x1a7",
1096 "PublicDescription": "tbd; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1097 "SampleAfterValue": "100003",
1098 "CounterHTOff": "0,1,2,3"
1099 },
1100 {
1101 "Offcore": "1",
1102 "EventCode": "0xB7, 0xBB",
1103 "UMask": "0x1",
1104 "BriefDescription": "Counts all prefetch (that bring data to L2) RFOs that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.",
1105 "MSRValue": "0x10003c0020 ",
1106 "Counter": "0,1,2,3",
1107 "EventName": "OFFCORE_RESPONSE.PF_L2_RFO.L3_HIT.HITM_OTHER_CORE",
1108 "MSRIndex": "0x1a6,0x1a7",
1109 "PublicDescription": "Counts all prefetch (that bring data to L2) RFOs that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1110 "SampleAfterValue": "100003",
1111 "CounterHTOff": "0,1,2,3"
1112 },
1113 {
1114 "Offcore": "1",
1115 "EventCode": "0xB7, 0xBB",
1116 "UMask": "0x1",
1117 "BriefDescription": "Counts all prefetch (that bring data to L2) RFOs that hit in the L3.",
1118 "MSRValue": "0x3f803c0020 ",
1119 "Counter": "0,1,2,3",
1120 "EventName": "OFFCORE_RESPONSE.PF_L2_RFO.L3_HIT.ANY_SNOOP",
1121 "MSRIndex": "0x1a6,0x1a7",
1122 "PublicDescription": "Counts all prefetch (that bring data to L2) RFOs that hit in the L3.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1123 "SampleAfterValue": "100003",
1124 "CounterHTOff": "0,1,2,3"
1125 },
1126 {
1127 "Offcore": "1",
1128 "EventCode": "0xB7, 0xBB",
1129 "UMask": "0x1",
1130 "BriefDescription": "Counts all prefetch (that bring data to LLC only) data reads that have any response type.",
1131 "MSRValue": "0x0000010080 ",
1132 "Counter": "0,1,2,3",
1133 "EventName": "OFFCORE_RESPONSE.PF_L3_DATA_RD.ANY_RESPONSE",
1134 "MSRIndex": "0x1a6,0x1a7",
1135 "PublicDescription": "Counts all prefetch (that bring data to LLC only) data reads that have any response type.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1136 "SampleAfterValue": "100003",
1137 "CounterHTOff": "0,1,2,3"
1138 },
1139 {
1140 "Offcore": "1",
1141 "EventCode": "0xB7, 0xBB",
1142 "UMask": "0x1",
1143 "BriefDescription": "Counts all prefetch (that bring data to LLC only) data reads that hit in the L3 and sibling core snoops are not needed as either the core-valid bit is not set or the shared line is present in multiple cores.",
1144 "MSRValue": "0x01003c0080 ",
1145 "Counter": "0,1,2,3",
1146 "EventName": "OFFCORE_RESPONSE.PF_L3_DATA_RD.L3_HIT.NO_SNOOP_NEEDED",
1147 "MSRIndex": "0x1a6,0x1a7",
1148 "PublicDescription": "Counts all prefetch (that bring data to LLC only) data reads that hit in the L3 and sibling core snoops are not needed as either the core-valid bit is not set or the shared line is present in multiple cores.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1149 "SampleAfterValue": "100003",
1150 "CounterHTOff": "0,1,2,3"
1151 },
1152 {
1153 "Offcore": "1",
1154 "EventCode": "0xB7, 0xBB",
1155 "UMask": "0x1",
1156 "BriefDescription": "Counts all prefetch (that bring data to LLC only) data reads that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.",
1157 "MSRValue": "0x04003c0080 ",
1158 "Counter": "0,1,2,3",
1159 "EventName": "OFFCORE_RESPONSE.PF_L3_DATA_RD.L3_HIT.HIT_OTHER_CORE_NO_FWD",
1160 "MSRIndex": "0x1a6,0x1a7",
1161 "PublicDescription": "Counts all prefetch (that bring data to LLC only) data reads that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1162 "SampleAfterValue": "100003",
1163 "CounterHTOff": "0,1,2,3"
1164 },
1165 {
1166 "Offcore": "1",
1167 "EventCode": "0xB7, 0xBB",
1168 "UMask": "0x1",
1169 "BriefDescription": "PF_L3_DATA_RD & L3_HIT & SNOOP_HIT_WITH_FWD",
1170 "MSRValue": "0x08003c0080 ",
1171 "Counter": "0,1,2,3",
1172 "EventName": "OFFCORE_RESPONSE.PF_L3_DATA_RD.L3_HIT.SNOOP_HIT_WITH_FWD",
1173 "MSRIndex": "0x1a6,0x1a7",
1174 "PublicDescription": "tbd; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1175 "SampleAfterValue": "100003",
1176 "CounterHTOff": "0,1,2,3"
1177 },
1178 {
1179 "Offcore": "1",
1180 "EventCode": "0xB7, 0xBB",
1181 "UMask": "0x1",
1182 "BriefDescription": "Counts all prefetch (that bring data to LLC only) data reads that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.",
1183 "MSRValue": "0x10003c0080 ",
1184 "Counter": "0,1,2,3",
1185 "EventName": "OFFCORE_RESPONSE.PF_L3_DATA_RD.L3_HIT.HITM_OTHER_CORE",
1186 "MSRIndex": "0x1a6,0x1a7",
1187 "PublicDescription": "Counts all prefetch (that bring data to LLC only) data reads that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1188 "SampleAfterValue": "100003",
1189 "CounterHTOff": "0,1,2,3"
1190 },
1191 {
1192 "Offcore": "1",
1193 "EventCode": "0xB7, 0xBB",
1194 "UMask": "0x1",
1195 "BriefDescription": "Counts all prefetch (that bring data to LLC only) data reads that hit in the L3.",
1196 "MSRValue": "0x3f803c0080 ",
1197 "Counter": "0,1,2,3",
1198 "EventName": "OFFCORE_RESPONSE.PF_L3_DATA_RD.L3_HIT.ANY_SNOOP",
1199 "MSRIndex": "0x1a6,0x1a7",
1200 "PublicDescription": "Counts all prefetch (that bring data to LLC only) data reads that hit in the L3.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1201 "SampleAfterValue": "100003",
1202 "CounterHTOff": "0,1,2,3"
1203 },
1204 {
1205 "Offcore": "1",
1206 "EventCode": "0xB7, 0xBB",
1207 "UMask": "0x1",
1208 "BriefDescription": "Counts all prefetch (that bring data to LLC only) RFOs that have any response type.",
1209 "MSRValue": "0x0000010100 ",
1210 "Counter": "0,1,2,3",
1211 "EventName": "OFFCORE_RESPONSE.PF_L3_RFO.ANY_RESPONSE",
1212 "MSRIndex": "0x1a6,0x1a7",
1213 "PublicDescription": "Counts all prefetch (that bring data to LLC only) RFOs that have any response type.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1214 "SampleAfterValue": "100003",
1215 "CounterHTOff": "0,1,2,3"
1216 },
1217 {
1218 "Offcore": "1",
1219 "EventCode": "0xB7, 0xBB",
1220 "UMask": "0x1",
1221 "BriefDescription": "Counts all prefetch (that bring data to LLC only) RFOs that hit in the L3 and sibling core snoops are not needed as either the core-valid bit is not set or the shared line is present in multiple cores.",
1222 "MSRValue": "0x01003c0100 ",
1223 "Counter": "0,1,2,3",
1224 "EventName": "OFFCORE_RESPONSE.PF_L3_RFO.L3_HIT.NO_SNOOP_NEEDED",
1225 "MSRIndex": "0x1a6,0x1a7",
1226 "PublicDescription": "Counts all prefetch (that bring data to LLC only) RFOs that hit in the L3 and sibling core snoops are not needed as either the core-valid bit is not set or the shared line is present in multiple cores.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1227 "SampleAfterValue": "100003",
1228 "CounterHTOff": "0,1,2,3"
1229 },
1230 {
1231 "Offcore": "1",
1232 "EventCode": "0xB7, 0xBB",
1233 "UMask": "0x1",
1234 "BriefDescription": "Counts all prefetch (that bring data to LLC only) RFOs that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.",
1235 "MSRValue": "0x04003c0100 ",
1236 "Counter": "0,1,2,3",
1237 "EventName": "OFFCORE_RESPONSE.PF_L3_RFO.L3_HIT.HIT_OTHER_CORE_NO_FWD",
1238 "MSRIndex": "0x1a6,0x1a7",
1239 "PublicDescription": "Counts all prefetch (that bring data to LLC only) RFOs that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1240 "SampleAfterValue": "100003",
1241 "CounterHTOff": "0,1,2,3"
1242 },
1243 {
1244 "Offcore": "1",
1245 "EventCode": "0xB7, 0xBB",
1246 "UMask": "0x1",
1247 "BriefDescription": "PF_L3_RFO & L3_HIT & SNOOP_HIT_WITH_FWD",
1248 "MSRValue": "0x08003c0100 ",
1249 "Counter": "0,1,2,3",
1250 "EventName": "OFFCORE_RESPONSE.PF_L3_RFO.L3_HIT.SNOOP_HIT_WITH_FWD",
1251 "MSRIndex": "0x1a6,0x1a7",
1252 "PublicDescription": "tbd; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1253 "SampleAfterValue": "100003",
1254 "CounterHTOff": "0,1,2,3"
1255 },
1256 {
1257 "Offcore": "1",
1258 "EventCode": "0xB7, 0xBB",
1259 "UMask": "0x1",
1260 "BriefDescription": "Counts all prefetch (that bring data to LLC only) RFOs that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.",
1261 "MSRValue": "0x10003c0100 ",
1262 "Counter": "0,1,2,3",
1263 "EventName": "OFFCORE_RESPONSE.PF_L3_RFO.L3_HIT.HITM_OTHER_CORE",
1264 "MSRIndex": "0x1a6,0x1a7",
1265 "PublicDescription": "Counts all prefetch (that bring data to LLC only) RFOs that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1266 "SampleAfterValue": "100003",
1267 "CounterHTOff": "0,1,2,3"
1268 },
1269 {
1270 "Offcore": "1",
1271 "EventCode": "0xB7, 0xBB",
1272 "UMask": "0x1",
1273 "BriefDescription": "Counts all prefetch (that bring data to LLC only) RFOs that hit in the L3.",
1274 "MSRValue": "0x3f803c0100 ",
1275 "Counter": "0,1,2,3",
1276 "EventName": "OFFCORE_RESPONSE.PF_L3_RFO.L3_HIT.ANY_SNOOP",
1277 "MSRIndex": "0x1a6,0x1a7",
1278 "PublicDescription": "Counts all prefetch (that bring data to LLC only) RFOs that hit in the L3.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1279 "SampleAfterValue": "100003",
1280 "CounterHTOff": "0,1,2,3"
1281 },
1282 {
1283 "Offcore": "1",
1284 "EventCode": "0xB7, 0xBB",
1285 "UMask": "0x1",
1286 "BriefDescription": "Counts L1 data cache hardware prefetch requests and software prefetch requests that have any response type.",
1287 "MSRValue": "0x0000010400 ",
1288 "Counter": "0,1,2,3",
1289 "EventName": "OFFCORE_RESPONSE.PF_L1D_AND_SW.ANY_RESPONSE",
1290 "MSRIndex": "0x1a6,0x1a7",
1291 "PublicDescription": "Counts L1 data cache hardware prefetch requests and software prefetch requests that have any response type.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1292 "SampleAfterValue": "100003",
1293 "CounterHTOff": "0,1,2,3"
1294 },
1295 {
1296 "Offcore": "1",
1297 "EventCode": "0xB7, 0xBB",
1298 "UMask": "0x1",
1299 "BriefDescription": "Counts L1 data cache hardware prefetch requests and software prefetch requests that hit in the L3 and sibling core snoops are not needed as either the core-valid bit is not set or the shared line is present in multiple cores.",
1300 "MSRValue": "0x01003c0400 ",
1301 "Counter": "0,1,2,3",
1302 "EventName": "OFFCORE_RESPONSE.PF_L1D_AND_SW.L3_HIT.NO_SNOOP_NEEDED",
1303 "MSRIndex": "0x1a6,0x1a7",
1304 "PublicDescription": "Counts L1 data cache hardware prefetch requests and software prefetch requests that hit in the L3 and sibling core snoops are not needed as either the core-valid bit is not set or the shared line is present in multiple cores.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1305 "SampleAfterValue": "100003",
1306 "CounterHTOff": "0,1,2,3"
1307 },
1308 {
1309 "Offcore": "1",
1310 "EventCode": "0xB7, 0xBB",
1311 "UMask": "0x1",
1312 "BriefDescription": "Counts L1 data cache hardware prefetch requests and software prefetch requests that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.",
1313 "MSRValue": "0x04003c0400 ",
1314 "Counter": "0,1,2,3",
1315 "EventName": "OFFCORE_RESPONSE.PF_L1D_AND_SW.L3_HIT.HIT_OTHER_CORE_NO_FWD",
1316 "MSRIndex": "0x1a6,0x1a7",
1317 "PublicDescription": "Counts L1 data cache hardware prefetch requests and software prefetch requests that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1318 "SampleAfterValue": "100003",
1319 "CounterHTOff": "0,1,2,3"
1320 },
1321 {
1322 "Offcore": "1",
1323 "EventCode": "0xB7, 0xBB",
1324 "UMask": "0x1",
1325 "BriefDescription": "PF_L1D_AND_SW & L3_HIT & SNOOP_HIT_WITH_FWD",
1326 "MSRValue": "0x08003c0400 ",
1327 "Counter": "0,1,2,3",
1328 "EventName": "OFFCORE_RESPONSE.PF_L1D_AND_SW.L3_HIT.SNOOP_HIT_WITH_FWD",
1329 "MSRIndex": "0x1a6,0x1a7",
1330 "PublicDescription": "tbd; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1331 "SampleAfterValue": "100003",
1332 "CounterHTOff": "0,1,2,3"
1333 },
1334 {
1335 "Offcore": "1",
1336 "EventCode": "0xB7, 0xBB",
1337 "UMask": "0x1",
1338 "BriefDescription": "Counts L1 data cache hardware prefetch requests and software prefetch requests that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.",
1339 "MSRValue": "0x10003c0400 ",
1340 "Counter": "0,1,2,3",
1341 "EventName": "OFFCORE_RESPONSE.PF_L1D_AND_SW.L3_HIT.HITM_OTHER_CORE",
1342 "MSRIndex": "0x1a6,0x1a7",
1343 "PublicDescription": "Counts L1 data cache hardware prefetch requests and software prefetch requests that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1344 "SampleAfterValue": "100003",
1345 "CounterHTOff": "0,1,2,3"
1346 },
1347 {
1348 "Offcore": "1",
1349 "EventCode": "0xB7, 0xBB",
1350 "UMask": "0x1",
1351 "BriefDescription": "Counts L1 data cache hardware prefetch requests and software prefetch requests that hit in the L3.",
1352 "MSRValue": "0x3f803c0400 ",
1353 "Counter": "0,1,2,3",
1354 "EventName": "OFFCORE_RESPONSE.PF_L1D_AND_SW.L3_HIT.ANY_SNOOP",
1355 "MSRIndex": "0x1a6,0x1a7",
1356 "PublicDescription": "Counts L1 data cache hardware prefetch requests and software prefetch requests that hit in the L3.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1357 "SampleAfterValue": "100003",
1358 "CounterHTOff": "0,1,2,3"
1359 },
1360 {
1361 "Offcore": "1",
1362 "EventCode": "0xB7, 0xBB",
1363 "UMask": "0x1",
1364 "BriefDescription": "Counts all prefetch data reads that have any response type.",
1365 "MSRValue": "0x0000010490 ",
1366 "Counter": "0,1,2,3",
1367 "EventName": "OFFCORE_RESPONSE.ALL_PF_DATA_RD.ANY_RESPONSE",
1368 "MSRIndex": "0x1a6,0x1a7",
1369 "PublicDescription": "Counts all prefetch data reads that have any response type.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1370 "SampleAfterValue": "100003",
1371 "CounterHTOff": "0,1,2,3"
1372 },
1373 {
1374 "Offcore": "1",
1375 "EventCode": "0xB7, 0xBB",
1376 "UMask": "0x1",
1377 "BriefDescription": "Counts all prefetch data reads that hit in the L3 and sibling core snoops are not needed as either the core-valid bit is not set or the shared line is present in multiple cores.",
1378 "MSRValue": "0x01003c0490 ",
1379 "Counter": "0,1,2,3",
1380 "EventName": "OFFCORE_RESPONSE.ALL_PF_DATA_RD.L3_HIT.NO_SNOOP_NEEDED",
1381 "MSRIndex": "0x1a6,0x1a7",
1382 "PublicDescription": "Counts all prefetch data reads that hit in the L3 and sibling core snoops are not needed as either the core-valid bit is not set or the shared line is present in multiple cores.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1383 "SampleAfterValue": "100003",
1384 "CounterHTOff": "0,1,2,3"
1385 },
1386 {
1387 "Offcore": "1",
1388 "EventCode": "0xB7, 0xBB",
1389 "UMask": "0x1",
1390 "BriefDescription": "Counts all prefetch data reads that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.",
1391 "MSRValue": "0x04003c0490 ",
1392 "Counter": "0,1,2,3",
1393 "EventName": "OFFCORE_RESPONSE.ALL_PF_DATA_RD.L3_HIT.HIT_OTHER_CORE_NO_FWD",
1394 "MSRIndex": "0x1a6,0x1a7",
1395 "PublicDescription": "Counts all prefetch data reads that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1396 "SampleAfterValue": "100003",
1397 "CounterHTOff": "0,1,2,3"
1398 },
1399 {
1400 "Offcore": "1",
1401 "EventCode": "0xB7, 0xBB",
1402 "UMask": "0x1",
1403 "BriefDescription": "ALL_PF_DATA_RD & L3_HIT & SNOOP_HIT_WITH_FWD",
1404 "MSRValue": "0x08003c0490 ",
1405 "Counter": "0,1,2,3",
1406 "EventName": "OFFCORE_RESPONSE.ALL_PF_DATA_RD.L3_HIT.SNOOP_HIT_WITH_FWD",
1407 "MSRIndex": "0x1a6,0x1a7",
1408 "PublicDescription": "tbd; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1409 "SampleAfterValue": "100003",
1410 "CounterHTOff": "0,1,2,3"
1411 },
1412 {
1413 "Offcore": "1",
1414 "EventCode": "0xB7, 0xBB",
1415 "UMask": "0x1",
1416 "BriefDescription": "Counts all prefetch data reads that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.",
1417 "MSRValue": "0x10003c0490 ",
1418 "Counter": "0,1,2,3",
1419 "EventName": "OFFCORE_RESPONSE.ALL_PF_DATA_RD.L3_HIT.HITM_OTHER_CORE",
1420 "MSRIndex": "0x1a6,0x1a7",
1421 "PublicDescription": "Counts all prefetch data reads that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1422 "SampleAfterValue": "100003",
1423 "CounterHTOff": "0,1,2,3"
1424 },
1425 {
1426 "Offcore": "1",
1427 "EventCode": "0xB7, 0xBB",
1428 "UMask": "0x1",
1429 "BriefDescription": "Counts all prefetch data reads that hit in the L3.",
1430 "MSRValue": "0x3f803c0490 ",
1431 "Counter": "0,1,2,3",
1432 "EventName": "OFFCORE_RESPONSE.ALL_PF_DATA_RD.L3_HIT.ANY_SNOOP",
1433 "MSRIndex": "0x1a6,0x1a7",
1434 "PublicDescription": "Counts all prefetch data reads that hit in the L3.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1435 "SampleAfterValue": "100003",
1436 "CounterHTOff": "0,1,2,3"
1437 },
1438 {
1439 "Offcore": "1",
1440 "EventCode": "0xB7, 0xBB",
1441 "UMask": "0x1",
1442 "BriefDescription": "Counts prefetch RFOs that have any response type.",
1443 "MSRValue": "0x0000010120 ",
1444 "Counter": "0,1,2,3",
1445 "EventName": "OFFCORE_RESPONSE.ALL_PF_RFO.ANY_RESPONSE",
1446 "MSRIndex": "0x1a6,0x1a7",
1447 "PublicDescription": "Counts prefetch RFOs that have any response type.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1448 "SampleAfterValue": "100003",
1449 "CounterHTOff": "0,1,2,3"
1450 },
1451 {
1452 "Offcore": "1",
1453 "EventCode": "0xB7, 0xBB",
1454 "UMask": "0x1",
1455 "BriefDescription": "Counts prefetch RFOs that hit in the L3 and sibling core snoops are not needed as either the core-valid bit is not set or the shared line is present in multiple cores.",
1456 "MSRValue": "0x01003c0120 ",
1457 "Counter": "0,1,2,3",
1458 "EventName": "OFFCORE_RESPONSE.ALL_PF_RFO.L3_HIT.NO_SNOOP_NEEDED",
1459 "MSRIndex": "0x1a6,0x1a7",
1460 "PublicDescription": "Counts prefetch RFOs that hit in the L3 and sibling core snoops are not needed as either the core-valid bit is not set or the shared line is present in multiple cores.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1461 "SampleAfterValue": "100003",
1462 "CounterHTOff": "0,1,2,3"
1463 },
1464 {
1465 "Offcore": "1",
1466 "EventCode": "0xB7, 0xBB",
1467 "UMask": "0x1",
1468 "BriefDescription": "Counts prefetch RFOs that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.",
1469 "MSRValue": "0x04003c0120 ",
1470 "Counter": "0,1,2,3",
1471 "EventName": "OFFCORE_RESPONSE.ALL_PF_RFO.L3_HIT.HIT_OTHER_CORE_NO_FWD",
1472 "MSRIndex": "0x1a6,0x1a7",
1473 "PublicDescription": "Counts prefetch RFOs that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1474 "SampleAfterValue": "100003",
1475 "CounterHTOff": "0,1,2,3"
1476 },
1477 {
1478 "Offcore": "1",
1479 "EventCode": "0xB7, 0xBB",
1480 "UMask": "0x1",
1481 "BriefDescription": "ALL_PF_RFO & L3_HIT & SNOOP_HIT_WITH_FWD",
1482 "MSRValue": "0x08003c0120 ",
1483 "Counter": "0,1,2,3",
1484 "EventName": "OFFCORE_RESPONSE.ALL_PF_RFO.L3_HIT.SNOOP_HIT_WITH_FWD",
1485 "MSRIndex": "0x1a6,0x1a7",
1486 "PublicDescription": "tbd; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1487 "SampleAfterValue": "100003",
1488 "CounterHTOff": "0,1,2,3"
1489 },
1490 {
1491 "Offcore": "1",
1492 "EventCode": "0xB7, 0xBB",
1493 "UMask": "0x1",
1494 "BriefDescription": "Counts prefetch RFOs that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.",
1495 "MSRValue": "0x10003c0120 ",
1496 "Counter": "0,1,2,3",
1497 "EventName": "OFFCORE_RESPONSE.ALL_PF_RFO.L3_HIT.HITM_OTHER_CORE",
1498 "MSRIndex": "0x1a6,0x1a7",
1499 "PublicDescription": "Counts prefetch RFOs that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1500 "SampleAfterValue": "100003",
1501 "CounterHTOff": "0,1,2,3"
1502 },
1503 {
1504 "Offcore": "1",
1505 "EventCode": "0xB7, 0xBB",
1506 "UMask": "0x1",
1507 "BriefDescription": "Counts prefetch RFOs that hit in the L3.",
1508 "MSRValue": "0x3f803c0120 ",
1509 "Counter": "0,1,2,3",
1510 "EventName": "OFFCORE_RESPONSE.ALL_PF_RFO.L3_HIT.ANY_SNOOP",
1511 "MSRIndex": "0x1a6,0x1a7",
1512 "PublicDescription": "Counts prefetch RFOs that hit in the L3.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1513 "SampleAfterValue": "100003",
1514 "CounterHTOff": "0,1,2,3"
1515 },
1516 {
1517 "Offcore": "1",
1518 "EventCode": "0xB7, 0xBB",
1519 "UMask": "0x1",
1520 "BriefDescription": "Counts all demand & prefetch data reads that have any response type.",
1521 "MSRValue": "0x0000010491 ",
1522 "Counter": "0,1,2,3",
1523 "EventName": "OFFCORE_RESPONSE.ALL_DATA_RD.ANY_RESPONSE",
1524 "MSRIndex": "0x1a6,0x1a7",
1525 "PublicDescription": "Counts all demand & prefetch data reads that have any response type.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1526 "SampleAfterValue": "100003",
1527 "CounterHTOff": "0,1,2,3"
1528 },
1529 {
1530 "Offcore": "1",
1531 "EventCode": "0xB7, 0xBB",
1532 "UMask": "0x1",
1533 "BriefDescription": "Counts all demand & prefetch data reads that hit in the L3 and sibling core snoops are not needed as either the core-valid bit is not set or the shared line is present in multiple cores.",
1534 "MSRValue": "0x01003c0491 ",
1535 "Counter": "0,1,2,3",
1536 "EventName": "OFFCORE_RESPONSE.ALL_DATA_RD.L3_HIT.NO_SNOOP_NEEDED",
1537 "MSRIndex": "0x1a6,0x1a7",
1538 "PublicDescription": "Counts all demand & prefetch data reads that hit in the L3 and sibling core snoops are not needed as either the core-valid bit is not set or the shared line is present in multiple cores.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1539 "SampleAfterValue": "100003",
1540 "CounterHTOff": "0,1,2,3"
1541 },
1542 {
1543 "Offcore": "1",
1544 "EventCode": "0xB7, 0xBB",
1545 "UMask": "0x1",
1546 "BriefDescription": "Counts all demand & prefetch data reads that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.",
1547 "MSRValue": "0x04003c0491 ",
1548 "Counter": "0,1,2,3",
1549 "EventName": "OFFCORE_RESPONSE.ALL_DATA_RD.L3_HIT.HIT_OTHER_CORE_NO_FWD",
1550 "MSRIndex": "0x1a6,0x1a7",
1551 "PublicDescription": "Counts all demand & prefetch data reads that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1552 "SampleAfterValue": "100003",
1553 "CounterHTOff": "0,1,2,3"
1554 },
1555 {
1556 "Offcore": "1",
1557 "EventCode": "0xB7, 0xBB",
1558 "UMask": "0x1",
1559 "BriefDescription": "ALL_DATA_RD & L3_HIT & SNOOP_HIT_WITH_FWD",
1560 "MSRValue": "0x08003c0491 ",
1561 "Counter": "0,1,2,3",
1562 "EventName": "OFFCORE_RESPONSE.ALL_DATA_RD.L3_HIT.SNOOP_HIT_WITH_FWD",
1563 "MSRIndex": "0x1a6,0x1a7",
1564 "PublicDescription": "tbd; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1565 "SampleAfterValue": "100003",
1566 "CounterHTOff": "0,1,2,3"
1567 },
1568 {
1569 "Offcore": "1",
1570 "EventCode": "0xB7, 0xBB",
1571 "UMask": "0x1",
1572 "BriefDescription": "Counts all demand & prefetch data reads that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.",
1573 "MSRValue": "0x10003c0491 ",
1574 "Counter": "0,1,2,3",
1575 "EventName": "OFFCORE_RESPONSE.ALL_DATA_RD.L3_HIT.HITM_OTHER_CORE",
1576 "MSRIndex": "0x1a6,0x1a7",
1577 "PublicDescription": "Counts all demand & prefetch data reads that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1578 "SampleAfterValue": "100003",
1579 "CounterHTOff": "0,1,2,3"
1580 },
1581 {
1582 "Offcore": "1",
1583 "EventCode": "0xB7, 0xBB",
1584 "UMask": "0x1",
1585 "BriefDescription": "Counts all demand & prefetch data reads that hit in the L3.",
1586 "MSRValue": "0x3f803c0491 ",
1587 "Counter": "0,1,2,3",
1588 "EventName": "OFFCORE_RESPONSE.ALL_DATA_RD.L3_HIT.ANY_SNOOP",
1589 "MSRIndex": "0x1a6,0x1a7",
1590 "PublicDescription": "Counts all demand & prefetch data reads that hit in the L3.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1591 "SampleAfterValue": "100003",
1592 "CounterHTOff": "0,1,2,3"
1593 },
1594 {
1595 "Offcore": "1",
1596 "EventCode": "0xB7, 0xBB",
1597 "UMask": "0x1",
1598 "BriefDescription": "Counts all demand & prefetch RFOs that have any response type.",
1599 "MSRValue": "0x0000010122 ",
1600 "Counter": "0,1,2,3",
1601 "EventName": "OFFCORE_RESPONSE.ALL_RFO.ANY_RESPONSE",
1602 "MSRIndex": "0x1a6,0x1a7",
1603 "PublicDescription": "Counts all demand & prefetch RFOs that have any response type.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1604 "SampleAfterValue": "100003",
1605 "CounterHTOff": "0,1,2,3"
1606 },
1607 {
1608 "Offcore": "1",
1609 "EventCode": "0xB7, 0xBB",
1610 "UMask": "0x1",
1611 "BriefDescription": "Counts all demand & prefetch RFOs that hit in the L3 and sibling core snoops are not needed as either the core-valid bit is not set or the shared line is present in multiple cores.",
1612 "MSRValue": "0x01003c0122 ",
1613 "Counter": "0,1,2,3",
1614 "EventName": "OFFCORE_RESPONSE.ALL_RFO.L3_HIT.NO_SNOOP_NEEDED",
1615 "MSRIndex": "0x1a6,0x1a7",
1616 "PublicDescription": "Counts all demand & prefetch RFOs that hit in the L3 and sibling core snoops are not needed as either the core-valid bit is not set or the shared line is present in multiple cores.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1617 "SampleAfterValue": "100003",
1618 "CounterHTOff": "0,1,2,3"
1619 },
1620 {
1621 "Offcore": "1",
1622 "EventCode": "0xB7, 0xBB",
1623 "UMask": "0x1",
1624 "BriefDescription": "Counts all demand & prefetch RFOs that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.",
1625 "MSRValue": "0x04003c0122 ",
1626 "Counter": "0,1,2,3",
1627 "EventName": "OFFCORE_RESPONSE.ALL_RFO.L3_HIT.HIT_OTHER_CORE_NO_FWD",
1628 "MSRIndex": "0x1a6,0x1a7",
1629 "PublicDescription": "Counts all demand & prefetch RFOs that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1630 "SampleAfterValue": "100003",
1631 "CounterHTOff": "0,1,2,3"
1632 },
1633 {
1634 "Offcore": "1",
1635 "EventCode": "0xB7, 0xBB",
1636 "UMask": "0x1",
1637 "BriefDescription": "ALL_RFO & L3_HIT & SNOOP_HIT_WITH_FWD",
1638 "MSRValue": "0x08003c0122 ",
1639 "Counter": "0,1,2,3",
1640 "EventName": "OFFCORE_RESPONSE.ALL_RFO.L3_HIT.SNOOP_HIT_WITH_FWD",
1641 "MSRIndex": "0x1a6,0x1a7",
1642 "PublicDescription": "tbd; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1643 "SampleAfterValue": "100003",
1644 "CounterHTOff": "0,1,2,3"
1645 },
1646 {
1647 "Offcore": "1",
1648 "EventCode": "0xB7, 0xBB",
1649 "UMask": "0x1",
1650 "BriefDescription": "Counts all demand & prefetch RFOs that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.",
1651 "MSRValue": "0x10003c0122 ",
1652 "Counter": "0,1,2,3",
1653 "EventName": "OFFCORE_RESPONSE.ALL_RFO.L3_HIT.HITM_OTHER_CORE",
1654 "MSRIndex": "0x1a6,0x1a7",
1655 "PublicDescription": "Counts all demand & prefetch RFOs that hit in the L3 and the snoop to one of the sibling cores hits the line in M state and the line is forwarded.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1656 "SampleAfterValue": "100003",
1657 "CounterHTOff": "0,1,2,3"
1658 },
1659 {
1660 "Offcore": "1",
1661 "EventCode": "0xB7, 0xBB",
1662 "UMask": "0x1",
1663 "BriefDescription": "Counts all demand & prefetch RFOs that hit in the L3.",
1664 "MSRValue": "0x3f803c0122 ",
1665 "Counter": "0,1,2,3",
1666 "EventName": "OFFCORE_RESPONSE.ALL_RFO.L3_HIT.ANY_SNOOP",
1667 "MSRIndex": "0x1a6,0x1a7",
1668 "PublicDescription": "Counts all demand & prefetch RFOs that hit in the L3.; Offcore response can be programmed only with a specific pair of event select and counter MSR, and with specific event codes and predefine mask bit value in a dedicated MSR to specify attributes of the offcore transaction.",
1669 "SampleAfterValue": "100003",
1670 "CounterHTOff": "0,1,2,3"
1671 }
1672] \ No newline at end of file
diff --git a/tools/perf/pmu-events/arch/x86/skylakex/floating-point.json b/tools/perf/pmu-events/arch/x86/skylakex/floating-point.json
new file mode 100644
index 000000000000..1c09a328df36
--- /dev/null
+++ b/tools/perf/pmu-events/arch/x86/skylakex/floating-point.json
@@ -0,0 +1,88 @@
1[
2 {
3 "EventCode": "0xC7",
4 "UMask": "0x1",
5 "BriefDescription": "Number of SSE/AVX computational scalar double precision floating-point instructions retired. Each count represents 1 computation. Applies to SSE* and AVX* scalar double precision floating-point instructions: ADD SUB MUL DIV MIN MAX SQRT FM(N)ADD/SUB. FM(N)ADD/SUB instructions count twice as they perform multiple calculations per element.",
6 "Counter": "0,1,2,3",
7 "EventName": "FP_ARITH_INST_RETIRED.SCALAR_DOUBLE",
8 "SampleAfterValue": "2000003",
9 "CounterHTOff": "0,1,2,3,4,5,6,7"
10 },
11 {
12 "EventCode": "0xC7",
13 "UMask": "0x2",
14 "BriefDescription": "Number of SSE/AVX computational scalar single precision floating-point instructions retired. Each count represents 1 computation. Applies to SSE* and AVX* scalar single precision floating-point instructions: ADD SUB MUL DIV MIN MAX RCP RSQRT SQRT FM(N)ADD/SUB. FM(N)ADD/SUB instructions count twice as they perform multiple calculations per element.",
15 "Counter": "0,1,2,3",
16 "EventName": "FP_ARITH_INST_RETIRED.SCALAR_SINGLE",
17 "SampleAfterValue": "2000003",
18 "CounterHTOff": "0,1,2,3,4,5,6,7"
19 },
20 {
21 "EventCode": "0xC7",
22 "UMask": "0x4",
23 "BriefDescription": "Number of SSE/AVX computational 128-bit packed double precision floating-point instructions retired. Each count represents 2 computations. Applies to SSE* and AVX* packed double precision floating-point instructions: ADD SUB MUL DIV MIN MAX SQRT DPP FM(N)ADD/SUB. DPP and FM(N)ADD/SUB instructions count twice as they perform multiple calculations per element.",
24 "Counter": "0,1,2,3",
25 "EventName": "FP_ARITH_INST_RETIRED.128B_PACKED_DOUBLE",
26 "SampleAfterValue": "2000003",
27 "CounterHTOff": "0,1,2,3,4,5,6,7"
28 },
29 {
30 "EventCode": "0xC7",
31 "UMask": "0x8",
32 "BriefDescription": "Number of SSE/AVX computational 128-bit packed single precision floating-point instructions retired. Each count represents 4 computations. Applies to SSE* and AVX* packed single precision floating-point instructions: ADD SUB MUL DIV MIN MAX RCP RSQRT SQRT DPP FM(N)ADD/SUB. DPP and FM(N)ADD/SUB instructions count twice as they perform multiple calculations per element. ",
33 "Counter": "0,1,2,3",
34 "EventName": "FP_ARITH_INST_RETIRED.128B_PACKED_SINGLE",
35 "PublicDescription": "Number of SSE/AVX computational 128-bit packed single precision floating-point instructions retired. Each count represents 4 computations. Applies to SSE* and AVX* packed single precision floating-point instructions: ADD SUB MUL DIV MIN MAX RCP RSQRT SQRT DPP FM(N)ADD/SUB. DPP and FM(N)ADD/SUB instructions count twice as they perform multiple calculations per element.",
36 "SampleAfterValue": "2000003",
37 "CounterHTOff": "0,1,2,3,4,5,6,7"
38 },
39 {
40 "EventCode": "0xC7",
41 "UMask": "0x10",
42 "BriefDescription": "Number of SSE/AVX computational 256-bit packed double precision floating-point instructions retired. Each count represents 4 computations. Applies to SSE* and AVX* packed double precision floating-point instructions: ADD SUB MUL DIV MIN MAX SQRT DPP FM(N)ADD/SUB. DPP and FM(N)ADD/SUB instructions count twice as they perform multiple calculations per element.",
43 "Counter": "0,1,2,3",
44 "EventName": "FP_ARITH_INST_RETIRED.256B_PACKED_DOUBLE",
45 "SampleAfterValue": "2000003",
46 "CounterHTOff": "0,1,2,3,4,5,6,7"
47 },
48 {
49 "EventCode": "0xC7",
50 "UMask": "0x20",
51 "BriefDescription": "Number of SSE/AVX computational 256-bit packed single precision floating-point instructions retired. Each count represents 8 computations. Applies to SSE* and AVX* packed single precision floating-point instructions: ADD SUB MUL DIV MIN MAX RCP RSQRT SQRT DPP FM(N)ADD/SUB. DPP and FM(N)ADD/SUB instructions count twice as they perform multiple calculations per element.",
52 "Counter": "0,1,2,3",
53 "EventName": "FP_ARITH_INST_RETIRED.256B_PACKED_SINGLE",
54 "SampleAfterValue": "2000003",
55 "CounterHTOff": "0,1,2,3,4,5,6,7"
56 },
57 {
58 "EventCode": "0xC7",
59 "UMask": "0x40",
60 "BriefDescription": "Number of Packed Double-Precision FP arithmetic instructions (Use operation multiplier of 8)",
61 "Counter": "0,1,2,3",
62 "EventName": "FP_ARITH_INST_RETIRED.512B_PACKED_DOUBLE",
63 "PublicDescription": "Number of Packed Double-Precision FP arithmetic instructions (Use operation multiplier of 8).",
64 "SampleAfterValue": "2000003",
65 "CounterHTOff": "0,1,2,3,4,5,6,7"
66 },
67 {
68 "EventCode": "0xC7",
69 "UMask": "0x80",
70 "BriefDescription": "Number of Packed Single-Precision FP arithmetic instructions (Use operation multiplier of 16)",
71 "Counter": "0,1,2,3",
72 "EventName": "FP_ARITH_INST_RETIRED.512B_PACKED_SINGLE",
73 "PublicDescription": "Number of Packed Single-Precision FP arithmetic instructions (Use operation multiplier of 16).",
74 "SampleAfterValue": "2000003",
75 "CounterHTOff": "0,1,2,3,4,5,6,7"
76 },
77 {
78 "EventCode": "0xCA",
79 "UMask": "0x1e",
80 "BriefDescription": "Cycles with any input/output SSE or FP assist",
81 "Counter": "0,1,2,3",
82 "EventName": "FP_ASSIST.ANY",
83 "CounterMask": "1",
84 "PublicDescription": "Counts cycles with any input and output SSE or x87 FP assist. If an input and output assist are detected on the same cycle the event increments by 1.",
85 "SampleAfterValue": "100003",
86 "CounterHTOff": "0,1,2,3,4,5,6,7"
87 }
88] \ No newline at end of file
diff --git a/tools/perf/pmu-events/arch/x86/skylakex/frontend.json b/tools/perf/pmu-events/arch/x86/skylakex/frontend.json
new file mode 100644
index 000000000000..40abc0852cd6
--- /dev/null
+++ b/tools/perf/pmu-events/arch/x86/skylakex/frontend.json
@@ -0,0 +1,482 @@
1[
2 {
3 "EventCode": "0x79",
4 "UMask": "0x4",
5 "BriefDescription": "Uops delivered to Instruction Decode Queue (IDQ) from MITE path",
6 "Counter": "0,1,2,3",
7 "EventName": "IDQ.MITE_UOPS",
8 "PublicDescription": "Counts the number of uops delivered to Instruction Decode Queue (IDQ) from the MITE path. Counting includes uops that may 'bypass' the IDQ. This also means that uops are not being delivered from the Decode Stream Buffer (DSB).",
9 "SampleAfterValue": "2000003",
10 "CounterHTOff": "0,1,2,3,4,5,6,7"
11 },
12 {
13 "EventCode": "0x79",
14 "UMask": "0x4",
15 "BriefDescription": "Cycles when uops are being delivered to Instruction Decode Queue (IDQ) from MITE path",
16 "Counter": "0,1,2,3",
17 "EventName": "IDQ.MITE_CYCLES",
18 "CounterMask": "1",
19 "PublicDescription": "Counts cycles during which uops are being delivered to Instruction Decode Queue (IDQ) from the MITE path. Counting includes uops that may 'bypass' the IDQ.",
20 "SampleAfterValue": "2000003",
21 "CounterHTOff": "0,1,2,3,4,5,6,7"
22 },
23 {
24 "EventCode": "0x79",
25 "UMask": "0x8",
26 "BriefDescription": "Uops delivered to Instruction Decode Queue (IDQ) from the Decode Stream Buffer (DSB) path",
27 "Counter": "0,1,2,3",
28 "EventName": "IDQ.DSB_UOPS",
29 "PublicDescription": "Counts the number of uops delivered to Instruction Decode Queue (IDQ) from the Decode Stream Buffer (DSB) path. Counting includes uops that may 'bypass' the IDQ.",
30 "SampleAfterValue": "2000003",
31 "CounterHTOff": "0,1,2,3,4,5,6,7"
32 },
33 {
34 "EventCode": "0x79",
35 "UMask": "0x8",
36 "BriefDescription": "Cycles when uops are being delivered to Instruction Decode Queue (IDQ) from Decode Stream Buffer (DSB) path",
37 "Counter": "0,1,2,3",
38 "EventName": "IDQ.DSB_CYCLES",
39 "CounterMask": "1",
40 "PublicDescription": "Counts cycles during which uops are being delivered to Instruction Decode Queue (IDQ) from the Decode Stream Buffer (DSB) path. Counting includes uops that may 'bypass' the IDQ.",
41 "SampleAfterValue": "2000003",
42 "CounterHTOff": "0,1,2,3,4,5,6,7"
43 },
44 {
45 "EventCode": "0x79",
46 "UMask": "0x10",
47 "BriefDescription": "Cycles when uops initiated by Decode Stream Buffer (DSB) are being delivered to Instruction Decode Queue (IDQ) while Microcode Sequenser (MS) is busy",
48 "Counter": "0,1,2,3",
49 "EventName": "IDQ.MS_DSB_CYCLES",
50 "CounterMask": "1",
51 "PublicDescription": "Counts cycles during which uops initiated by Decode Stream Buffer (DSB) are being delivered to Instruction Decode Queue (IDQ) while the Microcode Sequencer (MS) is busy. Counting includes uops that may 'bypass' the IDQ.",
52 "SampleAfterValue": "2000003",
53 "CounterHTOff": "0,1,2,3,4,5,6,7"
54 },
55 {
56 "EventCode": "0x79",
57 "UMask": "0x18",
58 "BriefDescription": "Cycles Decode Stream Buffer (DSB) is delivering 4 Uops",
59 "Counter": "0,1,2,3",
60 "EventName": "IDQ.ALL_DSB_CYCLES_4_UOPS",
61 "CounterMask": "4",
62 "PublicDescription": "Counts the number of cycles 4 uops were delivered to Instruction Decode Queue (IDQ) from the Decode Stream Buffer (DSB) path. Count includes uops that may 'bypass' the IDQ.",
63 "SampleAfterValue": "2000003",
64 "CounterHTOff": "0,1,2,3,4,5,6,7"
65 },
66 {
67 "EventCode": "0x79",
68 "UMask": "0x18",
69 "BriefDescription": "Cycles Decode Stream Buffer (DSB) is delivering any Uop",
70 "Counter": "0,1,2,3",
71 "EventName": "IDQ.ALL_DSB_CYCLES_ANY_UOPS",
72 "CounterMask": "1",
73 "PublicDescription": "Counts the number of cycles uops were delivered to Instruction Decode Queue (IDQ) from the Decode Stream Buffer (DSB) path. Count includes uops that may 'bypass' the IDQ.",
74 "SampleAfterValue": "2000003",
75 "CounterHTOff": "0,1,2,3,4,5,6,7"
76 },
77 {
78 "EventCode": "0x79",
79 "UMask": "0x20",
80 "BriefDescription": "Uops initiated by MITE and delivered to Instruction Decode Queue (IDQ) while Microcode Sequenser (MS) is busy",
81 "Counter": "0,1,2,3",
82 "EventName": "IDQ.MS_MITE_UOPS",
83 "PublicDescription": "Counts the number of uops initiated by MITE and delivered to Instruction Decode Queue (IDQ) while the Microcode Sequencer (MS) is busy. Counting includes uops that may 'bypass' the IDQ.",
84 "SampleAfterValue": "2000003",
85 "CounterHTOff": "0,1,2,3,4,5,6,7"
86 },
87 {
88 "EventCode": "0x79",
89 "UMask": "0x24",
90 "BriefDescription": "Cycles MITE is delivering 4 Uops",
91 "Counter": "0,1,2,3",
92 "EventName": "IDQ.ALL_MITE_CYCLES_4_UOPS",
93 "CounterMask": "4",
94 "PublicDescription": "Counts the number of cycles 4 uops were delivered to the Instruction Decode Queue (IDQ) from the MITE (legacy decode pipeline) path. Counting includes uops that may 'bypass' the IDQ. During these cycles uops are not being delivered from the Decode Stream Buffer (DSB).",
95 "SampleAfterValue": "2000003",
96 "CounterHTOff": "0,1,2,3,4,5,6,7"
97 },
98 {
99 "EventCode": "0x79",
100 "UMask": "0x24",
101 "BriefDescription": "Cycles MITE is delivering any Uop",
102 "Counter": "0,1,2,3",
103 "EventName": "IDQ.ALL_MITE_CYCLES_ANY_UOPS",
104 "CounterMask": "1",
105 "PublicDescription": "Counts the number of cycles uops were delivered to the Instruction Decode Queue (IDQ) from the MITE (legacy decode pipeline) path. Counting includes uops that may 'bypass' the IDQ. During these cycles uops are not being delivered from the Decode Stream Buffer (DSB).",
106 "SampleAfterValue": "2000003",
107 "CounterHTOff": "0,1,2,3,4,5,6,7"
108 },
109 {
110 "EventCode": "0x79",
111 "UMask": "0x30",
112 "BriefDescription": "Cycles when uops are being delivered to Instruction Decode Queue (IDQ) while Microcode Sequenser (MS) is busy",
113 "Counter": "0,1,2,3",
114 "EventName": "IDQ.MS_CYCLES",
115 "CounterMask": "1",
116 "PublicDescription": "Counts cycles during which uops are being delivered to Instruction Decode Queue (IDQ) while the Microcode Sequencer (MS) is busy. Counting includes uops that may 'bypass' the IDQ. Uops maybe initiated by Decode Stream Buffer (DSB) or MITE.",
117 "SampleAfterValue": "2000003",
118 "CounterHTOff": "0,1,2,3,4,5,6,7"
119 },
120 {
121 "EdgeDetect": "1",
122 "EventCode": "0x79",
123 "UMask": "0x30",
124 "BriefDescription": "Number of switches from DSB (Decode Stream Buffer) or MITE (legacy decode pipeline) to the Microcode Sequencer",
125 "Counter": "0,1,2,3",
126 "EventName": "IDQ.MS_SWITCHES",
127 "CounterMask": "1",
128 "PublicDescription": "Number of switches from DSB (Decode Stream Buffer) or MITE (legacy decode pipeline) to the Microcode Sequencer.",
129 "SampleAfterValue": "2000003",
130 "CounterHTOff": "0,1,2,3,4,5,6,7"
131 },
132 {
133 "EventCode": "0x79",
134 "UMask": "0x30",
135 "BriefDescription": "Uops delivered to Instruction Decode Queue (IDQ) while Microcode Sequenser (MS) is busy",
136 "Counter": "0,1,2,3",
137 "EventName": "IDQ.MS_UOPS",
138 "PublicDescription": "Counts the total number of uops delivered by the Microcode Sequencer (MS). Any instruction over 4 uops will be delivered by the MS. Some instructions such as transcendentals may additionally generate uops from the MS.",
139 "SampleAfterValue": "2000003",
140 "CounterHTOff": "0,1,2,3,4,5,6,7"
141 },
142 {
143 "EventCode": "0x80",
144 "UMask": "0x4",
145 "BriefDescription": "Cycles where a code fetch is stalled due to L1 instruction cache miss.",
146 "Counter": "0,1,2,3",
147 "EventName": "ICACHE_16B.IFDATA_STALL",
148 "PublicDescription": "Cycles where a code line fetch is stalled due to an L1 instruction cache miss. The legacy decode pipeline works at a 16 Byte granularity.",
149 "SampleAfterValue": "2000003",
150 "CounterHTOff": "0,1,2,3,4,5,6,7"
151 },
152 {
153 "EventCode": "0x83",
154 "UMask": "0x1",
155 "BriefDescription": "Instruction fetch tag lookups that hit in the instruction cache (L1I). Counts at 64-byte cache-line granularity.",
156 "Counter": "0,1,2,3",
157 "EventName": "ICACHE_64B.IFTAG_HIT",
158 "SampleAfterValue": "200003",
159 "CounterHTOff": "0,1,2,3,4,5,6,7"
160 },
161 {
162 "EventCode": "0x83",
163 "UMask": "0x2",
164 "BriefDescription": "Instruction fetch tag lookups that miss in the instruction cache (L1I). Counts at 64-byte cache-line granularity.",
165 "Counter": "0,1,2,3",
166 "EventName": "ICACHE_64B.IFTAG_MISS",
167 "SampleAfterValue": "200003",
168 "CounterHTOff": "0,1,2,3,4,5,6,7"
169 },
170 {
171 "EventCode": "0x83",
172 "UMask": "0x4",
173 "BriefDescription": "Cycles where a code fetch is stalled due to L1 instruction cache tag miss.",
174 "Counter": "0,1,2,3",
175 "EventName": "ICACHE_64B.IFTAG_STALL",
176 "SampleAfterValue": "200003",
177 "CounterHTOff": "0,1,2,3,4,5,6,7"
178 },
179 {
180 "EventCode": "0x9C",
181 "UMask": "0x1",
182 "BriefDescription": "Uops not delivered to Resource Allocation Table (RAT) per thread when backend of the machine is not stalled",
183 "Counter": "0,1,2,3",
184 "EventName": "IDQ_UOPS_NOT_DELIVERED.CORE",
185 "PublicDescription": "Counts the number of uops not delivered to Resource Allocation Table (RAT) per thread adding \u201c4 \u2013 x\u201d when Resource Allocation Table (RAT) is not stalled and Instruction Decode Queue (IDQ) delivers x uops to Resource Allocation Table (RAT) (where x belongs to {0,1,2,3}). Counting does not cover cases when: a. IDQ-Resource Allocation Table (RAT) pipe serves the other thread. b. Resource Allocation Table (RAT) is stalled for the thread (including uop drops and clear BE conditions). c. Instruction Decode Queue (IDQ) delivers four uops.",
186 "SampleAfterValue": "2000003",
187 "CounterHTOff": "0,1,2,3,4,5,6,7"
188 },
189 {
190 "EventCode": "0x9C",
191 "UMask": "0x1",
192 "BriefDescription": "Cycles per thread when 4 or more uops are not delivered to Resource Allocation Table (RAT) when backend of the machine is not stalled",
193 "Counter": "0,1,2,3",
194 "EventName": "IDQ_UOPS_NOT_DELIVERED.CYCLES_0_UOPS_DELIV.CORE",
195 "CounterMask": "4",
196 "PublicDescription": "Counts, on the per-thread basis, cycles when no uops are delivered to Resource Allocation Table (RAT). IDQ_Uops_Not_Delivered.core =4.",
197 "SampleAfterValue": "2000003",
198 "CounterHTOff": "0,1,2,3,4,5,6,7"
199 },
200 {
201 "EventCode": "0x9C",
202 "UMask": "0x1",
203 "BriefDescription": "Cycles per thread when 3 or more uops are not delivered to Resource Allocation Table (RAT) when backend of the machine is not stalled",
204 "Counter": "0,1,2,3",
205 "EventName": "IDQ_UOPS_NOT_DELIVERED.CYCLES_LE_1_UOP_DELIV.CORE",
206 "CounterMask": "3",
207 "PublicDescription": "Counts, on the per-thread basis, cycles when less than 1 uop is delivered to Resource Allocation Table (RAT). IDQ_Uops_Not_Delivered.core >= 3.",
208 "SampleAfterValue": "2000003",
209 "CounterHTOff": "0,1,2,3,4,5,6,7"
210 },
211 {
212 "EventCode": "0x9C",
213 "UMask": "0x1",
214 "BriefDescription": "Cycles with less than 2 uops delivered by the front end.",
215 "Counter": "0,1,2,3",
216 "EventName": "IDQ_UOPS_NOT_DELIVERED.CYCLES_LE_2_UOP_DELIV.CORE",
217 "CounterMask": "2",
218 "PublicDescription": "Cycles with less than 2 uops delivered by the front-end.",
219 "SampleAfterValue": "2000003",
220 "CounterHTOff": "0,1,2,3,4,5,6,7"
221 },
222 {
223 "EventCode": "0x9C",
224 "UMask": "0x1",
225 "BriefDescription": "Cycles with less than 3 uops delivered by the front end.",
226 "Counter": "0,1,2,3",
227 "EventName": "IDQ_UOPS_NOT_DELIVERED.CYCLES_LE_3_UOP_DELIV.CORE",
228 "CounterMask": "1",
229 "PublicDescription": "Cycles with less than 3 uops delivered by the front-end.",
230 "SampleAfterValue": "2000003",
231 "CounterHTOff": "0,1,2,3,4,5,6,7"
232 },
233 {
234 "Invert": "1",
235 "EventCode": "0x9C",
236 "UMask": "0x1",
237 "BriefDescription": "Counts cycles FE delivered 4 uops or Resource Allocation Table (RAT) was stalling FE.",
238 "Counter": "0,1,2,3",
239 "EventName": "IDQ_UOPS_NOT_DELIVERED.CYCLES_FE_WAS_OK",
240 "CounterMask": "1",
241 "SampleAfterValue": "2000003",
242 "CounterHTOff": "0,1,2,3,4,5,6,7"
243 },
244 {
245 "EventCode": "0xAB",
246 "UMask": "0x2",
247 "BriefDescription": "Decode Stream Buffer (DSB)-to-MITE switch true penalty cycles.",
248 "Counter": "0,1,2,3",
249 "EventName": "DSB2MITE_SWITCHES.PENALTY_CYCLES",
250 "PublicDescription": "Counts Decode Stream Buffer (DSB)-to-MITE switch true penalty cycles. These cycles do not include uops routed through because of the switch itself, for example, when Instruction Decode Queue (IDQ) pre-allocation is unavailable, or Instruction Decode Queue (IDQ) is full. SBD-to-MITE switch true penalty cycles happen after the merge mux (MM) receives Decode Stream Buffer (DSB) Sync-indication until receiving the first MITE uop. MM is placed before Instruction Decode Queue (IDQ) to merge uops being fed from the MITE and Decode Stream Buffer (DSB) paths. Decode Stream Buffer (DSB) inserts the Sync-indication whenever a Decode Stream Buffer (DSB)-to-MITE switch occurs.Penalty: A Decode Stream Buffer (DSB) hit followed by a Decode Stream Buffer (DSB) miss can cost up to six cycles in which no uops are delivered to the IDQ. Most often, such switches from the Decode Stream Buffer (DSB) to the legacy pipeline cost 0\u20132 cycles.",
251 "SampleAfterValue": "2000003",
252 "CounterHTOff": "0,1,2,3,4,5,6,7"
253 },
254 {
255 "EventCode": "0xC6",
256 "UMask": "0x1",
257 "BriefDescription": "Retired Instructions who experienced decode stream buffer (DSB - the decoded instruction-cache) miss.",
258 "PEBS": "1",
259 "MSRValue": "0x11",
260 "Counter": "0,1,2,3",
261 "EventName": "FRONTEND_RETIRED.DSB_MISS",
262 "MSRIndex": "0x3F7",
263 "PublicDescription": "Counts retired Instructions that experienced DSB (Decode stream buffer i.e. the decoded instruction-cache) miss. ",
264 "TakenAlone": "1",
265 "SampleAfterValue": "100007",
266 "CounterHTOff": "0,1,2,3"
267 },
268 {
269 "EventCode": "0xC6",
270 "UMask": "0x1",
271 "BriefDescription": "Retired Instructions who experienced Instruction L1 Cache true miss.",
272 "PEBS": "1",
273 "MSRValue": "0x12",
274 "Counter": "0,1,2,3",
275 "EventName": "FRONTEND_RETIRED.L1I_MISS",
276 "MSRIndex": "0x3F7",
277 "TakenAlone": "1",
278 "SampleAfterValue": "100007",
279 "CounterHTOff": "0,1,2,3"
280 },
281 {
282 "EventCode": "0xC6",
283 "UMask": "0x1",
284 "BriefDescription": "Retired Instructions who experienced Instruction L2 Cache true miss.",
285 "PEBS": "1",
286 "MSRValue": "0x13",
287 "Counter": "0,1,2,3",
288 "EventName": "FRONTEND_RETIRED.L2_MISS",
289 "MSRIndex": "0x3F7",
290 "TakenAlone": "1",
291 "SampleAfterValue": "100007",
292 "CounterHTOff": "0,1,2,3"
293 },
294 {
295 "EventCode": "0xC6",
296 "UMask": "0x1",
297 "BriefDescription": "Retired Instructions who experienced iTLB true miss.",
298 "PEBS": "1",
299 "MSRValue": "0x14",
300 "Counter": "0,1,2,3",
301 "EventName": "FRONTEND_RETIRED.ITLB_MISS",
302 "MSRIndex": "0x3F7",
303 "PublicDescription": "Counts retired Instructions that experienced iTLB (Instruction TLB) true miss.",
304 "TakenAlone": "1",
305 "SampleAfterValue": "100007",
306 "CounterHTOff": "0,1,2,3"
307 },
308 {
309 "EventCode": "0xC6",
310 "UMask": "0x1",
311 "BriefDescription": "Retired Instructions who experienced STLB (2nd level TLB) true miss.",
312 "PEBS": "1",
313 "MSRValue": "0x15",
314 "Counter": "0,1,2,3",
315 "EventName": "FRONTEND_RETIRED.STLB_MISS",
316 "MSRIndex": "0x3F7",
317 "PublicDescription": "Counts retired Instructions that experienced STLB (2nd level TLB) true miss. ",
318 "TakenAlone": "1",
319 "SampleAfterValue": "100007",
320 "CounterHTOff": "0,1,2,3"
321 },
322 {
323 "EventCode": "0xC6",
324 "UMask": "0x1",
325 "BriefDescription": "Retired instructions that are fetched after an interval where the front-end delivered no uops for a period of 2 cycles which was not interrupted by a back-end stall.",
326 "PEBS": "1",
327 "MSRValue": "0x400206",
328 "Counter": "0,1,2,3",
329 "EventName": "FRONTEND_RETIRED.LATENCY_GE_2",
330 "MSRIndex": "0x3F7",
331 "TakenAlone": "1",
332 "SampleAfterValue": "100007",
333 "CounterHTOff": "0,1,2,3"
334 },
335 {
336 "EventCode": "0xC6",
337 "UMask": "0x1",
338 "BriefDescription": "Retired instructions that are fetched after an interval where the front-end had at least 2 bubble-slots for a period of 2 cycles which was not interrupted by a back-end stall.",
339 "PEBS": "1",
340 "MSRValue": "0x200206",
341 "Counter": "0,1,2,3",
342 "EventName": "FRONTEND_RETIRED.LATENCY_GE_2_BUBBLES_GE_2",
343 "MSRIndex": "0x3F7",
344 "TakenAlone": "1",
345 "SampleAfterValue": "100007",
346 "CounterHTOff": "0,1,2,3"
347 },
348 {
349 "EventCode": "0xC6",
350 "UMask": "0x1",
351 "BriefDescription": "Retired instructions that are fetched after an interval where the front-end delivered no uops for a period of 4 cycles which was not interrupted by a back-end stall.",
352 "PEBS": "1",
353 "MSRValue": "0x400406",
354 "Counter": "0,1,2,3",
355 "EventName": "FRONTEND_RETIRED.LATENCY_GE_4",
356 "MSRIndex": "0x3F7",
357 "TakenAlone": "1",
358 "SampleAfterValue": "100007",
359 "CounterHTOff": "0,1,2,3"
360 },
361 {
362 "EventCode": "0xC6",
363 "UMask": "0x1",
364 "BriefDescription": "Retired instructions that are fetched after an interval where the front-end delivered no uops for a period of 8 cycles which was not interrupted by a back-end stall.",
365 "PEBS": "1",
366 "MSRValue": "0x400806",
367 "Counter": "0,1,2,3",
368 "EventName": "FRONTEND_RETIRED.LATENCY_GE_8",
369 "MSRIndex": "0x3F7",
370 "PublicDescription": "Counts retired instructions that are delivered to the back-end after a front-end stall of at least 8 cycles. During this period the front-end delivered no uops.",
371 "TakenAlone": "1",
372 "SampleAfterValue": "100007",
373 "CounterHTOff": "0,1,2,3"
374 },
375 {
376 "EventCode": "0xC6",
377 "UMask": "0x1",
378 "BriefDescription": "Retired instructions that are fetched after an interval where the front-end delivered no uops for a period of 16 cycles which was not interrupted by a back-end stall.",
379 "PEBS": "1",
380 "MSRValue": "0x401006",
381 "Counter": "0,1,2,3",
382 "EventName": "FRONTEND_RETIRED.LATENCY_GE_16",
383 "MSRIndex": "0x3F7",
384 "PublicDescription": "Counts retired instructions that are delivered to the back-end after a front-end stall of at least 16 cycles. During this period the front-end delivered no uops.",
385 "TakenAlone": "1",
386 "SampleAfterValue": "100007",
387 "CounterHTOff": "0,1,2,3"
388 },
389 {
390 "EventCode": "0xC6",
391 "UMask": "0x1",
392 "BriefDescription": "Retired instructions that are fetched after an interval where the front-end delivered no uops for a period of 32 cycles which was not interrupted by a back-end stall.",
393 "PEBS": "1",
394 "MSRValue": "0x402006",
395 "Counter": "0,1,2,3",
396 "EventName": "FRONTEND_RETIRED.LATENCY_GE_32",
397 "MSRIndex": "0x3F7",
398 "PublicDescription": "Counts retired instructions that are delivered to the back-end after a front-end stall of at least 32 cycles. During this period the front-end delivered no uops.",
399 "TakenAlone": "1",
400 "SampleAfterValue": "100007",
401 "CounterHTOff": "0,1,2,3"
402 },
403 {
404 "EventCode": "0xC6",
405 "UMask": "0x1",
406 "BriefDescription": "Retired instructions that are fetched after an interval where the front-end delivered no uops for a period of 64 cycles which was not interrupted by a back-end stall.",
407 "PEBS": "1",
408 "MSRValue": "0x404006",
409 "Counter": "0,1,2,3",
410 "EventName": "FRONTEND_RETIRED.LATENCY_GE_64",
411 "MSRIndex": "0x3F7",
412 "TakenAlone": "1",
413 "SampleAfterValue": "100007",
414 "CounterHTOff": "0,1,2,3"
415 },
416 {
417 "EventCode": "0xC6",
418 "UMask": "0x1",
419 "BriefDescription": "Retired instructions that are fetched after an interval where the front-end delivered no uops for a period of 128 cycles which was not interrupted by a back-end stall.",
420 "PEBS": "1",
421 "MSRValue": "0x408006",
422 "Counter": "0,1,2,3",
423 "EventName": "FRONTEND_RETIRED.LATENCY_GE_128",
424 "MSRIndex": "0x3F7",
425 "TakenAlone": "1",
426 "SampleAfterValue": "100007",
427 "CounterHTOff": "0,1,2,3"
428 },
429 {
430 "EventCode": "0xC6",
431 "UMask": "0x1",
432 "BriefDescription": "Retired instructions that are fetched after an interval where the front-end delivered no uops for a period of 256 cycles which was not interrupted by a back-end stall.",
433 "PEBS": "1",
434 "MSRValue": "0x410006",
435 "Counter": "0,1,2,3",
436 "EventName": "FRONTEND_RETIRED.LATENCY_GE_256",
437 "MSRIndex": "0x3F7",
438 "TakenAlone": "1",
439 "SampleAfterValue": "100007",
440 "CounterHTOff": "0,1,2,3"
441 },
442 {
443 "EventCode": "0xC6",
444 "UMask": "0x1",
445 "BriefDescription": "Retired instructions that are fetched after an interval where the front-end delivered no uops for a period of 512 cycles which was not interrupted by a back-end stall.",
446 "PEBS": "1",
447 "MSRValue": "0x420006",
448 "Counter": "0,1,2,3",
449 "EventName": "FRONTEND_RETIRED.LATENCY_GE_512",
450 "MSRIndex": "0x3F7",
451 "TakenAlone": "1",
452 "SampleAfterValue": "100007",
453 "CounterHTOff": "0,1,2,3"
454 },
455 {
456 "EventCode": "0xC6",
457 "UMask": "0x1",
458 "BriefDescription": "Retired instructions that are fetched after an interval where the front-end had at least 1 bubble-slot for a period of 2 cycles which was not interrupted by a back-end stall.",
459 "PEBS": "1",
460 "MSRValue": "0x100206",
461 "Counter": "0,1,2,3",
462 "EventName": "FRONTEND_RETIRED.LATENCY_GE_2_BUBBLES_GE_1",
463 "MSRIndex": "0x3F7",
464 "PublicDescription": "Counts retired instructions that are delivered to the back-end after the front-end had at least 1 bubble-slot for a period of 2 cycles. A bubble-slot is an empty issue-pipeline slot while there was no RAT stall.",
465 "TakenAlone": "1",
466 "SampleAfterValue": "100007",
467 "CounterHTOff": "0,1,2,3"
468 },
469 {
470 "EventCode": "0xC6",
471 "UMask": "0x1",
472 "BriefDescription": "Retired instructions that are fetched after an interval where the front-end had at least 3 bubble-slots for a period of 2 cycles which was not interrupted by a back-end stall.",
473 "PEBS": "1",
474 "MSRValue": "0x300206",
475 "Counter": "0,1,2,3",
476 "EventName": "FRONTEND_RETIRED.LATENCY_GE_2_BUBBLES_GE_3",
477 "MSRIndex": "0x3F7",
478 "TakenAlone": "1",
479 "SampleAfterValue": "100007",
480 "CounterHTOff": "0,1,2,3"
481 }
482] \ No newline at end of file
diff --git a/tools/perf/pmu-events/arch/x86/skylakex/memory.json b/tools/perf/pmu-events/arch/x86/skylakex/memory.json
new file mode 100644
index 000000000000..ca22a22c1abd
--- /dev/null
+++ b/tools/perf/pmu-events/arch/x86/skylakex/memory.json
@@ -0,0 +1,1396 @@
1[
2 {
3 "EventCode": "0x54",
4 "UMask": "0x1",
5 "BriefDescription": "Number of times a transactional abort was signaled due to a data conflict on a transactionally accessed address",
6 "Counter": "0,1,2,3",
7 "EventName": "TX_MEM.ABORT_CONFLICT",
8 "PublicDescription": "Number of times a TSX line had a cache conflict.",
9 "SampleAfterValue": "2000003",
10 "CounterHTOff": "0,1,2,3,4,5,6,7"
11 },
12 {
13 "EventCode": "0x54",
14 "UMask": "0x2",
15 "BriefDescription": "Number of times a transactional abort was signaled due to a data capacity limitation for transactional reads or writes.",
16 "Counter": "0,1,2,3",
17 "EventName": "TX_MEM.ABORT_CAPACITY",
18 "SampleAfterValue": "2000003",
19 "CounterHTOff": "0,1,2,3,4,5,6,7"
20 },
21 {
22 "EventCode": "0x54",
23 "UMask": "0x4",
24 "BriefDescription": "Number of times a HLE transactional region aborted due to a non XRELEASE prefixed instruction writing to an elided lock in the elision buffer",
25 "Counter": "0,1,2,3",
26 "EventName": "TX_MEM.ABORT_HLE_STORE_TO_ELIDED_LOCK",
27 "PublicDescription": "Number of times a TSX Abort was triggered due to a non-release/commit store to lock.",
28 "SampleAfterValue": "2000003",
29 "CounterHTOff": "0,1,2,3,4,5,6,7"
30 },
31 {
32 "EventCode": "0x54",
33 "UMask": "0x8",
34 "BriefDescription": "Number of times an HLE transactional execution aborted due to NoAllocatedElisionBuffer being non-zero.",
35 "Counter": "0,1,2,3",
36 "EventName": "TX_MEM.ABORT_HLE_ELISION_BUFFER_NOT_EMPTY",
37 "PublicDescription": "Number of times a TSX Abort was triggered due to commit but Lock Buffer not empty.",
38 "SampleAfterValue": "2000003",
39 "CounterHTOff": "0,1,2,3,4,5,6,7"
40 },
41 {
42 "EventCode": "0x54",
43 "UMask": "0x10",
44 "BriefDescription": "Number of times an HLE transactional execution aborted due to XRELEASE lock not satisfying the address and value requirements in the elision buffer",
45 "Counter": "0,1,2,3",
46 "EventName": "TX_MEM.ABORT_HLE_ELISION_BUFFER_MISMATCH",
47 "PublicDescription": "Number of times a TSX Abort was triggered due to release/commit but data and address mismatch.",
48 "SampleAfterValue": "2000003",
49 "CounterHTOff": "0,1,2,3,4,5,6,7"
50 },
51 {
52 "EventCode": "0x54",
53 "UMask": "0x20",
54 "BriefDescription": "Number of times an HLE transactional execution aborted due to an unsupported read alignment from the elision buffer.",
55 "Counter": "0,1,2,3",
56 "EventName": "TX_MEM.ABORT_HLE_ELISION_BUFFER_UNSUPPORTED_ALIGNMENT",
57 "PublicDescription": "Number of times a TSX Abort was triggered due to attempting an unsupported alignment from Lock Buffer.",
58 "SampleAfterValue": "2000003",
59 "CounterHTOff": "0,1,2,3,4,5,6,7"
60 },
61 {
62 "EventCode": "0x54",
63 "UMask": "0x40",
64 "BriefDescription": "Number of times HLE lock could not be elided due to ElisionBufferAvailable being zero.",
65 "Counter": "0,1,2,3",
66 "EventName": "TX_MEM.HLE_ELISION_BUFFER_FULL",
67 "PublicDescription": "Number of times we could not allocate Lock Buffer.",
68 "SampleAfterValue": "2000003",
69 "CounterHTOff": "0,1,2,3,4,5,6,7"
70 },
71 {
72 "EventCode": "0x5d",
73 "UMask": "0x1",
74 "BriefDescription": "Counts the number of times a class of instructions that may cause a transactional abort was executed. Since this is the count of execution, it may not always cause a transactional abort.",
75 "Counter": "0,1,2,3",
76 "EventName": "TX_EXEC.MISC1",
77 "SampleAfterValue": "2000003",
78 "CounterHTOff": "0,1,2,3,4,5,6,7"
79 },
80 {
81 "EventCode": "0x5d",
82 "UMask": "0x2",
83 "BriefDescription": "Counts the number of times a class of instructions (e.g., vzeroupper) that may cause a transactional abort was executed inside a transactional region",
84 "Counter": "0,1,2,3",
85 "EventName": "TX_EXEC.MISC2",
86 "PublicDescription": "Unfriendly TSX abort triggered by a vzeroupper instruction.",
87 "SampleAfterValue": "2000003",
88 "CounterHTOff": "0,1,2,3,4,5,6,7"
89 },
90 {
91 "EventCode": "0x5d",
92 "UMask": "0x4",
93 "BriefDescription": "Counts the number of times an instruction execution caused the transactional nest count supported to be exceeded",
94 "Counter": "0,1,2,3",
95 "EventName": "TX_EXEC.MISC3",
96 "PublicDescription": "Unfriendly TSX abort triggered by a nest count that is too deep.",
97 "SampleAfterValue": "2000003",
98 "CounterHTOff": "0,1,2,3,4,5,6,7"
99 },
100 {
101 "EventCode": "0x5d",
102 "UMask": "0x8",
103 "BriefDescription": "Counts the number of times a XBEGIN instruction was executed inside an HLE transactional region.",
104 "Counter": "0,1,2,3",
105 "EventName": "TX_EXEC.MISC4",
106 "PublicDescription": "RTM region detected inside HLE.",
107 "SampleAfterValue": "2000003",
108 "CounterHTOff": "0,1,2,3,4,5,6,7"
109 },
110 {
111 "EventCode": "0x5d",
112 "UMask": "0x10",
113 "BriefDescription": "Counts the number of times an HLE XACQUIRE instruction was executed inside an RTM transactional region",
114 "Counter": "0,1,2,3",
115 "EventName": "TX_EXEC.MISC5",
116 "PublicDescription": "Counts the number of times an HLE XACQUIRE instruction was executed inside an RTM transactional region.",
117 "SampleAfterValue": "2000003",
118 "CounterHTOff": "0,1,2,3,4,5,6,7"
119 },
120 {
121 "EventCode": "0x60",
122 "UMask": "0x10",
123 "BriefDescription": "Counts number of Offcore outstanding Demand Data Read requests that miss L3 cache in the superQ every cycle.",
124 "Counter": "0,1,2,3",
125 "EventName": "OFFCORE_REQUESTS_OUTSTANDING.L3_MISS_DEMAND_DATA_RD",
126 "SampleAfterValue": "2000003",
127 "CounterHTOff": "0,1,2,3,4,5,6,7"
128 },
129 {
130 "EventCode": "0x60",
131 "UMask": "0x10",
132 "BriefDescription": "Cycles with at least 1 Demand Data Read requests who miss L3 cache in the superQ.",
133 "Counter": "0,1,2,3",
134 "EventName": "OFFCORE_REQUESTS_OUTSTANDING.CYCLES_WITH_L3_MISS_DEMAND_DATA_RD",
135 "CounterMask": "1",
136 "SampleAfterValue": "2000003",
137 "CounterHTOff": "0,1,2,3,4,5,6,7"
138 },
139 {
140 "EventCode": "0x60",
141 "UMask": "0x10",
142 "BriefDescription": "Cycles with at least 6 Demand Data Read requests that miss L3 cache in the superQ.",
143 "Counter": "0,1,2,3",
144 "EventName": "OFFCORE_REQUESTS_OUTSTANDING.L3_MISS_DEMAND_DATA_RD_GE_6",
145 "CounterMask": "6",
146 "SampleAfterValue": "2000003",
147 "CounterHTOff": "0,1,2,3,4,5,6,7"
148 },
149 {
150 "EventCode": "0xA3",
151 "UMask": "0x2",
152 "BriefDescription": "Cycles while L3 cache miss demand load is outstanding.",
153 "Counter": "0,1,2,3",
154 "EventName": "CYCLE_ACTIVITY.CYCLES_L3_MISS",
155 "CounterMask": "2",
156 "SampleAfterValue": "2000003",
157 "CounterHTOff": "0,1,2,3,4,5,6,7"
158 },
159 {
160 "EventCode": "0xA3",
161 "UMask": "0x6",
162 "BriefDescription": "Execution stalls while L3 cache miss demand load is outstanding.",
163 "Counter": "0,1,2,3",
164 "EventName": "CYCLE_ACTIVITY.STALLS_L3_MISS",
165 "CounterMask": "6",
166 "SampleAfterValue": "2000003",
167 "CounterHTOff": "0,1,2,3,4,5,6,7"
168 },
169 {
170 "EventCode": "0xB0",
171 "UMask": "0x10",
172 "BriefDescription": "Demand Data Read requests who miss L3 cache",
173 "Counter": "0,1,2,3",
174 "EventName": "OFFCORE_REQUESTS.L3_MISS_DEMAND_DATA_RD",
175 "PublicDescription": "Demand Data Read requests who miss L3 cache.",
176 "SampleAfterValue": "100003",
177 "CounterHTOff": "0,1,2,3,4,5,6,7"
178 },
179 {
180 "EventCode": "0xC3",
181 "UMask": "0x2",
182 "BriefDescription": "Counts the number of machine clears due to memory order conflicts.",
183 "Counter": "0,1,2,3",
184 "EventName": "MACHINE_CLEARS.MEMORY_ORDERING",
185 "Errata": "SKL089",
186 "PublicDescription": "Counts the number of memory ordering Machine Clears detected. Memory Ordering Machine Clears can result from one of the following:a. memory disambiguation,b. external snoop, orc. cross SMT-HW-thread snoop (stores) hitting load buffer.",
187 "SampleAfterValue": "100003",
188 "CounterHTOff": "0,1,2,3,4,5,6,7"
189 },
190 {
191 "EventCode": "0xC8",
192 "UMask": "0x1",
193 "BriefDescription": "Number of times an HLE execution started.",
194 "Counter": "0,1,2,3",
195 "EventName": "HLE_RETIRED.START",
196 "PublicDescription": "Number of times we entered an HLE region. Does not count nested transactions.",
197 "SampleAfterValue": "2000003",
198 "CounterHTOff": "0,1,2,3,4,5,6,7"
199 },
200 {
201 "EventCode": "0xC8",
202 "UMask": "0x2",
203 "BriefDescription": "Number of times an HLE execution successfully committed",
204 "Counter": "0,1,2,3",
205 "EventName": "HLE_RETIRED.COMMIT",
206 "PublicDescription": "Number of times HLE commit succeeded.",
207 "SampleAfterValue": "2000003",
208 "CounterHTOff": "0,1,2,3,4,5,6,7"
209 },
210 {
211 "EventCode": "0xC8",
212 "UMask": "0x4",
213 "BriefDescription": "Number of times an HLE execution aborted due to any reasons (multiple categories may count as one). ",
214 "PEBS": "1",
215 "Counter": "0,1,2,3",
216 "EventName": "HLE_RETIRED.ABORTED",
217 "PublicDescription": "Number of times HLE abort was triggered.",
218 "SampleAfterValue": "2000003",
219 "CounterHTOff": "0,1,2,3,4,5,6,7"
220 },
221 {
222 "EventCode": "0xC8",
223 "UMask": "0x8",
224 "BriefDescription": "Number of times an HLE execution aborted due to various memory events (e.g., read/write capacity and conflicts).",
225 "Counter": "0,1,2,3",
226 "EventName": "HLE_RETIRED.ABORTED_MEM",
227 "SampleAfterValue": "2000003",
228 "CounterHTOff": "0,1,2,3,4,5,6,7"
229 },
230 {
231 "EventCode": "0xC8",
232 "UMask": "0x10",
233 "BriefDescription": "Number of times an HLE execution aborted due to hardware timer expiration.",
234 "Counter": "0,1,2,3",
235 "EventName": "HLE_RETIRED.ABORTED_TIMER",
236 "SampleAfterValue": "2000003",
237 "CounterHTOff": "0,1,2,3,4,5,6,7"
238 },
239 {
240 "EventCode": "0xC8",
241 "UMask": "0x20",
242 "BriefDescription": "Number of times an HLE execution aborted due to HLE-unfriendly instructions and certain unfriendly events (such as AD assists etc.). ",
243 "Counter": "0,1,2,3",
244 "EventName": "HLE_RETIRED.ABORTED_UNFRIENDLY",
245 "PublicDescription": "Number of times an HLE execution aborted due to HLE-unfriendly instructions and certain unfriendly events (such as AD assists etc.).",
246 "SampleAfterValue": "2000003",
247 "CounterHTOff": "0,1,2,3,4,5,6,7"
248 },
249 {
250 "EventCode": "0xC8",
251 "UMask": "0x40",
252 "BriefDescription": "Number of times an HLE execution aborted due to incompatible memory type",
253 "Counter": "0,1,2,3",
254 "EventName": "HLE_RETIRED.ABORTED_MEMTYPE",
255 "PublicDescription": "Number of times an HLE execution aborted due to incompatible memory type.",
256 "SampleAfterValue": "2000003",
257 "CounterHTOff": "0,1,2,3,4,5,6,7"
258 },
259 {
260 "EventCode": "0xC8",
261 "UMask": "0x80",
262 "BriefDescription": "Number of times an HLE execution aborted due to unfriendly events (such as interrupts).",
263 "Counter": "0,1,2,3",
264 "EventName": "HLE_RETIRED.ABORTED_EVENTS",
265 "SampleAfterValue": "2000003",
266 "CounterHTOff": "0,1,2,3,4,5,6,7"
267 },
268 {
269 "EventCode": "0xC9",
270 "UMask": "0x1",
271 "BriefDescription": "Number of times an RTM execution started.",
272 "Counter": "0,1,2,3",
273 "EventName": "RTM_RETIRED.START",
274 "PublicDescription": "Number of times we entered an RTM region. Does not count nested transactions.",
275 "SampleAfterValue": "2000003",
276 "CounterHTOff": "0,1,2,3,4,5,6,7"
277 },
278 {
279 "EventCode": "0xC9",
280 "UMask": "0x2",
281 "BriefDescription": "Number of times an RTM execution successfully committed",
282 "Counter": "0,1,2,3",
283 "EventName": "RTM_RETIRED.COMMIT",
284 "PublicDescription": "Number of times RTM commit succeeded.",
285 "SampleAfterValue": "2000003",
286 "CounterHTOff": "0,1,2,3,4,5,6,7"
287 },
288 {
289 "EventCode": "0xC9",
290 "UMask": "0x4",
291 "BriefDescription": "Number of times an RTM execution aborted due to any reasons (multiple categories may count as one). ",
292 "PEBS": "1",
293 "Counter": "0,1,2,3",
294 "EventName": "RTM_RETIRED.ABORTED",
295 "PublicDescription": "Number of times RTM abort was triggered.",
296 "SampleAfterValue": "2000003",
297 "CounterHTOff": "0,1,2,3,4,5,6,7"
298 },
299 {
300 "EventCode": "0xC9",
301 "UMask": "0x8",
302 "BriefDescription": "Number of times an RTM execution aborted due to various memory events (e.g. read/write capacity and conflicts)",
303 "Counter": "0,1,2,3",
304 "EventName": "RTM_RETIRED.ABORTED_MEM",
305 "PublicDescription": "Number of times an RTM execution aborted due to various memory events (e.g. read/write capacity and conflicts).",
306 "SampleAfterValue": "2000003",
307 "CounterHTOff": "0,1,2,3,4,5,6,7"
308 },
309 {
310 "EventCode": "0xC9",
311 "UMask": "0x10",
312 "BriefDescription": "Number of times an RTM execution aborted due to uncommon conditions.",
313 "Counter": "0,1,2,3",
314 "EventName": "RTM_RETIRED.ABORTED_TIMER",
315 "SampleAfterValue": "2000003",
316 "CounterHTOff": "0,1,2,3,4,5,6,7"
317 },
318 {
319 "EventCode": "0xC9",
320 "UMask": "0x20",
321 "BriefDescription": "Number of times an RTM execution aborted due to HLE-unfriendly instructions",
322 "Counter": "0,1,2,3",
323 "EventName": "RTM_RETIRED.ABORTED_UNFRIENDLY",
324 "PublicDescription": "Number of times an RTM execution aborted due to HLE-unfriendly instructions.",
325 "SampleAfterValue": "2000003",
326 "CounterHTOff": "0,1,2,3,4,5,6,7"
327 },
328 {
329 "EventCode": "0xC9",
330 "UMask": "0x40",
331 "BriefDescription": "Number of times an RTM execution aborted due to incompatible memory type",
332 "Counter": "0,1,2,3",
333 "EventName": "RTM_RETIRED.ABORTED_MEMTYPE",
334 "PublicDescription": "Number of times an RTM execution aborted due to incompatible memory type.",
335 "SampleAfterValue": "2000003",
336 "CounterHTOff": "0,1,2,3,4,5,6,7"
337 },
338 {
339 "EventCode": "0xC9",
340 "UMask": "0x80",
341 "BriefDescription": "Number of times an RTM execution aborted due to none of the previous 4 categories (e.g. interrupt)",
342 "Counter": "0,1,2,3",
343 "EventName": "RTM_RETIRED.ABORTED_EVENTS",
344 "PublicDescription": "Number of times an RTM execution aborted due to none of the previous 4 categories (e.g. interrupt).",
345 "SampleAfterValue": "2000003",
346 "CounterHTOff": "0,1,2,3,4,5,6,7"
347 },
348 {
349 "EventCode": "0xCD",
350 "UMask": "0x1",
351 "BriefDescription": "Counts loads when the latency from first dispatch to completion is greater than 4 cycles.",
352 "PEBS": "2",
353 "MSRValue": "0x4",
354 "Counter": "0,1,2,3",
355 "EventName": "MEM_TRANS_RETIRED.LOAD_LATENCY_GT_4",
356 "MSRIndex": "0x3F6",
357 "PublicDescription": "Counts loads when the latency from first dispatch to completion is greater than 4 cycles. Reported latency may be longer than just the memory latency.",
358 "TakenAlone": "1",
359 "SampleAfterValue": "100003",
360 "CounterHTOff": "0,1,2,3"
361 },
362 {
363 "EventCode": "0xCD",
364 "UMask": "0x1",
365 "BriefDescription": "Counts loads when the latency from first dispatch to completion is greater than 8 cycles.",
366 "PEBS": "2",
367 "MSRValue": "0x8",
368 "Counter": "0,1,2,3",
369 "EventName": "MEM_TRANS_RETIRED.LOAD_LATENCY_GT_8",
370 "MSRIndex": "0x3F6",
371 "PublicDescription": "Counts loads when the latency from first dispatch to completion is greater than 8 cycles. Reported latency may be longer than just the memory latency.",
372 "TakenAlone": "1",
373 "SampleAfterValue": "50021",
374 "CounterHTOff": "0,1,2,3"
375 },
376 {
377 "EventCode": "0xCD",
378 "UMask": "0x1",
379 "BriefDescription": "Counts loads when the latency from first dispatch to completion is greater than 16 cycles.",
380 "PEBS": "2",
381 "MSRValue": "0x10",
382 "Counter": "0,1,2,3",
383 "EventName": "MEM_TRANS_RETIRED.LOAD_LATENCY_GT_16",
384 "MSRIndex": "0x3F6",
385 "PublicDescription": "Counts loads when the latency from first dispatch to completion is greater than 16 cycles. Reported latency may be longer than just the memory latency.",
386 "TakenAlone": "1",
387 "SampleAfterValue": "20011",
388 "CounterHTOff": "0,1,2,3"
389 },
390 {
391 "EventCode": "0xCD",
392 "UMask": "0x1",
393 "BriefDescription": "Counts loads when the latency from first dispatch to completion is greater than 32 cycles.",
394 "PEBS": "2",
395 "MSRValue": "0x20",
396 "Counter": "0,1,2,3",
397 "EventName": "MEM_TRANS_RETIRED.LOAD_LATENCY_GT_32",
398 "MSRIndex": "0x3F6",
399 "PublicDescription": "Counts loads when the latency from first dispatch to completion is greater than 32 cycles. Reported latency may be longer than just the memory latency.",
400 "TakenAlone": "1",
401 "SampleAfterValue": "100007",
402 "CounterHTOff": "0,1,2,3"
403 },
404 {
405 "EventCode": "0xCD",
406 "UMask": "0x1",
407 "BriefDescription": "Counts loads when the latency from first dispatch to completion is greater than 64 cycles.",
408 "PEBS": "2",
409 "MSRValue": "0x40",
410 "Counter": "0,1,2,3",
411 "EventName": "MEM_TRANS_RETIRED.LOAD_LATENCY_GT_64",
412 "MSRIndex": "0x3F6",
413 "PublicDescription": "Counts loads when the latency from first dispatch to completion is greater than 64 cycles. Reported latency may be longer than just the memory latency.",
414 "TakenAlone": "1",
415 "SampleAfterValue": "2003",
416 "CounterHTOff": "0,1,2,3"
417 },
418 {
419 "EventCode": "0xCD",
420 "UMask": "0x1",
421 "BriefDescription": "Counts loads when the latency from first dispatch to completion is greater than 128 cycles.",
422 "PEBS": "2",
423 "MSRValue": "0x80",
424 "Counter": "0,1,2,3",
425 "EventName": "MEM_TRANS_RETIRED.LOAD_LATENCY_GT_128",
426 "MSRIndex": "0x3F6",
427 "PublicDescription": "Counts loads when the latency from first dispatch to completion is greater than 128 cycles. Reported latency may be longer than just the memory latency.",
428 "TakenAlone": "1",
429 "SampleAfterValue": "1009",
430 "CounterHTOff": "0,1,2,3"
431 },
432 {
433 "EventCode": "0xCD",
434 "UMask": "0x1",
435 "BriefDescription": "Counts loads when the latency from first dispatch to completion is greater than 256 cycles.",
436 "PEBS": "2",
437 "MSRValue": "0x100",
438 "Counter": "0,1,2,3",
439 "EventName": "MEM_TRANS_RETIRED.LOAD_LATENCY_GT_256",
440 "MSRIndex": "0x3F6",
441 "PublicDescription": "Counts loads when the latency from first dispatch to completion is greater than 256 cycles. Reported latency may be longer than just the memory latency.",
442 "TakenAlone": "1",
443 "SampleAfterValue": "503",
444 "CounterHTOff": "0,1,2,3"
445 },
446 {
447 "EventCode": "0xCD",
448 "UMask": "0x1",
449 "BriefDescription": "Counts loads when the latency from first dispatch to completion is greater than 512 cycles.",
450 "PEBS": "2",
451 "MSRValue": "0x200",
452 "Counter": "0,1,2,3",
453 "EventName": "MEM_TRANS_RETIRED.LOAD_LATENCY_GT_512",
454 "MSRIndex": "0x3F6",
455 "PublicDescription": "Counts loads when the latency from first dispatch to completion is greater than 512 cycles. Reported latency may be longer than just the memory latency.",
456 "TakenAlone": "1",
457 "SampleAfterValue": "101",
458 "CounterHTOff": "0,1,2,3"
459 },
460 {
461 "Offcore": "1",
462 "EventCode": "0xB7, 0xBB",
463 "UMask": "0x1",
464 "BriefDescription": "Counts demand data reads that miss in the L3.",
465 "MSRValue": "0x3fbc000001 ",
466 "Counter": "0,1,2,3",
467 "EventName": "OFFCORE_RESPONSE.DEMAND_DATA_RD.L3_MISS.ANY_SNOOP",
468 "MSRIndex": "0x1a6,0x1a7",
469 "PublicDescription": "Counts demand data reads that miss in the L3. ",
470 "SampleAfterValue": "100003",
471 "CounterHTOff": "0,1,2,3"
472 },
473 {
474 "Offcore": "1",
475 "EventCode": "0xB7, 0xBB",
476 "UMask": "0x1",
477 "BriefDescription": "Counts demand data reads that miss the L3 and clean or shared data is transferred from remote cache.",
478 "MSRValue": "0x083fc00001 ",
479 "Counter": "0,1,2,3",
480 "EventName": "OFFCORE_RESPONSE.DEMAND_DATA_RD.L3_MISS.REMOTE_HIT_FORWARD",
481 "MSRIndex": "0x1a6,0x1a7",
482 "PublicDescription": "Counts demand data reads that miss the L3 and clean or shared data is transferred from remote cache. ",
483 "SampleAfterValue": "100003",
484 "CounterHTOff": "0,1,2,3"
485 },
486 {
487 "Offcore": "1",
488 "EventCode": "0xB7, 0xBB",
489 "UMask": "0x1",
490 "BriefDescription": "Counts demand data reads that miss the L3 and the modified data is transferred from remote cache.",
491 "MSRValue": "0x103fc00001 ",
492 "Counter": "0,1,2,3",
493 "EventName": "OFFCORE_RESPONSE.DEMAND_DATA_RD.L3_MISS.REMOTE_HITM",
494 "MSRIndex": "0x1a6,0x1a7",
495 "PublicDescription": "Counts demand data reads that miss the L3 and the modified data is transferred from remote cache. ",
496 "SampleAfterValue": "100003",
497 "CounterHTOff": "0,1,2,3"
498 },
499 {
500 "Offcore": "1",
501 "EventCode": "0xB7, 0xBB",
502 "UMask": "0x1",
503 "BriefDescription": "Counts demand data reads that miss the L3 and the data is returned from local or remote dram.",
504 "MSRValue": "0x063fc00001 ",
505 "Counter": "0,1,2,3",
506 "EventName": "OFFCORE_RESPONSE.DEMAND_DATA_RD.L3_MISS.SNOOP_MISS_OR_NO_FWD",
507 "MSRIndex": "0x1a6,0x1a7",
508 "PublicDescription": "Counts demand data reads that miss the L3 and the data is returned from local or remote dram. ",
509 "SampleAfterValue": "100003",
510 "CounterHTOff": "0,1,2,3"
511 },
512 {
513 "Offcore": "1",
514 "EventCode": "0xB7, 0xBB",
515 "UMask": "0x1",
516 "BriefDescription": "Counts demand data reads that miss the L3 and the data is returned from remote dram.",
517 "MSRValue": "0x063b800001 ",
518 "Counter": "0,1,2,3",
519 "EventName": "OFFCORE_RESPONSE.DEMAND_DATA_RD.L3_MISS_REMOTE_DRAM.SNOOP_MISS_OR_NO_FWD",
520 "MSRIndex": "0x1a6,0x1a7",
521 "PublicDescription": "Counts demand data reads that miss the L3 and the data is returned from remote dram. ",
522 "SampleAfterValue": "100003",
523 "CounterHTOff": "0,1,2,3"
524 },
525 {
526 "Offcore": "1",
527 "EventCode": "0xB7, 0xBB",
528 "UMask": "0x1",
529 "BriefDescription": "Counts demand data reads that miss the L3 and the data is returned from local dram.",
530 "MSRValue": "0x0604000001 ",
531 "Counter": "0,1,2,3",
532 "EventName": "OFFCORE_RESPONSE.DEMAND_DATA_RD.L3_MISS_LOCAL_DRAM.SNOOP_MISS_OR_NO_FWD",
533 "MSRIndex": "0x1a6,0x1a7",
534 "PublicDescription": "Counts demand data reads that miss the L3 and the data is returned from local dram. ",
535 "SampleAfterValue": "100003",
536 "CounterHTOff": "0,1,2,3"
537 },
538 {
539 "Offcore": "1",
540 "EventCode": "0xB7, 0xBB",
541 "UMask": "0x1",
542 "BriefDescription": "Counts all demand data writes (RFOs) that miss in the L3.",
543 "MSRValue": "0x3fbc000002 ",
544 "Counter": "0,1,2,3",
545 "EventName": "OFFCORE_RESPONSE.DEMAND_RFO.L3_MISS.ANY_SNOOP",
546 "MSRIndex": "0x1a6,0x1a7",
547 "PublicDescription": "Counts all demand data writes (RFOs) that miss in the L3. ",
548 "SampleAfterValue": "100003",
549 "CounterHTOff": "0,1,2,3"
550 },
551 {
552 "Offcore": "1",
553 "EventCode": "0xB7, 0xBB",
554 "UMask": "0x1",
555 "BriefDescription": "Counts all demand data writes (RFOs) that miss the L3 and clean or shared data is transferred from remote cache.",
556 "MSRValue": "0x083fc00002 ",
557 "Counter": "0,1,2,3",
558 "EventName": "OFFCORE_RESPONSE.DEMAND_RFO.L3_MISS.REMOTE_HIT_FORWARD",
559 "MSRIndex": "0x1a6,0x1a7",
560 "PublicDescription": "Counts all demand data writes (RFOs) that miss the L3 and clean or shared data is transferred from remote cache. ",
561 "SampleAfterValue": "100003",
562 "CounterHTOff": "0,1,2,3"
563 },
564 {
565 "Offcore": "1",
566 "EventCode": "0xB7, 0xBB",
567 "UMask": "0x1",
568 "BriefDescription": "Counts all demand data writes (RFOs) that miss the L3 and the modified data is transferred from remote cache.",
569 "MSRValue": "0x103fc00002 ",
570 "Counter": "0,1,2,3",
571 "EventName": "OFFCORE_RESPONSE.DEMAND_RFO.L3_MISS.REMOTE_HITM",
572 "MSRIndex": "0x1a6,0x1a7",
573 "PublicDescription": "Counts all demand data writes (RFOs) that miss the L3 and the modified data is transferred from remote cache. ",
574 "SampleAfterValue": "100003",
575 "CounterHTOff": "0,1,2,3"
576 },
577 {
578 "Offcore": "1",
579 "EventCode": "0xB7, 0xBB",
580 "UMask": "0x1",
581 "BriefDescription": "Counts all demand data writes (RFOs) that miss the L3 and the data is returned from local or remote dram.",
582 "MSRValue": "0x063fc00002 ",
583 "Counter": "0,1,2,3",
584 "EventName": "OFFCORE_RESPONSE.DEMAND_RFO.L3_MISS.SNOOP_MISS_OR_NO_FWD",
585 "MSRIndex": "0x1a6,0x1a7",
586 "PublicDescription": "Counts all demand data writes (RFOs) that miss the L3 and the data is returned from local or remote dram. ",
587 "SampleAfterValue": "100003",
588 "CounterHTOff": "0,1,2,3"
589 },
590 {
591 "Offcore": "1",
592 "EventCode": "0xB7, 0xBB",
593 "UMask": "0x1",
594 "BriefDescription": "Counts all demand data writes (RFOs) that miss the L3 and the data is returned from remote dram.",
595 "MSRValue": "0x063b800002 ",
596 "Counter": "0,1,2,3",
597 "EventName": "OFFCORE_RESPONSE.DEMAND_RFO.L3_MISS_REMOTE_DRAM.SNOOP_MISS_OR_NO_FWD",
598 "MSRIndex": "0x1a6,0x1a7",
599 "PublicDescription": "Counts all demand data writes (RFOs) that miss the L3 and the data is returned from remote dram. ",
600 "SampleAfterValue": "100003",
601 "CounterHTOff": "0,1,2,3"
602 },
603 {
604 "Offcore": "1",
605 "EventCode": "0xB7, 0xBB",
606 "UMask": "0x1",
607 "BriefDescription": "Counts all demand data writes (RFOs) that miss the L3 and the data is returned from local dram.",
608 "MSRValue": "0x0604000002 ",
609 "Counter": "0,1,2,3",
610 "EventName": "OFFCORE_RESPONSE.DEMAND_RFO.L3_MISS_LOCAL_DRAM.SNOOP_MISS_OR_NO_FWD",
611 "MSRIndex": "0x1a6,0x1a7",
612 "PublicDescription": "Counts all demand data writes (RFOs) that miss the L3 and the data is returned from local dram. ",
613 "SampleAfterValue": "100003",
614 "CounterHTOff": "0,1,2,3"
615 },
616 {
617 "Offcore": "1",
618 "EventCode": "0xB7, 0xBB",
619 "UMask": "0x1",
620 "BriefDescription": "Counts all demand code reads that miss in the L3.",
621 "MSRValue": "0x3fbc000004 ",
622 "Counter": "0,1,2,3",
623 "EventName": "OFFCORE_RESPONSE.DEMAND_CODE_RD.L3_MISS.ANY_SNOOP",
624 "MSRIndex": "0x1a6,0x1a7",
625 "PublicDescription": "Counts all demand code reads that miss in the L3. ",
626 "SampleAfterValue": "100003",
627 "CounterHTOff": "0,1,2,3"
628 },
629 {
630 "Offcore": "1",
631 "EventCode": "0xB7, 0xBB",
632 "UMask": "0x1",
633 "BriefDescription": "Counts all demand code reads that miss the L3 and clean or shared data is transferred from remote cache.",
634 "MSRValue": "0x083fc00004 ",
635 "Counter": "0,1,2,3",
636 "EventName": "OFFCORE_RESPONSE.DEMAND_CODE_RD.L3_MISS.REMOTE_HIT_FORWARD",
637 "MSRIndex": "0x1a6,0x1a7",
638 "PublicDescription": "Counts all demand code reads that miss the L3 and clean or shared data is transferred from remote cache. ",
639 "SampleAfterValue": "100003",
640 "CounterHTOff": "0,1,2,3"
641 },
642 {
643 "Offcore": "1",
644 "EventCode": "0xB7, 0xBB",
645 "UMask": "0x1",
646 "BriefDescription": "Counts all demand code reads that miss the L3 and the modified data is transferred from remote cache.",
647 "MSRValue": "0x103fc00004 ",
648 "Counter": "0,1,2,3",
649 "EventName": "OFFCORE_RESPONSE.DEMAND_CODE_RD.L3_MISS.REMOTE_HITM",
650 "MSRIndex": "0x1a6,0x1a7",
651 "PublicDescription": "Counts all demand code reads that miss the L3 and the modified data is transferred from remote cache. ",
652 "SampleAfterValue": "100003",
653 "CounterHTOff": "0,1,2,3"
654 },
655 {
656 "Offcore": "1",
657 "EventCode": "0xB7, 0xBB",
658 "UMask": "0x1",
659 "BriefDescription": "Counts all demand code reads that miss the L3 and the data is returned from local or remote dram.",
660 "MSRValue": "0x063fc00004 ",
661 "Counter": "0,1,2,3",
662 "EventName": "OFFCORE_RESPONSE.DEMAND_CODE_RD.L3_MISS.SNOOP_MISS_OR_NO_FWD",
663 "MSRIndex": "0x1a6,0x1a7",
664 "PublicDescription": "Counts all demand code reads that miss the L3 and the data is returned from local or remote dram. ",
665 "SampleAfterValue": "100003",
666 "CounterHTOff": "0,1,2,3"
667 },
668 {
669 "Offcore": "1",
670 "EventCode": "0xB7, 0xBB",
671 "UMask": "0x1",
672 "BriefDescription": "Counts all demand code reads that miss the L3 and the data is returned from remote dram.",
673 "MSRValue": "0x063b800004 ",
674 "Counter": "0,1,2,3",
675 "EventName": "OFFCORE_RESPONSE.DEMAND_CODE_RD.L3_MISS_REMOTE_DRAM.SNOOP_MISS_OR_NO_FWD",
676 "MSRIndex": "0x1a6,0x1a7",
677 "PublicDescription": "Counts all demand code reads that miss the L3 and the data is returned from remote dram. ",
678 "SampleAfterValue": "100003",
679 "CounterHTOff": "0,1,2,3"
680 },
681 {
682 "Offcore": "1",
683 "EventCode": "0xB7, 0xBB",
684 "UMask": "0x1",
685 "BriefDescription": "Counts all demand code reads that miss the L3 and the data is returned from local dram.",
686 "MSRValue": "0x0604000004 ",
687 "Counter": "0,1,2,3",
688 "EventName": "OFFCORE_RESPONSE.DEMAND_CODE_RD.L3_MISS_LOCAL_DRAM.SNOOP_MISS_OR_NO_FWD",
689 "MSRIndex": "0x1a6,0x1a7",
690 "PublicDescription": "Counts all demand code reads that miss the L3 and the data is returned from local dram. ",
691 "SampleAfterValue": "100003",
692 "CounterHTOff": "0,1,2,3"
693 },
694 {
695 "Offcore": "1",
696 "EventCode": "0xB7, 0xBB",
697 "UMask": "0x1",
698 "BriefDescription": "Counts prefetch (that bring data to L2) data reads that miss in the L3.",
699 "MSRValue": "0x3fbc000010 ",
700 "Counter": "0,1,2,3",
701 "EventName": "OFFCORE_RESPONSE.PF_L2_DATA_RD.L3_MISS.ANY_SNOOP",
702 "MSRIndex": "0x1a6,0x1a7",
703 "PublicDescription": "Counts prefetch (that bring data to L2) data reads that miss in the L3. ",
704 "SampleAfterValue": "100003",
705 "CounterHTOff": "0,1,2,3"
706 },
707 {
708 "Offcore": "1",
709 "EventCode": "0xB7, 0xBB",
710 "UMask": "0x1",
711 "BriefDescription": "Counts prefetch (that bring data to L2) data reads that miss the L3 and clean or shared data is transferred from remote cache.",
712 "MSRValue": "0x083fc00010 ",
713 "Counter": "0,1,2,3",
714 "EventName": "OFFCORE_RESPONSE.PF_L2_DATA_RD.L3_MISS.REMOTE_HIT_FORWARD",
715 "MSRIndex": "0x1a6,0x1a7",
716 "PublicDescription": "Counts prefetch (that bring data to L2) data reads that miss the L3 and clean or shared data is transferred from remote cache. ",
717 "SampleAfterValue": "100003",
718 "CounterHTOff": "0,1,2,3"
719 },
720 {
721 "Offcore": "1",
722 "EventCode": "0xB7, 0xBB",
723 "UMask": "0x1",
724 "BriefDescription": "Counts prefetch (that bring data to L2) data reads that miss the L3 and the modified data is transferred from remote cache.",
725 "MSRValue": "0x103fc00010 ",
726 "Counter": "0,1,2,3",
727 "EventName": "OFFCORE_RESPONSE.PF_L2_DATA_RD.L3_MISS.REMOTE_HITM",
728 "MSRIndex": "0x1a6,0x1a7",
729 "PublicDescription": "Counts prefetch (that bring data to L2) data reads that miss the L3 and the modified data is transferred from remote cache. ",
730 "SampleAfterValue": "100003",
731 "CounterHTOff": "0,1,2,3"
732 },
733 {
734 "Offcore": "1",
735 "EventCode": "0xB7, 0xBB",
736 "UMask": "0x1",
737 "BriefDescription": "Counts prefetch (that bring data to L2) data reads that miss the L3 and the data is returned from local or remote dram.",
738 "MSRValue": "0x063fc00010 ",
739 "Counter": "0,1,2,3",
740 "EventName": "OFFCORE_RESPONSE.PF_L2_DATA_RD.L3_MISS.SNOOP_MISS_OR_NO_FWD",
741 "MSRIndex": "0x1a6,0x1a7",
742 "PublicDescription": "Counts prefetch (that bring data to L2) data reads that miss the L3 and the data is returned from local or remote dram. ",
743 "SampleAfterValue": "100003",
744 "CounterHTOff": "0,1,2,3"
745 },
746 {
747 "Offcore": "1",
748 "EventCode": "0xB7, 0xBB",
749 "UMask": "0x1",
750 "BriefDescription": "Counts prefetch (that bring data to L2) data reads that miss the L3 and the data is returned from remote dram.",
751 "MSRValue": "0x063b800010 ",
752 "Counter": "0,1,2,3",
753 "EventName": "OFFCORE_RESPONSE.PF_L2_DATA_RD.L3_MISS_REMOTE_DRAM.SNOOP_MISS_OR_NO_FWD",
754 "MSRIndex": "0x1a6,0x1a7",
755 "PublicDescription": "Counts prefetch (that bring data to L2) data reads that miss the L3 and the data is returned from remote dram. ",
756 "SampleAfterValue": "100003",
757 "CounterHTOff": "0,1,2,3"
758 },
759 {
760 "Offcore": "1",
761 "EventCode": "0xB7, 0xBB",
762 "UMask": "0x1",
763 "BriefDescription": "Counts prefetch (that bring data to L2) data reads that miss the L3 and the data is returned from local dram.",
764 "MSRValue": "0x0604000010 ",
765 "Counter": "0,1,2,3",
766 "EventName": "OFFCORE_RESPONSE.PF_L2_DATA_RD.L3_MISS_LOCAL_DRAM.SNOOP_MISS_OR_NO_FWD",
767 "MSRIndex": "0x1a6,0x1a7",
768 "PublicDescription": "Counts prefetch (that bring data to L2) data reads that miss the L3 and the data is returned from local dram. ",
769 "SampleAfterValue": "100003",
770 "CounterHTOff": "0,1,2,3"
771 },
772 {
773 "Offcore": "1",
774 "EventCode": "0xB7, 0xBB",
775 "UMask": "0x1",
776 "BriefDescription": "Counts all prefetch (that bring data to L2) RFOs that miss in the L3.",
777 "MSRValue": "0x3fbc000020 ",
778 "Counter": "0,1,2,3",
779 "EventName": "OFFCORE_RESPONSE.PF_L2_RFO.L3_MISS.ANY_SNOOP",
780 "MSRIndex": "0x1a6,0x1a7",
781 "PublicDescription": "Counts all prefetch (that bring data to L2) RFOs that miss in the L3. ",
782 "SampleAfterValue": "100003",
783 "CounterHTOff": "0,1,2,3"
784 },
785 {
786 "Offcore": "1",
787 "EventCode": "0xB7, 0xBB",
788 "UMask": "0x1",
789 "BriefDescription": "Counts all prefetch (that bring data to L2) RFOs that miss the L3 and clean or shared data is transferred from remote cache.",
790 "MSRValue": "0x083fc00020 ",
791 "Counter": "0,1,2,3",
792 "EventName": "OFFCORE_RESPONSE.PF_L2_RFO.L3_MISS.REMOTE_HIT_FORWARD",
793 "MSRIndex": "0x1a6,0x1a7",
794 "PublicDescription": "Counts all prefetch (that bring data to L2) RFOs that miss the L3 and clean or shared data is transferred from remote cache. ",
795 "SampleAfterValue": "100003",
796 "CounterHTOff": "0,1,2,3"
797 },
798 {
799 "Offcore": "1",
800 "EventCode": "0xB7, 0xBB",
801 "UMask": "0x1",
802 "BriefDescription": "Counts all prefetch (that bring data to L2) RFOs that miss the L3 and the modified data is transferred from remote cache.",
803 "MSRValue": "0x103fc00020 ",
804 "Counter": "0,1,2,3",
805 "EventName": "OFFCORE_RESPONSE.PF_L2_RFO.L3_MISS.REMOTE_HITM",
806 "MSRIndex": "0x1a6,0x1a7",
807 "PublicDescription": "Counts all prefetch (that bring data to L2) RFOs that miss the L3 and the modified data is transferred from remote cache. ",
808 "SampleAfterValue": "100003",
809 "CounterHTOff": "0,1,2,3"
810 },
811 {
812 "Offcore": "1",
813 "EventCode": "0xB7, 0xBB",
814 "UMask": "0x1",
815 "BriefDescription": "Counts all prefetch (that bring data to L2) RFOs that miss the L3 and the data is returned from local or remote dram.",
816 "MSRValue": "0x063fc00020 ",
817 "Counter": "0,1,2,3",
818 "EventName": "OFFCORE_RESPONSE.PF_L2_RFO.L3_MISS.SNOOP_MISS_OR_NO_FWD",
819 "MSRIndex": "0x1a6,0x1a7",
820 "PublicDescription": "Counts all prefetch (that bring data to L2) RFOs that miss the L3 and the data is returned from local or remote dram. ",
821 "SampleAfterValue": "100003",
822 "CounterHTOff": "0,1,2,3"
823 },
824 {
825 "Offcore": "1",
826 "EventCode": "0xB7, 0xBB",
827 "UMask": "0x1",
828 "BriefDescription": "Counts all prefetch (that bring data to L2) RFOs that miss the L3 and the data is returned from remote dram.",
829 "MSRValue": "0x063b800020 ",
830 "Counter": "0,1,2,3",
831 "EventName": "OFFCORE_RESPONSE.PF_L2_RFO.L3_MISS_REMOTE_DRAM.SNOOP_MISS_OR_NO_FWD",
832 "MSRIndex": "0x1a6,0x1a7",
833 "PublicDescription": "Counts all prefetch (that bring data to L2) RFOs that miss the L3 and the data is returned from remote dram. ",
834 "SampleAfterValue": "100003",
835 "CounterHTOff": "0,1,2,3"
836 },
837 {
838 "Offcore": "1",
839 "EventCode": "0xB7, 0xBB",
840 "UMask": "0x1",
841 "BriefDescription": "Counts all prefetch (that bring data to L2) RFOs that miss the L3 and the data is returned from local dram.",
842 "MSRValue": "0x0604000020 ",
843 "Counter": "0,1,2,3",
844 "EventName": "OFFCORE_RESPONSE.PF_L2_RFO.L3_MISS_LOCAL_DRAM.SNOOP_MISS_OR_NO_FWD",
845 "MSRIndex": "0x1a6,0x1a7",
846 "PublicDescription": "Counts all prefetch (that bring data to L2) RFOs that miss the L3 and the data is returned from local dram. ",
847 "SampleAfterValue": "100003",
848 "CounterHTOff": "0,1,2,3"
849 },
850 {
851 "Offcore": "1",
852 "EventCode": "0xB7, 0xBB",
853 "UMask": "0x1",
854 "BriefDescription": "Counts all prefetch (that bring data to LLC only) data reads that miss in the L3.",
855 "MSRValue": "0x3fbc000080 ",
856 "Counter": "0,1,2,3",
857 "EventName": "OFFCORE_RESPONSE.PF_L3_DATA_RD.L3_MISS.ANY_SNOOP",
858 "MSRIndex": "0x1a6,0x1a7",
859 "PublicDescription": "Counts all prefetch (that bring data to LLC only) data reads that miss in the L3. ",
860 "SampleAfterValue": "100003",
861 "CounterHTOff": "0,1,2,3"
862 },
863 {
864 "Offcore": "1",
865 "EventCode": "0xB7, 0xBB",
866 "UMask": "0x1",
867 "BriefDescription": "Counts all prefetch (that bring data to LLC only) data reads that miss the L3 and clean or shared data is transferred from remote cache.",
868 "MSRValue": "0x083fc00080 ",
869 "Counter": "0,1,2,3",
870 "EventName": "OFFCORE_RESPONSE.PF_L3_DATA_RD.L3_MISS.REMOTE_HIT_FORWARD",
871 "MSRIndex": "0x1a6,0x1a7",
872 "PublicDescription": "Counts all prefetch (that bring data to LLC only) data reads that miss the L3 and clean or shared data is transferred from remote cache. ",
873 "SampleAfterValue": "100003",
874 "CounterHTOff": "0,1,2,3"
875 },
876 {
877 "Offcore": "1",
878 "EventCode": "0xB7, 0xBB",
879 "UMask": "0x1",
880 "BriefDescription": "Counts all prefetch (that bring data to LLC only) data reads that miss the L3 and the modified data is transferred from remote cache.",
881 "MSRValue": "0x103fc00080 ",
882 "Counter": "0,1,2,3",
883 "EventName": "OFFCORE_RESPONSE.PF_L3_DATA_RD.L3_MISS.REMOTE_HITM",
884 "MSRIndex": "0x1a6,0x1a7",
885 "PublicDescription": "Counts all prefetch (that bring data to LLC only) data reads that miss the L3 and the modified data is transferred from remote cache. ",
886 "SampleAfterValue": "100003",
887 "CounterHTOff": "0,1,2,3"
888 },
889 {
890 "Offcore": "1",
891 "EventCode": "0xB7, 0xBB",
892 "UMask": "0x1",
893 "BriefDescription": "Counts all prefetch (that bring data to LLC only) data reads that miss the L3 and the data is returned from local or remote dram.",
894 "MSRValue": "0x063fc00080 ",
895 "Counter": "0,1,2,3",
896 "EventName": "OFFCORE_RESPONSE.PF_L3_DATA_RD.L3_MISS.SNOOP_MISS_OR_NO_FWD",
897 "MSRIndex": "0x1a6,0x1a7",
898 "PublicDescription": "Counts all prefetch (that bring data to LLC only) data reads that miss the L3 and the data is returned from local or remote dram. ",
899 "SampleAfterValue": "100003",
900 "CounterHTOff": "0,1,2,3"
901 },
902 {
903 "Offcore": "1",
904 "EventCode": "0xB7, 0xBB",
905 "UMask": "0x1",
906 "BriefDescription": "Counts all prefetch (that bring data to LLC only) data reads that miss the L3 and the data is returned from remote dram.",
907 "MSRValue": "0x063b800080 ",
908 "Counter": "0,1,2,3",
909 "EventName": "OFFCORE_RESPONSE.PF_L3_DATA_RD.L3_MISS_REMOTE_DRAM.SNOOP_MISS_OR_NO_FWD",
910 "MSRIndex": "0x1a6,0x1a7",
911 "PublicDescription": "Counts all prefetch (that bring data to LLC only) data reads that miss the L3 and the data is returned from remote dram. ",
912 "SampleAfterValue": "100003",
913 "CounterHTOff": "0,1,2,3"
914 },
915 {
916 "Offcore": "1",
917 "EventCode": "0xB7, 0xBB",
918 "UMask": "0x1",
919 "BriefDescription": "Counts all prefetch (that bring data to LLC only) data reads that miss the L3 and the data is returned from local dram.",
920 "MSRValue": "0x0604000080 ",
921 "Counter": "0,1,2,3",
922 "EventName": "OFFCORE_RESPONSE.PF_L3_DATA_RD.L3_MISS_LOCAL_DRAM.SNOOP_MISS_OR_NO_FWD",
923 "MSRIndex": "0x1a6,0x1a7",
924 "PublicDescription": "Counts all prefetch (that bring data to LLC only) data reads that miss the L3 and the data is returned from local dram. ",
925 "SampleAfterValue": "100003",
926 "CounterHTOff": "0,1,2,3"
927 },
928 {
929 "Offcore": "1",
930 "EventCode": "0xB7, 0xBB",
931 "UMask": "0x1",
932 "BriefDescription": "Counts all prefetch (that bring data to LLC only) RFOs that miss in the L3.",
933 "MSRValue": "0x3fbc000100 ",
934 "Counter": "0,1,2,3",
935 "EventName": "OFFCORE_RESPONSE.PF_L3_RFO.L3_MISS.ANY_SNOOP",
936 "MSRIndex": "0x1a6,0x1a7",
937 "PublicDescription": "Counts all prefetch (that bring data to LLC only) RFOs that miss in the L3. ",
938 "SampleAfterValue": "100003",
939 "CounterHTOff": "0,1,2,3"
940 },
941 {
942 "Offcore": "1",
943 "EventCode": "0xB7, 0xBB",
944 "UMask": "0x1",
945 "BriefDescription": "Counts all prefetch (that bring data to LLC only) RFOs that miss the L3 and clean or shared data is transferred from remote cache.",
946 "MSRValue": "0x083fc00100 ",
947 "Counter": "0,1,2,3",
948 "EventName": "OFFCORE_RESPONSE.PF_L3_RFO.L3_MISS.REMOTE_HIT_FORWARD",
949 "MSRIndex": "0x1a6,0x1a7",
950 "PublicDescription": "Counts all prefetch (that bring data to LLC only) RFOs that miss the L3 and clean or shared data is transferred from remote cache. ",
951 "SampleAfterValue": "100003",
952 "CounterHTOff": "0,1,2,3"
953 },
954 {
955 "Offcore": "1",
956 "EventCode": "0xB7, 0xBB",
957 "UMask": "0x1",
958 "BriefDescription": "Counts all prefetch (that bring data to LLC only) RFOs that miss the L3 and the modified data is transferred from remote cache.",
959 "MSRValue": "0x103fc00100 ",
960 "Counter": "0,1,2,3",
961 "EventName": "OFFCORE_RESPONSE.PF_L3_RFO.L3_MISS.REMOTE_HITM",
962 "MSRIndex": "0x1a6,0x1a7",
963 "PublicDescription": "Counts all prefetch (that bring data to LLC only) RFOs that miss the L3 and the modified data is transferred from remote cache. ",
964 "SampleAfterValue": "100003",
965 "CounterHTOff": "0,1,2,3"
966 },
967 {
968 "Offcore": "1",
969 "EventCode": "0xB7, 0xBB",
970 "UMask": "0x1",
971 "BriefDescription": "Counts all prefetch (that bring data to LLC only) RFOs that miss the L3 and the data is returned from local or remote dram.",
972 "MSRValue": "0x063fc00100 ",
973 "Counter": "0,1,2,3",
974 "EventName": "OFFCORE_RESPONSE.PF_L3_RFO.L3_MISS.SNOOP_MISS_OR_NO_FWD",
975 "MSRIndex": "0x1a6,0x1a7",
976 "PublicDescription": "Counts all prefetch (that bring data to LLC only) RFOs that miss the L3 and the data is returned from local or remote dram. ",
977 "SampleAfterValue": "100003",
978 "CounterHTOff": "0,1,2,3"
979 },
980 {
981 "Offcore": "1",
982 "EventCode": "0xB7, 0xBB",
983 "UMask": "0x1",
984 "BriefDescription": "Counts all prefetch (that bring data to LLC only) RFOs that miss the L3 and the data is returned from remote dram.",
985 "MSRValue": "0x063b800100 ",
986 "Counter": "0,1,2,3",
987 "EventName": "OFFCORE_RESPONSE.PF_L3_RFO.L3_MISS_REMOTE_DRAM.SNOOP_MISS_OR_NO_FWD",
988 "MSRIndex": "0x1a6,0x1a7",
989 "PublicDescription": "Counts all prefetch (that bring data to LLC only) RFOs that miss the L3 and the data is returned from remote dram. ",
990 "SampleAfterValue": "100003",
991 "CounterHTOff": "0,1,2,3"
992 },
993 {
994 "Offcore": "1",
995 "EventCode": "0xB7, 0xBB",
996 "UMask": "0x1",
997 "BriefDescription": "Counts all prefetch (that bring data to LLC only) RFOs that miss the L3 and the data is returned from local dram.",
998 "MSRValue": "0x0604000100 ",
999 "Counter": "0,1,2,3",
1000 "EventName": "OFFCORE_RESPONSE.PF_L3_RFO.L3_MISS_LOCAL_DRAM.SNOOP_MISS_OR_NO_FWD",
1001 "MSRIndex": "0x1a6,0x1a7",
1002 "PublicDescription": "Counts all prefetch (that bring data to LLC only) RFOs that miss the L3 and the data is returned from local dram. ",
1003 "SampleAfterValue": "100003",
1004 "CounterHTOff": "0,1,2,3"
1005 },
1006 {
1007 "Offcore": "1",
1008 "EventCode": "0xB7, 0xBB",
1009 "UMask": "0x1",
1010 "BriefDescription": "Counts L1 data cache hardware prefetch requests and software prefetch requests that miss in the L3.",
1011 "MSRValue": "0x3fbc000400 ",
1012 "Counter": "0,1,2,3",
1013 "EventName": "OFFCORE_RESPONSE.PF_L1D_AND_SW.L3_MISS.ANY_SNOOP",
1014 "MSRIndex": "0x1a6,0x1a7",
1015 "PublicDescription": "Counts L1 data cache hardware prefetch requests and software prefetch requests that miss in the L3. ",
1016 "SampleAfterValue": "100003",
1017 "CounterHTOff": "0,1,2,3"
1018 },
1019 {
1020 "Offcore": "1",
1021 "EventCode": "0xB7, 0xBB",
1022 "UMask": "0x1",
1023 "BriefDescription": "Counts L1 data cache hardware prefetch requests and software prefetch requests that miss the L3 and clean or shared data is transferred from remote cache.",
1024 "MSRValue": "0x083fc00400 ",
1025 "Counter": "0,1,2,3",
1026 "EventName": "OFFCORE_RESPONSE.PF_L1D_AND_SW.L3_MISS.REMOTE_HIT_FORWARD",
1027 "MSRIndex": "0x1a6,0x1a7",
1028 "PublicDescription": "Counts L1 data cache hardware prefetch requests and software prefetch requests that miss the L3 and clean or shared data is transferred from remote cache. ",
1029 "SampleAfterValue": "100003",
1030 "CounterHTOff": "0,1,2,3"
1031 },
1032 {
1033 "Offcore": "1",
1034 "EventCode": "0xB7, 0xBB",
1035 "UMask": "0x1",
1036 "BriefDescription": "Counts L1 data cache hardware prefetch requests and software prefetch requests that miss the L3 and the modified data is transferred from remote cache.",
1037 "MSRValue": "0x103fc00400 ",
1038 "Counter": "0,1,2,3",
1039 "EventName": "OFFCORE_RESPONSE.PF_L1D_AND_SW.L3_MISS.REMOTE_HITM",
1040 "MSRIndex": "0x1a6,0x1a7",
1041 "PublicDescription": "Counts L1 data cache hardware prefetch requests and software prefetch requests that miss the L3 and the modified data is transferred from remote cache. ",
1042 "SampleAfterValue": "100003",
1043 "CounterHTOff": "0,1,2,3"
1044 },
1045 {
1046 "Offcore": "1",
1047 "EventCode": "0xB7, 0xBB",
1048 "UMask": "0x1",
1049 "BriefDescription": "Counts L1 data cache hardware prefetch requests and software prefetch requests that miss the L3 and the data is returned from local or remote dram.",
1050 "MSRValue": "0x063fc00400 ",
1051 "Counter": "0,1,2,3",
1052 "EventName": "OFFCORE_RESPONSE.PF_L1D_AND_SW.L3_MISS.SNOOP_MISS_OR_NO_FWD",
1053 "MSRIndex": "0x1a6,0x1a7",
1054 "PublicDescription": "Counts L1 data cache hardware prefetch requests and software prefetch requests that miss the L3 and the data is returned from local or remote dram. ",
1055 "SampleAfterValue": "100003",
1056 "CounterHTOff": "0,1,2,3"
1057 },
1058 {
1059 "Offcore": "1",
1060 "EventCode": "0xB7, 0xBB",
1061 "UMask": "0x1",
1062 "BriefDescription": "Counts L1 data cache hardware prefetch requests and software prefetch requests that miss the L3 and the data is returned from remote dram.",
1063 "MSRValue": "0x063b800400 ",
1064 "Counter": "0,1,2,3",
1065 "EventName": "OFFCORE_RESPONSE.PF_L1D_AND_SW.L3_MISS_REMOTE_DRAM.SNOOP_MISS_OR_NO_FWD",
1066 "MSRIndex": "0x1a6,0x1a7",
1067 "PublicDescription": "Counts L1 data cache hardware prefetch requests and software prefetch requests that miss the L3 and the data is returned from remote dram. ",
1068 "SampleAfterValue": "100003",
1069 "CounterHTOff": "0,1,2,3"
1070 },
1071 {
1072 "Offcore": "1",
1073 "EventCode": "0xB7, 0xBB",
1074 "UMask": "0x1",
1075 "BriefDescription": "Counts L1 data cache hardware prefetch requests and software prefetch requests that miss the L3 and the data is returned from local dram.",
1076 "MSRValue": "0x0604000400 ",
1077 "Counter": "0,1,2,3",
1078 "EventName": "OFFCORE_RESPONSE.PF_L1D_AND_SW.L3_MISS_LOCAL_DRAM.SNOOP_MISS_OR_NO_FWD",
1079 "MSRIndex": "0x1a6,0x1a7",
1080 "PublicDescription": "Counts L1 data cache hardware prefetch requests and software prefetch requests that miss the L3 and the data is returned from local dram. ",
1081 "SampleAfterValue": "100003",
1082 "CounterHTOff": "0,1,2,3"
1083 },
1084 {
1085 "Offcore": "1",
1086 "EventCode": "0xB7, 0xBB",
1087 "UMask": "0x1",
1088 "BriefDescription": "Counts all prefetch data reads that miss in the L3.",
1089 "MSRValue": "0x3fbc000490 ",
1090 "Counter": "0,1,2,3",
1091 "EventName": "OFFCORE_RESPONSE.ALL_PF_DATA_RD.L3_MISS.ANY_SNOOP",
1092 "MSRIndex": "0x1a6,0x1a7",
1093 "PublicDescription": "Counts all prefetch data reads that miss in the L3. ",
1094 "SampleAfterValue": "100003",
1095 "CounterHTOff": "0,1,2,3"
1096 },
1097 {
1098 "Offcore": "1",
1099 "EventCode": "0xB7, 0xBB",
1100 "UMask": "0x1",
1101 "BriefDescription": "Counts all prefetch data reads that miss the L3 and clean or shared data is transferred from remote cache.",
1102 "MSRValue": "0x083fc00490 ",
1103 "Counter": "0,1,2,3",
1104 "EventName": "OFFCORE_RESPONSE.ALL_PF_DATA_RD.L3_MISS.REMOTE_HIT_FORWARD",
1105 "MSRIndex": "0x1a6,0x1a7",
1106 "PublicDescription": "Counts all prefetch data reads that miss the L3 and clean or shared data is transferred from remote cache. ",
1107 "SampleAfterValue": "100003",
1108 "CounterHTOff": "0,1,2,3"
1109 },
1110 {
1111 "Offcore": "1",
1112 "EventCode": "0xB7, 0xBB",
1113 "UMask": "0x1",
1114 "BriefDescription": "Counts all prefetch data reads that miss the L3 and the modified data is transferred from remote cache.",
1115 "MSRValue": "0x103fc00490 ",
1116 "Counter": "0,1,2,3",
1117 "EventName": "OFFCORE_RESPONSE.ALL_PF_DATA_RD.L3_MISS.REMOTE_HITM",
1118 "MSRIndex": "0x1a6,0x1a7",
1119 "PublicDescription": "Counts all prefetch data reads that miss the L3 and the modified data is transferred from remote cache. ",
1120 "SampleAfterValue": "100003",
1121 "CounterHTOff": "0,1,2,3"
1122 },
1123 {
1124 "Offcore": "1",
1125 "EventCode": "0xB7, 0xBB",
1126 "UMask": "0x1",
1127 "BriefDescription": "Counts all prefetch data reads that miss the L3 and the data is returned from local or remote dram.",
1128 "MSRValue": "0x063fc00490 ",
1129 "Counter": "0,1,2,3",
1130 "EventName": "OFFCORE_RESPONSE.ALL_PF_DATA_RD.L3_MISS.SNOOP_MISS_OR_NO_FWD",
1131 "MSRIndex": "0x1a6,0x1a7",
1132 "PublicDescription": "Counts all prefetch data reads that miss the L3 and the data is returned from local or remote dram. ",
1133 "SampleAfterValue": "100003",
1134 "CounterHTOff": "0,1,2,3"
1135 },
1136 {
1137 "Offcore": "1",
1138 "EventCode": "0xB7, 0xBB",
1139 "UMask": "0x1",
1140 "BriefDescription": "Counts all prefetch data reads that miss the L3 and the data is returned from remote dram.",
1141 "MSRValue": "0x063b800490 ",
1142 "Counter": "0,1,2,3",
1143 "EventName": "OFFCORE_RESPONSE.ALL_PF_DATA_RD.L3_MISS_REMOTE_DRAM.SNOOP_MISS_OR_NO_FWD",
1144 "MSRIndex": "0x1a6,0x1a7",
1145 "PublicDescription": "Counts all prefetch data reads that miss the L3 and the data is returned from remote dram. ",
1146 "SampleAfterValue": "100003",
1147 "CounterHTOff": "0,1,2,3"
1148 },
1149 {
1150 "Offcore": "1",
1151 "EventCode": "0xB7, 0xBB",
1152 "UMask": "0x1",
1153 "BriefDescription": "Counts all prefetch data reads that miss the L3 and the data is returned from local dram.",
1154 "MSRValue": "0x0604000490 ",
1155 "Counter": "0,1,2,3",
1156 "EventName": "OFFCORE_RESPONSE.ALL_PF_DATA_RD.L3_MISS_LOCAL_DRAM.SNOOP_MISS_OR_NO_FWD",
1157 "MSRIndex": "0x1a6,0x1a7",
1158 "PublicDescription": "Counts all prefetch data reads that miss the L3 and the data is returned from local dram. ",
1159 "SampleAfterValue": "100003",
1160 "CounterHTOff": "0,1,2,3"
1161 },
1162 {
1163 "Offcore": "1",
1164 "EventCode": "0xB7, 0xBB",
1165 "UMask": "0x1",
1166 "BriefDescription": "Counts prefetch RFOs that miss in the L3.",
1167 "MSRValue": "0x3fbc000120 ",
1168 "Counter": "0,1,2,3",
1169 "EventName": "OFFCORE_RESPONSE.ALL_PF_RFO.L3_MISS.ANY_SNOOP",
1170 "MSRIndex": "0x1a6,0x1a7",
1171 "PublicDescription": "Counts prefetch RFOs that miss in the L3. ",
1172 "SampleAfterValue": "100003",
1173 "CounterHTOff": "0,1,2,3"
1174 },
1175 {
1176 "Offcore": "1",
1177 "EventCode": "0xB7, 0xBB",
1178 "UMask": "0x1",
1179 "BriefDescription": "Counts prefetch RFOs that miss the L3 and clean or shared data is transferred from remote cache.",
1180 "MSRValue": "0x083fc00120 ",
1181 "Counter": "0,1,2,3",
1182 "EventName": "OFFCORE_RESPONSE.ALL_PF_RFO.L3_MISS.REMOTE_HIT_FORWARD",
1183 "MSRIndex": "0x1a6,0x1a7",
1184 "PublicDescription": "Counts prefetch RFOs that miss the L3 and clean or shared data is transferred from remote cache. ",
1185 "SampleAfterValue": "100003",
1186 "CounterHTOff": "0,1,2,3"
1187 },
1188 {
1189 "Offcore": "1",
1190 "EventCode": "0xB7, 0xBB",
1191 "UMask": "0x1",
1192 "BriefDescription": "Counts prefetch RFOs that miss the L3 and the modified data is transferred from remote cache.",
1193 "MSRValue": "0x103fc00120 ",
1194 "Counter": "0,1,2,3",
1195 "EventName": "OFFCORE_RESPONSE.ALL_PF_RFO.L3_MISS.REMOTE_HITM",
1196 "MSRIndex": "0x1a6,0x1a7",
1197 "PublicDescription": "Counts prefetch RFOs that miss the L3 and the modified data is transferred from remote cache. ",
1198 "SampleAfterValue": "100003",
1199 "CounterHTOff": "0,1,2,3"
1200 },
1201 {
1202 "Offcore": "1",
1203 "EventCode": "0xB7, 0xBB",
1204 "UMask": "0x1",
1205 "BriefDescription": "Counts prefetch RFOs that miss the L3 and the data is returned from local or remote dram.",
1206 "MSRValue": "0x063fc00120 ",
1207 "Counter": "0,1,2,3",
1208 "EventName": "OFFCORE_RESPONSE.ALL_PF_RFO.L3_MISS.SNOOP_MISS_OR_NO_FWD",
1209 "MSRIndex": "0x1a6,0x1a7",
1210 "PublicDescription": "Counts prefetch RFOs that miss the L3 and the data is returned from local or remote dram. ",
1211 "SampleAfterValue": "100003",
1212 "CounterHTOff": "0,1,2,3"
1213 },
1214 {
1215 "Offcore": "1",
1216 "EventCode": "0xB7, 0xBB",
1217 "UMask": "0x1",
1218 "BriefDescription": "Counts prefetch RFOs that miss the L3 and the data is returned from remote dram.",
1219 "MSRValue": "0x063b800120 ",
1220 "Counter": "0,1,2,3",
1221 "EventName": "OFFCORE_RESPONSE.ALL_PF_RFO.L3_MISS_REMOTE_DRAM.SNOOP_MISS_OR_NO_FWD",
1222 "MSRIndex": "0x1a6,0x1a7",
1223 "PublicDescription": "Counts prefetch RFOs that miss the L3 and the data is returned from remote dram. ",
1224 "SampleAfterValue": "100003",
1225 "CounterHTOff": "0,1,2,3"
1226 },
1227 {
1228 "Offcore": "1",
1229 "EventCode": "0xB7, 0xBB",
1230 "UMask": "0x1",
1231 "BriefDescription": "Counts prefetch RFOs that miss the L3 and the data is returned from local dram.",
1232 "MSRValue": "0x0604000120 ",
1233 "Counter": "0,1,2,3",
1234 "EventName": "OFFCORE_RESPONSE.ALL_PF_RFO.L3_MISS_LOCAL_DRAM.SNOOP_MISS_OR_NO_FWD",
1235 "MSRIndex": "0x1a6,0x1a7",
1236 "PublicDescription": "Counts prefetch RFOs that miss the L3 and the data is returned from local dram. ",
1237 "SampleAfterValue": "100003",
1238 "CounterHTOff": "0,1,2,3"
1239 },
1240 {
1241 "Offcore": "1",
1242 "EventCode": "0xB7, 0xBB",
1243 "UMask": "0x1",
1244 "BriefDescription": "Counts all demand & prefetch data reads that miss in the L3.",
1245 "MSRValue": "0x3fbc000491 ",
1246 "Counter": "0,1,2,3",
1247 "EventName": "OFFCORE_RESPONSE.ALL_DATA_RD.L3_MISS.ANY_SNOOP",
1248 "MSRIndex": "0x1a6,0x1a7",
1249 "PublicDescription": "Counts all demand & prefetch data reads that miss in the L3. ",
1250 "SampleAfterValue": "100003",
1251 "CounterHTOff": "0,1,2,3"
1252 },
1253 {
1254 "Offcore": "1",
1255 "EventCode": "0xB7, 0xBB",
1256 "UMask": "0x1",
1257 "BriefDescription": "Counts all demand & prefetch data reads that miss the L3 and clean or shared data is transferred from remote cache.",
1258 "MSRValue": "0x083fc00491 ",
1259 "Counter": "0,1,2,3",
1260 "EventName": "OFFCORE_RESPONSE.ALL_DATA_RD.L3_MISS.REMOTE_HIT_FORWARD",
1261 "MSRIndex": "0x1a6,0x1a7",
1262 "PublicDescription": "Counts all demand & prefetch data reads that miss the L3 and clean or shared data is transferred from remote cache. ",
1263 "SampleAfterValue": "100003",
1264 "CounterHTOff": "0,1,2,3"
1265 },
1266 {
1267 "Offcore": "1",
1268 "EventCode": "0xB7, 0xBB",
1269 "UMask": "0x1",
1270 "BriefDescription": "Counts all demand & prefetch data reads that miss the L3 and the modified data is transferred from remote cache.",
1271 "MSRValue": "0x103fc00491 ",
1272 "Counter": "0,1,2,3",
1273 "EventName": "OFFCORE_RESPONSE.ALL_DATA_RD.L3_MISS.REMOTE_HITM",
1274 "MSRIndex": "0x1a6,0x1a7",
1275 "PublicDescription": "Counts all demand & prefetch data reads that miss the L3 and the modified data is transferred from remote cache. ",
1276 "SampleAfterValue": "100003",
1277 "CounterHTOff": "0,1,2,3"
1278 },
1279 {
1280 "Offcore": "1",
1281 "EventCode": "0xB7, 0xBB",
1282 "UMask": "0x1",
1283 "BriefDescription": "Counts all demand & prefetch data reads that miss the L3 and the data is returned from local or remote dram.",
1284 "MSRValue": "0x063fc00491 ",
1285 "Counter": "0,1,2,3",
1286 "EventName": "OFFCORE_RESPONSE.ALL_DATA_RD.L3_MISS.SNOOP_MISS_OR_NO_FWD",
1287 "MSRIndex": "0x1a6,0x1a7",
1288 "PublicDescription": "Counts all demand & prefetch data reads that miss the L3 and the data is returned from local or remote dram. ",
1289 "SampleAfterValue": "100003",
1290 "CounterHTOff": "0,1,2,3"
1291 },
1292 {
1293 "Offcore": "1",
1294 "EventCode": "0xB7, 0xBB",
1295 "UMask": "0x1",
1296 "BriefDescription": "Counts all demand & prefetch data reads that miss the L3 and the data is returned from remote dram.",
1297 "MSRValue": "0x063b800491 ",
1298 "Counter": "0,1,2,3",
1299 "EventName": "OFFCORE_RESPONSE.ALL_DATA_RD.L3_MISS_REMOTE_DRAM.SNOOP_MISS_OR_NO_FWD",
1300 "MSRIndex": "0x1a6,0x1a7",
1301 "PublicDescription": "Counts all demand & prefetch data reads that miss the L3 and the data is returned from remote dram. ",
1302 "SampleAfterValue": "100003",
1303 "CounterHTOff": "0,1,2,3"
1304 },
1305 {
1306 "Offcore": "1",
1307 "EventCode": "0xB7, 0xBB",
1308 "UMask": "0x1",
1309 "BriefDescription": "Counts all demand & prefetch data reads that miss the L3 and the data is returned from local dram.",
1310 "MSRValue": "0x0604000491 ",
1311 "Counter": "0,1,2,3",
1312 "EventName": "OFFCORE_RESPONSE.ALL_DATA_RD.L3_MISS_LOCAL_DRAM.SNOOP_MISS_OR_NO_FWD",
1313 "MSRIndex": "0x1a6,0x1a7",
1314 "PublicDescription": "Counts all demand & prefetch data reads that miss the L3 and the data is returned from local dram. ",
1315 "SampleAfterValue": "100003",
1316 "CounterHTOff": "0,1,2,3"
1317 },
1318 {
1319 "Offcore": "1",
1320 "EventCode": "0xB7, 0xBB",
1321 "UMask": "0x1",
1322 "BriefDescription": "Counts all demand & prefetch RFOs that miss in the L3.",
1323 "MSRValue": "0x3fbc000122 ",
1324 "Counter": "0,1,2,3",
1325 "EventName": "OFFCORE_RESPONSE.ALL_RFO.L3_MISS.ANY_SNOOP",
1326 "MSRIndex": "0x1a6,0x1a7",
1327 "PublicDescription": "Counts all demand & prefetch RFOs that miss in the L3. ",
1328 "SampleAfterValue": "100003",
1329 "CounterHTOff": "0,1,2,3"
1330 },
1331 {
1332 "Offcore": "1",
1333 "EventCode": "0xB7, 0xBB",
1334 "UMask": "0x1",
1335 "BriefDescription": "Counts all demand & prefetch RFOs that miss the L3 and clean or shared data is transferred from remote cache.",
1336 "MSRValue": "0x083fc00122 ",
1337 "Counter": "0,1,2,3",
1338 "EventName": "OFFCORE_RESPONSE.ALL_RFO.L3_MISS.REMOTE_HIT_FORWARD",
1339 "MSRIndex": "0x1a6,0x1a7",
1340 "PublicDescription": "Counts all demand & prefetch RFOs that miss the L3 and clean or shared data is transferred from remote cache. ",
1341 "SampleAfterValue": "100003",
1342 "CounterHTOff": "0,1,2,3"
1343 },
1344 {
1345 "Offcore": "1",
1346 "EventCode": "0xB7, 0xBB",
1347 "UMask": "0x1",
1348 "BriefDescription": "Counts all demand & prefetch RFOs that miss the L3 and the modified data is transferred from remote cache.",
1349 "MSRValue": "0x103fc00122 ",
1350 "Counter": "0,1,2,3",
1351 "EventName": "OFFCORE_RESPONSE.ALL_RFO.L3_MISS.REMOTE_HITM",
1352 "MSRIndex": "0x1a6,0x1a7",
1353 "PublicDescription": "Counts all demand & prefetch RFOs that miss the L3 and the modified data is transferred from remote cache. ",
1354 "SampleAfterValue": "100003",
1355 "CounterHTOff": "0,1,2,3"
1356 },
1357 {
1358 "Offcore": "1",
1359 "EventCode": "0xB7, 0xBB",
1360 "UMask": "0x1",
1361 "BriefDescription": "Counts all demand & prefetch RFOs that miss the L3 and the data is returned from local or remote dram.",
1362 "MSRValue": "0x063fc00122 ",
1363 "Counter": "0,1,2,3",
1364 "EventName": "OFFCORE_RESPONSE.ALL_RFO.L3_MISS.SNOOP_MISS_OR_NO_FWD",
1365 "MSRIndex": "0x1a6,0x1a7",
1366 "PublicDescription": "Counts all demand & prefetch RFOs that miss the L3 and the data is returned from local or remote dram. ",
1367 "SampleAfterValue": "100003",
1368 "CounterHTOff": "0,1,2,3"
1369 },
1370 {
1371 "Offcore": "1",
1372 "EventCode": "0xB7, 0xBB",
1373 "UMask": "0x1",
1374 "BriefDescription": "Counts all demand & prefetch RFOs that miss the L3 and the data is returned from remote dram.",
1375 "MSRValue": "0x063b800122 ",
1376 "Counter": "0,1,2,3",
1377 "EventName": "OFFCORE_RESPONSE.ALL_RFO.L3_MISS_REMOTE_DRAM.SNOOP_MISS_OR_NO_FWD",
1378 "MSRIndex": "0x1a6,0x1a7",
1379 "PublicDescription": "Counts all demand & prefetch RFOs that miss the L3 and the data is returned from remote dram. ",
1380 "SampleAfterValue": "100003",
1381 "CounterHTOff": "0,1,2,3"
1382 },
1383 {
1384 "Offcore": "1",
1385 "EventCode": "0xB7, 0xBB",
1386 "UMask": "0x1",
1387 "BriefDescription": "Counts all demand & prefetch RFOs that miss the L3 and the data is returned from local dram.",
1388 "MSRValue": "0x0604000122 ",
1389 "Counter": "0,1,2,3",
1390 "EventName": "OFFCORE_RESPONSE.ALL_RFO.L3_MISS_LOCAL_DRAM.SNOOP_MISS_OR_NO_FWD",
1391 "MSRIndex": "0x1a6,0x1a7",
1392 "PublicDescription": "Counts all demand & prefetch RFOs that miss the L3 and the data is returned from local dram.",
1393 "SampleAfterValue": "100003",
1394 "CounterHTOff": "0,1,2,3"
1395 }
1396]
diff --git a/tools/perf/pmu-events/arch/x86/skylakex/other.json b/tools/perf/pmu-events/arch/x86/skylakex/other.json
new file mode 100644
index 000000000000..70243b0b0586
--- /dev/null
+++ b/tools/perf/pmu-events/arch/x86/skylakex/other.json
@@ -0,0 +1,72 @@
1[
2 {
3 "EventCode": "0x28",
4 "UMask": "0x7",
5 "BriefDescription": "Core cycles where the core was running in a manner where Turbo may be clipped to the Non-AVX turbo schedule.",
6 "Counter": "0,1,2,3",
7 "EventName": "CORE_POWER.LVL0_TURBO_LICENSE",
8 "PublicDescription": "Core cycles where the core was running with power-delivery for baseline license level 0. This includes non-AVX codes, SSE, AVX 128-bit, and low-current AVX 256-bit codes.",
9 "SampleAfterValue": "200003",
10 "CounterHTOff": "0,1,2,3,4,5,6,7"
11 },
12 {
13 "EventCode": "0x28",
14 "UMask": "0x18",
15 "BriefDescription": "Core cycles where the core was running in a manner where Turbo may be clipped to the AVX2 turbo schedule.",
16 "Counter": "0,1,2,3",
17 "EventName": "CORE_POWER.LVL1_TURBO_LICENSE",
18 "PublicDescription": "Core cycles where the core was running with power-delivery for license level 1. This includes high current AVX 256-bit instructions as well as low current AVX 512-bit instructions.",
19 "SampleAfterValue": "200003",
20 "CounterHTOff": "0,1,2,3,4,5,6,7"
21 },
22 {
23 "EventCode": "0x28",
24 "UMask": "0x20",
25 "BriefDescription": "Core cycles where the core was running in a manner where Turbo may be clipped to the AVX512 turbo schedule.",
26 "Counter": "0,1,2,3",
27 "EventName": "CORE_POWER.LVL2_TURBO_LICENSE",
28 "PublicDescription": "Core cycles where the core was running with power-delivery for license level 2 (introduced in Skylake Server michroarchtecture). This includes high current AVX 512-bit instructions.",
29 "SampleAfterValue": "200003",
30 "CounterHTOff": "0,1,2,3,4,5,6,7"
31 },
32 {
33 "EventCode": "0x28",
34 "UMask": "0x40",
35 "BriefDescription": "Core cycles the core was throttled due to a pending power level request.",
36 "Counter": "0,1,2,3",
37 "EventName": "CORE_POWER.THROTTLE",
38 "PublicDescription": "Core cycles the out-of-order engine was throttled due to a pending power level request.",
39 "SampleAfterValue": "200003",
40 "CounterHTOff": "0,1,2,3,4,5,6,7"
41 },
42 {
43 "EventCode": "0xCB",
44 "UMask": "0x1",
45 "BriefDescription": "Number of hardware interrupts received by the processor.",
46 "Counter": "0,1,2,3",
47 "EventName": "HW_INTERRUPTS.RECEIVED",
48 "PublicDescription": "Counts the number of hardware interruptions received by the processor.",
49 "SampleAfterValue": "203",
50 "CounterHTOff": "0,1,2,3,4,5,6,7"
51 },
52 {
53 "EventCode": "0xFE",
54 "UMask": "0x2",
55 "BriefDescription": "Counts number of cache lines that are allocated and written back to L3 with the intention that they are more likely to be reused shortly",
56 "Counter": "0,1,2,3",
57 "EventName": "IDI_MISC.WB_UPGRADE",
58 "PublicDescription": "Counts number of cache lines that are allocated and written back to L3 with the intention that they are more likely to be reused shortly.",
59 "SampleAfterValue": "100003",
60 "CounterHTOff": "0,1,2,3,4,5,6,7"
61 },
62 {
63 "EventCode": "0xFE",
64 "UMask": "0x4",
65 "BriefDescription": "Counts number of cache lines that are dropped and not written back to L3 as they are deemed to be less likely to be reused shortly",
66 "Counter": "0,1,2,3",
67 "EventName": "IDI_MISC.WB_DOWNGRADE",
68 "PublicDescription": "Counts number of cache lines that are dropped and not written back to L3 as they are deemed to be less likely to be reused shortly.",
69 "SampleAfterValue": "100003",
70 "CounterHTOff": "0,1,2,3,4,5,6,7"
71 }
72]
diff --git a/tools/perf/pmu-events/arch/x86/skylakex/pipeline.json b/tools/perf/pmu-events/arch/x86/skylakex/pipeline.json
new file mode 100644
index 000000000000..0895d1e52a4a
--- /dev/null
+++ b/tools/perf/pmu-events/arch/x86/skylakex/pipeline.json
@@ -0,0 +1,950 @@
1[
2 {
3 "EventCode": "0x00",
4 "UMask": "0x1",
5 "BriefDescription": "Instructions retired from execution.",
6 "Counter": "Fixed counter 1",
7 "EventName": "INST_RETIRED.ANY",
8 "PublicDescription": "Counts the number of instructions retired from execution. For instructions that consist of multiple micro-ops, Counts the retirement of the last micro-op of the instruction. Counting continues during hardware interrupts, traps, and inside interrupt handlers. Notes: INST_RETIRED.ANY is counted by a designated fixed counter, leaving the four (eight when Hyperthreading is disabled) programmable counters available for other events. INST_RETIRED.ANY_P is counted by a programmable counter and it is an architectural performance event. Counting: Faulting executions of GETSEC/VM entry/VM Exit/MWait will not count as retired instructions.",
9 "SampleAfterValue": "2000003",
10 "CounterHTOff": "Fixed counter 1"
11 },
12 {
13 "EventCode": "0x00",
14 "UMask": "0x2",
15 "BriefDescription": "Core cycles when the thread is not in halt state",
16 "Counter": "Fixed counter 2",
17 "EventName": "CPU_CLK_UNHALTED.THREAD",
18 "PublicDescription": "Counts the number of core cycles while the thread is not in a halt state. The thread enters the halt state when it is running the HLT instruction. This event is a component in many key event ratios. The core frequency may change from time to time due to transitions associated with Enhanced Intel SpeedStep Technology or TM2. For this reason this event may have a changing ratio with regards to time. When the core frequency is constant, this event can approximate elapsed time while the core was not in the halt state. It is counted on a dedicated fixed counter, leaving the four (eight when Hyperthreading is disabled) programmable counters available for other events.",
19 "SampleAfterValue": "2000003",
20 "CounterHTOff": "Fixed counter 2"
21 },
22 {
23 "EventCode": "0x00",
24 "UMask": "0x2",
25 "BriefDescription": "Core cycles when at least one thread on the physical core is not in halt state.",
26 "Counter": "Fixed counter 2",
27 "EventName": "CPU_CLK_UNHALTED.THREAD_ANY",
28 "AnyThread": "1",
29 "SampleAfterValue": "2000003",
30 "CounterHTOff": "Fixed counter 2"
31 },
32 {
33 "EventCode": "0x00",
34 "UMask": "0x3",
35 "BriefDescription": "Reference cycles when the core is not in halt state.",
36 "Counter": "Fixed counter 3",
37 "EventName": "CPU_CLK_UNHALTED.REF_TSC",
38 "PublicDescription": "Counts the number of reference cycles when the core is not in a halt state. The core enters the halt state when it is running the HLT instruction or the MWAIT instruction. This event is not affected by core frequency changes (for example, P states, TM2 transitions) but has the same incrementing frequency as the time stamp counter. This event can approximate elapsed time while the core was not in a halt state. This event has a constant ratio with the CPU_CLK_UNHALTED.REF_XCLK event. It is counted on a dedicated fixed counter, leaving the four (eight when Hyperthreading is disabled) programmable counters available for other events. Note: On all current platforms this event stops counting during 'throttling (TM)' states duty off periods the processor is 'halted'. The counter update is done at a lower clock rate then the core clock the overflow status bit for this counter may appear 'sticky'. After the counter has overflowed and software clears the overflow status bit and resets the counter to less than MAX. The reset value to the counter is not clocked immediately so the overflow status bit will flip 'high (1)' and generate another PMI (if enabled) after which the reset value gets clocked into the counter. Therefore, software will get the interrupt, read the overflow status bit '1 for bit 34 while the counter value is less than MAX. Software should ignore this case.",
39 "SampleAfterValue": "2000003",
40 "CounterHTOff": "Fixed counter 3"
41 },
42 {
43 "EventCode": "0x03",
44 "UMask": "0x2",
45 "BriefDescription": "Loads blocked by overlapping with store buffer that cannot be forwarded .",
46 "Counter": "0,1,2,3",
47 "EventName": "LD_BLOCKS.STORE_FORWARD",
48 "PublicDescription": "Counts how many times the load operation got the true Block-on-Store blocking code preventing store forwarding. This includes cases when:a. preceding store conflicts with the load (incomplete overlap),b. store forwarding is impossible due to u-arch limitations,c. preceding lock RMW operations are not forwarded,d. store has the no-forward bit set (uncacheable/page-split/masked stores),e. all-blocking stores are used (mostly, fences and port I/O), and others.The most common case is a load blocked due to its address range overlapping with a preceding smaller uncompleted store. Note: This event does not take into account cases of out-of-SW-control (for example, SbTailHit), unknown physical STA, and cases of blocking loads on store due to being non-WB memory type or a lock. These cases are covered by other events. See the table of not supported store forwards in the Optimization Guide.",
49 "SampleAfterValue": "100003",
50 "CounterHTOff": "0,1,2,3,4,5,6,7"
51 },
52 {
53 "EventCode": "0x03",
54 "UMask": "0x8",
55 "BriefDescription": "The number of times that split load operations are temporarily blocked because all resources for handling the split accesses are in use",
56 "Counter": "0,1,2,3",
57 "EventName": "LD_BLOCKS.NO_SR",
58 "PublicDescription": "The number of times that split load operations are temporarily blocked because all resources for handling the split accesses are in use.",
59 "SampleAfterValue": "100003",
60 "CounterHTOff": "0,1,2,3,4,5,6,7"
61 },
62 {
63 "EventCode": "0x07",
64 "UMask": "0x1",
65 "BriefDescription": "False dependencies in MOB due to partial compare on address.",
66 "Counter": "0,1,2,3",
67 "EventName": "LD_BLOCKS_PARTIAL.ADDRESS_ALIAS",
68 "PublicDescription": "Counts false dependencies in MOB when the partial comparison upon loose net check and dependency was resolved by the Enhanced Loose net mechanism. This may not result in high performance penalties. Loose net checks can fail when loads and stores are 4k aliased.",
69 "SampleAfterValue": "100003",
70 "CounterHTOff": "0,1,2,3,4,5,6,7"
71 },
72 {
73 "EventCode": "0x0D",
74 "UMask": "0x1",
75 "BriefDescription": "Core cycles the allocator was stalled due to recovery from earlier clear event for this thread (e.g. misprediction or memory nuke)",
76 "Counter": "0,1,2,3",
77 "EventName": "INT_MISC.RECOVERY_CYCLES",
78 "PublicDescription": "Core cycles the Resource allocator was stalled due to recovery from an earlier branch misprediction or machine clear event.",
79 "SampleAfterValue": "2000003",
80 "CounterHTOff": "0,1,2,3,4,5,6,7"
81 },
82 {
83 "EventCode": "0x0D",
84 "UMask": "0x1",
85 "BriefDescription": "Core cycles the allocator was stalled due to recovery from earlier clear event for any thread running on the physical core (e.g. misprediction or memory nuke).",
86 "Counter": "0,1,2,3",
87 "EventName": "INT_MISC.RECOVERY_CYCLES_ANY",
88 "AnyThread": "1",
89 "SampleAfterValue": "2000003",
90 "CounterHTOff": "0,1,2,3,4,5,6,7"
91 },
92 {
93 "EventCode": "0x0D",
94 "UMask": "0x80",
95 "BriefDescription": "Cycles the issue-stage is waiting for front-end to fetch from resteered path following branch misprediction or machine clear events.",
96 "Counter": "0,1,2,3",
97 "EventName": "INT_MISC.CLEAR_RESTEER_CYCLES",
98 "SampleAfterValue": "2000003",
99 "CounterHTOff": "0,1,2,3,4,5,6,7"
100 },
101 {
102 "EventCode": "0x0E",
103 "UMask": "0x1",
104 "BriefDescription": "Uops that Resource Allocation Table (RAT) issues to Reservation Station (RS)",
105 "Counter": "0,1,2,3",
106 "EventName": "UOPS_ISSUED.ANY",
107 "PublicDescription": "Counts the number of uops that the Resource Allocation Table (RAT) issues to the Reservation Station (RS).",
108 "SampleAfterValue": "2000003",
109 "CounterHTOff": "0,1,2,3,4,5,6,7"
110 },
111 {
112 "Invert": "1",
113 "EventCode": "0x0E",
114 "UMask": "0x1",
115 "BriefDescription": "Cycles when Resource Allocation Table (RAT) does not issue Uops to Reservation Station (RS) for the thread",
116 "Counter": "0,1,2,3",
117 "EventName": "UOPS_ISSUED.STALL_CYCLES",
118 "CounterMask": "1",
119 "PublicDescription": "Counts cycles during which the Resource Allocation Table (RAT) does not issue any Uops to the reservation station (RS) for the current thread.",
120 "SampleAfterValue": "2000003",
121 "CounterHTOff": "0,1,2,3,4,5,6,7"
122 },
123 {
124 "EventCode": "0x0E",
125 "UMask": "0x2",
126 "BriefDescription": "Uops inserted at issue-stage in order to preserve upper bits of vector registers.",
127 "Counter": "0,1,2,3",
128 "EventName": "UOPS_ISSUED.VECTOR_WIDTH_MISMATCH",
129 "PublicDescription": "Counts the number of Blend Uops issued by the Resource Allocation Table (RAT) to the reservation station (RS) in order to preserve upper bits of vector registers. Starting with the Skylake microarchitecture, these Blend uops are needed since every Intel SSE instruction executed in Dirty Upper State needs to preserve bits 128-255 of the destination register. For more information, refer to \u201cMixing Intel AVX and Intel SSE Code\u201d section of the Optimization Guide.",
130 "SampleAfterValue": "2000003",
131 "CounterHTOff": "0,1,2,3,4,5,6,7"
132 },
133 {
134 "EventCode": "0x0E",
135 "UMask": "0x20",
136 "BriefDescription": "Number of slow LEA uops being allocated. A uop is generally considered SlowLea if it has 3 sources (e.g. 2 sources + immediate) regardless if as a result of LEA instruction or not.",
137 "Counter": "0,1,2,3",
138 "EventName": "UOPS_ISSUED.SLOW_LEA",
139 "SampleAfterValue": "2000003",
140 "CounterHTOff": "0,1,2,3,4,5,6,7"
141 },
142 {
143 "EventCode": "0x14",
144 "UMask": "0x1",
145 "BriefDescription": "Cycles when divide unit is busy executing divide or square root operations. Accounts for integer and floating-point operations.",
146 "Counter": "0,1,2,3",
147 "EventName": "ARITH.DIVIDER_ACTIVE",
148 "CounterMask": "1",
149 "SampleAfterValue": "2000003",
150 "CounterHTOff": "0,1,2,3,4,5,6,7"
151 },
152 {
153 "EventCode": "0x3C",
154 "UMask": "0x0",
155 "BriefDescription": "Thread cycles when thread is not in halt state",
156 "Counter": "0,1,2,3",
157 "EventName": "CPU_CLK_UNHALTED.THREAD_P",
158 "PublicDescription": "This is an architectural event that counts the number of thread cycles while the thread is not in a halt state. The thread enters the halt state when it is running the HLT instruction. The core frequency may change from time to time due to power or thermal throttling. For this reason, this event may have a changing ratio with regards to wall clock time.",
159 "SampleAfterValue": "2000003",
160 "CounterHTOff": "0,1,2,3,4,5,6,7"
161 },
162 {
163 "EventCode": "0x3C",
164 "UMask": "0x0",
165 "BriefDescription": "Core cycles when at least one thread on the physical core is not in halt state.",
166 "Counter": "0,1,2,3",
167 "EventName": "CPU_CLK_UNHALTED.THREAD_P_ANY",
168 "AnyThread": "1",
169 "SampleAfterValue": "2000003",
170 "CounterHTOff": "0,1,2,3,4,5,6,7"
171 },
172 {
173 "EdgeDetect": "1",
174 "EventCode": "0x3C",
175 "UMask": "0x0",
176 "BriefDescription": "Counts when there is a transition from ring 1, 2 or 3 to ring 0.",
177 "Counter": "0,1,2,3",
178 "EventName": "CPU_CLK_UNHALTED.RING0_TRANS",
179 "CounterMask": "1",
180 "PublicDescription": "Counts when the Current Privilege Level (CPL) transitions from ring 1, 2 or 3 to ring 0 (Kernel).",
181 "SampleAfterValue": "100007",
182 "CounterHTOff": "0,1,2,3,4,5,6,7"
183 },
184 {
185 "EventCode": "0x3C",
186 "UMask": "0x1",
187 "BriefDescription": "Core crystal clock cycles when the thread is unhalted.",
188 "Counter": "0,1,2,3",
189 "EventName": "CPU_CLK_THREAD_UNHALTED.REF_XCLK",
190 "SampleAfterValue": "2503",
191 "CounterHTOff": "0,1,2,3,4,5,6,7"
192 },
193 {
194 "EventCode": "0x3C",
195 "UMask": "0x1",
196 "BriefDescription": "Core crystal clock cycles when at least one thread on the physical core is unhalted.",
197 "Counter": "0,1,2,3",
198 "EventName": "CPU_CLK_THREAD_UNHALTED.REF_XCLK_ANY",
199 "AnyThread": "1",
200 "SampleAfterValue": "2503",
201 "CounterHTOff": "0,1,2,3,4,5,6,7"
202 },
203 {
204 "EventCode": "0x3C",
205 "UMask": "0x1",
206 "BriefDescription": "Core crystal clock cycles when the thread is unhalted.",
207 "Counter": "0,1,2,3",
208 "EventName": "CPU_CLK_UNHALTED.REF_XCLK",
209 "SampleAfterValue": "2503",
210 "CounterHTOff": "0,1,2,3,4,5,6,7"
211 },
212 {
213 "EventCode": "0x3C",
214 "UMask": "0x1",
215 "BriefDescription": "Core crystal clock cycles when at least one thread on the physical core is unhalted.",
216 "Counter": "0,1,2,3",
217 "EventName": "CPU_CLK_UNHALTED.REF_XCLK_ANY",
218 "AnyThread": "1",
219 "SampleAfterValue": "2503",
220 "CounterHTOff": "0,1,2,3,4,5,6,7"
221 },
222 {
223 "EventCode": "0x3C",
224 "UMask": "0x2",
225 "BriefDescription": "Core crystal clock cycles when this thread is unhalted and the other thread is halted.",
226 "Counter": "0,1,2,3",
227 "EventName": "CPU_CLK_THREAD_UNHALTED.ONE_THREAD_ACTIVE",
228 "SampleAfterValue": "2000003",
229 "CounterHTOff": "0,1,2,3,4,5,6,7"
230 },
231 {
232 "EventCode": "0x3C",
233 "UMask": "0x2",
234 "BriefDescription": "Core crystal clock cycles when this thread is unhalted and the other thread is halted.",
235 "Counter": "0,1,2,3",
236 "EventName": "CPU_CLK_UNHALTED.ONE_THREAD_ACTIVE",
237 "SampleAfterValue": "2503",
238 "CounterHTOff": "0,1,2,3,4,5,6,7"
239 },
240 {
241 "EventCode": "0x4C",
242 "UMask": "0x1",
243 "BriefDescription": "Demand load dispatches that hit L1D fill buffer (FB) allocated for software prefetch.",
244 "Counter": "0,1,2,3",
245 "EventName": "LOAD_HIT_PRE.SW_PF",
246 "PublicDescription": "Counts all not software-prefetch load dispatches that hit the fill buffer (FB) allocated for the software prefetch. It can also be incremented by some lock instructions. So it should only be used with profiling so that the locks can be excluded by ASM (Assembly File) inspection of the nearby instructions.",
247 "SampleAfterValue": "100003",
248 "CounterHTOff": "0,1,2,3,4,5,6,7"
249 },
250 {
251 "EventCode": "0x5E",
252 "UMask": "0x1",
253 "BriefDescription": "Cycles when Reservation Station (RS) is empty for the thread",
254 "Counter": "0,1,2,3",
255 "EventName": "RS_EVENTS.EMPTY_CYCLES",
256 "PublicDescription": "Counts cycles during which the reservation station (RS) is empty for the thread.; Note: In ST-mode, not active thread should drive 0. This is usually caused by severely costly branch mispredictions, or allocator/FE issues.",
257 "SampleAfterValue": "2000003",
258 "CounterHTOff": "0,1,2,3,4,5,6,7"
259 },
260 {
261 "EdgeDetect": "1",
262 "Invert": "1",
263 "EventCode": "0x5E",
264 "UMask": "0x1",
265 "BriefDescription": "Counts end of periods where the Reservation Station (RS) was empty. Could be useful to precisely locate Frontend Latency Bound issues.",
266 "Counter": "0,1,2,3",
267 "EventName": "RS_EVENTS.EMPTY_END",
268 "CounterMask": "1",
269 "PublicDescription": "Counts end of periods where the Reservation Station (RS) was empty. Could be useful to precisely locate front-end Latency Bound issues.",
270 "SampleAfterValue": "2000003",
271 "CounterHTOff": "0,1,2,3,4,5,6,7"
272 },
273 {
274 "EventCode": "0x87",
275 "UMask": "0x1",
276 "BriefDescription": "Stalls caused by changing prefix length of the instruction.",
277 "Counter": "0,1,2,3",
278 "EventName": "ILD_STALL.LCP",
279 "PublicDescription": "Counts cycles that the Instruction Length decoder (ILD) stalls occurred due to dynamically changing prefix length of the decoded instruction (by operand size prefix instruction 0x66, address size prefix instruction 0x67 or REX.W for Intel64). Count is proportional to the number of prefixes in a 16B-line. This may result in a three-cycle penalty for each LCP (Length changing prefix) in a 16-byte chunk.",
280 "SampleAfterValue": "2000003",
281 "CounterHTOff": "0,1,2,3,4,5,6,7"
282 },
283 {
284 "EventCode": "0xA1",
285 "UMask": "0x1",
286 "BriefDescription": "Cycles per thread when uops are executed in port 0",
287 "Counter": "0,1,2,3",
288 "EventName": "UOPS_DISPATCHED_PORT.PORT_0",
289 "PublicDescription": "Counts, on the per-thread basis, cycles during which at least one uop is dispatched from the Reservation Station (RS) to port 0.",
290 "SampleAfterValue": "2000003",
291 "CounterHTOff": "0,1,2,3,4,5,6,7"
292 },
293 {
294 "EventCode": "0xA1",
295 "UMask": "0x2",
296 "BriefDescription": "Cycles per thread when uops are executed in port 1",
297 "Counter": "0,1,2,3",
298 "EventName": "UOPS_DISPATCHED_PORT.PORT_1",
299 "PublicDescription": "Counts, on the per-thread basis, cycles during which at least one uop is dispatched from the Reservation Station (RS) to port 1.",
300 "SampleAfterValue": "2000003",
301 "CounterHTOff": "0,1,2,3,4,5,6,7"
302 },
303 {
304 "EventCode": "0xA1",
305 "UMask": "0x4",
306 "BriefDescription": "Cycles per thread when uops are executed in port 2",
307 "Counter": "0,1,2,3",
308 "EventName": "UOPS_DISPATCHED_PORT.PORT_2",
309 "PublicDescription": "Counts, on the per-thread basis, cycles during which at least one uop is dispatched from the Reservation Station (RS) to port 2.",
310 "SampleAfterValue": "2000003",
311 "CounterHTOff": "0,1,2,3,4,5,6,7"
312 },
313 {
314 "EventCode": "0xA1",
315 "UMask": "0x8",
316 "BriefDescription": "Cycles per thread when uops are executed in port 3",
317 "Counter": "0,1,2,3",
318 "EventName": "UOPS_DISPATCHED_PORT.PORT_3",
319 "PublicDescription": "Counts, on the per-thread basis, cycles during which at least one uop is dispatched from the Reservation Station (RS) to port 3.",
320 "SampleAfterValue": "2000003",
321 "CounterHTOff": "0,1,2,3,4,5,6,7"
322 },
323 {
324 "EventCode": "0xA1",
325 "UMask": "0x10",
326 "BriefDescription": "Cycles per thread when uops are executed in port 4",
327 "Counter": "0,1,2,3",
328 "EventName": "UOPS_DISPATCHED_PORT.PORT_4",
329 "PublicDescription": "Counts, on the per-thread basis, cycles during which at least one uop is dispatched from the Reservation Station (RS) to port 4.",
330 "SampleAfterValue": "2000003",
331 "CounterHTOff": "0,1,2,3,4,5,6,7"
332 },
333 {
334 "EventCode": "0xA1",
335 "UMask": "0x20",
336 "BriefDescription": "Cycles per thread when uops are executed in port 5",
337 "Counter": "0,1,2,3",
338 "EventName": "UOPS_DISPATCHED_PORT.PORT_5",
339 "PublicDescription": "Counts, on the per-thread basis, cycles during which at least one uop is dispatched from the Reservation Station (RS) to port 5.",
340 "SampleAfterValue": "2000003",
341 "CounterHTOff": "0,1,2,3,4,5,6,7"
342 },
343 {
344 "EventCode": "0xA1",
345 "UMask": "0x40",
346 "BriefDescription": "Cycles per thread when uops are executed in port 6",
347 "Counter": "0,1,2,3",
348 "EventName": "UOPS_DISPATCHED_PORT.PORT_6",
349 "PublicDescription": "Counts, on the per-thread basis, cycles during which at least one uop is dispatched from the Reservation Station (RS) to port 6.",
350 "SampleAfterValue": "2000003",
351 "CounterHTOff": "0,1,2,3,4,5,6,7"
352 },
353 {
354 "EventCode": "0xA1",
355 "UMask": "0x80",
356 "BriefDescription": "Cycles per thread when uops are executed in port 7",
357 "Counter": "0,1,2,3",
358 "EventName": "UOPS_DISPATCHED_PORT.PORT_7",
359 "PublicDescription": "Counts, on the per-thread basis, cycles during which at least one uop is dispatched from the Reservation Station (RS) to port 7.",
360 "SampleAfterValue": "2000003",
361 "CounterHTOff": "0,1,2,3,4,5,6,7"
362 },
363 {
364 "EventCode": "0xA2",
365 "UMask": "0x1",
366 "BriefDescription": "Resource-related stall cycles",
367 "Counter": "0,1,2,3",
368 "EventName": "RESOURCE_STALLS.ANY",
369 "PublicDescription": "Counts resource-related stall cycles. Reasons for stalls can be as follows:a. *any* u-arch structure got full (LB, SB, RS, ROB, BOB, LM, Physical Register Reclaim Table (PRRT), or Physical History Table (PHT) slots).b. *any* u-arch structure got empty (like INT/SIMD FreeLists).c. FPU control word (FPCW), MXCSR.and others. This counts cycles that the pipeline back-end blocked uop delivery from the front-end.",
370 "SampleAfterValue": "2000003",
371 "CounterHTOff": "0,1,2,3,4,5,6,7"
372 },
373 {
374 "EventCode": "0xA2",
375 "UMask": "0x8",
376 "BriefDescription": "Cycles stalled due to no store buffers available. (not including draining form sync).",
377 "Counter": "0,1,2,3",
378 "EventName": "RESOURCE_STALLS.SB",
379 "PublicDescription": "Counts allocation stall cycles caused by the store buffer (SB) being full. This counts cycles that the pipeline back-end blocked uop delivery from the front-end.",
380 "SampleAfterValue": "2000003",
381 "CounterHTOff": "0,1,2,3,4,5,6,7"
382 },
383 {
384 "EventCode": "0xA3",
385 "UMask": "0x1",
386 "BriefDescription": "Cycles while L2 cache miss demand load is outstanding.",
387 "Counter": "0,1,2,3",
388 "EventName": "CYCLE_ACTIVITY.CYCLES_L2_MISS",
389 "CounterMask": "1",
390 "SampleAfterValue": "2000003",
391 "CounterHTOff": "0,1,2,3,4,5,6,7"
392 },
393 {
394 "EventCode": "0xA3",
395 "UMask": "0x4",
396 "BriefDescription": "Total execution stalls.",
397 "Counter": "0,1,2,3",
398 "EventName": "CYCLE_ACTIVITY.STALLS_TOTAL",
399 "CounterMask": "4",
400 "SampleAfterValue": "2000003",
401 "CounterHTOff": "0,1,2,3,4,5,6,7"
402 },
403 {
404 "EventCode": "0xA3",
405 "UMask": "0x5",
406 "BriefDescription": "Execution stalls while L2 cache miss demand load is outstanding.",
407 "Counter": "0,1,2,3",
408 "EventName": "CYCLE_ACTIVITY.STALLS_L2_MISS",
409 "CounterMask": "5",
410 "SampleAfterValue": "2000003",
411 "CounterHTOff": "0,1,2,3,4,5,6,7"
412 },
413 {
414 "EventCode": "0xA3",
415 "UMask": "0x8",
416 "BriefDescription": "Cycles while L1 cache miss demand load is outstanding.",
417 "Counter": "0,1,2,3",
418 "EventName": "CYCLE_ACTIVITY.CYCLES_L1D_MISS",
419 "CounterMask": "8",
420 "SampleAfterValue": "2000003",
421 "CounterHTOff": "0,1,2,3,4,5,6,7"
422 },
423 {
424 "EventCode": "0xA3",
425 "UMask": "0xc",
426 "BriefDescription": "Execution stalls while L1 cache miss demand load is outstanding.",
427 "Counter": "0,1,2,3",
428 "EventName": "CYCLE_ACTIVITY.STALLS_L1D_MISS",
429 "CounterMask": "12",
430 "SampleAfterValue": "2000003",
431 "CounterHTOff": "0,1,2,3,4,5,6,7"
432 },
433 {
434 "EventCode": "0xA3",
435 "UMask": "0x10",
436 "BriefDescription": "Cycles while memory subsystem has an outstanding load.",
437 "Counter": "0,1,2,3",
438 "EventName": "CYCLE_ACTIVITY.CYCLES_MEM_ANY",
439 "CounterMask": "16",
440 "SampleAfterValue": "2000003",
441 "CounterHTOff": "0,1,2,3,4,5,6,7"
442 },
443 {
444 "EventCode": "0xA3",
445 "UMask": "0x14",
446 "BriefDescription": "Execution stalls while memory subsystem has an outstanding load.",
447 "Counter": "0,1,2,3",
448 "EventName": "CYCLE_ACTIVITY.STALLS_MEM_ANY",
449 "CounterMask": "20",
450 "SampleAfterValue": "2000003",
451 "CounterHTOff": "0,1,2,3"
452 },
453 {
454 "EventCode": "0xA6",
455 "UMask": "0x1",
456 "BriefDescription": "Cycles where no uops were executed, the Reservation Station was not empty, the Store Buffer was full and there was no outstanding load.",
457 "Counter": "0,1,2,3",
458 "EventName": "EXE_ACTIVITY.EXE_BOUND_0_PORTS",
459 "PublicDescription": "Counts cycles during which no uops were executed on all ports and Reservation Station (RS) was not empty.",
460 "SampleAfterValue": "2000003",
461 "CounterHTOff": "0,1,2,3,4,5,6,7"
462 },
463 {
464 "EventCode": "0xA6",
465 "UMask": "0x2",
466 "BriefDescription": "Cycles total of 1 uop is executed on all ports and Reservation Station was not empty.",
467 "Counter": "0,1,2,3",
468 "EventName": "EXE_ACTIVITY.1_PORTS_UTIL",
469 "PublicDescription": "Counts cycles during which a total of 1 uop was executed on all ports and Reservation Station (RS) was not empty.",
470 "SampleAfterValue": "2000003",
471 "CounterHTOff": "0,1,2,3,4,5,6,7"
472 },
473 {
474 "EventCode": "0xA6",
475 "UMask": "0x4",
476 "BriefDescription": "Cycles total of 2 uops are executed on all ports and Reservation Station was not empty.",
477 "Counter": "0,1,2,3",
478 "EventName": "EXE_ACTIVITY.2_PORTS_UTIL",
479 "PublicDescription": "Counts cycles during which a total of 2 uops were executed on all ports and Reservation Station (RS) was not empty.",
480 "SampleAfterValue": "2000003",
481 "CounterHTOff": "0,1,2,3,4,5,6,7"
482 },
483 {
484 "EventCode": "0xA6",
485 "UMask": "0x8",
486 "BriefDescription": "Cycles total of 3 uops are executed on all ports and Reservation Station was not empty.",
487 "Counter": "0,1,2,3",
488 "EventName": "EXE_ACTIVITY.3_PORTS_UTIL",
489 "PublicDescription": "Cycles total of 3 uops are executed on all ports and Reservation Station (RS) was not empty.",
490 "SampleAfterValue": "2000003",
491 "CounterHTOff": "0,1,2,3,4,5,6,7"
492 },
493 {
494 "EventCode": "0xA6",
495 "UMask": "0x10",
496 "BriefDescription": "Cycles total of 4 uops are executed on all ports and Reservation Station was not empty.",
497 "Counter": "0,1,2,3",
498 "EventName": "EXE_ACTIVITY.4_PORTS_UTIL",
499 "PublicDescription": "Cycles total of 4 uops are executed on all ports and Reservation Station (RS) was not empty.",
500 "SampleAfterValue": "2000003",
501 "CounterHTOff": "0,1,2,3,4,5,6,7"
502 },
503 {
504 "EventCode": "0xA6",
505 "UMask": "0x40",
506 "BriefDescription": "Cycles where the Store Buffer was full and no outstanding load.",
507 "Counter": "0,1,2,3",
508 "EventName": "EXE_ACTIVITY.BOUND_ON_STORES",
509 "SampleAfterValue": "2000003",
510 "CounterHTOff": "0,1,2,3,4,5,6,7"
511 },
512 {
513 "EventCode": "0xA8",
514 "UMask": "0x1",
515 "BriefDescription": "Number of Uops delivered by the LSD.",
516 "Counter": "0,1,2,3",
517 "EventName": "LSD.UOPS",
518 "PublicDescription": "Number of uops delivered to the back-end by the LSD(Loop Stream Detector).",
519 "SampleAfterValue": "2000003",
520 "CounterHTOff": "0,1,2,3,4,5,6,7"
521 },
522 {
523 "EventCode": "0xA8",
524 "UMask": "0x1",
525 "BriefDescription": "Cycles Uops delivered by the LSD, but didn't come from the decoder.",
526 "Counter": "0,1,2,3",
527 "EventName": "LSD.CYCLES_ACTIVE",
528 "CounterMask": "1",
529 "PublicDescription": "Counts the cycles when at least one uop is delivered by the LSD (Loop-stream detector).",
530 "SampleAfterValue": "2000003",
531 "CounterHTOff": "0,1,2,3,4,5,6,7"
532 },
533 {
534 "EventCode": "0xA8",
535 "UMask": "0x1",
536 "BriefDescription": "Cycles 4 Uops delivered by the LSD, but didn't come from the decoder.",
537 "Counter": "0,1,2,3",
538 "EventName": "LSD.CYCLES_4_UOPS",
539 "CounterMask": "4",
540 "PublicDescription": "Counts the cycles when 4 uops are delivered by the LSD (Loop-stream detector).",
541 "SampleAfterValue": "2000003",
542 "CounterHTOff": "0,1,2,3,4,5,6,7"
543 },
544 {
545 "EventCode": "0xB1",
546 "UMask": "0x1",
547 "BriefDescription": "Counts the number of uops to be executed per-thread each cycle.",
548 "Counter": "0,1,2,3",
549 "EventName": "UOPS_EXECUTED.THREAD",
550 "PublicDescription": "Number of uops to be executed per-thread each cycle.",
551 "SampleAfterValue": "2000003",
552 "CounterHTOff": "0,1,2,3,4,5,6,7"
553 },
554 {
555 "Invert": "1",
556 "EventCode": "0xB1",
557 "UMask": "0x1",
558 "BriefDescription": "Counts number of cycles no uops were dispatched to be executed on this thread.",
559 "Counter": "0,1,2,3",
560 "EventName": "UOPS_EXECUTED.STALL_CYCLES",
561 "CounterMask": "1",
562 "PublicDescription": "Counts cycles during which no uops were dispatched from the Reservation Station (RS) per thread.",
563 "SampleAfterValue": "2000003",
564 "CounterHTOff": "0,1,2,3,4,5,6,7"
565 },
566 {
567 "EventCode": "0xB1",
568 "UMask": "0x1",
569 "BriefDescription": "Cycles where at least 1 uop was executed per-thread",
570 "Counter": "0,1,2,3",
571 "EventName": "UOPS_EXECUTED.CYCLES_GE_1_UOP_EXEC",
572 "CounterMask": "1",
573 "PublicDescription": "Cycles where at least 1 uop was executed per-thread.",
574 "SampleAfterValue": "2000003",
575 "CounterHTOff": "0,1,2,3,4,5,6,7"
576 },
577 {
578 "EventCode": "0xB1",
579 "UMask": "0x1",
580 "BriefDescription": "Cycles where at least 2 uops were executed per-thread",
581 "Counter": "0,1,2,3",
582 "EventName": "UOPS_EXECUTED.CYCLES_GE_2_UOPS_EXEC",
583 "CounterMask": "2",
584 "PublicDescription": "Cycles where at least 2 uops were executed per-thread.",
585 "SampleAfterValue": "2000003",
586 "CounterHTOff": "0,1,2,3,4,5,6,7"
587 },
588 {
589 "EventCode": "0xB1",
590 "UMask": "0x1",
591 "BriefDescription": "Cycles where at least 3 uops were executed per-thread",
592 "Counter": "0,1,2,3",
593 "EventName": "UOPS_EXECUTED.CYCLES_GE_3_UOPS_EXEC",
594 "CounterMask": "3",
595 "PublicDescription": "Cycles where at least 3 uops were executed per-thread.",
596 "SampleAfterValue": "2000003",
597 "CounterHTOff": "0,1,2,3,4,5,6,7"
598 },
599 {
600 "EventCode": "0xB1",
601 "UMask": "0x1",
602 "BriefDescription": "Cycles where at least 4 uops were executed per-thread",
603 "Counter": "0,1,2,3",
604 "EventName": "UOPS_EXECUTED.CYCLES_GE_4_UOPS_EXEC",
605 "CounterMask": "4",
606 "PublicDescription": "Cycles where at least 4 uops were executed per-thread.",
607 "SampleAfterValue": "2000003",
608 "CounterHTOff": "0,1,2,3,4,5,6,7"
609 },
610 {
611 "EventCode": "0xB1",
612 "UMask": "0x2",
613 "BriefDescription": "Number of uops executed on the core.",
614 "Counter": "0,1,2,3",
615 "EventName": "UOPS_EXECUTED.CORE",
616 "PublicDescription": "Number of uops executed from any thread.",
617 "SampleAfterValue": "2000003",
618 "CounterHTOff": "0,1,2,3,4,5,6,7"
619 },
620 {
621 "EventCode": "0xB1",
622 "UMask": "0x2",
623 "BriefDescription": "Cycles at least 1 micro-op is executed from any thread on physical core.",
624 "Counter": "0,1,2,3",
625 "EventName": "UOPS_EXECUTED.CORE_CYCLES_GE_1",
626 "CounterMask": "1",
627 "SampleAfterValue": "2000003",
628 "CounterHTOff": "0,1,2,3,4,5,6,7"
629 },
630 {
631 "EventCode": "0xB1",
632 "UMask": "0x2",
633 "BriefDescription": "Cycles at least 2 micro-op is executed from any thread on physical core.",
634 "Counter": "0,1,2,3",
635 "EventName": "UOPS_EXECUTED.CORE_CYCLES_GE_2",
636 "CounterMask": "2",
637 "SampleAfterValue": "2000003",
638 "CounterHTOff": "0,1,2,3,4,5,6,7"
639 },
640 {
641 "EventCode": "0xB1",
642 "UMask": "0x2",
643 "BriefDescription": "Cycles at least 3 micro-op is executed from any thread on physical core.",
644 "Counter": "0,1,2,3",
645 "EventName": "UOPS_EXECUTED.CORE_CYCLES_GE_3",
646 "CounterMask": "3",
647 "SampleAfterValue": "2000003",
648 "CounterHTOff": "0,1,2,3,4,5,6,7"
649 },
650 {
651 "EventCode": "0xB1",
652 "UMask": "0x2",
653 "BriefDescription": "Cycles at least 4 micro-op is executed from any thread on physical core.",
654 "Counter": "0,1,2,3",
655 "EventName": "UOPS_EXECUTED.CORE_CYCLES_GE_4",
656 "CounterMask": "4",
657 "SampleAfterValue": "2000003",
658 "CounterHTOff": "0,1,2,3,4,5,6,7"
659 },
660 {
661 "Invert": "1",
662 "EventCode": "0xB1",
663 "UMask": "0x2",
664 "BriefDescription": "Cycles with no micro-ops executed from any thread on physical core.",
665 "Counter": "0,1,2,3",
666 "EventName": "UOPS_EXECUTED.CORE_CYCLES_NONE",
667 "CounterMask": "1",
668 "SampleAfterValue": "2000003",
669 "CounterHTOff": "0,1,2,3,4,5,6,7"
670 },
671 {
672 "EventCode": "0xB1",
673 "UMask": "0x10",
674 "BriefDescription": "Counts the number of x87 uops dispatched.",
675 "Counter": "0,1,2,3",
676 "EventName": "UOPS_EXECUTED.X87",
677 "PublicDescription": "Counts the number of x87 uops executed.",
678 "SampleAfterValue": "2000003",
679 "CounterHTOff": "0,1,2,3,4,5,6,7"
680 },
681 {
682 "EventCode": "0xC0",
683 "UMask": "0x0",
684 "BriefDescription": "Number of instructions retired. General Counter - architectural event",
685 "Counter": "0,1,2,3",
686 "EventName": "INST_RETIRED.ANY_P",
687 "Errata": "SKL091, SKL044",
688 "PublicDescription": "Counts the number of instructions (EOMs) retired. Counting covers macro-fused instructions individually (that is, increments by two).",
689 "SampleAfterValue": "2000003",
690 "CounterHTOff": "0,1,2,3,4,5,6,7"
691 },
692 {
693 "EventCode": "0xC0",
694 "UMask": "0x1",
695 "BriefDescription": "Precise instruction retired event with HW to reduce effect of PEBS shadow in IP distribution",
696 "PEBS": "2",
697 "Counter": "1",
698 "EventName": "INST_RETIRED.PREC_DIST",
699 "Errata": "SKL091, SKL044",
700 "PublicDescription": "A version of INST_RETIRED that allows for a more unbiased distribution of samples across instructions retired. It utilizes the Precise Distribution of Instructions Retired (PDIR) feature to mitigate some bias in how retired instructions get sampled.",
701 "SampleAfterValue": "2000003",
702 "CounterHTOff": "1"
703 },
704 {
705 "Invert": "1",
706 "EventCode": "0xC0",
707 "UMask": "0x1",
708 "BriefDescription": "Number of cycles using always true condition applied to PEBS instructions retired event.",
709 "PEBS": "2",
710 "Counter": "0,2,3",
711 "EventName": "INST_RETIRED.TOTAL_CYCLES_PS",
712 "CounterMask": "10",
713 "Errata": "SKL091, SKL044",
714 "PublicDescription": "Number of cycles using an always true condition applied to PEBS instructions retired event. (inst_ret< 16)",
715 "SampleAfterValue": "2000003",
716 "CounterHTOff": "0,2,3"
717 },
718 {
719 "EventCode": "0xC1",
720 "UMask": "0x3f",
721 "BriefDescription": "Number of times a microcode assist is invoked by HW other than FP-assist. Examples include AD (page Access Dirty) and AVX* related assists.",
722 "Counter": "0,1,2,3",
723 "EventName": "OTHER_ASSISTS.ANY",
724 "SampleAfterValue": "100003",
725 "CounterHTOff": "0,1,2,3,4,5,6,7"
726 },
727 {
728 "EventCode": "0xC2",
729 "UMask": "0x2",
730 "BriefDescription": "Retirement slots used.",
731 "Counter": "0,1,2,3",
732 "EventName": "UOPS_RETIRED.RETIRE_SLOTS",
733 "PublicDescription": "Counts the retirement slots used.",
734 "SampleAfterValue": "2000003",
735 "CounterHTOff": "0,1,2,3,4,5,6,7"
736 },
737 {
738 "Invert": "1",
739 "EventCode": "0xC2",
740 "UMask": "0x2",
741 "BriefDescription": "Cycles without actually retired uops.",
742 "Counter": "0,1,2,3",
743 "EventName": "UOPS_RETIRED.STALL_CYCLES",
744 "CounterMask": "1",
745 "PublicDescription": "This is a non-precise version (that is, does not use PEBS) of the event that counts cycles without actually retired uops.",
746 "SampleAfterValue": "2000003",
747 "CounterHTOff": "0,1,2,3,4,5,6,7"
748 },
749 {
750 "Invert": "1",
751 "EventCode": "0xC2",
752 "UMask": "0x2",
753 "BriefDescription": "Cycles with less than 10 actually retired uops.",
754 "Counter": "0,1,2,3",
755 "EventName": "UOPS_RETIRED.TOTAL_CYCLES",
756 "CounterMask": "10",
757 "PublicDescription": "Number of cycles using always true condition (uops_ret < 16) applied to non PEBS uops retired event.",
758 "SampleAfterValue": "2000003",
759 "CounterHTOff": "0,1,2,3,4,5,6,7"
760 },
761 {
762 "EdgeDetect": "1",
763 "EventCode": "0xC3",
764 "UMask": "0x1",
765 "BriefDescription": "Number of machine clears (nukes) of any type. ",
766 "Counter": "0,1,2,3",
767 "EventName": "MACHINE_CLEARS.COUNT",
768 "CounterMask": "1",
769 "PublicDescription": "Number of machine clears (nukes) of any type.",
770 "SampleAfterValue": "100003",
771 "CounterHTOff": "0,1,2,3,4,5,6,7"
772 },
773 {
774 "EventCode": "0xC3",
775 "UMask": "0x4",
776 "BriefDescription": "Self-modifying code (SMC) detected.",
777 "Counter": "0,1,2,3",
778 "EventName": "MACHINE_CLEARS.SMC",
779 "PublicDescription": "Counts self-modifying code (SMC) detected, which causes a machine clear.",
780 "SampleAfterValue": "100003",
781 "CounterHTOff": "0,1,2,3,4,5,6,7"
782 },
783 {
784 "EventCode": "0xC4",
785 "UMask": "0x0",
786 "BriefDescription": "All (macro) branch instructions retired.",
787 "Counter": "0,1,2,3",
788 "EventName": "BR_INST_RETIRED.ALL_BRANCHES",
789 "Errata": "SKL091",
790 "PublicDescription": "Counts all (macro) branch instructions retired.",
791 "SampleAfterValue": "400009",
792 "CounterHTOff": "0,1,2,3,4,5,6,7"
793 },
794 {
795 "EventCode": "0xC4",
796 "UMask": "0x1",
797 "BriefDescription": "Conditional branch instructions retired.",
798 "PEBS": "1",
799 "Counter": "0,1,2,3",
800 "EventName": "BR_INST_RETIRED.CONDITIONAL",
801 "Errata": "SKL091",
802 "PublicDescription": "This is a non-precise version (that is, does not use PEBS) of the event that counts conditional branch instructions retired.",
803 "SampleAfterValue": "400009",
804 "CounterHTOff": "0,1,2,3,4,5,6,7"
805 },
806 {
807 "EventCode": "0xC4",
808 "UMask": "0x2",
809 "BriefDescription": "Direct and indirect near call instructions retired.",
810 "PEBS": "1",
811 "Counter": "0,1,2,3",
812 "EventName": "BR_INST_RETIRED.NEAR_CALL",
813 "Errata": "SKL091",
814 "PublicDescription": "This is a non-precise version (that is, does not use PEBS) of the event that counts both direct and indirect near call instructions retired.",
815 "SampleAfterValue": "100007",
816 "CounterHTOff": "0,1,2,3,4,5,6,7"
817 },
818 {
819 "EventCode": "0xC4",
820 "UMask": "0x4",
821 "BriefDescription": "All (macro) branch instructions retired. ",
822 "PEBS": "2",
823 "Counter": "0,1,2,3",
824 "EventName": "BR_INST_RETIRED.ALL_BRANCHES_PEBS",
825 "Errata": "SKL091",
826 "PublicDescription": "This is a precise version of BR_INST_RETIRED.ALL_BRANCHES that counts all (macro) branch instructions retired.",
827 "SampleAfterValue": "400009",
828 "CounterHTOff": "0,1,2,3"
829 },
830 {
831 "EventCode": "0xC4",
832 "UMask": "0x8",
833 "BriefDescription": "Return instructions retired.",
834 "PEBS": "1",
835 "Counter": "0,1,2,3",
836 "EventName": "BR_INST_RETIRED.NEAR_RETURN",
837 "Errata": "SKL091",
838 "PublicDescription": "This is a non-precise version (that is, does not use PEBS) of the event that counts return instructions retired.",
839 "SampleAfterValue": "100007",
840 "CounterHTOff": "0,1,2,3,4,5,6,7"
841 },
842 {
843 "EventCode": "0xC4",
844 "UMask": "0x10",
845 "BriefDescription": "Not taken branch instructions retired.",
846 "Counter": "0,1,2,3",
847 "EventName": "BR_INST_RETIRED.NOT_TAKEN",
848 "Errata": "SKL091",
849 "PublicDescription": "This is a non-precise version (that is, does not use PEBS) of the event that counts not taken branch instructions retired.",
850 "SampleAfterValue": "400009",
851 "CounterHTOff": "0,1,2,3,4,5,6,7"
852 },
853 {
854 "EventCode": "0xC4",
855 "UMask": "0x20",
856 "BriefDescription": "Taken branch instructions retired.",
857 "PEBS": "1",
858 "Counter": "0,1,2,3",
859 "EventName": "BR_INST_RETIRED.NEAR_TAKEN",
860 "Errata": "SKL091",
861 "PublicDescription": "This is a non-precise version (that is, does not use PEBS) of the event that counts taken branch instructions retired.",
862 "SampleAfterValue": "400009",
863 "CounterHTOff": "0,1,2,3,4,5,6,7"
864 },
865 {
866 "EventCode": "0xC4",
867 "UMask": "0x40",
868 "BriefDescription": "Far branch instructions retired.",
869 "PEBS": "1",
870 "Counter": "0,1,2,3",
871 "EventName": "BR_INST_RETIRED.FAR_BRANCH",
872 "Errata": "SKL091",
873 "PublicDescription": "This is a non-precise version (that is, does not use PEBS) of the event that counts far branch instructions retired.",
874 "SampleAfterValue": "100007",
875 "CounterHTOff": "0,1,2,3,4,5,6,7"
876 },
877 {
878 "EventCode": "0xC5",
879 "UMask": "0x0",
880 "BriefDescription": "All mispredicted macro branch instructions retired.",
881 "Counter": "0,1,2,3",
882 "EventName": "BR_MISP_RETIRED.ALL_BRANCHES",
883 "PublicDescription": "Counts all the retired branch instructions that were mispredicted by the processor. A branch misprediction occurs when the processor incorrectly predicts the destination of the branch. When the misprediction is discovered at execution, all the instructions executed in the wrong (speculative) path must be discarded, and the processor must start fetching from the correct path.",
884 "SampleAfterValue": "400009",
885 "CounterHTOff": "0,1,2,3,4,5,6,7"
886 },
887 {
888 "EventCode": "0xC5",
889 "UMask": "0x1",
890 "BriefDescription": "Mispredicted conditional branch instructions retired.",
891 "PEBS": "1",
892 "Counter": "0,1,2,3",
893 "EventName": "BR_MISP_RETIRED.CONDITIONAL",
894 "PublicDescription": "This is a non-precise version (that is, does not use PEBS) of the event that counts mispredicted conditional branch instructions retired.",
895 "SampleAfterValue": "400009",
896 "CounterHTOff": "0,1,2,3,4,5,6,7"
897 },
898 {
899 "EventCode": "0xC5",
900 "UMask": "0x2",
901 "BriefDescription": "Mispredicted direct and indirect near call instructions retired.",
902 "PEBS": "1",
903 "Counter": "0,1,2,3",
904 "EventName": "BR_MISP_RETIRED.NEAR_CALL",
905 "PublicDescription": "Counts both taken and not taken retired mispredicted direct and indirect near calls, including both register and memory indirect.",
906 "SampleAfterValue": "400009",
907 "CounterHTOff": "0,1,2,3,4,5,6,7"
908 },
909 {
910 "EventCode": "0xC5",
911 "UMask": "0x4",
912 "BriefDescription": "Mispredicted macro branch instructions retired. ",
913 "PEBS": "2",
914 "Counter": "0,1,2,3",
915 "EventName": "BR_MISP_RETIRED.ALL_BRANCHES_PEBS",
916 "PublicDescription": "This is a precise version of BR_MISP_RETIRED.ALL_BRANCHES that counts all mispredicted macro branch instructions retired.",
917 "SampleAfterValue": "400009",
918 "CounterHTOff": "0,1,2,3"
919 },
920 {
921 "EventCode": "0xC5",
922 "UMask": "0x20",
923 "BriefDescription": "Number of near branch instructions retired that were mispredicted and taken.",
924 "PEBS": "1",
925 "Counter": "0,1,2,3",
926 "EventName": "BR_MISP_RETIRED.NEAR_TAKEN",
927 "SampleAfterValue": "400009",
928 "CounterHTOff": "0,1,2,3,4,5,6,7"
929 },
930 {
931 "EventCode": "0xCC",
932 "UMask": "0x20",
933 "BriefDescription": "Increments whenever there is an update to the LBR array.",
934 "Counter": "0,1,2,3",
935 "EventName": "ROB_MISC_EVENTS.LBR_INSERTS",
936 "PublicDescription": "Increments when an entry is added to the Last Branch Record (LBR) array (or removed from the array in case of RETURNs in call stack mode). The event requires LBR enable via IA32_DEBUGCTL MSR and branch type selection via MSR_LBR_SELECT.",
937 "SampleAfterValue": "2000003",
938 "CounterHTOff": "0,1,2,3,4,5,6,7"
939 },
940 {
941 "EventCode": "0xE6",
942 "UMask": "0x1",
943 "BriefDescription": "Counts the total number when the front end is resteered, mainly when the BPU cannot provide a correct prediction and this is corrected by other branch handling mechanisms at the front end.",
944 "Counter": "0,1,2,3",
945 "EventName": "BACLEARS.ANY",
946 "PublicDescription": "Counts the number of times the front-end is resteered when it finds a branch instruction in a fetch line. This occurs for the first time a branch instruction is fetched or when the branch is not tracked by the BPU (Branch Prediction Unit) anymore.",
947 "SampleAfterValue": "100003",
948 "CounterHTOff": "0,1,2,3,4,5,6,7"
949 }
950] \ No newline at end of file
diff --git a/tools/perf/pmu-events/arch/x86/skylakex/uncore-memory.json b/tools/perf/pmu-events/arch/x86/skylakex/uncore-memory.json
new file mode 100644
index 000000000000..9c7e5f8beee2
--- /dev/null
+++ b/tools/perf/pmu-events/arch/x86/skylakex/uncore-memory.json
@@ -0,0 +1,172 @@
1[
2 {
3 "BriefDescription": "read requests to memory controller. Derived from unc_m_cas_count.rd",
4 "Counter": "0,1,2,3",
5 "EventCode": "0x4",
6 "EventName": "LLC_MISSES.MEM_READ",
7 "PerPkg": "1",
8 "ScaleUnit": "64Bytes",
9 "UMask": "0x3",
10 "Unit": "iMC"
11 },
12 {
13 "BriefDescription": "write requests to memory controller. Derived from unc_m_cas_count.wr",
14 "Counter": "0,1,2,3",
15 "EventCode": "0x4",
16 "EventName": "LLC_MISSES.MEM_WRITE",
17 "PerPkg": "1",
18 "ScaleUnit": "64Bytes",
19 "UMask": "0xC",
20 "Unit": "iMC"
21 },
22 {
23 "BriefDescription": "Memory controller clock ticks",
24 "Counter": "0,1,2,3",
25 "EventName": "UNC_M_CLOCKTICKS",
26 "PerPkg": "1",
27 "Unit": "iMC"
28 },
29 {
30 "BriefDescription": "Cycles where DRAM ranks are in power down (CKE) mode",
31 "Counter": "0,1,2,3",
32 "EventCode": "0x85",
33 "EventName": "UNC_M_POWER_CHANNEL_PPD",
34 "MetricExpr": "(UNC_M_POWER_CHANNEL_PPD / UNC_M_CLOCKTICKS) * 100.",
35 "MetricName": "power_channel_ppd %",
36 "PerPkg": "1",
37 "Unit": "iMC"
38 },
39 {
40 "BriefDescription": "Cycles Memory is in self refresh power mode",
41 "Counter": "0,1,2,3",
42 "EventCode": "0x43",
43 "EventName": "UNC_M_POWER_SELF_REFRESH",
44 "MetricExpr": "(UNC_M_POWER_SELF_REFRESH / UNC_M_CLOCKTICKS) * 100.",
45 "MetricName": "power_self_refresh %",
46 "PerPkg": "1",
47 "Unit": "iMC"
48 },
49 {
50 "BriefDescription": "Pre-charges due to page misses",
51 "Counter": "0,1,2,3",
52 "EventCode": "0x2",
53 "EventName": "UNC_M_PRE_COUNT.PAGE_MISS",
54 "PerPkg": "1",
55 "UMask": "0x1",
56 "Unit": "iMC"
57 },
58 {
59 "BriefDescription": "Pre-charge for reads",
60 "Counter": "0,1,2,3",
61 "EventCode": "0x2",
62 "EventName": "UNC_M_PRE_COUNT.RD",
63 "PerPkg": "1",
64 "UMask": "0x4",
65 "Unit": "iMC"
66 },
67 {
68 "BriefDescription": "Pre-charge for writes",
69 "Counter": "0,1,2,3",
70 "EventCode": "0x2",
71 "EventName": "UNC_M_PRE_COUNT.WR",
72 "PerPkg": "1",
73 "UMask": "0x8",
74 "Unit": "iMC"
75 },
76 {
77 "BriefDescription": "DRAM Page Activate commands sent due to a write request",
78 "Counter": "0,1,2,3",
79 "EventCode": "0x1",
80 "EventName": "UNC_M_ACT_COUNT.WR",
81 "PerPkg": "1",
82 "PublicDescription": "Counts DRAM Page Activate commands sent on this channel due to a write request to the iMC (Memory Controller). Activate commands are issued to open up a page on the DRAM devices so that it can be read or written to with a CAS (Column Access Select) command.",
83 "UMask": "0x2",
84 "Unit": "iMC"
85 },
86 {
87 "BriefDescription": "All DRAM CAS Commands issued",
88 "Counter": "0,1,2,3",
89 "EventCode": "0x4",
90 "EventName": "UNC_M_CAS_COUNT.ALL",
91 "PerPkg": "1",
92 "PublicDescription": "Counts all CAS (Column Address Select) commands issued to DRAM per memory channel. CAS commands are issued to specify the address to read or write on DRAM, so this event increments for every read and write. This event counts whether AutoPrecharge (which closes the DRAM Page automatically after a read/write) is enabled or not.",
93 "UMask": "0xF",
94 "Unit": "iMC"
95 },
96 {
97 "BriefDescription": "read requests to memory controller. Derived from unc_m_cas_count.rd",
98 "Counter": "0,1,2,3",
99 "EventCode": "0x4",
100 "EventName": "LLC_MISSES.MEM_READ",
101 "PerPkg": "1",
102 "ScaleUnit": "64Bytes",
103 "UMask": "0x3",
104 "Unit": "iMC"
105 },
106 {
107 "BriefDescription": "All DRAM Read CAS Commands issued (does not include underfills) ",
108 "Counter": "0,1,2,3",
109 "EventCode": "0x4",
110 "EventName": "UNC_M_CAS_COUNT.RD_REG",
111 "PerPkg": "1",
112 "PublicDescription": "Counts CAS (Column Access Select) regular read commands issued to DRAM on a per channel basis. CAS commands are issued to specify the address to read or write on DRAM, and this event increments for every regular read. This event only counts regular reads and does not includes underfill reads due to partial write requests. This event counts whether AutoPrecharge (which closes the DRAM Page automatically after a read/write) is enabled or not.",
113 "UMask": "0x1",
114 "Unit": "iMC"
115 },
116 {
117 "BriefDescription": "DRAM Underfill Read CAS Commands issued",
118 "Counter": "0,1,2,3",
119 "EventCode": "0x4",
120 "EventName": "UNC_M_CAS_COUNT.RD_UNDERFILL",
121 "PerPkg": "1",
122 "PublicDescription": "Counts CAS (Column Access Select) underfill read commands issued to DRAM due to a partial write, on a per channel basis. CAS commands are issued to specify the address to read or write on DRAM, and this command counts underfill reads. Partial writes must be completed by first reading in the underfill from DRAM and then merging in the partial write data before writing the full line back to DRAM. This event will generally count about the same as the number of partial writes, but may be slightly less because of partials hitting in the WPQ (due to a previous write request). ",
123 "UMask": "0x2",
124 "Unit": "iMC"
125 },
126 {
127 "BriefDescription": "write requests to memory controller. Derived from unc_m_cas_count.wr",
128 "Counter": "0,1,2,3",
129 "EventCode": "0x4",
130 "EventName": "LLC_MISSES.MEM_WRITE",
131 "PerPkg": "1",
132 "ScaleUnit": "64Bytes",
133 "UMask": "0xC",
134 "Unit": "iMC"
135 },
136 {
137 "BriefDescription": "Read Pending Queue Allocations",
138 "Counter": "0,1,2,3",
139 "EventCode": "0x10",
140 "EventName": "UNC_M_RPQ_INSERTS",
141 "PerPkg": "1",
142 "PublicDescription": "Counts the number of read requests allocated into the Read Pending Queue (RPQ). This queue is used to schedule reads out to the memory controller and to track the requests. Requests allocate into the RPQ soon after they enter the memory controller, and need credits for an entry in this buffer before being sent from the CHA to the iMC. The requests deallocate after the read CAS command has been issued to DRAM. This event counts both Isochronous and non-Isochronous requests which were issued to the RPQ. ",
143 "Unit": "iMC"
144 },
145 {
146 "BriefDescription": "Read Pending Queue Occupancy",
147 "Counter": "0,1,2,3",
148 "EventCode": "0x80",
149 "EventName": "UNC_M_RPQ_OCCUPANCY",
150 "PerPkg": "1",
151 "PublicDescription": "Counts the number of entries in the Read Pending Queue (RPQ) at each cycle. This can then be used to calculate both the average occupancy of the queue (in conjunction with the number of cycles not empty) and the average latency in the queue (in conjunction with the number of allocations). The RPQ is used to schedule reads out to the memory controller and to track the requests. Requests allocate into the RPQ soon after they enter the memory controller, and need credits for an entry in this buffer before being sent from the CHA to the iMC. They deallocate from the RPQ after the CAS command has been issued to memory.",
152 "Unit": "iMC"
153 },
154 {
155 "BriefDescription": "Write Pending Queue Allocations",
156 "Counter": "0,1,2,3",
157 "EventCode": "0x20",
158 "EventName": "UNC_M_WPQ_INSERTS",
159 "PerPkg": "1",
160 "PublicDescription": "Counts the number of writes requests allocated into the Write Pending Queue (WPQ). The WPQ is used to schedule writes out to the memory controller and to track the requests. Requests allocate into the WPQ soon after they enter the memory controller, and need credits for an entry in this buffer before being sent from the CHA to the iMC (Memory Controller). The write requests deallocate after being issued to DRAM. Write requests themselves are able to complete (from the perspective of the rest of the system) as soon they have 'posted' to the iMC.",
161 "Unit": "iMC"
162 },
163 {
164 "BriefDescription": "Write Pending Queue Occupancy",
165 "Counter": "0,1,2,3",
166 "EventCode": "0x81",
167 "EventName": "UNC_M_WPQ_OCCUPANCY",
168 "PerPkg": "1",
169 "PublicDescription": "Counts the number of entries in the Write Pending Queue (WPQ) at each cycle. This can then be used to calculate both the average queue occupancy (in conjunction with the number of cycles not empty) and the average latency (in conjunction with the number of allocations). The WPQ is used to schedule writes out to the memory controller and to track the requests.",
170 "Unit": "iMC"
171 }
172]
diff --git a/tools/perf/pmu-events/arch/x86/skylakex/uncore-other.json b/tools/perf/pmu-events/arch/x86/skylakex/uncore-other.json
new file mode 100644
index 000000000000..de6e70e552e2
--- /dev/null
+++ b/tools/perf/pmu-events/arch/x86/skylakex/uncore-other.json
@@ -0,0 +1,1156 @@
1[
2 {
3 "BriefDescription": "Uncore cache clock ticks",
4 "Counter": "0,1,2,3",
5 "EventName": "UNC_CHA_CLOCKTICKS",
6 "PerPkg": "1",
7 "Unit": "CHA"
8 },
9 {
10 "BriefDescription": "LLC misses - Uncacheable reads (from cpu) . Derived from unc_cha_tor_inserts.ia_miss",
11 "Counter": "0,1,2,3",
12 "EventCode": "0x35",
13 "EventName": "LLC_MISSES.UNCACHEABLE",
14 "Filter": "config1=0x40e33",
15 "PerPkg": "1",
16 "UMask": "0x21",
17 "Unit": "CHA"
18 },
19 {
20 "BriefDescription": "MMIO reads. Derived from unc_cha_tor_inserts.ia_miss",
21 "Counter": "0,1,2,3",
22 "EventCode": "0x35",
23 "EventName": "LLC_MISSES.MMIO_READ",
24 "Filter": "config1=0x40040e33",
25 "PerPkg": "1",
26 "UMask": "0x21",
27 "Unit": "CHA"
28 },
29 {
30 "BriefDescription": "MMIO writes. Derived from unc_cha_tor_inserts.ia_miss",
31 "Counter": "0,1,2,3",
32 "EventCode": "0x35",
33 "EventName": "LLC_MISSES.MMIO_WRITE",
34 "Filter": "config1=0x40041e33",
35 "PerPkg": "1",
36 "UMask": "0x21",
37 "Unit": "CHA"
38 },
39 {
40 "BriefDescription": "Streaming stores (full cache line). Derived from unc_cha_tor_inserts.ia_miss",
41 "Counter": "0,1,2,3",
42 "EventCode": "0x35",
43 "EventName": "LLC_REFERENCES.STREAMING_FULL",
44 "Filter": "config1=0x41833",
45 "PerPkg": "1",
46 "ScaleUnit": "64Bytes",
47 "UMask": "0x21",
48 "Unit": "CHA"
49 },
50 {
51 "BriefDescription": "Streaming stores (partial cache line). Derived from unc_cha_tor_inserts.ia_miss",
52 "Counter": "0,1,2,3",
53 "EventCode": "0x35",
54 "EventName": "LLC_REFERENCES.STREAMING_PARTIAL",
55 "Filter": "config1=0x41a33",
56 "PerPkg": "1",
57 "ScaleUnit": "64Bytes",
58 "UMask": "0x21",
59 "Unit": "CHA"
60 },
61 {
62 "BriefDescription": "read requests from home agent",
63 "Counter": "0,1,2,3",
64 "EventCode": "0x50",
65 "EventName": "UNC_CHA_REQUESTS.READS",
66 "PerPkg": "1",
67 "UMask": "0x03",
68 "Unit": "CHA"
69 },
70 {
71 "BriefDescription": "read requests from local home agent",
72 "Counter": "0,1,2,3",
73 "EventCode": "0x50",
74 "EventName": "UNC_CHA_REQUESTS.READS_LOCAL",
75 "PerPkg": "1",
76 "UMask": "0x01",
77 "Unit": "CHA"
78 },
79 {
80 "BriefDescription": "read requests from remote home agent",
81 "Counter": "0,1,2,3",
82 "EventCode": "0x50",
83 "EventName": "UNC_CHA_REQUESTS.READS_REMOTE",
84 "PerPkg": "1",
85 "UMask": "0x02",
86 "Unit": "CHA"
87 },
88 {
89 "BriefDescription": "write requests from home agent",
90 "Counter": "0,1,2,3",
91 "EventCode": "0x50",
92 "EventName": "UNC_CHA_REQUESTS.WRITES",
93 "PerPkg": "1",
94 "UMask": "0x0C",
95 "Unit": "CHA"
96 },
97 {
98 "BriefDescription": "write requests from local home agent",
99 "Counter": "0,1,2,3",
100 "EventCode": "0x50",
101 "EventName": "UNC_CHA_REQUESTS.WRITES_LOCAL",
102 "PerPkg": "1",
103 "UMask": "0x04",
104 "Unit": "CHA"
105 },
106 {
107 "BriefDescription": "write requests from remote home agent",
108 "Counter": "0,1,2,3",
109 "EventCode": "0x50",
110 "EventName": "UNC_CHA_REQUESTS.WRITES_REMOTE",
111 "PerPkg": "1",
112 "UMask": "0x08",
113 "Unit": "CHA"
114 },
115 {
116 "BriefDescription": "UPI interconnect send bandwidth for payload. Derived from unc_upi_txl_flits.all_data",
117 "Counter": "0,1,2,3",
118 "EventCode": "0x2",
119 "EventName": "UPI_DATA_BANDWIDTH_TX",
120 "PerPkg": "1",
121 "ScaleUnit": "7.11E-06Bytes",
122 "UMask": "0x0F",
123 "Unit": "UPI LL"
124 },
125 {
126 "BriefDescription": "PCI Express bandwidth reading at IIO. Derived from unc_iio_data_req_of_cpu.mem_read.part0",
127 "Counter": "0,1",
128 "EventCode": "0x83",
129 "EventName": "LLC_MISSES.PCIE_READ",
130 "FCMask": "0x07",
131 "Filter": "ch_mask=0x1f",
132 "MetricExpr": "UNC_IIO_DATA_REQ_OF_CPU.MEM_READ.PART0 + UNC_IIO_DATA_REQ_OF_CPU.MEM_READ.PART1 + UNC_IIO_DATA_REQ_OF_CPU.MEM_READ.PART2 + UNC_IIO_DATA_REQ_OF_CPU.MEM_READ.PART3",
133 "MetricName": "LLC_MISSES.PCIE_READ",
134 "PerPkg": "1",
135 "PortMask": "0x01",
136 "ScaleUnit": "4Bytes",
137 "UMask": "0x04",
138 "Unit": "IIO"
139 },
140 {
141 "BriefDescription": "PCI Express bandwidth writing at IIO. Derived from unc_iio_data_req_of_cpu.mem_write.part0",
142 "Counter": "0,1",
143 "EventCode": "0x83",
144 "EventName": "LLC_MISSES.PCIE_WRITE",
145 "FCMask": "0x07",
146 "Filter": "ch_mask=0x1f",
147 "MetricExpr": "UNC_IIO_DATA_REQ_OF_CPU.MEM_WRITE.PART0 +UNC_IIO_DATA_REQ_OF_CPU.MEM_WRITE.PART1 +UNC_IIO_DATA_REQ_OF_CPU.MEM_WRITE.PART2 +UNC_IIO_DATA_REQ_OF_CPU.MEM_WRITE.PART3",
148 "MetricName": "LLC_MISSES.PCIE_WRITE",
149 "PerPkg": "1",
150 "PortMask": "0x01",
151 "ScaleUnit": "4Bytes",
152 "UMask": "0x01",
153 "Unit": "IIO"
154 },
155 {
156 "BriefDescription": "PCI Express bandwidth writing at IIO, part 0",
157 "Counter": "0,1",
158 "EventCode": "0x83",
159 "EventName": "UNC_IIO_DATA_REQ_OF_CPU.MEM_WRITE.PART0",
160 "FCMask": "0x07",
161 "MetricExpr": "UNC_IIO_DATA_REQ_OF_CPU.MEM_WRITE.PART0 +UNC_IIO_DATA_REQ_OF_CPU.MEM_WRITE.PART1 +UNC_IIO_DATA_REQ_OF_CPU.MEM_WRITE.PART2 +UNC_IIO_DATA_REQ_OF_CPU.MEM_WRITE.PART3",
162 "MetricName": "LLC_MISSES.PCIE_WRITE",
163 "PerPkg": "1",
164 "PortMask": "0x01",
165 "ScaleUnit": "4Bytes",
166 "UMask": "0x01",
167 "Unit": "IIO"
168 },
169 {
170 "BriefDescription": "PCI Express bandwidth writing at IIO, part 1",
171 "Counter": "0,1",
172 "EventCode": "0x83",
173 "EventName": "UNC_IIO_DATA_REQ_OF_CPU.MEM_WRITE.PART1",
174 "FCMask": "0x07",
175 "PerPkg": "1",
176 "PortMask": "0x02",
177 "ScaleUnit": "4Bytes",
178 "UMask": "0x01",
179 "Unit": "IIO"
180 },
181 {
182 "BriefDescription": "PCI Express bandwidth writing at IIO, part 2",
183 "Counter": "0,1",
184 "EventCode": "0x83",
185 "EventName": "UNC_IIO_DATA_REQ_OF_CPU.MEM_WRITE.PART2",
186 "FCMask": "0x07",
187 "PerPkg": "1",
188 "PortMask": "0x04",
189 "ScaleUnit": "4Bytes",
190 "UMask": "0x01",
191 "Unit": "IIO"
192 },
193 {
194 "BriefDescription": "PCI Express bandwidth writing at IIO, part 3",
195 "Counter": "0,1",
196 "EventCode": "0x83",
197 "EventName": "UNC_IIO_DATA_REQ_OF_CPU.MEM_WRITE.PART3",
198 "FCMask": "0x07",
199 "PerPkg": "1",
200 "PortMask": "0x08",
201 "ScaleUnit": "4Bytes",
202 "UMask": "0x01",
203 "Unit": "IIO"
204 },
205 {
206 "BriefDescription": "PCI Express bandwidth reading at IIO, part 0",
207 "Counter": "0,1",
208 "EventCode": "0x83",
209 "EventName": "UNC_IIO_DATA_REQ_OF_CPU.MEM_READ.PART0",
210 "FCMask": "0x07",
211 "MetricExpr": "UNC_IIO_DATA_REQ_OF_CPU.MEM_READ.PART0 + UNC_IIO_DATA_REQ_OF_CPU.MEM_READ.PART1 + UNC_IIO_DATA_REQ_OF_CPU.MEM_READ.PART2 + UNC_IIO_DATA_REQ_OF_CPU.MEM_READ.PART3",
212 "MetricName": "LLC_MISSES.PCIE_READ",
213 "PerPkg": "1",
214 "PortMask": "0x01",
215 "ScaleUnit": "4Bytes",
216 "UMask": "0x04",
217 "Unit": "IIO"
218 },
219 {
220 "BriefDescription": "PCI Express bandwidth reading at IIO, part 1",
221 "Counter": "0,1",
222 "EventCode": "0x83",
223 "EventName": "UNC_IIO_DATA_REQ_OF_CPU.MEM_READ.PART1",
224 "FCMask": "0x07",
225 "PerPkg": "1",
226 "PortMask": "0x02",
227 "ScaleUnit": "4Bytes",
228 "UMask": "0x04",
229 "Unit": "IIO"
230 },
231 {
232 "BriefDescription": "PCI Express bandwidth reading at IIO, part 2",
233 "Counter": "0,1",
234 "EventCode": "0x83",
235 "EventName": "UNC_IIO_DATA_REQ_OF_CPU.MEM_READ.PART2",
236 "FCMask": "0x07",
237 "PerPkg": "1",
238 "PortMask": "0x04",
239 "ScaleUnit": "4Bytes",
240 "UMask": "0x04",
241 "Unit": "IIO"
242 },
243 {
244 "BriefDescription": "PCI Express bandwidth reading at IIO, part 3",
245 "Counter": "0,1",
246 "EventCode": "0x83",
247 "EventName": "UNC_IIO_DATA_REQ_OF_CPU.MEM_READ.PART3",
248 "FCMask": "0x07",
249 "PerPkg": "1",
250 "PortMask": "0x08",
251 "ScaleUnit": "4Bytes",
252 "UMask": "0x04",
253 "Unit": "IIO"
254 },
255 {
256 "BriefDescription": "Core Cross Snoops Issued; Multiple Core Requests",
257 "Counter": "0,1,2,3",
258 "EventCode": "0x33",
259 "EventName": "UNC_CHA_CORE_SNP.CORE_GTONE",
260 "PerPkg": "1",
261 "PublicDescription": "Counts the number of transactions that trigger a configurable number of cross snoops. Cores are snooped if the transaction looks up the cache and determines that it is necessary based on the operation type and what CoreValid bits are set. For example, if 2 CV bits are set on a data read, the cores must have the data in S state so it is not necessary to snoop them. However, if only 1 CV bit is set the core my have modified the data. If the transaction was an RFO, it would need to invalidate the lines. This event can be filtered based on who triggered the initial snoop(s).",
262 "UMask": "0x42",
263 "Unit": "CHA"
264 },
265 {
266 "BriefDescription": "Core Cross Snoops Issued; Multiple Eviction",
267 "Counter": "0,1,2,3",
268 "EventCode": "0x33",
269 "EventName": "UNC_CHA_CORE_SNP.EVICT_GTONE",
270 "PerPkg": "1",
271 "PublicDescription": "Counts the number of transactions that trigger a configurable number of cross snoops. Cores are snooped if the transaction looks up the cache and determines that it is necessary based on the operation type and what CoreValid bits are set. For example, if 2 CV bits are set on a data read, the cores must have the data in S state so it is not necessary to snoop them. However, if only 1 CV bit is set the core my have modified the data. If the transaction was an RFO, it would need to invalidate the lines. This event can be filtered based on who triggered the initial snoop(s).",
272 "UMask": "0x82",
273 "Unit": "CHA"
274 },
275 {
276 "BriefDescription": "Multi-socket cacheline Directory state lookups; Snoop Not Needed",
277 "Counter": "0,1,2,3",
278 "EventCode": "0x53",
279 "EventName": "UNC_CHA_DIR_LOOKUP.NO_SNP",
280 "PerPkg": "1",
281 "PublicDescription": "Counts transactions that looked into the multi-socket cacheline Directory state, and therefore did not send a snoop because the Directory indicated it was not needed",
282 "UMask": "0x02",
283 "Unit": "CHA"
284 },
285 {
286 "BriefDescription": "Multi-socket cacheline Directory state lookups; Snoop Needed",
287 "Counter": "0,1,2,3",
288 "EventCode": "0x53",
289 "EventName": "UNC_CHA_DIR_LOOKUP.SNP",
290 "PerPkg": "1",
291 "PublicDescription": "Counts transactions that looked into the multi-socket cacheline Directory state, and sent one or more snoops, because the Directory indicated it was needed",
292 "UMask": "0x01",
293 "Unit": "CHA"
294 },
295 {
296 "BriefDescription": "Multi-socket cacheline Directory state updates; Directory Updated memory write from the HA pipe",
297 "Counter": "0,1,2,3",
298 "EventCode": "0x54",
299 "EventName": "UNC_CHA_DIR_UPDATE.HA",
300 "PerPkg": "1",
301 "PublicDescription": "Counts only multi-socket cacheline Directory state updates memory writes issued from the HA pipe. This does not include memory write requests which are for I (Invalid) or E (Exclusive) cachelines.",
302 "UMask": "0x01",
303 "Unit": "CHA"
304 },
305 {
306 "BriefDescription": "Multi-socket cacheline Directory state updates; Directory Updated memory write from TOR pipe",
307 "Counter": "0,1,2,3",
308 "EventCode": "0x54",
309 "EventName": "UNC_CHA_DIR_UPDATE.TOR",
310 "PerPkg": "1",
311 "PublicDescription": "Counts only multi-socket cacheline Directory state updates due to memory writes issued from the TOR pipe which are the result of remote transaction hitting the SF/LLC and returning data Core2Core. This does not include memory write requests which are for I (Invalid) or E (Exclusive) cachelines.",
312 "UMask": "0x02",
313 "Unit": "CHA"
314 },
315 {
316 "BriefDescription": "Read request from a remote socket which hit in the HitMe Cache to a line In the E state",
317 "Counter": "0,1,2,3",
318 "EventCode": "0x5F",
319 "EventName": "UNC_CHA_HITME_HIT.EX_RDS",
320 "PerPkg": "1",
321 "PublicDescription": "Counts read requests from a remote socket which hit in the HitME cache (used to cache the multi-socket Directory state) to a line in the E(Exclusive) state. This includes the following read opcodes (RdCode, RdData, RdDataMigratory, RdCur, RdInv*, Inv*)",
322 "UMask": "0x01",
323 "Unit": "CHA"
324 },
325 {
326 "BriefDescription": "Normal priority reads issued to the memory controller from the CHA",
327 "Counter": "0,1,2,3",
328 "EventCode": "0x59",
329 "EventName": "UNC_CHA_IMC_READS_COUNT.NORMAL",
330 "PerPkg": "1",
331 "PublicDescription": "Counts when a normal (Non-Isochronous) read is issued to any of the memory controller channels from the CHA.",
332 "UMask": "0x01",
333 "Unit": "CHA"
334 },
335 {
336 "BriefDescription": "CHA to iMC Full Line Writes Issued; Full Line Non-ISOCH",
337 "Counter": "0,1,2,3",
338 "EventCode": "0x5B",
339 "EventName": "UNC_CHA_IMC_WRITES_COUNT.FULL",
340 "PerPkg": "1",
341 "PublicDescription": "Counts when a normal (Non-Isochronous) full line write is issued from the CHA to the any of the memory controller channels.",
342 "UMask": "0x01",
343 "Unit": "CHA"
344 },
345 {
346 "BriefDescription": "Number of times that an RFO hit in S state.",
347 "Counter": "0,1,2,3",
348 "EventCode": "0x39",
349 "EventName": "UNC_CHA_MISC.RFO_HIT_S",
350 "PerPkg": "1",
351 "PublicDescription": "Counts when a RFO (the Read for Ownership issued before a write) request hit a cacheline in the S (Shared) state.",
352 "UMask": "0x08",
353 "Unit": "CHA"
354 },
355 {
356 "BriefDescription": "Local requests for exclusive ownership of a cache line without receiving data",
357 "Counter": "0,1,2,3",
358 "EventCode": "0x50",
359 "EventName": "UNC_CHA_REQUESTS.INVITOE_LOCAL",
360 "PerPkg": "1",
361 "PublicDescription": "Counts the total number of requests coming from a unit on this socket for exclusive ownership of a cache line without receiving data (INVITOE) to the CHA.",
362 "UMask": "0x10",
363 "Unit": "CHA"
364 },
365 {
366 "BriefDescription": "Local requests for exclusive ownership of a cache line without receiving data",
367 "Counter": "0,1,2,3",
368 "EventCode": "0x50",
369 "EventName": "UNC_CHA_REQUESTS.INVITOE_REMOTE",
370 "PerPkg": "1",
371 "PublicDescription": "Counts the total number of requests coming from a remote socket for exclusive ownership of a cache line without receiving data (INVITOE) to the CHA.",
372 "UMask": "0x20",
373 "Unit": "CHA"
374 },
375 {
376 "BriefDescription": "RspCnflct* Snoop Responses Received",
377 "Counter": "0,1,2,3",
378 "EventCode": "0x5C",
379 "EventName": "UNC_CHA_SNOOP_RESP.RSPCNFLCTS",
380 "PerPkg": "1",
381 "PublicDescription": "Counts when a a transaction with the opcode type RspCnflct* Snoop Response was received. This is returned when a snoop finds an existing outstanding transaction in a remote caching agent. This triggers conflict resolution hardware. This covers both the opcode RspCnflct and RspCnflctWbI.",
382 "UMask": "0x40",
383 "Unit": "CHA"
384 },
385 {
386 "BriefDescription": "RspI Snoop Responses Received",
387 "Counter": "0,1,2,3",
388 "EventCode": "0x5C",
389 "EventName": "UNC_CHA_SNOOP_RESP.RSPI",
390 "PerPkg": "1",
391 "PublicDescription": "Counts when a transaction with the opcode type RspI Snoop Response was received which indicates the remote cache does not have the data, or when the remote cache silently evicts data (such as when an RFO: the Read for Ownership issued before a write hits non-modified data).",
392 "UMask": "0x01",
393 "Unit": "CHA"
394 },
395 {
396 "BriefDescription": "RspIFwd Snoop Responses Received",
397 "Counter": "0,1,2,3",
398 "EventCode": "0x5C",
399 "EventName": "UNC_CHA_SNOOP_RESP.RSPIFWD",
400 "PerPkg": "1",
401 "PublicDescription": "Counts when a a transaction with the opcode type RspIFwd Snoop Response was received which indicates a remote caching agent forwarded the data and the requesting agent is able to acquire the data in E (Exclusive) or M (modified) states. This is commonly returned with RFO (the Read for Ownership issued before a write) transactions. The snoop could have either been to a cacheline in the M,E,F (Modified, Exclusive or Forward) states.",
402 "UMask": "0x04",
403 "Unit": "CHA"
404 },
405 {
406 "BriefDescription": "RspSFwd Snoop Responses Received",
407 "Counter": "0,1,2,3",
408 "EventCode": "0x5C",
409 "EventName": "UNC_CHA_SNOOP_RESP.RSPSFWD",
410 "PerPkg": "1",
411 "PublicDescription": "Counts when a a transaction with the opcode type RspSFwd Snoop Response was received which indicates a remote caching agent forwarded the data but held on to its current copy. This is common for data and code reads that hit in a remote socket in E (Exclusive) or F (Forward) state.",
412 "UMask": "0x08",
413 "Unit": "CHA"
414 },
415 {
416 "BriefDescription": "Rsp*Fwd*WB Snoop Responses Received",
417 "Counter": "0,1,2,3",
418 "EventCode": "0x5C",
419 "EventName": "UNC_CHA_SNOOP_RESP.RSP_FWD_WB",
420 "PerPkg": "1",
421 "PublicDescription": "Counts when a transaction with the opcode type Rsp*Fwd*WB Snoop Response was received which indicates the data was written back to it's home socket, and the cacheline was forwarded to the requestor socket. This snoop response is only used in >= 4 socket systems. It is used when a snoop HITM's in a remote caching agent and it directly forwards data to a requestor, and simultaneously returns data to it's home socket to be written back to memory.",
422 "UMask": "0x20",
423 "Unit": "CHA"
424 },
425 {
426 "BriefDescription": "Rsp*WB Snoop Responses Received",
427 "Counter": "0,1,2,3",
428 "EventCode": "0x5C",
429 "EventName": "UNC_CHA_SNOOP_RESP.RSP_WBWB",
430 "PerPkg": "1",
431 "PublicDescription": "Counts when a transaction with the opcode type Rsp*WB Snoop Response was received which indicates which indicates the data was written back to it's home. This is returned when a non-RFO request hits a cacheline in the Modified state. The Cache can either downgrade the cacheline to a S (Shared) or I (Invalid) state depending on how the system has been configured. This reponse will also be sent when a cache requests E (Exclusive) ownership of a cache line without receiving data, because the cache must acquire ownership.",
432 "UMask": "0x10",
433 "Unit": "CHA"
434 },
435 {
436 "BriefDescription": "Clockticks of the IIO Traffic Controller",
437 "Counter": "0,1,2,3",
438 "EventCode": "0x1",
439 "EventName": "UNC_IIO_CLOCKTICKS",
440 "PerPkg": "1",
441 "PublicDescription": "Counts clockticks of the 1GHz trafiic controller clock in the IIO unit.",
442 "Unit": "IIO"
443 },
444 {
445 "BriefDescription": "Read request for 4 bytes made by the CPU to IIO Part0",
446 "Counter": "2,3",
447 "EventCode": "0xC0",
448 "EventName": "UNC_IIO_DATA_REQ_BY_CPU.MEM_READ.PART0",
449 "FCMask": "0x07",
450 "PerPkg": "1",
451 "PortMask": "0x01",
452 "PublicDescription": "Counts every read request for 4 bytes of data made by a unit on the main die (generally a core) to the MMIO space of a card on IIO Part0. In the general case, Part0 refers to a standard PCIe card of any size (x16,x8,x4) that is plugged directly into one of the PCIe slots. Part0 could also refer to any device plugged into the first slot of a PCIe riser card or to a device attached to the IIO unit which starts its use of the bus using lane 0 of the 16 lanes supported by the bus.",
453 "UMask": "0x04",
454 "Unit": "IIO"
455 },
456 {
457 "BriefDescription": "Read request for 4 bytes made by the CPU to IIO Part1",
458 "Counter": "2,3",
459 "EventCode": "0xC0",
460 "EventName": "UNC_IIO_DATA_REQ_BY_CPU.MEM_READ.PART1",
461 "FCMask": "0x07",
462 "PerPkg": "1",
463 "PortMask": "0x02",
464 "PublicDescription": "Counts every read request for 4 bytes of data made by a unit on the main die (generally a core) to the MMIO space of a card on IIO Part1. In the general case, Part1 refers to a x4 PCIe card plugged into the second slot of a PCIe riser card, but it could refer to any x4 device attached to the IIO unit using lanes starting at lane 4 of the 16 lanes supported by the bus.",
465 "UMask": "0x04",
466 "Unit": "IIO"
467 },
468 {
469 "BriefDescription": "Read request for 4 bytes made by the CPU to IIO Part2",
470 "Counter": "2,3",
471 "EventCode": "0xC0",
472 "EventName": "UNC_IIO_DATA_REQ_BY_CPU.MEM_READ.PART2",
473 "FCMask": "0x07",
474 "PerPkg": "1",
475 "PortMask": "0x04",
476 "PublicDescription": "Counts every read request for 4 bytes of data made by a unit on the main die (generally a core) to the MMIO space of a card on IIO Part2. In the general case, Part2 refers to a x4 or x8 PCIe card plugged into the third slot of a PCIe riser card, but it could refer to any x4 or x8 device attached to the IIO unit and using lanes starting at lane 8 of the 16 lanes supported by the bus.",
477 "UMask": "0x04",
478 "Unit": "IIO"
479 },
480 {
481 "BriefDescription": "Read request for 4 bytes made by the CPU to IIO Part3",
482 "Counter": "2,3",
483 "EventCode": "0xC0",
484 "EventName": "UNC_IIO_DATA_REQ_BY_CPU.MEM_READ.PART3",
485 "FCMask": "0x07",
486 "PerPkg": "1",
487 "PortMask": "0x08",
488 "PublicDescription": "Counts every read request for 4 bytes of data made by a unit on the main die (generally a core) to the MMIO space of a card on IIO Part3. In the general case, Part3 refers to a x4 PCIe card plugged into the fourth slot of a PCIe riser card, but it could brefer to any device attached to the IIO unit using the lanes starting at lane 12 of the 16 lanes supported by the bus.",
489 "UMask": "0x04",
490 "Unit": "IIO"
491 },
492 {
493 "BriefDescription": "Write request of 4 bytes made to IIO Part0 by the CPU",
494 "Counter": "2,3",
495 "EventCode": "0xC0",
496 "EventName": "UNC_IIO_DATA_REQ_BY_CPU.MEM_WRITE.PART0",
497 "FCMask": "0x07",
498 "PerPkg": "1",
499 "PortMask": "0x01",
500 "PublicDescription": "Counts every write request of 4 bytes of data made to the MMIO space of a card on IIO Part0 by a unit on the main die (generally a core). In the general case, Part0 refers to a standard PCIe card of any size (x16,x8,x4) that is plugged directly into one of the PCIe slots. Part0 could also refer to any device plugged into the first slot of a PCIe riser card or to a device attached to the IIO unit which starts its use of the bus using lane 0 of the 16 lanes supported by the bus.",
501 "UMask": "0x01",
502 "Unit": "IIO"
503 },
504 {
505 "BriefDescription": "Write request of 4 bytes made to IIO Part1 by the CPU",
506 "Counter": "2,3",
507 "EventCode": "0xC0",
508 "EventName": "UNC_IIO_DATA_REQ_BY_CPU.MEM_WRITE.PART1",
509 "FCMask": "0x07",
510 "PerPkg": "1",
511 "PortMask": "0x02",
512 "PublicDescription": "Counts every write request of 4 bytes of data made to the MMIO space of a card on IIO Part1 by a unit on the main die (generally a core). In the general case, Part1 refers to a x4 PCIe card plugged into the second slot of a PCIe riser card, but it could refer to any x4 device attached to the IIO unit using lanes starting at lane 4 of the 16 lanes supported by the bus.",
513 "UMask": "0x01",
514 "Unit": "IIO"
515 },
516 {
517 "BriefDescription": "Write request of 4 bytes made to IIO Part2 by the CPU ",
518 "Counter": "2,3",
519 "EventCode": "0xC0",
520 "EventName": "UNC_IIO_DATA_REQ_BY_CPU.MEM_WRITE.PART2",
521 "FCMask": "0x07",
522 "PerPkg": "1",
523 "PortMask": "0x04",
524 "PublicDescription": "Counts every write request of 4 bytes of data made to the MMIO space of a card on IIO Part2 by a unit on the main die (generally a core). In the general case, Part2 refers to a x4 or x8 PCIe card plugged into the third slot of a PCIe riser card, but it could refer to any x4 or x8 device attached to the IIO unit and using lanes starting at lane 8 of the 16 lanes supported by the bus.",
525 "UMask": "0x01",
526 "Unit": "IIO"
527 },
528 {
529 "BriefDescription": "Write request of 4 bytes made to IIO Part3 by the CPU ",
530 "Counter": "2,3",
531 "EventCode": "0xC0",
532 "EventName": "UNC_IIO_DATA_REQ_BY_CPU.MEM_WRITE.PART3",
533 "FCMask": "0x07",
534 "PerPkg": "1",
535 "PortMask": "0x08",
536 "PublicDescription": "Counts every write request of 4 bytes of data made to the MMIO space of a card on IIO Part3 by a unit on the main die (generally a core). In the general case, Part3 refers to a x4 PCIe card plugged into the fourth slot of a PCIe riser card, but it could brefer to any device attached to the IIO unit using the lanes starting at lane 12 of the 16 lanes supported by the bus.",
537 "UMask": "0x01",
538 "Unit": "IIO"
539 },
540 {
541 "BriefDescription": "Read request for up to a 64 byte transaction is made by the CPU to IIO Part0",
542 "Counter": "0,1,2,3",
543 "EventCode": "0xC1",
544 "EventName": "UNC_IIO_TXN_REQ_BY_CPU.MEM_READ.PART0",
545 "FCMask": "0x07",
546 "PerPkg": "1",
547 "PortMask": "0x01",
548 "PublicDescription": "Counts every read request for up to a 64 byte transaction of data made by a unit on the main die (generally a core) to the MMIO space of a card on IIO Part0. In the general case, part0 refers to a standard PCIe card of any size (x16,x8,x4) that is plugged directly into one of the PCIe slots. Part0 could also refer to any device plugged into the first slot of a PCIe riser card or to a device attached to the IIO unit which starts its use of the bus using lane 0 of the 16 lanes supported by the bus.",
549 "UMask": "0x04",
550 "Unit": "IIO"
551 },
552 {
553 "BriefDescription": "Read request for up to a 64 byte transaction is made by the CPU to IIO Part1",
554 "Counter": "0,1,2,3",
555 "EventCode": "0xC1",
556 "EventName": "UNC_IIO_TXN_REQ_BY_CPU.MEM_READ.PART1",
557 "FCMask": "0x07",
558 "PerPkg": "1",
559 "PortMask": "0x02",
560 "PublicDescription": "Counts every read request for up to a 64 byte transaction of data made by a unit on the main die (generally a core) to the MMIO space of a card on IIO Part1. In the general case, Part1 refers to a x4 PCIe card plugged into the second slot of a PCIe riser card, but it could refer to any x4 device attached to the IIO unit using lanes starting at lane 4 of the 16 lanes supported by the bus.",
561 "UMask": "0x04",
562 "Unit": "IIO"
563 },
564 {
565 "BriefDescription": "Read request for up to a 64 byte transaction is made by the CPU to IIO Part2",
566 "Counter": "0,1,2,3",
567 "EventCode": "0xC1",
568 "EventName": "UNC_IIO_TXN_REQ_BY_CPU.MEM_READ.PART2",
569 "FCMask": "0x07",
570 "PerPkg": "1",
571 "PortMask": "0x04",
572 "PublicDescription": "Counts every read request for up to a 64 byte transaction of data made by a unit on the main die (generally a core) to the MMIO space of a card on IIO Part2. In the general case, Part2 refers to a x4 or x8 PCIe card plugged into the third slot of a PCIe riser card, but it could refer to any x4 or x8 device attached to the IIO unit and using lanes starting at lane 8 of the 16 lanes supported by the bus.",
573 "UMask": "0x04",
574 "Unit": "IIO"
575 },
576 {
577 "BriefDescription": "Read request for up to a 64 byte transaction is made by the CPU to IIO Part3",
578 "Counter": "0,1,2,3",
579 "EventCode": "0xC1",
580 "EventName": "UNC_IIO_TXN_REQ_BY_CPU.MEM_READ.PART3",
581 "FCMask": "0x07",
582 "PerPkg": "1",
583 "PortMask": "0x08",
584 "PublicDescription": "Counts every read request for up to a 64 byte transaction of data made by a unit on the main die (generally a core) to the MMIO space of a card on IIO Part3. In the general case, Part3 refers to a x4 PCIe card plugged into the fourth slot of a PCIe riser card, but it could brefer to any device attached to the IIO unit using the lanes starting at lane 12 of the 16 lanes supported by the bus.",
585 "UMask": "0x04",
586 "Unit": "IIO"
587 },
588 {
589 "BriefDescription": "Write request of up to a 64 byte transaction is made to IIO Part0 by the CPU",
590 "Counter": "0,1,2,3",
591 "EventCode": "0xC1",
592 "EventName": "UNC_IIO_TXN_REQ_BY_CPU.MEM_WRITE.PART0",
593 "FCMask": "0x07",
594 "PerPkg": "1",
595 "PortMask": "0x01",
596 "PublicDescription": "Counts every write request of up to a 64 byte transaction of data made to the MMIO space of a card on IIO Part0 by a unit on the main die (generally a core). In the general case, Part0 refers to a standard PCIe card of any size (x16,x8,x4) that is plugged directly into one of the PCIe slots. Part0 could also refer to any device plugged into the first slot of a PCIe riser card or to a device attached to the IIO unit which starts its use of the bus using lane 0 of the 16 lanes supported by the bus.",
597 "UMask": "0x01",
598 "Unit": "IIO"
599 },
600 {
601 "BriefDescription": "Write request of up to a 64 byte transaction is made to IIO Part1 by the CPU",
602 "Counter": "0,1,2,3",
603 "EventCode": "0xC1",
604 "EventName": "UNC_IIO_TXN_REQ_BY_CPU.MEM_WRITE.PART1",
605 "FCMask": "0x07",
606 "PerPkg": "1",
607 "PortMask": "0x02",
608 "PublicDescription": "Counts every write request of up to a 64 byte transaction of data made to the MMIO space of a card on IIO Part1 by a unit on the main die (generally a core). In the general case, Part1 refers to a x4 PCIe card plugged into the second slot of a PCIe riser card, but it could refer to any x4 device attached to the IIO unit using lanes starting at lane 4 of the 16 lanes supported by the bus.",
609 "UMask": "0x01",
610 "Unit": "IIO"
611 },
612 {
613 "BriefDescription": "Write request of up to a 64 byte transaction is made to IIO Part2 by the CPU ",
614 "Counter": "0,1,2,3",
615 "EventCode": "0xC1",
616 "EventName": "UNC_IIO_TXN_REQ_BY_CPU.MEM_WRITE.PART2",
617 "FCMask": "0x07",
618 "PerPkg": "1",
619 "PortMask": "0x04",
620 "PublicDescription": "Counts every write request of up to a 64 byte transaction of data made to the MMIO space of a card on IIO Part2 by a unit on the main die (generally a core). In the general case, Part2 refers to a x4 or x8 PCIe card plugged into the third slot of a PCIe riser card, but it could refer to any x4 or x8 device attached to the IIO unit and using lanes starting at lane 8 of the 16 lanes supported by the bus.",
621 "UMask": "0x01",
622 "Unit": "IIO"
623 },
624 {
625 "BriefDescription": "Write request of up to a 64 byte transaction is made to IIO Part3 by the CPU ",
626 "Counter": "0,1,2,3",
627 "EventCode": "0xC1",
628 "EventName": "UNC_IIO_TXN_REQ_BY_CPU.MEM_WRITE.PART3",
629 "FCMask": "0x07",
630 "PerPkg": "1",
631 "PortMask": "0x08",
632 "PublicDescription": "Counts every write request of up to a 64 byte transaction of data made to the MMIO space of a card on IIO Part3 by a unit on the main die (generally a core). In the general case, Part3 refers to a x4 PCIe card plugged into the fourth slot of a PCIe riser card, but it could brefer to any device attached to the IIO unit using the lanes starting at lane 12 of the 16 lanes supported by the bus.",
633 "UMask": "0x01",
634 "Unit": "IIO"
635 },
636 {
637 "BriefDescription": "Read request for up to a 64 byte transaction is made by IIO Part0 to Memory",
638 "Counter": "0,1,2,3",
639 "EventCode": "0x84",
640 "EventName": "UNC_IIO_TXN_REQ_OF_CPU.MEM_READ.PART0",
641 "FCMask": "0x07",
642 "PerPkg": "1",
643 "PortMask": "0x01",
644 "PublicDescription": "Counts every read request for up to a 64 byte transaction of data made by IIO Part0 to a unit on the main die (generally memory). In the general case, Part0 refers to a standard PCIe card of any size (x16,x8,x4) that is plugged directly into one of the PCIe slots. Part0 could also refer to any device plugged into the first slot of a PCIe riser card or to a device attached to the IIO unit which starts its use of the bus using lane 0 of the 16 lanes supported by the bus.",
645 "UMask": "0x04",
646 "Unit": "IIO"
647 },
648 {
649 "BriefDescription": "Read request for up to a 64 byte transaction is made by IIO Part1 to Memory",
650 "Counter": "0,1,2,3",
651 "EventCode": "0x84",
652 "EventName": "UNC_IIO_TXN_REQ_OF_CPU.MEM_READ.PART1",
653 "FCMask": "0x07",
654 "PerPkg": "1",
655 "PortMask": "0x02",
656 "PublicDescription": "Counts every read request for up to a 64 byte transaction of data made by IIO Part1 to a unit on the main die (generally memory). In the general case, Part1 refers to a x4 PCIe card plugged into the second slot of a PCIe riser card, but it could refer to any x4 device attached to the IIO unit using lanes starting at lane 4 of the 16 lanes supported by the bus.",
657 "UMask": "0x04",
658 "Unit": "IIO"
659 },
660 {
661 "BriefDescription": "Read request for up to a 64 byte transaction is made by IIO Part2 to Memory",
662 "Counter": "0,1,2,3",
663 "EventCode": "0x84",
664 "EventName": "UNC_IIO_TXN_REQ_OF_CPU.MEM_READ.PART2",
665 "FCMask": "0x07",
666 "PerPkg": "1",
667 "PortMask": "0x04",
668 "PublicDescription": "Counts every read request for up to a 64 byte transaction of data made by IIO Part2 to a unit on the main die (generally memory). In the general case, Part2 refers to a x4 or x8 PCIe card plugged into the third slot of a PCIe riser card, but it could refer to any x4 or x8 device attached to the IIO unit and using lanes starting at lane 8 of the 16 lanes supported by the bus.",
669 "UMask": "0x04",
670 "Unit": "IIO"
671 },
672 {
673 "BriefDescription": "Read request for up to a 64 byte transaction is made by IIO Part3 to Memory",
674 "Counter": "0,1,2,3",
675 "EventCode": "0x84",
676 "EventName": "UNC_IIO_TXN_REQ_OF_CPU.MEM_READ.PART3",
677 "FCMask": "0x07",
678 "PerPkg": "1",
679 "PortMask": "0x08",
680 "PublicDescription": "Counts every read request for up to a 64 byte transaction of data made by IIO Part3 to a unit on the main die (generally memory). In the general case, Part3 refers to a x4 PCIe card plugged into the fourth slot of a PCIe riser card, but it could brefer to any device attached to the IIO unit using the lanes starting at lane 12 of the 16 lanes supported by the bus.",
681 "UMask": "0x04",
682 "Unit": "IIO"
683 },
684 {
685 "BriefDescription": "Write request of up to a 64 byte transaction is made by IIO Part0 to Memory",
686 "Counter": "0,1,2,3",
687 "EventCode": "0x84",
688 "EventName": "UNC_IIO_TXN_REQ_OF_CPU.MEM_WRITE.PART0",
689 "FCMask": "0x07",
690 "PerPkg": "1",
691 "PortMask": "0x01",
692 "PublicDescription": "Counts every write request of up to a 64 byte transaction of data made by IIO Part0 to a unit on the main die (generally memory). In the general case, Part0 refers to a standard PCIe card of any size (x16,x8,x4) that is plugged directly into one of the PCIe slots. Part0 could also refer to any device plugged into the first slot of a PCIe riser card or to a device attached to the IIO unit which starts its use of the bus using lane 0 of the 16 lanes supported by the bus.",
693 "UMask": "0x01",
694 "Unit": "IIO"
695 },
696 {
697 "BriefDescription": "Write request of up to a 64 byte transaction is made by IIO Part1 to Memory",
698 "Counter": "0,1,2,3",
699 "EventCode": "0x84",
700 "EventName": "UNC_IIO_TXN_REQ_OF_CPU.MEM_WRITE.PART1",
701 "FCMask": "0x07",
702 "PerPkg": "1",
703 "PortMask": "0x02",
704 "PublicDescription": "Counts every write request of up to a 64 byte transaction of data made by IIO Part1 to a unit on the main die (generally memory). In the general case, Part1 refers to a x4 PCIe card plugged into the second slot of a PCIe riser card, but it could refer to any x4 device attached to the IIO unit using lanes starting at lane 4 of the 16 lanes supported by the bus.",
705 "UMask": "0x01",
706 "Unit": "IIO"
707 },
708 {
709 "BriefDescription": "Write request of up to a 64 byte transaction is made by IIO Part2 to Memory",
710 "Counter": "0,1,2,3",
711 "EventCode": "0x84",
712 "EventName": "UNC_IIO_TXN_REQ_OF_CPU.MEM_WRITE.PART2",
713 "FCMask": "0x07",
714 "PerPkg": "1",
715 "PortMask": "0x04",
716 "PublicDescription": "Counts every write request of up to a 64 byte transaction of data made by IIO Part2 to a unit on the main die (generally memory). In the general case, Part2 refers to a x4 or x8 PCIe card plugged into the third slot of a PCIe riser card, but it could refer to any x4 or x8 device attached to the IIO unit and using lanes starting at lane 8 of the 16 lanes supported by the bus.",
717 "UMask": "0x01",
718 "Unit": "IIO"
719 },
720 {
721 "BriefDescription": "Write request of up to a 64 byte transaction is made by IIO Part3 to Memory",
722 "Counter": "0,1,2,3",
723 "EventCode": "0x84",
724 "EventName": "UNC_IIO_TXN_REQ_OF_CPU.MEM_WRITE.PART3",
725 "FCMask": "0x07",
726 "PerPkg": "1",
727 "PortMask": "0x08",
728 "PublicDescription": "Counts every write request of up to a 64 byte transaction of data made by IIO Part3 to a unit on the main die (generally memory). In the general case, Part3 refers to a x4 PCIe card plugged into the fourth slot of a PCIe riser card, but it could brefer to any device attached to the IIO unit using the lanes starting at lane 12 of the 16 lanes supported by the bus.",
729 "UMask": "0x01",
730 "Unit": "IIO"
731 },
732 {
733 "BriefDescription": "Traffic in which the M2M to iMC Bypass was not taken",
734 "Counter": "0,1,2,3",
735 "EventCode": "0x22",
736 "EventName": "UNC_M2M_BYPASS_M2M_Egress.NOT_TAKEN",
737 "PerPkg": "1",
738 "PublicDescription": "Counts traffic in which the M2M (Mesh to Memory) to iMC (Memory Controller) bypass was not taken",
739 "UMask": "0x2",
740 "Unit": "M2M"
741 },
742 {
743 "BriefDescription": "Cycles when direct to core mode (which bypasses the CHA) was disabled",
744 "Counter": "0,1,2,3",
745 "EventCode": "0x24",
746 "EventName": "UNC_M2M_DIRECT2CORE_NOT_TAKEN_DIRSTATE",
747 "PerPkg": "1",
748 "PublicDescription": "Counts cycles when direct to core mode (which bypasses the CHA) was disabled",
749 "Unit": "M2M"
750 },
751 {
752 "BriefDescription": "Messages sent direct to core (bypassing the CHA)",
753 "Counter": "0,1,2,3",
754 "EventCode": "0x23",
755 "EventName": "UNC_M2M_DIRECT2CORE_TAKEN",
756 "PerPkg": "1",
757 "PublicDescription": "Counts when messages were sent direct to core (bypassing the CHA)",
758 "Unit": "M2M"
759 },
760 {
761 "BriefDescription": "Number of reads in which direct to core transaction were overridden",
762 "Counter": "0,1,2,3",
763 "EventCode": "0x25",
764 "EventName": "UNC_M2M_DIRECT2CORE_TXN_OVERRIDE",
765 "PerPkg": "1",
766 "PublicDescription": "Counts reads in which direct to core transactions (which would have bypassed the CHA) were overridden",
767 "Unit": "M2M"
768 },
769 {
770 "BriefDescription": "Number of reads in which direct to Intel UPI transactions were overridden",
771 "Counter": "0,1,2,3",
772 "EventCode": "0x28",
773 "EventName": "UNC_M2M_DIRECT2UPI_NOT_TAKEN_CREDITS",
774 "PerPkg": "1",
775 "PublicDescription": "Counts reads in which direct to Intel Ultra Path Interconnect (UPI) transactions (which would have bypassed the CHA) were overridden",
776 "Unit": "M2M"
777 },
778 {
779 "BriefDescription": "Cycles when direct to Intel UPI was disabled",
780 "Counter": "0,1,2,3",
781 "EventCode": "0x27",
782 "EventName": "UNC_M2M_DIRECT2UPI_NOT_TAKEN_DIRSTATE",
783 "PerPkg": "1",
784 "PublicDescription": "Counts cycles when the ability to send messages direct to the Intel Ultra Path Interconnect (bypassing the CHA) was disabled",
785 "Unit": "M2M"
786 },
787 {
788 "BriefDescription": "Messages sent direct to the Intel UPI",
789 "Counter": "0,1,2,3",
790 "EventCode": "0x26",
791 "EventName": "UNC_M2M_DIRECT2UPI_TAKEN",
792 "PerPkg": "1",
793 "PublicDescription": "Counts when messages were sent direct to the Intel Ultra Path Interconnect (bypassing the CHA)",
794 "Unit": "M2M"
795 },
796 {
797 "BriefDescription": "Number of reads that a message sent direct2 Intel UPI was overridden",
798 "Counter": "0,1,2,3",
799 "EventCode": "0x29",
800 "EventName": "UNC_M2M_DIRECT2UPI_TXN_OVERRIDE",
801 "PerPkg": "1",
802 "PublicDescription": "Counts when a read message that was sent direct to the Intel Ultra Path Interconnect (bypassing the CHA) was overridden",
803 "Unit": "M2M"
804 },
805 {
806 "BriefDescription": "Multi-socket cacheline Directory lookups (any state found)",
807 "Counter": "0,1,2,3",
808 "EventCode": "0x2D",
809 "EventName": "UNC_M2M_DIRECTORY_LOOKUP.ANY",
810 "PerPkg": "1",
811 "PublicDescription": "Counts when the M2M (Mesh to Memory) looks into the multi-socket cacheline Directory state, and found the cacheline marked in Any State (A, I, S or unused)",
812 "UMask": "0x1",
813 "Unit": "M2M"
814 },
815 {
816 "BriefDescription": "Multi-socket cacheline Directory lookups (cacheline found in A state) ",
817 "Counter": "0,1,2,3",
818 "EventCode": "0x2D",
819 "EventName": "UNC_M2M_DIRECTORY_LOOKUP.STATE_A",
820 "PerPkg": "1",
821 "PublicDescription": "Counts when the M2M (Mesh to Memory) looks into the multi-socket cacheline Directory state, and found the cacheline marked in the A (SnoopAll) state, indicating the cacheline is stored in another socket in any state, and we must snoop the other sockets to make sure we get the latest data. The data may be stored in any state in the local socket.",
822 "UMask": "0x8",
823 "Unit": "M2M"
824 },
825 {
826 "BriefDescription": "Multi-socket cacheline Directory lookup (cacheline found in I state) ",
827 "Counter": "0,1,2,3",
828 "EventCode": "0x2D",
829 "EventName": "UNC_M2M_DIRECTORY_LOOKUP.STATE_I",
830 "PerPkg": "1",
831 "PublicDescription": "Counts when the M2M (Mesh to Memory) looks into the multi-socket cacheline Directory state , and found the cacheline marked in the I (Invalid) state indicating the cacheline is not stored in another socket, and so there is no need to snoop the other sockets for the latest data. The data may be stored in any state in the local socket.",
832 "UMask": "0x2",
833 "Unit": "M2M"
834 },
835 {
836 "BriefDescription": "Multi-socket cacheline Directory lookup (cacheline found in S state) ",
837 "Counter": "0,1,2,3",
838 "EventCode": "0x2D",
839 "EventName": "UNC_M2M_DIRECTORY_LOOKUP.STATE_S",
840 "PerPkg": "1",
841 "PublicDescription": "Counts when the M2M (Mesh to Memory) looks into the multi-socket cacheline Directory state , and found the cacheline marked in the S (Shared) state indicating the cacheline is either stored in another socket in the S(hared) state , and so there is no need to snoop the other sockets for the latest data. The data may be stored in any state in the local socket.",
842 "UMask": "0x4",
843 "Unit": "M2M"
844 },
845 {
846 "BriefDescription": "Multi-socket cacheline Directory update from A to I",
847 "Counter": "0,1,2,3",
848 "EventCode": "0x2E",
849 "EventName": "UNC_M2M_DIRECTORY_UPDATE.A2I",
850 "PerPkg": "1",
851 "PublicDescription": "Counts when the M2M (Mesh to Memory) updates the multi-socket cacheline Directory state from from A (SnoopAll) to I (Invalid)",
852 "UMask": "0x20",
853 "Unit": "M2M"
854 },
855 {
856 "BriefDescription": "Multi-socket cacheline Directory update from A to S",
857 "Counter": "0,1,2,3",
858 "EventCode": "0x2E",
859 "EventName": "UNC_M2M_DIRECTORY_UPDATE.A2S",
860 "PerPkg": "1",
861 "PublicDescription": "Counts when the M2M (Mesh to Memory) updates the multi-socket cacheline Directory state from from A (SnoopAll) to S (Shared)",
862 "UMask": "0x40",
863 "Unit": "M2M"
864 },
865 {
866 "BriefDescription": "Multi-socket cacheline Directory update from/to Any state ",
867 "Counter": "0,1,2,3",
868 "EventCode": "0x2E",
869 "EventName": "UNC_M2M_DIRECTORY_UPDATE.ANY",
870 "PerPkg": "1",
871 "PublicDescription": "Counts when the M2M (Mesh to Memory) updates the multi-socket cacheline Directory to a new state",
872 "UMask": "0x1",
873 "Unit": "M2M"
874 },
875 {
876 "BriefDescription": "Multi-socket cacheline Directory update from I to A",
877 "Counter": "0,1,2,3",
878 "EventCode": "0x2E",
879 "EventName": "UNC_M2M_DIRECTORY_UPDATE.I2A",
880 "PerPkg": "1",
881 "PublicDescription": "Counts when the M2M (Mesh to Memory) updates the multi-socket cacheline Directory state from from I (Invalid) to A (SnoopAll)",
882 "UMask": "0x4",
883 "Unit": "M2M"
884 },
885 {
886 "BriefDescription": "Multi-socket cacheline Directory update from I to S",
887 "Counter": "0,1,2,3",
888 "EventCode": "0x2E",
889 "EventName": "UNC_M2M_DIRECTORY_UPDATE.I2S",
890 "PerPkg": "1",
891 "PublicDescription": "Counts when the M2M (Mesh to Memory) updates the multi-socket cacheline Directory state from from I (Invalid) to S (Shared)",
892 "UMask": "0x2",
893 "Unit": "M2M"
894 },
895 {
896 "BriefDescription": "Multi-socket cacheline Directory update from S to A",
897 "Counter": "0,1,2,3",
898 "EventCode": "0x2E",
899 "EventName": "UNC_M2M_DIRECTORY_UPDATE.S2A",
900 "PerPkg": "1",
901 "PublicDescription": "Counts when the M2M (Mesh to Memory) updates the multi-socket cacheline Directory state from from S (Shared) to A (SnoopAll)",
902 "UMask": "0x10",
903 "Unit": "M2M"
904 },
905 {
906 "BriefDescription": "Multi-socket cacheline Directory update from S to I",
907 "Counter": "0,1,2,3",
908 "EventCode": "0x2E",
909 "EventName": "UNC_M2M_DIRECTORY_UPDATE.S2I",
910 "PerPkg": "1",
911 "PublicDescription": "Counts when the M2M (Mesh to Memory) updates the multi-socket cacheline Directory state from from S (Shared) to I (Invalid)",
912 "UMask": "0x8",
913 "Unit": "M2M"
914 },
915 {
916 "BriefDescription": "Reads to iMC issued",
917 "Counter": "0,1,2,3",
918 "EventCode": "0x37",
919 "EventName": "UNC_M2M_IMC_READS.ALL",
920 "PerPkg": "1",
921 "PublicDescription": "Counts when the M2M (Mesh to Memory) issues reads to the iMC (Memory Controller). ",
922 "UMask": "0x4",
923 "Unit": "M2M"
924 },
925 {
926 "BriefDescription": "Reads to iMC issued at Normal Priority (Non-Isochronous)",
927 "Counter": "0,1,2,3",
928 "EventCode": "0x37",
929 "EventName": "UNC_M2M_IMC_READS.NORMAL",
930 "PerPkg": "1",
931 "PublicDescription": "Counts when the M2M (Mesh to Memory) issues reads to the iMC (Memory Controller). It only counts normal priority non-isochronous reads.",
932 "UMask": "0x1",
933 "Unit": "M2M"
934 },
935 {
936 "BriefDescription": "Writes to iMC issued",
937 "Counter": "0,1,2,3",
938 "EventCode": "0x38",
939 "EventName": "UNC_M2M_IMC_WRITES.ALL",
940 "PerPkg": "1",
941 "PublicDescription": "Counts when the M2M (Mesh to Memory) issues writes to the iMC (Memory Controller).",
942 "UMask": "0x10",
943 "Unit": "M2M"
944 },
945 {
946 "BriefDescription": "Partial Non-Isochronous writes to the iMC",
947 "Counter": "0,1,2,3",
948 "EventCode": "0x38",
949 "EventName": "UNC_M2M_IMC_WRITES.PARTIAL",
950 "PerPkg": "1",
951 "PublicDescription": "Counts when the M2M (Mesh to Memory) issues partial writes to the iMC (Memory Controller). It only counts normal priority non-isochronous writes.",
952 "UMask": "0x2",
953 "Unit": "M2M"
954 },
955 {
956 "BriefDescription": "Prefecth requests that got turn into a demand request",
957 "Counter": "0,1,2,3",
958 "EventCode": "0x56",
959 "EventName": "UNC_M2M_PREFCAM_DEMAND_PROMOTIONS",
960 "PerPkg": "1",
961 "PublicDescription": "Counts when the M2M (Mesh to Memory) promotes a outstanding request in the prefetch queue due to a subsequent demand read request that entered the M2M with the same address. Explanatory Side Note: The Prefecth queue is made of CAM (Content Addressable Memory)",
962 "Unit": "M2M"
963 },
964 {
965 "BriefDescription": "Inserts into the Memory Controller Prefetch Queue",
966 "Counter": "0,1,2,3",
967 "EventCode": "0x57",
968 "EventName": "UNC_M2M_PREFCAM_INSERTS",
969 "PerPkg": "1",
970 "PublicDescription": "Counts when the M2M (Mesh to Memory) recieves a prefetch request and inserts it into its outstanding prefetch queue. Explanatory Side Note: the prefect queue is made from CAM: Content Addressable Memory",
971 "Unit": "M2M"
972 },
973 {
974 "BriefDescription": "AD Ingress (from CMS) Queue Inserts",
975 "Counter": "0,1,2,3",
976 "EventCode": "0x1",
977 "EventName": "UNC_M2M_RxC_AD_INSERTS",
978 "PerPkg": "1",
979 "PublicDescription": "Counts when the a new entry is Received(RxC) and then added to the AD (Address Ring) Ingress Queue from the CMS (Common Mesh Stop). This is generally used for reads, and ",
980 "Unit": "M2M"
981 },
982 {
983 "BriefDescription": "Prefetches generated by the flow control queue of the M3UPI unit.",
984 "Counter": "0,1,2,3",
985 "EventCode": "0x29",
986 "EventName": "UNC_M3UPI_UPI_PREFETCH_SPAWN",
987 "PerPkg": "1",
988 "PublicDescription": "Count cases where flow control queue that sits between the Intel Ultra Path Interconnect (UPI) and the mesh spawns a prefetch to the iMC (Memory Controller)",
989 "Unit": "M3UPI"
990 },
991 {
992 "BriefDescription": "Clocks of the Intel Ultra Path Interconnect (UPI)",
993 "Counter": "0,1,2,3",
994 "EventCode": "0x1",
995 "EventName": "UNC_UPI_CLOCKTICKS",
996 "PerPkg": "1",
997 "PublicDescription": "Counts clockticks of the fixed frequency clock controlling the Intel Ultra Path Interconnect (UPI). This clock runs at1/8th the 'GT/s' speed of the UPI link. For example, a 9.6GT/s link will have a fixed Frequency of 1.2 Ghz.",
998 "Unit": "UPI LL"
999 },
1000 {
1001 "BriefDescription": "Data Response packets that go direct to core",
1002 "Counter": "0,1,2,3",
1003 "EventCode": "0x12",
1004 "EventName": "UNC_UPI_DIRECT_ATTEMPTS.D2C",
1005 "PerPkg": "1",
1006 "PublicDescription": "Counts Data Response (DRS) packets that attempted to go direct to core bypassing the CHA.",
1007 "UMask": "0x1",
1008 "Unit": "UPI LL"
1009 },
1010 {
1011 "BriefDescription": "Data Response packets that go direct to Intel UPI",
1012 "Counter": "0,1,2,3",
1013 "EventCode": "0x12",
1014 "EventName": "UNC_UPI_DIRECT_ATTEMPTS.D2U",
1015 "PerPkg": "1",
1016 "PublicDescription": "Counts Data Response (DRS) packets that attempted to go direct to Intel Ultra Path Interconnect (UPI) bypassing the CHA .",
1017 "UMask": "0x2",
1018 "Unit": "UPI LL"
1019 },
1020 {
1021 "BriefDescription": "Cycles Intel UPI is in L1 power mode (shutdown)",
1022 "Counter": "0,1,2,3",
1023 "EventCode": "0x21",
1024 "EventName": "UNC_UPI_L1_POWER_CYCLES",
1025 "PerPkg": "1",
1026 "PublicDescription": "Counts cycles when the Intel Ultra Path Interconnect (UPI) is in L1 power mode. L1 is a mode that totally shuts down the UPI link. Link power states are per link and per direction, so for example the Tx direction could be in one state while Rx was in another, this event only coutns when both links are shutdown.",
1027 "Unit": "UPI LL"
1028 },
1029 {
1030 "BriefDescription": "Cycles the Rx of the Intel UPI is in L0p power mode",
1031 "Counter": "0,1,2,3",
1032 "EventCode": "0x25",
1033 "EventName": "UNC_UPI_RxL0P_POWER_CYCLES",
1034 "PerPkg": "1",
1035 "PublicDescription": "Counts cycles when the the receive side (Rx) of the Intel Ultra Path Interconnect(UPI) is in L0p power mode. L0p is a mode where we disable 60% of the UPI lanes, decreasing our bandwidth in order to save power.",
1036 "Unit": "UPI LL"
1037 },
1038 {
1039 "BriefDescription": "FLITs received which bypassed the Slot0 Receive Buffer",
1040 "Counter": "0,1,2,3",
1041 "EventCode": "0x31",
1042 "EventName": "UNC_UPI_RxL_BYPASSED.SLOT0",
1043 "PerPkg": "1",
1044 "PublicDescription": "Counts incoming FLITs (FLow control unITs) which bypassed the slot0 RxQ buffer (Receive Queue) and passed directly to the Egress. This is a latency optimization, and should generally be the common case. If this value is less than the number of FLITs transfered, it implies that there was queueing getting onto the ring, and thus the transactions saw higher latency.",
1045 "UMask": "0x1",
1046 "Unit": "UPI LL"
1047 },
1048 {
1049 "BriefDescription": "FLITs received which bypassed the Slot0 Receive Buffer",
1050 "Counter": "0,1,2,3",
1051 "EventCode": "0x31",
1052 "EventName": "UNC_UPI_RxL_BYPASSED.SLOT1",
1053 "PerPkg": "1",
1054 "PublicDescription": "Counts incoming FLITs (FLow control unITs) which bypassed the slot1 RxQ buffer (Receive Queue) and passed directly across the BGF and into the Egress. This is a latency optimization, and should generally be the common case. If this value is less than the number of FLITs transfered, it implies that there was queueing getting onto the ring, and thus the transactions saw higher latency.",
1055 "UMask": "0x2",
1056 "Unit": "UPI LL"
1057 },
1058 {
1059 "BriefDescription": "FLITs received which bypassed the Slot0 Recieve Buffer",
1060 "Counter": "0,1,2,3",
1061 "EventCode": "0x31",
1062 "EventName": "UNC_UPI_RxL_BYPASSED.SLOT2",
1063 "PerPkg": "1",
1064 "PublicDescription": "Counts incoming FLITs (FLow control unITs) whcih bypassed the slot2 RxQ buffer (Receive Queue) and passed directly to the Egress. This is a latency optimization, and should generally be the common case. If this value is less than the number of FLITs transfered, it implies that there was queueing getting onto the ring, and thus the transactions saw higher latency.",
1065 "UMask": "0x4",
1066 "Unit": "UPI LL"
1067 },
1068 {
1069 "BriefDescription": "Valid data FLITs received from any slot",
1070 "Counter": "0,1,2,3",
1071 "EventCode": "0x3",
1072 "EventName": "UNC_UPI_RxL_FLITS.ALL_DATA",
1073 "PerPkg": "1",
1074 "PublicDescription": "Counts valid data FLITs (80 bit FLow control unITs: 64bits of data) received from any of the 3 Intel Ultra Path Interconnect (UPI) Receive Queue slots on this UPI unit.",
1075 "UMask": "0x0F",
1076 "Unit": "UPI LL"
1077 },
1078 {
1079 "BriefDescription": "Null FLITs received from any slot",
1080 "Counter": "0,1,2,3",
1081 "EventCode": "0x3",
1082 "EventName": "UNC_UPI_RxL_FLITS.ALL_NULL",
1083 "PerPkg": "1",
1084 "PublicDescription": "Counts null FLITs (80 bit FLow control unITs) received from any of the 3 Intel Ultra Path Interconnect (UPI) Receive Queue slots on this UPI unit.",
1085 "UMask": "0x27",
1086 "Unit": "UPI LL"
1087 },
1088 {
1089 "BriefDescription": "Protocol header and credit FLITs received from any slot",
1090 "Counter": "0,1,2,3",
1091 "EventCode": "0x3",
1092 "EventName": "UNC_UPI_RxL_FLITS.NON_DATA",
1093 "PerPkg": "1",
1094 "PublicDescription": "Counts protocol header and credit FLITs (80 bit FLow control unITs) received from any of the 3 UPI slots on this UPI unit.",
1095 "UMask": "0x97",
1096 "Unit": "UPI LL"
1097 },
1098 {
1099 "BriefDescription": "Cycles in which the Tx of the Intel Ultra Path Interconnect (UPI) is in L0p power mode",
1100 "Counter": "0,1,2,3",
1101 "EventCode": "0x27",
1102 "EventName": "UNC_UPI_TxL0P_POWER_CYCLES",
1103 "PerPkg": "1",
1104 "PublicDescription": "Counts cycles when the transmit side (Tx) of the Intel Ultra Path Interconnect(UPI) is in L0p power mode. L0p is a mode where we disable 60% of the UPI lanes, decreasing our bandwidth in order to save power.",
1105 "Unit": "UPI LL"
1106 },
1107 {
1108 "BriefDescription": "FLITs that bypassed the TxL Buffer",
1109 "Counter": "0,1,2,3",
1110 "EventCode": "0x41",
1111 "EventName": "UNC_UPI_TxL_BYPASSED",
1112 "PerPkg": "1",
1113 "PublicDescription": "Counts incoming FLITs (FLow control unITs) which bypassed the TxL(transmit) FLIT buffer and pass directly out the UPI Link. Generally, when data is transmitted across the Intel Ultra Path Interconnect (UPI), it will bypass the TxQ and pass directly to the link. However, the TxQ will be used in L0p (Low Power) mode and (Link Layer Retry) LLR mode, increasing latency to transfer out to the link.",
1114 "Unit": "UPI LL"
1115 },
1116 {
1117 "BriefDescription": "UPI interconnect send bandwidth for payload. Derived from unc_upi_txl_flits.all_data",
1118 "Counter": "0,1,2,3",
1119 "EventCode": "0x2",
1120 "EventName": "UPI_DATA_BANDWIDTH_TX",
1121 "PerPkg": "1",
1122 "ScaleUnit": "7.11E-06Bytes",
1123 "UMask": "0x0F",
1124 "Unit": "UPI LL"
1125 },
1126 {
1127 "BriefDescription": "Null FLITs transmitted from any slot",
1128 "Counter": "0,1,2,3",
1129 "EventCode": "0x2",
1130 "EventName": "UNC_UPI_TxL_FLITS.ALL_NULL",
1131 "PerPkg": "1",
1132 "PublicDescription": "Counts null FLITs (80 bit FLow control unITs) transmitted via any of the 3 Intel Ulra Path Interconnect (UPI) slots on this UPI unit.",
1133 "UMask": "0x27",
1134 "Unit": "UPI LL"
1135 },
1136 {
1137 "BriefDescription": "Idle FLITs transmitted",
1138 "Counter": "0,1,2,3",
1139 "EventCode": "0x2",
1140 "EventName": "UNC_UPI_TxL_FLITS.IDLE",
1141 "PerPkg": "1",
1142 "PublicDescription": "Counts when the Intel Ultra Path Interconnect(UPI) transmits an idle FLIT(80 bit FLow control unITs). Every UPI cycle must be sending either data FLITs, protocol/credit FLITs or idle FLITs.",
1143 "UMask": "0x47",
1144 "Unit": "UPI LL"
1145 },
1146 {
1147 "BriefDescription": "Protocol header and credit FLITs transmitted across any slot",
1148 "Counter": "0,1,2,3",
1149 "EventCode": "0x2",
1150 "EventName": "UNC_UPI_TxL_FLITS.NON_DATA",
1151 "PerPkg": "1",
1152 "PublicDescription": "Counts protocol header and credit FLITs (80 bit FLow control unITs) transmitted across any of the 3 UPI (Ultra Path Interconnect) slots on this UPI unit.",
1153 "UMask": "0x97",
1154 "Unit": "UPI LL"
1155 }
1156]
diff --git a/tools/perf/pmu-events/arch/x86/skylakex/virtual-memory.json b/tools/perf/pmu-events/arch/x86/skylakex/virtual-memory.json
new file mode 100644
index 000000000000..70750dab7ead
--- /dev/null
+++ b/tools/perf/pmu-events/arch/x86/skylakex/virtual-memory.json
@@ -0,0 +1,284 @@
1[
2 {
3 "EventCode": "0x08",
4 "UMask": "0x1",
5 "BriefDescription": "Load misses in all DTLB levels that cause page walks",
6 "Counter": "0,1,2,3",
7 "EventName": "DTLB_LOAD_MISSES.MISS_CAUSES_A_WALK",
8 "PublicDescription": "Counts demand data loads that caused a page walk of any page size (4K/2M/4M/1G). This implies it missed in all TLB levels, but the walk need not have completed.",
9 "SampleAfterValue": "100003",
10 "CounterHTOff": "0,1,2,3,4,5,6,7"
11 },
12 {
13 "EventCode": "0x08",
14 "UMask": "0x2",
15 "BriefDescription": "Demand load Miss in all translation lookaside buffer (TLB) levels causes a page walk that completes (4K).",
16 "Counter": "0,1,2,3",
17 "EventName": "DTLB_LOAD_MISSES.WALK_COMPLETED_4K",
18 "PublicDescription": "Counts demand data loads that caused a completed page walk (4K page size). This implies it missed in all TLB levels. The page walk can end with or without a fault.",
19 "SampleAfterValue": "2000003",
20 "CounterHTOff": "0,1,2,3,4,5,6,7"
21 },
22 {
23 "EventCode": "0x08",
24 "UMask": "0x4",
25 "BriefDescription": "Demand load Miss in all translation lookaside buffer (TLB) levels causes a page walk that completes (2M/4M).",
26 "Counter": "0,1,2,3",
27 "EventName": "DTLB_LOAD_MISSES.WALK_COMPLETED_2M_4M",
28 "PublicDescription": "Counts demand data loads that caused a completed page walk (2M and 4M page sizes). This implies it missed in all TLB levels. The page walk can end with or without a fault.",
29 "SampleAfterValue": "2000003",
30 "CounterHTOff": "0,1,2,3,4,5,6,7"
31 },
32 {
33 "EventCode": "0x08",
34 "UMask": "0x8",
35 "BriefDescription": "Load miss in all TLB levels causes a page walk that completes. (1G)",
36 "Counter": "0,1,2,3",
37 "EventName": "DTLB_LOAD_MISSES.WALK_COMPLETED_1G",
38 "PublicDescription": "Counts load misses in all DTLB levels that cause a completed page walk (1G page size). The page walk can end with or without a fault.",
39 "SampleAfterValue": "2000003",
40 "CounterHTOff": "0,1,2,3,4,5,6,7"
41 },
42 {
43 "EventCode": "0x08",
44 "UMask": "0xe",
45 "BriefDescription": "Load miss in all TLB levels causes a page walk that completes. (All page sizes)",
46 "Counter": "0,1,2,3",
47 "EventName": "DTLB_LOAD_MISSES.WALK_COMPLETED",
48 "PublicDescription": "Counts demand data loads that caused a completed page walk of any page size (4K/2M/4M/1G). This implies it missed in all TLB levels. The page walk can end with or without a fault.",
49 "SampleAfterValue": "100003",
50 "CounterHTOff": "0,1,2,3,4,5,6,7"
51 },
52 {
53 "EventCode": "0x08",
54 "UMask": "0x10",
55 "BriefDescription": "Counts 1 per cycle for each PMH that is busy with a page walk for a load. EPT page walk duration are excluded in Skylake. ",
56 "Counter": "0,1,2,3",
57 "EventName": "DTLB_LOAD_MISSES.WALK_PENDING",
58 "PublicDescription": "Counts 1 per cycle for each PMH that is busy with a page walk for a load. EPT page walk duration are excluded in Skylake microarchitecture. ",
59 "SampleAfterValue": "2000003",
60 "CounterHTOff": "0,1,2,3,4,5,6,7"
61 },
62 {
63 "EventCode": "0x08",
64 "UMask": "0x10",
65 "BriefDescription": "Cycles when at least one PMH is busy with a page walk for a load. EPT page walk duration are excluded in Skylake. ",
66 "Counter": "0,1,2,3",
67 "EventName": "DTLB_LOAD_MISSES.WALK_ACTIVE",
68 "CounterMask": "1",
69 "PublicDescription": "Counts cycles when at least one PMH (Page Miss Handler) is busy with a page walk for a load.",
70 "SampleAfterValue": "100003",
71 "CounterHTOff": "0,1,2,3,4,5,6,7"
72 },
73 {
74 "EventCode": "0x08",
75 "UMask": "0x20",
76 "BriefDescription": "Loads that miss the DTLB and hit the STLB.",
77 "Counter": "0,1,2,3",
78 "EventName": "DTLB_LOAD_MISSES.STLB_HIT",
79 "PublicDescription": "Counts loads that miss the DTLB (Data TLB) and hit the STLB (Second level TLB).",
80 "SampleAfterValue": "2000003",
81 "CounterHTOff": "0,1,2,3,4,5,6,7"
82 },
83 {
84 "EventCode": "0x49",
85 "UMask": "0x1",
86 "BriefDescription": "Store misses in all DTLB levels that cause page walks",
87 "Counter": "0,1,2,3",
88 "EventName": "DTLB_STORE_MISSES.MISS_CAUSES_A_WALK",
89 "PublicDescription": "Counts demand data stores that caused a page walk of any page size (4K/2M/4M/1G). This implies it missed in all TLB levels, but the walk need not have completed.",
90 "SampleAfterValue": "100003",
91 "CounterHTOff": "0,1,2,3,4,5,6,7"
92 },
93 {
94 "EventCode": "0x49",
95 "UMask": "0x2",
96 "BriefDescription": "Store miss in all TLB levels causes a page walk that completes. (4K)",
97 "Counter": "0,1,2,3",
98 "EventName": "DTLB_STORE_MISSES.WALK_COMPLETED_4K",
99 "PublicDescription": "Counts demand data stores that caused a completed page walk (4K page size). This implies it missed in all TLB levels. The page walk can end with or without a fault.",
100 "SampleAfterValue": "100003",
101 "CounterHTOff": "0,1,2,3,4,5,6,7"
102 },
103 {
104 "EventCode": "0x49",
105 "UMask": "0x4",
106 "BriefDescription": "Store misses in all DTLB levels that cause completed page walks (2M/4M)",
107 "Counter": "0,1,2,3",
108 "EventName": "DTLB_STORE_MISSES.WALK_COMPLETED_2M_4M",
109 "PublicDescription": "Counts demand data stores that caused a completed page walk (2M and 4M page sizes). This implies it missed in all TLB levels. The page walk can end with or without a fault.",
110 "SampleAfterValue": "100003",
111 "CounterHTOff": "0,1,2,3,4,5,6,7"
112 },
113 {
114 "EventCode": "0x49",
115 "UMask": "0x8",
116 "BriefDescription": "Store misses in all DTLB levels that cause completed page walks (1G)",
117 "Counter": "0,1,2,3",
118 "EventName": "DTLB_STORE_MISSES.WALK_COMPLETED_1G",
119 "PublicDescription": "Counts store misses in all DTLB levels that cause a completed page walk (1G page size). The page walk can end with or without a fault.",
120 "SampleAfterValue": "100003",
121 "CounterHTOff": "0,1,2,3,4,5,6,7"
122 },
123 {
124 "EventCode": "0x49",
125 "UMask": "0xe",
126 "BriefDescription": "Store misses in all TLB levels causes a page walk that completes. (All page sizes)",
127 "Counter": "0,1,2,3",
128 "EventName": "DTLB_STORE_MISSES.WALK_COMPLETED",
129 "PublicDescription": "Counts demand data stores that caused a completed page walk of any page size (4K/2M/4M/1G). This implies it missed in all TLB levels. The page walk can end with or without a fault.",
130 "SampleAfterValue": "100003",
131 "CounterHTOff": "0,1,2,3,4,5,6,7"
132 },
133 {
134 "EventCode": "0x49",
135 "UMask": "0x10",
136 "BriefDescription": "Counts 1 per cycle for each PMH that is busy with a page walk for a store. EPT page walk duration are excluded in Skylake. ",
137 "Counter": "0,1,2,3",
138 "EventName": "DTLB_STORE_MISSES.WALK_PENDING",
139 "PublicDescription": "Counts 1 per cycle for each PMH that is busy with a page walk for a store. EPT page walk duration are excluded in Skylake microarchitecture. ",
140 "SampleAfterValue": "2000003",
141 "CounterHTOff": "0,1,2,3,4,5,6,7"
142 },
143 {
144 "EventCode": "0x49",
145 "UMask": "0x10",
146 "BriefDescription": "Cycles when at least one PMH is busy with a page walk for a store. EPT page walk duration are excluded in Skylake. ",
147 "Counter": "0,1,2,3",
148 "EventName": "DTLB_STORE_MISSES.WALK_ACTIVE",
149 "CounterMask": "1",
150 "PublicDescription": "Counts cycles when at least one PMH (Page Miss Handler) is busy with a page walk for a store.",
151 "SampleAfterValue": "100003",
152 "CounterHTOff": "0,1,2,3,4,5,6,7"
153 },
154 {
155 "EventCode": "0x49",
156 "UMask": "0x20",
157 "BriefDescription": "Stores that miss the DTLB and hit the STLB.",
158 "Counter": "0,1,2,3",
159 "EventName": "DTLB_STORE_MISSES.STLB_HIT",
160 "PublicDescription": "Stores that miss the DTLB (Data TLB) and hit the STLB (2nd Level TLB).",
161 "SampleAfterValue": "100003",
162 "CounterHTOff": "0,1,2,3,4,5,6,7"
163 },
164 {
165 "EventCode": "0x4F",
166 "UMask": "0x10",
167 "BriefDescription": "Counts 1 per cycle for each PMH that is busy with a EPT (Extended Page Table) walk for any request type.",
168 "Counter": "0,1,2,3",
169 "EventName": "EPT.WALK_PENDING",
170 "PublicDescription": "Counts cycles for each PMH (Page Miss Handler) that is busy with an EPT (Extended Page Table) walk for any request type.",
171 "SampleAfterValue": "2000003",
172 "CounterHTOff": "0,1,2,3,4,5,6,7"
173 },
174 {
175 "EventCode": "0x85",
176 "UMask": "0x1",
177 "BriefDescription": "Misses at all ITLB levels that cause page walks",
178 "Counter": "0,1,2,3",
179 "EventName": "ITLB_MISSES.MISS_CAUSES_A_WALK",
180 "PublicDescription": "Counts page walks of any page size (4K/2M/4M/1G) caused by a code fetch. This implies it missed in the ITLB and further levels of TLB, but the walk need not have completed.",
181 "SampleAfterValue": "100003",
182 "CounterHTOff": "0,1,2,3,4,5,6,7"
183 },
184 {
185 "EventCode": "0x85",
186 "UMask": "0x2",
187 "BriefDescription": "Code miss in all TLB levels causes a page walk that completes. (4K)",
188 "Counter": "0,1,2,3",
189 "EventName": "ITLB_MISSES.WALK_COMPLETED_4K",
190 "PublicDescription": "Counts completed page walks (4K page size) caused by a code fetch. This implies it missed in the ITLB and further levels of TLB. The page walk can end with or without a fault.",
191 "SampleAfterValue": "100003",
192 "CounterHTOff": "0,1,2,3,4,5,6,7"
193 },
194 {
195 "EventCode": "0x85",
196 "UMask": "0x4",
197 "BriefDescription": "Code miss in all TLB levels causes a page walk that completes. (2M/4M)",
198 "Counter": "0,1,2,3",
199 "EventName": "ITLB_MISSES.WALK_COMPLETED_2M_4M",
200 "PublicDescription": "Counts completed page walks of any page size (4K/2M/4M/1G) caused by a code fetch. This implies it missed in the ITLB and further levels of TLB. The page walk can end with or without a fault.",
201 "SampleAfterValue": "100003",
202 "CounterHTOff": "0,1,2,3,4,5,6,7"
203 },
204 {
205 "EventCode": "0x85",
206 "UMask": "0x8",
207 "BriefDescription": "Code miss in all TLB levels causes a page walk that completes. (1G)",
208 "Counter": "0,1,2,3",
209 "EventName": "ITLB_MISSES.WALK_COMPLETED_1G",
210 "PublicDescription": "Counts store misses in all DTLB levels that cause a completed page walk (1G page size). The page walk can end with or without a fault.",
211 "SampleAfterValue": "100003",
212 "CounterHTOff": "0,1,2,3,4,5,6,7"
213 },
214 {
215 "EventCode": "0x85",
216 "UMask": "0xe",
217 "BriefDescription": "Code miss in all TLB levels causes a page walk that completes. (All page sizes)",
218 "Counter": "0,1,2,3",
219 "EventName": "ITLB_MISSES.WALK_COMPLETED",
220 "PublicDescription": "Counts completed page walks (2M and 4M page sizes) caused by a code fetch. This implies it missed in the ITLB and further levels of TLB. The page walk can end with or without a fault.",
221 "SampleAfterValue": "100003",
222 "CounterHTOff": "0,1,2,3,4,5,6,7"
223 },
224 {
225 "EventCode": "0x85",
226 "UMask": "0x10",
227 "BriefDescription": "Counts 1 per cycle for each PMH that is busy with a page walk for an instruction fetch request. EPT page walk duration are excluded in Skylake. ",
228 "Counter": "0,1,2,3",
229 "EventName": "ITLB_MISSES.WALK_PENDING",
230 "PublicDescription": "Counts 1 per cycle for each PMH (Page Miss Handler) that is busy with a page walk for an instruction fetch request. EPT page walk duration are excluded in Skylake michroarchitecture. ",
231 "SampleAfterValue": "100003",
232 "CounterHTOff": "0,1,2,3,4,5,6,7"
233 },
234 {
235 "EventCode": "0x85",
236 "UMask": "0x10",
237 "BriefDescription": "Cycles when at least one PMH is busy with a page walk for code (instruction fetch) request. EPT page walk duration are excluded in Skylake.",
238 "Counter": "0,1,2,3",
239 "EventName": "ITLB_MISSES.WALK_ACTIVE",
240 "CounterMask": "1",
241 "PublicDescription": "Cycles when at least one PMH is busy with a page walk for code (instruction fetch) request. EPT page walk duration are excluded in Skylake microarchitecture.",
242 "SampleAfterValue": "100003",
243 "CounterHTOff": "0,1,2,3,4,5,6,7"
244 },
245 {
246 "EventCode": "0x85",
247 "UMask": "0x20",
248 "BriefDescription": "Instruction fetch requests that miss the ITLB and hit the STLB.",
249 "Counter": "0,1,2,3",
250 "EventName": "ITLB_MISSES.STLB_HIT",
251 "SampleAfterValue": "100003",
252 "CounterHTOff": "0,1,2,3,4,5,6,7"
253 },
254 {
255 "EventCode": "0xAE",
256 "UMask": "0x1",
257 "BriefDescription": "Flushing of the Instruction TLB (ITLB) pages, includes 4k/2M/4M pages.",
258 "Counter": "0,1,2,3",
259 "EventName": "ITLB.ITLB_FLUSH",
260 "PublicDescription": "Counts the number of flushes of the big or small ITLB pages. Counting include both TLB Flush (covering all sets) and TLB Set Clear (set-specific).",
261 "SampleAfterValue": "100007",
262 "CounterHTOff": "0,1,2,3,4,5,6,7"
263 },
264 {
265 "EventCode": "0xBD",
266 "UMask": "0x1",
267 "BriefDescription": "DTLB flush attempts of the thread-specific entries",
268 "Counter": "0,1,2,3",
269 "EventName": "TLB_FLUSH.DTLB_THREAD",
270 "PublicDescription": "Counts the number of DTLB flush attempts of the thread-specific entries.",
271 "SampleAfterValue": "100007",
272 "CounterHTOff": "0,1,2,3,4,5,6,7"
273 },
274 {
275 "EventCode": "0xBD",
276 "UMask": "0x20",
277 "BriefDescription": "STLB flush attempts",
278 "Counter": "0,1,2,3",
279 "EventName": "TLB_FLUSH.STLB_ANY",
280 "PublicDescription": "Counts the number of any STLB flush attempts (such as entire, VPID, PCID, InvPage, CR3 write, etc.).",
281 "SampleAfterValue": "100007",
282 "CounterHTOff": "0,1,2,3,4,5,6,7"
283 }
284] \ No newline at end of file
diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
index bd0aabb2bd0f..d51dc9ca8861 100644
--- a/tools/perf/pmu-events/jevents.c
+++ b/tools/perf/pmu-events/jevents.c
@@ -137,6 +137,8 @@ static struct field {
137 { "AnyThread", "any=" }, 137 { "AnyThread", "any=" },
138 { "EdgeDetect", "edge=" }, 138 { "EdgeDetect", "edge=" },
139 { "SampleAfterValue", "period=" }, 139 { "SampleAfterValue", "period=" },
140 { "FCMask", "fc_mask=" },
141 { "PortMask", "ch_mask=" },
140 { NULL, NULL } 142 { NULL, NULL }
141}; 143};
142 144
@@ -822,10 +824,6 @@ static int process_one_file(const char *fpath, const struct stat *sb,
822 * PMU event tables (see struct pmu_events_map). 824 * PMU event tables (see struct pmu_events_map).
823 * 825 *
824 * Write out the PMU events tables and the mapping table to pmu-event.c. 826 * Write out the PMU events tables and the mapping table to pmu-event.c.
825 *
826 * If unable to process the JSON or arch files, create an empty mapping
827 * table so we can continue to build/use perf even if we cannot use the
828 * PMU event aliases.
829 */ 827 */
830int main(int argc, char *argv[]) 828int main(int argc, char *argv[])
831{ 829{
@@ -836,6 +834,7 @@ int main(int argc, char *argv[])
836 const char *arch; 834 const char *arch;
837 const char *output_file; 835 const char *output_file;
838 const char *start_dirname; 836 const char *start_dirname;
837 struct stat stbuf;
839 838
840 prog = basename(argv[0]); 839 prog = basename(argv[0]);
841 if (argc < 4) { 840 if (argc < 4) {
@@ -857,11 +856,17 @@ int main(int argc, char *argv[])
857 return 2; 856 return 2;
858 } 857 }
859 858
859 sprintf(ldirname, "%s/%s", start_dirname, arch);
860
861 /* If architecture does not have any event lists, bail out */
862 if (stat(ldirname, &stbuf) < 0) {
863 pr_info("%s: Arch %s has no PMU event lists\n", prog, arch);
864 goto empty_map;
865 }
866
860 /* Include pmu-events.h first */ 867 /* Include pmu-events.h first */
861 fprintf(eventsfp, "#include \"../../pmu-events/pmu-events.h\"\n"); 868 fprintf(eventsfp, "#include \"../../pmu-events/pmu-events.h\"\n");
862 869
863 sprintf(ldirname, "%s/%s", start_dirname, arch);
864
865 /* 870 /*
866 * The mapfile allows multiple CPUids to point to the same JSON file, 871 * The mapfile allows multiple CPUids to point to the same JSON file,
867 * so, not sure if there is a need for symlinks within the pmu-events 872 * so, not sure if there is a need for symlinks within the pmu-events
@@ -878,6 +883,9 @@ int main(int argc, char *argv[])
878 if (rc && verbose) { 883 if (rc && verbose) {
879 pr_info("%s: Error walking file tree %s\n", prog, ldirname); 884 pr_info("%s: Error walking file tree %s\n", prog, ldirname);
880 goto empty_map; 885 goto empty_map;
886 } else if (rc < 0) {
887 /* Make build fail */
888 return 1;
881 } else if (rc) { 889 } else if (rc) {
882 goto empty_map; 890 goto empty_map;
883 } 891 }
@@ -892,7 +900,8 @@ int main(int argc, char *argv[])
892 900
893 if (process_mapfile(eventsfp, mapfile)) { 901 if (process_mapfile(eventsfp, mapfile)) {
894 pr_info("%s: Error processing mapfile %s\n", prog, mapfile); 902 pr_info("%s: Error processing mapfile %s\n", prog, mapfile);
895 goto empty_map; 903 /* Make build fail */
904 return 1;
896 } 905 }
897 906
898 return 0; 907 return 0;
diff --git a/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py b/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py
index 1d95009592eb..f6c84966e4f8 100644
--- a/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py
+++ b/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py
@@ -57,6 +57,7 @@ try:
57 'ia64' : audit.MACH_IA64, 57 'ia64' : audit.MACH_IA64,
58 'ppc' : audit.MACH_PPC, 58 'ppc' : audit.MACH_PPC,
59 'ppc64' : audit.MACH_PPC64, 59 'ppc64' : audit.MACH_PPC64,
60 'ppc64le' : audit.MACH_PPC64LE,
60 's390' : audit.MACH_S390, 61 's390' : audit.MACH_S390,
61 's390x' : audit.MACH_S390X, 62 's390x' : audit.MACH_S390X,
62 'i386' : audit.MACH_X86, 63 'i386' : audit.MACH_X86,
diff --git a/tools/perf/scripts/python/bin/export-to-sqlite-record b/tools/perf/scripts/python/bin/export-to-sqlite-record
new file mode 100644
index 000000000000..070204fd6d00
--- /dev/null
+++ b/tools/perf/scripts/python/bin/export-to-sqlite-record
@@ -0,0 +1,8 @@
1#!/bin/bash
2
3#
4# export perf data to a sqlite3 database. Can cover
5# perf ip samples (excluding the tracepoints). No special
6# record requirements, just record what you want to export.
7#
8perf record $@
diff --git a/tools/perf/scripts/python/bin/export-to-sqlite-report b/tools/perf/scripts/python/bin/export-to-sqlite-report
new file mode 100644
index 000000000000..5ff6033e70ba
--- /dev/null
+++ b/tools/perf/scripts/python/bin/export-to-sqlite-report
@@ -0,0 +1,29 @@
1#!/bin/bash
2# description: export perf data to a sqlite3 database
3# args: [database name] [columns] [calls]
4n_args=0
5for i in "$@"
6do
7 if expr match "$i" "-" > /dev/null ; then
8 break
9 fi
10 n_args=$(( $n_args + 1 ))
11done
12if [ "$n_args" -gt 3 ] ; then
13 echo "usage: export-to-sqlite-report [database name] [columns] [calls]"
14 exit
15fi
16if [ "$n_args" -gt 2 ] ; then
17 dbname=$1
18 columns=$2
19 calls=$3
20 shift 3
21elif [ "$n_args" -gt 1 ] ; then
22 dbname=$1
23 columns=$2
24 shift 2
25elif [ "$n_args" -gt 0 ] ; then
26 dbname=$1
27 shift
28fi
29perf script $@ -s "$PERF_EXEC_PATH"/scripts/python/export-to-sqlite.py $dbname $columns $calls
diff --git a/tools/perf/scripts/python/call-graph-from-postgresql.py b/tools/perf/scripts/python/call-graph-from-sql.py
index e78fdc2a5a9d..b494a67a1c67 100644
--- a/tools/perf/scripts/python/call-graph-from-postgresql.py
+++ b/tools/perf/scripts/python/call-graph-from-sql.py
@@ -1,6 +1,6 @@
1#!/usr/bin/python2 1#!/usr/bin/python2
2# call-graph-from-postgresql.py: create call-graph from postgresql database 2# call-graph-from-sql.py: create call-graph from sql database
3# Copyright (c) 2014, Intel Corporation. 3# Copyright (c) 2014-2017, Intel Corporation.
4# 4#
5# This program is free software; you can redistribute it and/or modify it 5# This program is free software; you can redistribute it and/or modify it
6# under the terms and conditions of the GNU General Public License, 6# under the terms and conditions of the GNU General Public License,
@@ -11,18 +11,19 @@
11# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12# more details. 12# more details.
13 13
14# To use this script you will need to have exported data using the 14# To use this script you will need to have exported data using either the
15# export-to-postgresql.py script. Refer to that script for details. 15# export-to-sqlite.py or the export-to-postgresql.py script. Refer to those
16# scripts for details.
16# 17#
17# Following on from the example in the export-to-postgresql.py script, a 18# Following on from the example in the export scripts, a
18# call-graph can be displayed for the pt_example database like this: 19# call-graph can be displayed for the pt_example database like this:
19# 20#
20# python tools/perf/scripts/python/call-graph-from-postgresql.py pt_example 21# python tools/perf/scripts/python/call-graph-from-sql.py pt_example
21# 22#
22# Note this script supports connecting to remote databases by setting hostname, 23# Note that for PostgreSQL, this script supports connecting to remote databases
23# port, username, password, and dbname e.g. 24# by setting hostname, port, username, password, and dbname e.g.
24# 25#
25# python tools/perf/scripts/python/call-graph-from-postgresql.py "hostname=myhost username=myuser password=mypassword dbname=pt_example" 26# python tools/perf/scripts/python/call-graph-from-sql.py "hostname=myhost username=myuser password=mypassword dbname=pt_example"
26# 27#
27# The result is a GUI window with a tree representing a context-sensitive 28# The result is a GUI window with a tree representing a context-sensitive
28# call-graph. Expanding a couple of levels of the tree and adjusting column 29# call-graph. Expanding a couple of levels of the tree and adjusting column
@@ -160,7 +161,7 @@ class TreeItem():
160 '( SELECT short_name FROM dsos WHERE id = ( SELECT dso_id FROM symbols WHERE id = ( SELECT symbol_id FROM call_paths WHERE id = call_path_id ) ) ), ' 161 '( SELECT short_name FROM dsos WHERE id = ( SELECT dso_id FROM symbols WHERE id = ( SELECT symbol_id FROM call_paths WHERE id = call_path_id ) ) ), '
161 '( SELECT ip FROM call_paths where id = call_path_id ) ' 162 '( SELECT ip FROM call_paths where id = call_path_id ) '
162 'FROM calls WHERE parent_call_path_id = ' + str(self.call_path_id) + ' AND comm_id = ' + str(self.comm_id) + ' AND thread_id = ' + str(self.thread_id) + 163 'FROM calls WHERE parent_call_path_id = ' + str(self.call_path_id) + ' AND comm_id = ' + str(self.comm_id) + ' AND thread_id = ' + str(self.thread_id) +
163 'ORDER BY call_path_id') 164 ' ORDER BY call_path_id')
164 if not ret: 165 if not ret:
165 raise Exception("Query failed: " + query.lastError().text()) 166 raise Exception("Query failed: " + query.lastError().text())
166 last_call_path_id = 0 167 last_call_path_id = 0
@@ -291,29 +292,40 @@ class MainWindow(QMainWindow):
291 292
292if __name__ == '__main__': 293if __name__ == '__main__':
293 if (len(sys.argv) < 2): 294 if (len(sys.argv) < 2):
294 print >> sys.stderr, "Usage is: call-graph-from-postgresql.py <database name>" 295 print >> sys.stderr, "Usage is: call-graph-from-sql.py <database name>"
295 raise Exception("Too few arguments") 296 raise Exception("Too few arguments")
296 297
297 dbname = sys.argv[1] 298 dbname = sys.argv[1]
298 299
299 db = QSqlDatabase.addDatabase('QPSQL') 300 is_sqlite3 = False
300 301 try:
301 opts = dbname.split() 302 f = open(dbname)
302 for opt in opts: 303 if f.read(15) == "SQLite format 3":
303 if '=' in opt: 304 is_sqlite3 = True
304 opt = opt.split('=') 305 f.close()
305 if opt[0] == 'hostname': 306 except:
306 db.setHostName(opt[1]) 307 pass
307 elif opt[0] == 'port': 308
308 db.setPort(int(opt[1])) 309 if is_sqlite3:
309 elif opt[0] == 'username': 310 db = QSqlDatabase.addDatabase('QSQLITE')
310 db.setUserName(opt[1]) 311 else:
311 elif opt[0] == 'password': 312 db = QSqlDatabase.addDatabase('QPSQL')
312 db.setPassword(opt[1]) 313 opts = dbname.split()
313 elif opt[0] == 'dbname': 314 for opt in opts:
314 dbname = opt[1] 315 if '=' in opt:
315 else: 316 opt = opt.split('=')
316 dbname = opt 317 if opt[0] == 'hostname':
318 db.setHostName(opt[1])
319 elif opt[0] == 'port':
320 db.setPort(int(opt[1]))
321 elif opt[0] == 'username':
322 db.setUserName(opt[1])
323 elif opt[0] == 'password':
324 db.setPassword(opt[1])
325 elif opt[0] == 'dbname':
326 dbname = opt[1]
327 else:
328 dbname = opt
317 329
318 db.setDatabaseName(dbname) 330 db.setDatabaseName(dbname)
319 if not db.open(): 331 if not db.open():
diff --git a/tools/perf/scripts/python/export-to-postgresql.py b/tools/perf/scripts/python/export-to-postgresql.py
index 7656ff8aa066..efcaf6cac2eb 100644
--- a/tools/perf/scripts/python/export-to-postgresql.py
+++ b/tools/perf/scripts/python/export-to-postgresql.py
@@ -59,7 +59,7 @@ import datetime
59# pt_example=# \q 59# pt_example=# \q
60# 60#
61# An example of using the database is provided by the script 61# An example of using the database is provided by the script
62# call-graph-from-postgresql.py. Refer to that script for details. 62# call-graph-from-sql.py. Refer to that script for details.
63# 63#
64# Tables: 64# Tables:
65# 65#
@@ -340,7 +340,8 @@ if branches:
340 'to_sym_offset bigint,' 340 'to_sym_offset bigint,'
341 'to_ip bigint,' 341 'to_ip bigint,'
342 'branch_type integer,' 342 'branch_type integer,'
343 'in_tx boolean)') 343 'in_tx boolean,'
344 'call_path_id bigint)')
344else: 345else:
345 do_query(query, 'CREATE TABLE samples (' 346 do_query(query, 'CREATE TABLE samples ('
346 'id bigint NOT NULL,' 347 'id bigint NOT NULL,'
diff --git a/tools/perf/scripts/python/export-to-sqlite.py b/tools/perf/scripts/python/export-to-sqlite.py
new file mode 100644
index 000000000000..f827bf77e9d2
--- /dev/null
+++ b/tools/perf/scripts/python/export-to-sqlite.py
@@ -0,0 +1,451 @@
1# export-to-sqlite.py: export perf data to a sqlite3 database
2# Copyright (c) 2017, Intel Corporation.
3#
4# This program is free software; you can redistribute it and/or modify it
5# under the terms and conditions of the GNU General Public License,
6# version 2, as published by the Free Software Foundation.
7#
8# This program is distributed in the hope it will be useful, but WITHOUT
9# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11# more details.
12
13import os
14import sys
15import struct
16import datetime
17
18# To use this script you will need to have installed package python-pyside which
19# provides LGPL-licensed Python bindings for Qt. You will also need the package
20# libqt4-sql-sqlite for Qt sqlite3 support.
21#
22# An example of using this script with Intel PT:
23#
24# $ perf record -e intel_pt//u ls
25# $ perf script -s ~/libexec/perf-core/scripts/python/export-to-sqlite.py pt_example branches calls
26# 2017-07-31 14:26:07.326913 Creating database...
27# 2017-07-31 14:26:07.538097 Writing records...
28# 2017-07-31 14:26:09.889292 Adding indexes
29# 2017-07-31 14:26:09.958746 Done
30#
31# To browse the database, sqlite3 can be used e.g.
32#
33# $ sqlite3 pt_example
34# sqlite> .header on
35# sqlite> select * from samples_view where id < 10;
36# sqlite> .mode column
37# sqlite> select * from samples_view where id < 10;
38# sqlite> .tables
39# sqlite> .schema samples_view
40# sqlite> .quit
41#
42# An example of using the database is provided by the script
43# call-graph-from-sql.py. Refer to that script for details.
44#
45# The database structure is practically the same as created by the script
46# export-to-postgresql.py. Refer to that script for details. A notable
47# difference is the 'transaction' column of the 'samples' table which is
48# renamed 'transaction_' in sqlite because 'transaction' is a reserved word.
49
50from PySide.QtSql import *
51
52sys.path.append(os.environ['PERF_EXEC_PATH'] + \
53 '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
54
55# These perf imports are not used at present
56#from perf_trace_context import *
57#from Core import *
58
59perf_db_export_mode = True
60perf_db_export_calls = False
61perf_db_export_callchains = False
62
63def usage():
64 print >> sys.stderr, "Usage is: export-to-sqlite.py <database name> [<columns>] [<calls>] [<callchains>]"
65 print >> sys.stderr, "where: columns 'all' or 'branches'"
66 print >> sys.stderr, " calls 'calls' => create calls and call_paths table"
67 print >> sys.stderr, " callchains 'callchains' => create call_paths table"
68 raise Exception("Too few arguments")
69
70if (len(sys.argv) < 2):
71 usage()
72
73dbname = sys.argv[1]
74
75if (len(sys.argv) >= 3):
76 columns = sys.argv[2]
77else:
78 columns = "all"
79
80if columns not in ("all", "branches"):
81 usage()
82
83branches = (columns == "branches")
84
85for i in range(3,len(sys.argv)):
86 if (sys.argv[i] == "calls"):
87 perf_db_export_calls = True
88 elif (sys.argv[i] == "callchains"):
89 perf_db_export_callchains = True
90 else:
91 usage()
92
93def do_query(q, s):
94 if (q.exec_(s)):
95 return
96 raise Exception("Query failed: " + q.lastError().text())
97
98def do_query_(q):
99 if (q.exec_()):
100 return
101 raise Exception("Query failed: " + q.lastError().text())
102
103print datetime.datetime.today(), "Creating database..."
104
105db_exists = False
106try:
107 f = open(dbname)
108 f.close()
109 db_exists = True
110except:
111 pass
112
113if db_exists:
114 raise Exception(dbname + " already exists")
115
116db = QSqlDatabase.addDatabase('QSQLITE')
117db.setDatabaseName(dbname)
118db.open()
119
120query = QSqlQuery(db)
121
122do_query(query, 'PRAGMA journal_mode = OFF')
123do_query(query, 'BEGIN TRANSACTION')
124
125do_query(query, 'CREATE TABLE selected_events ('
126 'id integer NOT NULL PRIMARY KEY,'
127 'name varchar(80))')
128do_query(query, 'CREATE TABLE machines ('
129 'id integer NOT NULL PRIMARY KEY,'
130 'pid integer,'
131 'root_dir varchar(4096))')
132do_query(query, 'CREATE TABLE threads ('
133 'id integer NOT NULL PRIMARY KEY,'
134 'machine_id bigint,'
135 'process_id bigint,'
136 'pid integer,'
137 'tid integer)')
138do_query(query, 'CREATE TABLE comms ('
139 'id integer NOT NULL PRIMARY KEY,'
140 'comm varchar(16))')
141do_query(query, 'CREATE TABLE comm_threads ('
142 'id integer NOT NULL PRIMARY KEY,'
143 'comm_id bigint,'
144 'thread_id bigint)')
145do_query(query, 'CREATE TABLE dsos ('
146 'id integer NOT NULL PRIMARY KEY,'
147 'machine_id bigint,'
148 'short_name varchar(256),'
149 'long_name varchar(4096),'
150 'build_id varchar(64))')
151do_query(query, 'CREATE TABLE symbols ('
152 'id integer NOT NULL PRIMARY KEY,'
153 'dso_id bigint,'
154 'sym_start bigint,'
155 'sym_end bigint,'
156 'binding integer,'
157 'name varchar(2048))')
158do_query(query, 'CREATE TABLE branch_types ('
159 'id integer NOT NULL PRIMARY KEY,'
160 'name varchar(80))')
161
162if branches:
163 do_query(query, 'CREATE TABLE samples ('
164 'id integer NOT NULL PRIMARY KEY,'
165 'evsel_id bigint,'
166 'machine_id bigint,'
167 'thread_id bigint,'
168 'comm_id bigint,'
169 'dso_id bigint,'
170 'symbol_id bigint,'
171 'sym_offset bigint,'
172 'ip bigint,'
173 'time bigint,'
174 'cpu integer,'
175 'to_dso_id bigint,'
176 'to_symbol_id bigint,'
177 'to_sym_offset bigint,'
178 'to_ip bigint,'
179 'branch_type integer,'
180 'in_tx boolean,'
181 'call_path_id bigint)')
182else:
183 do_query(query, 'CREATE TABLE samples ('
184 'id integer NOT NULL PRIMARY KEY,'
185 'evsel_id bigint,'
186 'machine_id bigint,'
187 'thread_id bigint,'
188 'comm_id bigint,'
189 'dso_id bigint,'
190 'symbol_id bigint,'
191 'sym_offset bigint,'
192 'ip bigint,'
193 'time bigint,'
194 'cpu integer,'
195 'to_dso_id bigint,'
196 'to_symbol_id bigint,'
197 'to_sym_offset bigint,'
198 'to_ip bigint,'
199 'period bigint,'
200 'weight bigint,'
201 'transaction_ bigint,'
202 'data_src bigint,'
203 'branch_type integer,'
204 'in_tx boolean,'
205 'call_path_id bigint)')
206
207if perf_db_export_calls or perf_db_export_callchains:
208 do_query(query, 'CREATE TABLE call_paths ('
209 'id integer NOT NULL PRIMARY KEY,'
210 'parent_id bigint,'
211 'symbol_id bigint,'
212 'ip bigint)')
213if perf_db_export_calls:
214 do_query(query, 'CREATE TABLE calls ('
215 'id integer NOT NULL PRIMARY KEY,'
216 'thread_id bigint,'
217 'comm_id bigint,'
218 'call_path_id bigint,'
219 'call_time bigint,'
220 'return_time bigint,'
221 'branch_count bigint,'
222 'call_id bigint,'
223 'return_id bigint,'
224 'parent_call_path_id bigint,'
225 'flags integer)')
226
227# printf was added to sqlite in version 3.8.3
228sqlite_has_printf = False
229try:
230 do_query(query, 'SELECT printf("") FROM machines')
231 sqlite_has_printf = True
232except:
233 pass
234
235def emit_to_hex(x):
236 if sqlite_has_printf:
237 return 'printf("%x", ' + x + ')'
238 else:
239 return x
240
241do_query(query, 'CREATE VIEW machines_view AS '
242 'SELECT '
243 'id,'
244 'pid,'
245 'root_dir,'
246 'CASE WHEN id=0 THEN \'unknown\' WHEN pid=-1 THEN \'host\' ELSE \'guest\' END AS host_or_guest'
247 ' FROM machines')
248
249do_query(query, 'CREATE VIEW dsos_view AS '
250 'SELECT '
251 'id,'
252 'machine_id,'
253 '(SELECT host_or_guest FROM machines_view WHERE id = machine_id) AS host_or_guest,'
254 'short_name,'
255 'long_name,'
256 'build_id'
257 ' FROM dsos')
258
259do_query(query, 'CREATE VIEW symbols_view AS '
260 'SELECT '
261 'id,'
262 'name,'
263 '(SELECT short_name FROM dsos WHERE id=dso_id) AS dso,'
264 'dso_id,'
265 'sym_start,'
266 'sym_end,'
267 'CASE WHEN binding=0 THEN \'local\' WHEN binding=1 THEN \'global\' ELSE \'weak\' END AS binding'
268 ' FROM symbols')
269
270do_query(query, 'CREATE VIEW threads_view AS '
271 'SELECT '
272 'id,'
273 'machine_id,'
274 '(SELECT host_or_guest FROM machines_view WHERE id = machine_id) AS host_or_guest,'
275 'process_id,'
276 'pid,'
277 'tid'
278 ' FROM threads')
279
280do_query(query, 'CREATE VIEW comm_threads_view AS '
281 'SELECT '
282 'comm_id,'
283 '(SELECT comm FROM comms WHERE id = comm_id) AS command,'
284 'thread_id,'
285 '(SELECT pid FROM threads WHERE id = thread_id) AS pid,'
286 '(SELECT tid FROM threads WHERE id = thread_id) AS tid'
287 ' FROM comm_threads')
288
289if perf_db_export_calls or perf_db_export_callchains:
290 do_query(query, 'CREATE VIEW call_paths_view AS '
291 'SELECT '
292 'c.id,'
293 + emit_to_hex('c.ip') + ' AS ip,'
294 'c.symbol_id,'
295 '(SELECT name FROM symbols WHERE id = c.symbol_id) AS symbol,'
296 '(SELECT dso_id FROM symbols WHERE id = c.symbol_id) AS dso_id,'
297 '(SELECT dso FROM symbols_view WHERE id = c.symbol_id) AS dso_short_name,'
298 'c.parent_id,'
299 + emit_to_hex('p.ip') + ' AS parent_ip,'
300 'p.symbol_id AS parent_symbol_id,'
301 '(SELECT name FROM symbols WHERE id = p.symbol_id) AS parent_symbol,'
302 '(SELECT dso_id FROM symbols WHERE id = p.symbol_id) AS parent_dso_id,'
303 '(SELECT dso FROM symbols_view WHERE id = p.symbol_id) AS parent_dso_short_name'
304 ' FROM call_paths c INNER JOIN call_paths p ON p.id = c.parent_id')
305if perf_db_export_calls:
306 do_query(query, 'CREATE VIEW calls_view AS '
307 'SELECT '
308 'calls.id,'
309 'thread_id,'
310 '(SELECT pid FROM threads WHERE id = thread_id) AS pid,'
311 '(SELECT tid FROM threads WHERE id = thread_id) AS tid,'
312 '(SELECT comm FROM comms WHERE id = comm_id) AS command,'
313 'call_path_id,'
314 + emit_to_hex('ip') + ' AS ip,'
315 'symbol_id,'
316 '(SELECT name FROM symbols WHERE id = symbol_id) AS symbol,'
317 'call_time,'
318 'return_time,'
319 'return_time - call_time AS elapsed_time,'
320 'branch_count,'
321 'call_id,'
322 'return_id,'
323 'CASE WHEN flags=1 THEN \'no call\' WHEN flags=2 THEN \'no return\' WHEN flags=3 THEN \'no call/return\' ELSE \'\' END AS flags,'
324 'parent_call_path_id'
325 ' FROM calls INNER JOIN call_paths ON call_paths.id = call_path_id')
326
327do_query(query, 'CREATE VIEW samples_view AS '
328 'SELECT '
329 'id,'
330 'time,'
331 'cpu,'
332 '(SELECT pid FROM threads WHERE id = thread_id) AS pid,'
333 '(SELECT tid FROM threads WHERE id = thread_id) AS tid,'
334 '(SELECT comm FROM comms WHERE id = comm_id) AS command,'
335 '(SELECT name FROM selected_events WHERE id = evsel_id) AS event,'
336 + emit_to_hex('ip') + ' AS ip_hex,'
337 '(SELECT name FROM symbols WHERE id = symbol_id) AS symbol,'
338 'sym_offset,'
339 '(SELECT short_name FROM dsos WHERE id = dso_id) AS dso_short_name,'
340 + emit_to_hex('to_ip') + ' AS to_ip_hex,'
341 '(SELECT name FROM symbols WHERE id = to_symbol_id) AS to_symbol,'
342 'to_sym_offset,'
343 '(SELECT short_name FROM dsos WHERE id = to_dso_id) AS to_dso_short_name,'
344 '(SELECT name FROM branch_types WHERE id = branch_type) AS branch_type_name,'
345 'in_tx'
346 ' FROM samples')
347
348do_query(query, 'END TRANSACTION')
349
350evsel_query = QSqlQuery(db)
351evsel_query.prepare("INSERT INTO selected_events VALUES (?, ?)")
352machine_query = QSqlQuery(db)
353machine_query.prepare("INSERT INTO machines VALUES (?, ?, ?)")
354thread_query = QSqlQuery(db)
355thread_query.prepare("INSERT INTO threads VALUES (?, ?, ?, ?, ?)")
356comm_query = QSqlQuery(db)
357comm_query.prepare("INSERT INTO comms VALUES (?, ?)")
358comm_thread_query = QSqlQuery(db)
359comm_thread_query.prepare("INSERT INTO comm_threads VALUES (?, ?, ?)")
360dso_query = QSqlQuery(db)
361dso_query.prepare("INSERT INTO dsos VALUES (?, ?, ?, ?, ?)")
362symbol_query = QSqlQuery(db)
363symbol_query.prepare("INSERT INTO symbols VALUES (?, ?, ?, ?, ?, ?)")
364branch_type_query = QSqlQuery(db)
365branch_type_query.prepare("INSERT INTO branch_types VALUES (?, ?)")
366sample_query = QSqlQuery(db)
367if branches:
368 sample_query.prepare("INSERT INTO samples VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
369else:
370 sample_query.prepare("INSERT INTO samples VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
371if perf_db_export_calls or perf_db_export_callchains:
372 call_path_query = QSqlQuery(db)
373 call_path_query.prepare("INSERT INTO call_paths VALUES (?, ?, ?, ?)")
374if perf_db_export_calls:
375 call_query = QSqlQuery(db)
376 call_query.prepare("INSERT INTO calls VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
377
378def trace_begin():
379 print datetime.datetime.today(), "Writing records..."
380 do_query(query, 'BEGIN TRANSACTION')
381 # id == 0 means unknown. It is easier to create records for them than replace the zeroes with NULLs
382 evsel_table(0, "unknown")
383 machine_table(0, 0, "unknown")
384 thread_table(0, 0, 0, -1, -1)
385 comm_table(0, "unknown")
386 dso_table(0, 0, "unknown", "unknown", "")
387 symbol_table(0, 0, 0, 0, 0, "unknown")
388 sample_table(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
389 if perf_db_export_calls or perf_db_export_callchains:
390 call_path_table(0, 0, 0, 0)
391
392unhandled_count = 0
393
394def trace_end():
395 do_query(query, 'END TRANSACTION')
396
397 print datetime.datetime.today(), "Adding indexes"
398 if perf_db_export_calls:
399 do_query(query, 'CREATE INDEX pcpid_idx ON calls (parent_call_path_id)')
400
401 if (unhandled_count):
402 print datetime.datetime.today(), "Warning: ", unhandled_count, " unhandled events"
403 print datetime.datetime.today(), "Done"
404
405def trace_unhandled(event_name, context, event_fields_dict):
406 global unhandled_count
407 unhandled_count += 1
408
409def sched__sched_switch(*x):
410 pass
411
412def bind_exec(q, n, x):
413 for xx in x[0:n]:
414 q.addBindValue(str(xx))
415 do_query_(q)
416
417def evsel_table(*x):
418 bind_exec(evsel_query, 2, x)
419
420def machine_table(*x):
421 bind_exec(machine_query, 3, x)
422
423def thread_table(*x):
424 bind_exec(thread_query, 5, x)
425
426def comm_table(*x):
427 bind_exec(comm_query, 2, x)
428
429def comm_thread_table(*x):
430 bind_exec(comm_thread_query, 3, x)
431
432def dso_table(*x):
433 bind_exec(dso_query, 5, x)
434
435def symbol_table(*x):
436 bind_exec(symbol_query, 6, x)
437
438def branch_type_table(*x):
439 bind_exec(branch_type_query, 2, x)
440
441def sample_table(*x):
442 if branches:
443 bind_exec(sample_query, 18, x)
444 else:
445 bind_exec(sample_query, 22, x)
446
447def call_path_table(*x):
448 bind_exec(call_path_query, 4, x)
449
450def call_return_table(*x):
451 bind_exec(call_query, 11, x)
diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build
index 84222bdb8689..87bf3edb037c 100644
--- a/tools/perf/tests/Build
+++ b/tools/perf/tests/Build
@@ -34,6 +34,7 @@ perf-y += thread-map.o
34perf-y += llvm.o llvm-src-base.o llvm-src-kbuild.o llvm-src-prologue.o llvm-src-relocation.o 34perf-y += llvm.o llvm-src-base.o llvm-src-kbuild.o llvm-src-prologue.o llvm-src-relocation.o
35perf-y += bpf.o 35perf-y += bpf.o
36perf-y += topology.o 36perf-y += topology.o
37perf-y += mem.o
37perf-y += cpumap.o 38perf-y += cpumap.o
38perf-y += stat.o 39perf-y += stat.o
39perf-y += event_update.o 40perf-y += event_update.o
diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c
index 0e77b2cf61ec..c9aafed7da15 100644
--- a/tools/perf/tests/attr.c
+++ b/tools/perf/tests/attr.c
@@ -36,6 +36,7 @@
36#define ENV "PERF_TEST_ATTR" 36#define ENV "PERF_TEST_ATTR"
37 37
38static char *dir; 38static char *dir;
39static bool ready;
39 40
40void test_attr__init(void) 41void test_attr__init(void)
41{ 42{
@@ -67,6 +68,9 @@ static int store_event(struct perf_event_attr *attr, pid_t pid, int cpu,
67 FILE *file; 68 FILE *file;
68 char path[PATH_MAX]; 69 char path[PATH_MAX];
69 70
71 if (!ready)
72 return 0;
73
70 snprintf(path, PATH_MAX, "%s/event-%d-%llu-%d", dir, 74 snprintf(path, PATH_MAX, "%s/event-%d-%llu-%d", dir,
71 attr->type, attr->config, fd); 75 attr->type, attr->config, fd);
72 76
@@ -136,7 +140,7 @@ void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu,
136{ 140{
137 int errno_saved = errno; 141 int errno_saved = errno;
138 142
139 if (store_event(attr, pid, cpu, fd, group_fd, flags)) { 143 if ((fd != -1) && store_event(attr, pid, cpu, fd, group_fd, flags)) {
140 pr_err("test attr FAILED"); 144 pr_err("test attr FAILED");
141 exit(128); 145 exit(128);
142 } 146 }
@@ -144,6 +148,12 @@ void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu,
144 errno = errno_saved; 148 errno = errno_saved;
145} 149}
146 150
151void test_attr__ready(void)
152{
153 if (unlikely(test_attr__enabled) && !ready)
154 ready = true;
155}
156
147static int run_dir(const char *d, const char *perf) 157static int run_dir(const char *d, const char *perf)
148{ 158{
149 char v[] = "-vvvvv"; 159 char v[] = "-vvvvv";
@@ -159,7 +169,7 @@ static int run_dir(const char *d, const char *perf)
159 return system(cmd); 169 return system(cmd);
160} 170}
161 171
162int test__attr(int subtest __maybe_unused) 172int test__attr(struct test *test __maybe_unused, int subtest __maybe_unused)
163{ 173{
164 struct stat st; 174 struct stat st;
165 char path_perf[PATH_MAX]; 175 char path_perf[PATH_MAX];
diff --git a/tools/perf/tests/attr.py b/tools/perf/tests/attr.py
index cdf21a9d0c35..6bb50e82a3e3 100644
--- a/tools/perf/tests/attr.py
+++ b/tools/perf/tests/attr.py
@@ -9,6 +9,20 @@ import logging
9import shutil 9import shutil
10import ConfigParser 10import ConfigParser
11 11
12def data_equal(a, b):
13 # Allow multiple values in assignment separated by '|'
14 a_list = a.split('|')
15 b_list = b.split('|')
16
17 for a_item in a_list:
18 for b_item in b_list:
19 if (a_item == b_item):
20 return True
21 elif (a_item == '*') or (b_item == '*'):
22 return True
23
24 return False
25
12class Fail(Exception): 26class Fail(Exception):
13 def __init__(self, test, msg): 27 def __init__(self, test, msg):
14 self.msg = msg 28 self.msg = msg
@@ -82,34 +96,25 @@ class Event(dict):
82 self.add(base) 96 self.add(base)
83 self.add(data) 97 self.add(data)
84 98
85 def compare_data(self, a, b):
86 # Allow multiple values in assignment separated by '|'
87 a_list = a.split('|')
88 b_list = b.split('|')
89
90 for a_item in a_list:
91 for b_item in b_list:
92 if (a_item == b_item):
93 return True
94 elif (a_item == '*') or (b_item == '*'):
95 return True
96
97 return False
98
99 def equal(self, other): 99 def equal(self, other):
100 for t in Event.terms: 100 for t in Event.terms:
101 log.debug(" [%s] %s %s" % (t, self[t], other[t])); 101 log.debug(" [%s] %s %s" % (t, self[t], other[t]));
102 if not self.has_key(t) or not other.has_key(t): 102 if not self.has_key(t) or not other.has_key(t):
103 return False 103 return False
104 if not self.compare_data(self[t], other[t]): 104 if not data_equal(self[t], other[t]):
105 return False 105 return False
106 return True 106 return True
107 107
108 def optional(self):
109 if self.has_key('optional') and self['optional'] == '1':
110 return True
111 return False
112
108 def diff(self, other): 113 def diff(self, other):
109 for t in Event.terms: 114 for t in Event.terms:
110 if not self.has_key(t) or not other.has_key(t): 115 if not self.has_key(t) or not other.has_key(t):
111 continue 116 continue
112 if not self.compare_data(self[t], other[t]): 117 if not data_equal(self[t], other[t]):
113 log.warning("expected %s=%s, got %s" % (t, self[t], other[t])) 118 log.warning("expected %s=%s, got %s" % (t, self[t], other[t]))
114 119
115# Test file description needs to have following sections: 120# Test file description needs to have following sections:
@@ -218,9 +223,9 @@ class Test(object):
218 self.perf, self.command, tempdir, self.args) 223 self.perf, self.command, tempdir, self.args)
219 ret = os.WEXITSTATUS(os.system(cmd)) 224 ret = os.WEXITSTATUS(os.system(cmd))
220 225
221 log.info(" '%s' ret %d " % (cmd, ret)) 226 log.info(" '%s' ret '%s', expected '%s'" % (cmd, str(ret), str(self.ret)))
222 227
223 if ret != int(self.ret): 228 if not data_equal(str(ret), str(self.ret)):
224 raise Unsup(self) 229 raise Unsup(self)
225 230
226 def compare(self, expect, result): 231 def compare(self, expect, result):
@@ -244,9 +249,12 @@ class Test(object):
244 log.debug(" match: [%s] matches %s" % (exp_name, str(exp_list))) 249 log.debug(" match: [%s] matches %s" % (exp_name, str(exp_list)))
245 250
246 # we did not any matching event - fail 251 # we did not any matching event - fail
247 if (not exp_list): 252 if not exp_list:
248 exp_event.diff(res_event) 253 if exp_event.optional():
249 raise Fail(self, 'match failure'); 254 log.debug(" %s does not match, but is optional" % exp_name)
255 else:
256 exp_event.diff(res_event)
257 raise Fail(self, 'match failure');
250 258
251 match[exp_name] = exp_list 259 match[exp_name] = exp_list
252 260
diff --git a/tools/perf/tests/attr/base-record b/tools/perf/tests/attr/base-record
index 7e6d74946e04..31e0b1da830b 100644
--- a/tools/perf/tests/attr/base-record
+++ b/tools/perf/tests/attr/base-record
@@ -7,7 +7,7 @@ cpu=*
7type=0|1 7type=0|1
8size=112 8size=112
9config=0 9config=0
10sample_period=4000 10sample_period=*
11sample_type=263 11sample_type=263
12read_format=0 12read_format=0
13disabled=1 13disabled=1
@@ -15,7 +15,7 @@ inherit=1
15pinned=0 15pinned=0
16exclusive=0 16exclusive=0
17exclude_user=0 17exclude_user=0
18exclude_kernel=0 18exclude_kernel=0|1
19exclude_hv=0 19exclude_hv=0
20exclude_idle=0 20exclude_idle=0
21mmap=1 21mmap=1
@@ -25,7 +25,7 @@ inherit_stat=0
25enable_on_exec=1 25enable_on_exec=1
26task=0 26task=0
27watermark=0 27watermark=0
28precise_ip=0 28precise_ip=0|1|2|3
29mmap_data=0 29mmap_data=0
30sample_id_all=1 30sample_id_all=1
31exclude_host=0|1 31exclude_host=0|1
diff --git a/tools/perf/tests/attr/base-stat b/tools/perf/tests/attr/base-stat
index f4cf148f14cb..4d0c2e42b64e 100644
--- a/tools/perf/tests/attr/base-stat
+++ b/tools/perf/tests/attr/base-stat
@@ -8,14 +8,14 @@ type=0
8size=112 8size=112
9config=0 9config=0
10sample_period=0 10sample_period=0
11sample_type=0 11sample_type=65536
12read_format=3 12read_format=3
13disabled=1 13disabled=1
14inherit=1 14inherit=1
15pinned=0 15pinned=0
16exclusive=0 16exclusive=0
17exclude_user=0 17exclude_user=0
18exclude_kernel=0 18exclude_kernel=0|1
19exclude_hv=0 19exclude_hv=0
20exclude_idle=0 20exclude_idle=0
21mmap=0 21mmap=0
diff --git a/tools/perf/tests/attr/test-record-C0 b/tools/perf/tests/attr/test-record-C0
index d6a7e43f61b3..cb0a3138fa54 100644
--- a/tools/perf/tests/attr/test-record-C0
+++ b/tools/perf/tests/attr/test-record-C0
@@ -1,6 +1,7 @@
1[config] 1[config]
2command = record 2command = record
3args = -C 0 kill >/dev/null 2>&1 3args = -C 0 kill >/dev/null 2>&1
4ret = 1
4 5
5[event:base-record] 6[event:base-record]
6cpu=0 7cpu=0
diff --git a/tools/perf/tests/attr/test-record-basic b/tools/perf/tests/attr/test-record-basic
index 55c0428370ca..85a23cf35ba1 100644
--- a/tools/perf/tests/attr/test-record-basic
+++ b/tools/perf/tests/attr/test-record-basic
@@ -1,5 +1,6 @@
1[config] 1[config]
2command = record 2command = record
3args = kill >/dev/null 2>&1 3args = kill >/dev/null 2>&1
4ret = 1
4 5
5[event:base-record] 6[event:base-record]
diff --git a/tools/perf/tests/attr/test-record-branch-any b/tools/perf/tests/attr/test-record-branch-any
index 1421960ed4e9..81f839e2fad0 100644
--- a/tools/perf/tests/attr/test-record-branch-any
+++ b/tools/perf/tests/attr/test-record-branch-any
@@ -1,8 +1,8 @@
1[config] 1[config]
2command = record 2command = record
3args = -b kill >/dev/null 2>&1 3args = -b kill >/dev/null 2>&1
4ret = 1
4 5
5[event:base-record] 6[event:base-record]
6sample_period=4000
7sample_type=2311 7sample_type=2311
8branch_sample_type=8 8branch_sample_type=8
diff --git a/tools/perf/tests/attr/test-record-branch-filter-any b/tools/perf/tests/attr/test-record-branch-filter-any
index 915c4df0e0c2..357421f4dfce 100644
--- a/tools/perf/tests/attr/test-record-branch-filter-any
+++ b/tools/perf/tests/attr/test-record-branch-filter-any
@@ -1,8 +1,8 @@
1[config] 1[config]
2command = record 2command = record
3args = -j any kill >/dev/null 2>&1 3args = -j any kill >/dev/null 2>&1
4ret = 1
4 5
5[event:base-record] 6[event:base-record]
6sample_period=4000
7sample_type=2311 7sample_type=2311
8branch_sample_type=8 8branch_sample_type=8
diff --git a/tools/perf/tests/attr/test-record-branch-filter-any_call b/tools/perf/tests/attr/test-record-branch-filter-any_call
index 8708dbd4f373..dbc55f2ab845 100644
--- a/tools/perf/tests/attr/test-record-branch-filter-any_call
+++ b/tools/perf/tests/attr/test-record-branch-filter-any_call
@@ -1,8 +1,8 @@
1[config] 1[config]
2command = record 2command = record
3args = -j any_call kill >/dev/null 2>&1 3args = -j any_call kill >/dev/null 2>&1
4ret = 1
4 5
5[event:base-record] 6[event:base-record]
6sample_period=4000
7sample_type=2311 7sample_type=2311
8branch_sample_type=16 8branch_sample_type=16
diff --git a/tools/perf/tests/attr/test-record-branch-filter-any_ret b/tools/perf/tests/attr/test-record-branch-filter-any_ret
index 0d3607a6dcbe..a0824ff8e131 100644
--- a/tools/perf/tests/attr/test-record-branch-filter-any_ret
+++ b/tools/perf/tests/attr/test-record-branch-filter-any_ret
@@ -1,8 +1,8 @@
1[config] 1[config]
2command = record 2command = record
3args = -j any_ret kill >/dev/null 2>&1 3args = -j any_ret kill >/dev/null 2>&1
4ret = 1
4 5
5[event:base-record] 6[event:base-record]
6sample_period=4000
7sample_type=2311 7sample_type=2311
8branch_sample_type=32 8branch_sample_type=32
diff --git a/tools/perf/tests/attr/test-record-branch-filter-hv b/tools/perf/tests/attr/test-record-branch-filter-hv
index f25526740cec..f34d6f120181 100644
--- a/tools/perf/tests/attr/test-record-branch-filter-hv
+++ b/tools/perf/tests/attr/test-record-branch-filter-hv
@@ -1,8 +1,8 @@
1[config] 1[config]
2command = record 2command = record
3args = -j hv kill >/dev/null 2>&1 3args = -j hv kill >/dev/null 2>&1
4ret = 1
4 5
5[event:base-record] 6[event:base-record]
6sample_period=4000
7sample_type=2311 7sample_type=2311
8branch_sample_type=8 8branch_sample_type=8
diff --git a/tools/perf/tests/attr/test-record-branch-filter-ind_call b/tools/perf/tests/attr/test-record-branch-filter-ind_call
index e862dd179128..b86a35232248 100644
--- a/tools/perf/tests/attr/test-record-branch-filter-ind_call
+++ b/tools/perf/tests/attr/test-record-branch-filter-ind_call
@@ -1,8 +1,8 @@
1[config] 1[config]
2command = record 2command = record
3args = -j ind_call kill >/dev/null 2>&1 3args = -j ind_call kill >/dev/null 2>&1
4ret = 1
4 5
5[event:base-record] 6[event:base-record]
6sample_period=4000
7sample_type=2311 7sample_type=2311
8branch_sample_type=64 8branch_sample_type=64
diff --git a/tools/perf/tests/attr/test-record-branch-filter-k b/tools/perf/tests/attr/test-record-branch-filter-k
index 182971e898f5..d3fbc5e1858a 100644
--- a/tools/perf/tests/attr/test-record-branch-filter-k
+++ b/tools/perf/tests/attr/test-record-branch-filter-k
@@ -1,8 +1,8 @@
1[config] 1[config]
2command = record 2command = record
3args = -j k kill >/dev/null 2>&1 3args = -j k kill >/dev/null 2>&1
4ret = 1
4 5
5[event:base-record] 6[event:base-record]
6sample_period=4000
7sample_type=2311 7sample_type=2311
8branch_sample_type=8 8branch_sample_type=8
diff --git a/tools/perf/tests/attr/test-record-branch-filter-u b/tools/perf/tests/attr/test-record-branch-filter-u
index 83449ef9e687..a318f0dda173 100644
--- a/tools/perf/tests/attr/test-record-branch-filter-u
+++ b/tools/perf/tests/attr/test-record-branch-filter-u
@@ -1,8 +1,8 @@
1[config] 1[config]
2command = record 2command = record
3args = -j u kill >/dev/null 2>&1 3args = -j u kill >/dev/null 2>&1
4ret = 1
4 5
5[event:base-record] 6[event:base-record]
6sample_period=4000
7sample_type=2311 7sample_type=2311
8branch_sample_type=8 8branch_sample_type=8
diff --git a/tools/perf/tests/attr/test-record-count b/tools/perf/tests/attr/test-record-count
index 2f841de56f6b..34f6cc577263 100644
--- a/tools/perf/tests/attr/test-record-count
+++ b/tools/perf/tests/attr/test-record-count
@@ -1,6 +1,7 @@
1[config] 1[config]
2command = record 2command = record
3args = -c 123 kill >/dev/null 2>&1 3args = -c 123 kill >/dev/null 2>&1
4ret = 1
4 5
5[event:base-record] 6[event:base-record]
6sample_period=123 7sample_period=123
diff --git a/tools/perf/tests/attr/test-record-data b/tools/perf/tests/attr/test-record-data
index 716e143b5291..a9cf2233b0ce 100644
--- a/tools/perf/tests/attr/test-record-data
+++ b/tools/perf/tests/attr/test-record-data
@@ -1,10 +1,9 @@
1[config] 1[config]
2command = record 2command = record
3args = -d kill >/dev/null 2>&1 3args = -d kill >/dev/null 2>&1
4ret = 1
4 5
5[event:base-record] 6[event:base-record]
6sample_period=4000
7
8# sample_type = PERF_SAMPLE_IP | PERF_SAMPLE_TID | PERF_SAMPLE_TIME | 7# sample_type = PERF_SAMPLE_IP | PERF_SAMPLE_TID | PERF_SAMPLE_TIME |
9# PERF_SAMPLE_ADDR | PERF_SAMPLE_PERIOD | PERF_SAMPLE_DATA_SRC 8# PERF_SAMPLE_ADDR | PERF_SAMPLE_PERIOD | PERF_SAMPLE_DATA_SRC
10sample_type=33039 9sample_type=33039
diff --git a/tools/perf/tests/attr/test-record-freq b/tools/perf/tests/attr/test-record-freq
index 600d0f8f2583..bf4cb459f0d5 100644
--- a/tools/perf/tests/attr/test-record-freq
+++ b/tools/perf/tests/attr/test-record-freq
@@ -1,6 +1,7 @@
1[config] 1[config]
2command = record 2command = record
3args = -F 100 kill >/dev/null 2>&1 3args = -F 100 kill >/dev/null 2>&1
4ret = 1
4 5
5[event:base-record] 6[event:base-record]
6sample_period=100 7sample_period=100
diff --git a/tools/perf/tests/attr/test-record-graph-default b/tools/perf/tests/attr/test-record-graph-default
index 853597a9a8f6..0b216e69760c 100644
--- a/tools/perf/tests/attr/test-record-graph-default
+++ b/tools/perf/tests/attr/test-record-graph-default
@@ -1,6 +1,7 @@
1[config] 1[config]
2command = record 2command = record
3args = -g kill >/dev/null 2>&1 3args = -g kill >/dev/null 2>&1
4ret = 1
4 5
5[event:base-record] 6[event:base-record]
6sample_type=295 7sample_type=295
diff --git a/tools/perf/tests/attr/test-record-graph-dwarf b/tools/perf/tests/attr/test-record-graph-dwarf
index d6f324ea578c..da2fa73bd0a2 100644
--- a/tools/perf/tests/attr/test-record-graph-dwarf
+++ b/tools/perf/tests/attr/test-record-graph-dwarf
@@ -1,10 +1,12 @@
1[config] 1[config]
2command = record 2command = record
3args = --call-graph dwarf -- kill >/dev/null 2>&1 3args = --call-graph dwarf -- kill >/dev/null 2>&1
4ret = 1
4 5
5[event:base-record] 6[event:base-record]
6sample_type=12583 7sample_type=45359
7exclude_callchain_user=1 8exclude_callchain_user=1
8sample_stack_user=8192 9sample_stack_user=8192
9# TODO different for each arch, no support for that now 10# TODO different for each arch, no support for that now
10sample_regs_user=* 11sample_regs_user=*
12mmap_data=1
diff --git a/tools/perf/tests/attr/test-record-graph-fp b/tools/perf/tests/attr/test-record-graph-fp
index 055e3bee7993..625d190bb798 100644
--- a/tools/perf/tests/attr/test-record-graph-fp
+++ b/tools/perf/tests/attr/test-record-graph-fp
@@ -1,6 +1,7 @@
1[config] 1[config]
2command = record 2command = record
3args = --call-graph fp kill >/dev/null 2>&1 3args = --call-graph fp kill >/dev/null 2>&1
4ret = 1
4 5
5[event:base-record] 6[event:base-record]
6sample_type=295 7sample_type=295
diff --git a/tools/perf/tests/attr/test-record-group b/tools/perf/tests/attr/test-record-group
index 57739cacdb2a..6e7961f6f7a5 100644
--- a/tools/perf/tests/attr/test-record-group
+++ b/tools/perf/tests/attr/test-record-group
@@ -1,6 +1,7 @@
1[config] 1[config]
2command = record 2command = record
3args = --group -e cycles,instructions kill >/dev/null 2>&1 3args = --group -e cycles,instructions kill >/dev/null 2>&1
4ret = 1
4 5
5[event-1:base-record] 6[event-1:base-record]
6fd=1 7fd=1
diff --git a/tools/perf/tests/attr/test-record-group-sampling b/tools/perf/tests/attr/test-record-group-sampling
index 658f5d60c873..ef59afd6d635 100644
--- a/tools/perf/tests/attr/test-record-group-sampling
+++ b/tools/perf/tests/attr/test-record-group-sampling
@@ -1,6 +1,7 @@
1[config] 1[config]
2command = record 2command = record
3args = -e '{cycles,cache-misses}:S' kill >/dev/null 2>&1 3args = -e '{cycles,cache-misses}:S' kill >/dev/null 2>&1
4ret = 1
4 5
5[event-1:base-record] 6[event-1:base-record]
6fd=1 7fd=1
diff --git a/tools/perf/tests/attr/test-record-group1 b/tools/perf/tests/attr/test-record-group1
index c5548d054aff..87a222d014d8 100644
--- a/tools/perf/tests/attr/test-record-group1
+++ b/tools/perf/tests/attr/test-record-group1
@@ -1,6 +1,7 @@
1[config] 1[config]
2command = record 2command = record
3args = -e '{cycles,instructions}' kill >/dev/null 2>&1 3args = -e '{cycles,instructions}' kill >/dev/null 2>&1
4ret = 1
4 5
5[event-1:base-record] 6[event-1:base-record]
6fd=1 7fd=1
diff --git a/tools/perf/tests/attr/test-record-no-delay b/tools/perf/tests/attr/test-record-no-buffering
index f253b78cdbf2..aa3956d8fe20 100644
--- a/tools/perf/tests/attr/test-record-no-delay
+++ b/tools/perf/tests/attr/test-record-no-buffering
@@ -1,9 +1,9 @@
1[config] 1[config]
2command = record 2command = record
3args = -D kill >/dev/null 2>&1 3args = --no-buffering kill >/dev/null 2>&1
4ret = 1
4 5
5[event:base-record] 6[event:base-record]
6sample_period=4000
7sample_type=263 7sample_type=263
8watermark=0 8watermark=0
9wakeup_events=1 9wakeup_events=1
diff --git a/tools/perf/tests/attr/test-record-no-inherit b/tools/perf/tests/attr/test-record-no-inherit
index 44edcb2edcd5..560943decb87 100644
--- a/tools/perf/tests/attr/test-record-no-inherit
+++ b/tools/perf/tests/attr/test-record-no-inherit
@@ -1,6 +1,7 @@
1[config] 1[config]
2command = record 2command = record
3args = -i kill >/dev/null 2>&1 3args = -i kill >/dev/null 2>&1
4ret = 1
4 5
5[event:base-record] 6[event:base-record]
6sample_type=263 7sample_type=263
diff --git a/tools/perf/tests/attr/test-record-no-samples b/tools/perf/tests/attr/test-record-no-samples
index d0141b2418b5..8eb73ab639e0 100644
--- a/tools/perf/tests/attr/test-record-no-samples
+++ b/tools/perf/tests/attr/test-record-no-samples
@@ -1,6 +1,7 @@
1[config] 1[config]
2command = record 2command = record
3args = -n kill >/dev/null 2>&1 3args = -n kill >/dev/null 2>&1
4ret = 1
4 5
5[event:base-record] 6[event:base-record]
6sample_period=0 7sample_period=0
diff --git a/tools/perf/tests/attr/test-record-period b/tools/perf/tests/attr/test-record-period
index 8abc5314fc52..69bc748f0f27 100644
--- a/tools/perf/tests/attr/test-record-period
+++ b/tools/perf/tests/attr/test-record-period
@@ -1,6 +1,7 @@
1[config] 1[config]
2command = record 2command = record
3args = -c 100 -P kill >/dev/null 2>&1 3args = -c 100 -P kill >/dev/null 2>&1
4ret = 1
4 5
5[event:base-record] 6[event:base-record]
6sample_period=100 7sample_period=100
diff --git a/tools/perf/tests/attr/test-record-raw b/tools/perf/tests/attr/test-record-raw
index 4a8ef25b5f49..a188a614a44c 100644
--- a/tools/perf/tests/attr/test-record-raw
+++ b/tools/perf/tests/attr/test-record-raw
@@ -1,7 +1,7 @@
1[config] 1[config]
2command = record 2command = record
3args = -R kill >/dev/null 2>&1 3args = -R kill >/dev/null 2>&1
4ret = 1
4 5
5[event:base-record] 6[event:base-record]
6sample_period=4000
7sample_type=1415 7sample_type=1415
diff --git a/tools/perf/tests/attr/test-stat-C0 b/tools/perf/tests/attr/test-stat-C0
index aa835950751f..67717fe6a65d 100644
--- a/tools/perf/tests/attr/test-stat-C0
+++ b/tools/perf/tests/attr/test-stat-C0
@@ -4,6 +4,6 @@ args = -e cycles -C 0 kill >/dev/null 2>&1
4ret = 1 4ret = 1
5 5
6[event:base-stat] 6[event:base-stat]
7# events are enabled by default when attached to cpu 7# events are disabled by default when attached to cpu
8disabled=0 8disabled=1
9enable_on_exec=0 9enable_on_exec=0
diff --git a/tools/perf/tests/attr/test-stat-default b/tools/perf/tests/attr/test-stat-default
index 19270f54c96e..e911dbd4eb47 100644
--- a/tools/perf/tests/attr/test-stat-default
+++ b/tools/perf/tests/attr/test-stat-default
@@ -38,12 +38,14 @@ config=0
38fd=6 38fd=6
39type=0 39type=0
40config=7 40config=7
41optional=1
41 42
42# PERF_TYPE_HARDWARE / PERF_COUNT_HW_STALLED_CYCLES_BACKEND 43# PERF_TYPE_HARDWARE / PERF_COUNT_HW_STALLED_CYCLES_BACKEND
43[event7:base-stat] 44[event7:base-stat]
44fd=7 45fd=7
45type=0 46type=0
46config=8 47config=8
48optional=1
47 49
48# PERF_TYPE_HARDWARE / PERF_COUNT_HW_INSTRUCTIONS 50# PERF_TYPE_HARDWARE / PERF_COUNT_HW_INSTRUCTIONS
49[event8:base-stat] 51[event8:base-stat]
diff --git a/tools/perf/tests/attr/test-stat-detailed-1 b/tools/perf/tests/attr/test-stat-detailed-1
index 51426b87153b..b39270a08e74 100644
--- a/tools/perf/tests/attr/test-stat-detailed-1
+++ b/tools/perf/tests/attr/test-stat-detailed-1
@@ -39,12 +39,14 @@ config=0
39fd=6 39fd=6
40type=0 40type=0
41config=7 41config=7
42optional=1
42 43
43# PERF_TYPE_HARDWARE / PERF_COUNT_HW_STALLED_CYCLES_BACKEND 44# PERF_TYPE_HARDWARE / PERF_COUNT_HW_STALLED_CYCLES_BACKEND
44[event7:base-stat] 45[event7:base-stat]
45fd=7 46fd=7
46type=0 47type=0
47config=8 48config=8
49optional=1
48 50
49# PERF_TYPE_HARDWARE / PERF_COUNT_HW_INSTRUCTIONS 51# PERF_TYPE_HARDWARE / PERF_COUNT_HW_INSTRUCTIONS
50[event8:base-stat] 52[event8:base-stat]
diff --git a/tools/perf/tests/attr/test-stat-detailed-2 b/tools/perf/tests/attr/test-stat-detailed-2
index 8de5acc31c27..45f8e6ea34f8 100644
--- a/tools/perf/tests/attr/test-stat-detailed-2
+++ b/tools/perf/tests/attr/test-stat-detailed-2
@@ -39,12 +39,14 @@ config=0
39fd=6 39fd=6
40type=0 40type=0
41config=7 41config=7
42optional=1
42 43
43# PERF_TYPE_HARDWARE / PERF_COUNT_HW_STALLED_CYCLES_BACKEND 44# PERF_TYPE_HARDWARE / PERF_COUNT_HW_STALLED_CYCLES_BACKEND
44[event7:base-stat] 45[event7:base-stat]
45fd=7 46fd=7
46type=0 47type=0
47config=8 48config=8
49optional=1
48 50
49# PERF_TYPE_HARDWARE / PERF_COUNT_HW_INSTRUCTIONS 51# PERF_TYPE_HARDWARE / PERF_COUNT_HW_INSTRUCTIONS
50[event8:base-stat] 52[event8:base-stat]
@@ -108,6 +110,7 @@ config=65538
108fd=15 110fd=15
109type=3 111type=3
110config=1 112config=1
113optional=1
111 114
112# PERF_TYPE_HW_CACHE, 115# PERF_TYPE_HW_CACHE,
113# PERF_COUNT_HW_CACHE_L1I << 0 | 116# PERF_COUNT_HW_CACHE_L1I << 0 |
diff --git a/tools/perf/tests/attr/test-stat-detailed-3 b/tools/perf/tests/attr/test-stat-detailed-3
index 0a1f45bf7d79..30ae0fb7a3fd 100644
--- a/tools/perf/tests/attr/test-stat-detailed-3
+++ b/tools/perf/tests/attr/test-stat-detailed-3
@@ -39,12 +39,14 @@ config=0
39fd=6 39fd=6
40type=0 40type=0
41config=7 41config=7
42optional=1
42 43
43# PERF_TYPE_HARDWARE / PERF_COUNT_HW_STALLED_CYCLES_BACKEND 44# PERF_TYPE_HARDWARE / PERF_COUNT_HW_STALLED_CYCLES_BACKEND
44[event7:base-stat] 45[event7:base-stat]
45fd=7 46fd=7
46type=0 47type=0
47config=8 48config=8
49optional=1
48 50
49# PERF_TYPE_HARDWARE / PERF_COUNT_HW_INSTRUCTIONS 51# PERF_TYPE_HARDWARE / PERF_COUNT_HW_INSTRUCTIONS
50[event8:base-stat] 52[event8:base-stat]
@@ -108,6 +110,7 @@ config=65538
108fd=15 110fd=15
109type=3 111type=3
110config=1 112config=1
113optional=1
111 114
112# PERF_TYPE_HW_CACHE, 115# PERF_TYPE_HW_CACHE,
113# PERF_COUNT_HW_CACHE_L1I << 0 | 116# PERF_COUNT_HW_CACHE_L1I << 0 |
@@ -162,6 +165,7 @@ config=65540
162fd=21 165fd=21
163type=3 166type=3
164config=512 167config=512
168optional=1
165 169
166# PERF_TYPE_HW_CACHE, 170# PERF_TYPE_HW_CACHE,
167# PERF_COUNT_HW_CACHE_L1D << 0 | 171# PERF_COUNT_HW_CACHE_L1D << 0 |
@@ -171,3 +175,4 @@ config=512
171fd=22 175fd=22
172type=3 176type=3
173config=66048 177config=66048
178optional=1
diff --git a/tools/perf/tests/backward-ring-buffer.c b/tools/perf/tests/backward-ring-buffer.c
index 50f6d7afee58..d233ad336463 100644
--- a/tools/perf/tests/backward-ring-buffer.c
+++ b/tools/perf/tests/backward-ring-buffer.c
@@ -75,7 +75,7 @@ static int do_test(struct perf_evlist *evlist, int mmap_pages,
75} 75}
76 76
77 77
78int test__backward_ring_buffer(int subtest __maybe_unused) 78int test__backward_ring_buffer(struct test *test __maybe_unused, int subtest __maybe_unused)
79{ 79{
80 int ret = TEST_SKIP, err, sample_count = 0, comm_count = 0; 80 int ret = TEST_SKIP, err, sample_count = 0, comm_count = 0;
81 char pid[16], sbuf[STRERR_BUFSIZE]; 81 char pid[16], sbuf[STRERR_BUFSIZE];
diff --git a/tools/perf/tests/bitmap.c b/tools/perf/tests/bitmap.c
index 9abe6c13090f..0d7c06584905 100644
--- a/tools/perf/tests/bitmap.c
+++ b/tools/perf/tests/bitmap.c
@@ -40,7 +40,7 @@ static int test_bitmap(const char *str)
40 return ret; 40 return ret;
41} 41}
42 42
43int test__bitmap_print(int subtest __maybe_unused) 43int test__bitmap_print(struct test *test __maybe_unused, int subtest __maybe_unused)
44{ 44{
45 TEST_ASSERT_VAL("failed to convert map", test_bitmap("1")); 45 TEST_ASSERT_VAL("failed to convert map", test_bitmap("1"));
46 TEST_ASSERT_VAL("failed to convert map", test_bitmap("1,5")); 46 TEST_ASSERT_VAL("failed to convert map", test_bitmap("1,5"));
diff --git a/tools/perf/tests/bp_signal.c b/tools/perf/tests/bp_signal.c
index 39bbb97cd30a..97937e1bc53a 100644
--- a/tools/perf/tests/bp_signal.c
+++ b/tools/perf/tests/bp_signal.c
@@ -164,7 +164,7 @@ static long long bp_count(int fd)
164 return count; 164 return count;
165} 165}
166 166
167int test__bp_signal(int subtest __maybe_unused) 167int test__bp_signal(struct test *test __maybe_unused, int subtest __maybe_unused)
168{ 168{
169 struct sigaction sa; 169 struct sigaction sa;
170 long long count1, count2, count3; 170 long long count1, count2, count3;
diff --git a/tools/perf/tests/bp_signal_overflow.c b/tools/perf/tests/bp_signal_overflow.c
index 3b1ac6f31b15..61ecd8021f49 100644
--- a/tools/perf/tests/bp_signal_overflow.c
+++ b/tools/perf/tests/bp_signal_overflow.c
@@ -57,7 +57,7 @@ static long long bp_count(int fd)
57#define EXECUTIONS 10000 57#define EXECUTIONS 10000
58#define THRESHOLD 100 58#define THRESHOLD 100
59 59
60int test__bp_signal_overflow(int subtest __maybe_unused) 60int test__bp_signal_overflow(struct test *test __maybe_unused, int subtest __maybe_unused)
61{ 61{
62 struct perf_event_attr pe; 62 struct perf_event_attr pe;
63 struct sigaction sa; 63 struct sigaction sa;
diff --git a/tools/perf/tests/bpf-script-test-prologue.c b/tools/perf/tests/bpf-script-test-prologue.c
index b4ebc75e25ae..43f1e16486f4 100644
--- a/tools/perf/tests/bpf-script-test-prologue.c
+++ b/tools/perf/tests/bpf-script-test-prologue.c
@@ -26,9 +26,11 @@ static void (*bpf_trace_printk)(const char *fmt, int fmt_size, ...) =
26 (void *) 6; 26 (void *) 6;
27 27
28SEC("func=null_lseek file->f_mode offset orig") 28SEC("func=null_lseek file->f_mode offset orig")
29int bpf_func__null_lseek(void *ctx, int err, unsigned long f_mode, 29int bpf_func__null_lseek(void *ctx, int err, unsigned long _f_mode,
30 unsigned long offset, unsigned long orig) 30 unsigned long offset, unsigned long orig)
31{ 31{
32 fmode_t f_mode = (fmode_t)_f_mode;
33
32 if (err) 34 if (err)
33 return 0; 35 return 0;
34 if (f_mode & FMODE_WRITE) 36 if (f_mode & FMODE_WRITE)
diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c
index 5876da126b58..34c22cdf4d5d 100644
--- a/tools/perf/tests/bpf.c
+++ b/tools/perf/tests/bpf.c
@@ -124,16 +124,16 @@ static int do_test(struct bpf_object *obj, int (*func)(void),
124 struct perf_evlist *evlist; 124 struct perf_evlist *evlist;
125 int i, ret = TEST_FAIL, err = 0, count = 0; 125 int i, ret = TEST_FAIL, err = 0, count = 0;
126 126
127 struct parse_events_evlist parse_evlist; 127 struct parse_events_state parse_state;
128 struct parse_events_error parse_error; 128 struct parse_events_error parse_error;
129 129
130 bzero(&parse_error, sizeof(parse_error)); 130 bzero(&parse_error, sizeof(parse_error));
131 bzero(&parse_evlist, sizeof(parse_evlist)); 131 bzero(&parse_state, sizeof(parse_state));
132 parse_evlist.error = &parse_error; 132 parse_state.error = &parse_error;
133 INIT_LIST_HEAD(&parse_evlist.list); 133 INIT_LIST_HEAD(&parse_state.list);
134 134
135 err = parse_events_load_bpf_obj(&parse_evlist, &parse_evlist.list, obj, NULL); 135 err = parse_events_load_bpf_obj(&parse_state, &parse_state.list, obj, NULL);
136 if (err || list_empty(&parse_evlist.list)) { 136 if (err || list_empty(&parse_state.list)) {
137 pr_debug("Failed to add events selected by BPF\n"); 137 pr_debug("Failed to add events selected by BPF\n");
138 return TEST_FAIL; 138 return TEST_FAIL;
139 } 139 }
@@ -155,8 +155,8 @@ static int do_test(struct bpf_object *obj, int (*func)(void),
155 goto out_delete_evlist; 155 goto out_delete_evlist;
156 } 156 }
157 157
158 perf_evlist__splice_list_tail(evlist, &parse_evlist.list); 158 perf_evlist__splice_list_tail(evlist, &parse_state.list);
159 evlist->nr_groups = parse_evlist.nr_groups; 159 evlist->nr_groups = parse_state.nr_groups;
160 160
161 perf_evlist__config(evlist, &opts, NULL); 161 perf_evlist__config(evlist, &opts, NULL);
162 162
@@ -321,7 +321,7 @@ static int check_env(void)
321 return 0; 321 return 0;
322} 322}
323 323
324int test__bpf(int i) 324int test__bpf(struct test *test __maybe_unused, int i)
325{ 325{
326 int err; 326 int err;
327 327
@@ -351,7 +351,7 @@ const char *test__bpf_subtest_get_desc(int i __maybe_unused)
351 return NULL; 351 return NULL;
352} 352}
353 353
354int test__bpf(int i __maybe_unused) 354int test__bpf(struct test *test __maybe_unused, int i __maybe_unused)
355{ 355{
356 pr_debug("Skip BPF test because BPF support is not compiled\n"); 356 pr_debug("Skip BPF test because BPF support is not compiled\n");
357 return TEST_SKIP; 357 return TEST_SKIP;
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 3ccfd58a8c3c..377bea009163 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -6,7 +6,10 @@
6#include <errno.h> 6#include <errno.h>
7#include <unistd.h> 7#include <unistd.h>
8#include <string.h> 8#include <string.h>
9#include <sys/types.h>
10#include <dirent.h>
9#include <sys/wait.h> 11#include <sys/wait.h>
12#include <sys/stat.h>
10#include "builtin.h" 13#include "builtin.h"
11#include "hist.h" 14#include "hist.h"
12#include "intlist.h" 15#include "intlist.h"
@@ -14,8 +17,10 @@
14#include "debug.h" 17#include "debug.h"
15#include "color.h" 18#include "color.h"
16#include <subcmd/parse-options.h> 19#include <subcmd/parse-options.h>
20#include "string2.h"
17#include "symbol.h" 21#include "symbol.h"
18#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <subcmd/exec-cmd.h>
19 24
20static bool dont_fork; 25static bool dont_fork;
21 26
@@ -43,6 +48,10 @@ static struct test generic_tests[] = {
43 .func = test__basic_mmap, 48 .func = test__basic_mmap,
44 }, 49 },
45 { 50 {
51 .desc = "Test data source output",
52 .func = test__mem,
53 },
54 {
46 .desc = "Parse event definition strings", 55 .desc = "Parse event definition strings",
47 .func = test__parse_events, 56 .func = test__parse_events,
48 }, 57 },
@@ -179,7 +188,7 @@ static struct test generic_tests[] = {
179 }, 188 },
180 { 189 {
181 .desc = "Session topology", 190 .desc = "Session topology",
182 .func = test_session_topology, 191 .func = test__session_topology,
183 }, 192 },
184 { 193 {
185 .desc = "BPF filter", 194 .desc = "BPF filter",
@@ -325,7 +334,7 @@ static int run_test(struct test *test, int subtest)
325 } 334 }
326 } 335 }
327 336
328 err = test->func(subtest); 337 err = test->func(test, subtest);
329 if (!dont_fork) 338 if (!dont_fork)
330 exit(err); 339 exit(err);
331 } 340 }
@@ -383,12 +392,143 @@ static int test_and_print(struct test *t, bool force_skip, int subtest)
383 return err; 392 return err;
384} 393}
385 394
395static const char *shell_test__description(char *description, size_t size,
396 const char *path, const char *name)
397{
398 FILE *fp;
399 char filename[PATH_MAX];
400
401 path__join(filename, sizeof(filename), path, name);
402 fp = fopen(filename, "r");
403 if (!fp)
404 return NULL;
405
406 description = fgets(description, size, fp);
407 fclose(fp);
408
409 return description ? trim(description + 1) : NULL;
410}
411
412#define for_each_shell_test(dir, ent) \
413 while ((ent = readdir(dir)) != NULL) \
414 if (ent->d_type == DT_REG && ent->d_name[0] != '.')
415
416static const char *shell_tests__dir(char *path, size_t size)
417{
418 const char *devel_dirs[] = { "./tools/perf/tests", "./tests", };
419 char *exec_path;
420 unsigned int i;
421
422 for (i = 0; i < ARRAY_SIZE(devel_dirs); ++i) {
423 struct stat st;
424 if (!lstat(devel_dirs[i], &st)) {
425 scnprintf(path, size, "%s/shell", devel_dirs[i]);
426 if (!lstat(devel_dirs[i], &st))
427 return path;
428 }
429 }
430
431 /* Then installed path. */
432 exec_path = get_argv_exec_path();
433 scnprintf(path, size, "%s/tests/shell", exec_path);
434 free(exec_path);
435 return path;
436}
437
438static int shell_tests__max_desc_width(void)
439{
440 DIR *dir;
441 struct dirent *ent;
442 char path_dir[PATH_MAX];
443 const char *path = shell_tests__dir(path_dir, sizeof(path_dir));
444 int width = 0;
445
446 if (path == NULL)
447 return -1;
448
449 dir = opendir(path);
450 if (!dir)
451 return -1;
452
453 for_each_shell_test(dir, ent) {
454 char bf[256];
455 const char *desc = shell_test__description(bf, sizeof(bf), path, ent->d_name);
456
457 if (desc) {
458 int len = strlen(desc);
459
460 if (width < len)
461 width = len;
462 }
463 }
464
465 closedir(dir);
466 return width;
467}
468
469struct shell_test {
470 const char *dir;
471 const char *file;
472};
473
474static int shell_test__run(struct test *test, int subdir __maybe_unused)
475{
476 int err;
477 char script[PATH_MAX];
478 struct shell_test *st = test->priv;
479
480 path__join(script, sizeof(script), st->dir, st->file);
481
482 err = system(script);
483 if (!err)
484 return TEST_OK;
485
486 return WEXITSTATUS(err) == 2 ? TEST_SKIP : TEST_FAIL;
487}
488
489static int run_shell_tests(int argc, const char *argv[], int i, int width)
490{
491 DIR *dir;
492 struct dirent *ent;
493 char path_dir[PATH_MAX];
494 struct shell_test st = {
495 .dir = shell_tests__dir(path_dir, sizeof(path_dir)),
496 };
497
498 if (st.dir == NULL)
499 return -1;
500
501 dir = opendir(st.dir);
502 if (!dir)
503 return -1;
504
505 for_each_shell_test(dir, ent) {
506 int curr = i++;
507 char desc[256];
508 struct test test = {
509 .desc = shell_test__description(desc, sizeof(desc), st.dir, ent->d_name),
510 .func = shell_test__run,
511 .priv = &st,
512 };
513
514 if (!perf_test__matches(&test, curr, argc, argv))
515 continue;
516
517 st.file = ent->d_name;
518 pr_info("%2d: %-*s:", i, width, test.desc);
519 test_and_print(&test, false, -1);
520 }
521
522 closedir(dir);
523 return 0;
524}
525
386static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist) 526static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
387{ 527{
388 struct test *t; 528 struct test *t;
389 unsigned int j; 529 unsigned int j;
390 int i = 0; 530 int i = 0;
391 int width = 0; 531 int width = shell_tests__max_desc_width();
392 532
393 for_each_test(j, t) { 533 for_each_test(j, t) {
394 int len = strlen(t->desc); 534 int len = strlen(t->desc);
@@ -455,6 +595,37 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
455 } 595 }
456 } 596 }
457 597
598 return run_shell_tests(argc, argv, i, width);
599}
600
601static int perf_test__list_shell(int argc, const char **argv, int i)
602{
603 DIR *dir;
604 struct dirent *ent;
605 char path_dir[PATH_MAX];
606 const char *path = shell_tests__dir(path_dir, sizeof(path_dir));
607
608 if (path == NULL)
609 return -1;
610
611 dir = opendir(path);
612 if (!dir)
613 return -1;
614
615 for_each_shell_test(dir, ent) {
616 int curr = i++;
617 char bf[256];
618 struct test t = {
619 .desc = shell_test__description(bf, sizeof(bf), path, ent->d_name),
620 };
621
622 if (!perf_test__matches(&t, curr, argc, argv))
623 continue;
624
625 pr_info("%2d: %s\n", i, t.desc);
626 }
627
628 closedir(dir);
458 return 0; 629 return 0;
459} 630}
460 631
@@ -465,12 +636,17 @@ static int perf_test__list(int argc, const char **argv)
465 int i = 0; 636 int i = 0;
466 637
467 for_each_test(j, t) { 638 for_each_test(j, t) {
468 if (argc > 1 && !strstr(t->desc, argv[1])) 639 int curr = i++;
640
641 if (!perf_test__matches(t, curr, argc, argv) ||
642 (t->is_supported && !t->is_supported()))
469 continue; 643 continue;
470 644
471 pr_info("%2d: %s\n", ++i, t->desc); 645 pr_info("%2d: %s\n", i, t->desc);
472 } 646 }
473 647
648 perf_test__list_shell(argc, argv, i);
649
474 return 0; 650 return 0;
475} 651}
476 652
@@ -498,7 +674,7 @@ int cmd_test(int argc, const char **argv)
498 674
499 argc = parse_options_subcommand(argc, argv, test_options, test_subcommands, test_usage, 0); 675 argc = parse_options_subcommand(argc, argv, test_options, test_subcommands, test_usage, 0);
500 if (argc >= 1 && !strcmp(argv[0], "list")) 676 if (argc >= 1 && !strcmp(argv[0], "list"))
501 return perf_test__list(argc, argv); 677 return perf_test__list(argc - 1, argv + 1);
502 678
503 symbol_conf.priv_size = sizeof(int); 679 symbol_conf.priv_size = sizeof(int);
504 symbol_conf.sort_by_name = true; 680 symbol_conf.sort_by_name = true;
diff --git a/tools/perf/tests/clang.c b/tools/perf/tests/clang.c
index c5bb2203f5a9..c60ec916f0f2 100644
--- a/tools/perf/tests/clang.c
+++ b/tools/perf/tests/clang.c
@@ -33,12 +33,12 @@ const char *test__clang_subtest_get_desc(int i)
33} 33}
34 34
35#ifndef HAVE_LIBCLANGLLVM_SUPPORT 35#ifndef HAVE_LIBCLANGLLVM_SUPPORT
36int test__clang(int i __maybe_unused) 36int test__clang(struct test *test __maybe_unused, int i __maybe_unused)
37{ 37{
38 return TEST_SKIP; 38 return TEST_SKIP;
39} 39}
40#else 40#else
41int test__clang(int i) 41int test__clang(struct test *test __maybe_unused, int i)
42{ 42{
43 if (i < 0 || i >= (int)ARRAY_SIZE(clang_testcase_table)) 43 if (i < 0 || i >= (int)ARRAY_SIZE(clang_testcase_table))
44 return TEST_FAIL; 44 return TEST_FAIL;
diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c
index 94b7c7b02bde..466a462b26d1 100644
--- a/tools/perf/tests/code-reading.c
+++ b/tools/perf/tests/code-reading.c
@@ -237,6 +237,11 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode,
237 237
238 thread__find_addr_map(thread, cpumode, MAP__FUNCTION, addr, &al); 238 thread__find_addr_map(thread, cpumode, MAP__FUNCTION, addr, &al);
239 if (!al.map || !al.map->dso) { 239 if (!al.map || !al.map->dso) {
240 if (cpumode == PERF_RECORD_MISC_HYPERVISOR) {
241 pr_debug("Hypervisor address can not be resolved - skipping\n");
242 return 0;
243 }
244
240 pr_debug("thread__find_addr_map failed\n"); 245 pr_debug("thread__find_addr_map failed\n");
241 return -1; 246 return -1;
242 } 247 }
@@ -673,7 +678,7 @@ out_err:
673 return err; 678 return err;
674} 679}
675 680
676int test__code_reading(int subtest __maybe_unused) 681int test__code_reading(struct test *test __maybe_unused, int subtest __maybe_unused)
677{ 682{
678 int ret; 683 int ret;
679 684
diff --git a/tools/perf/tests/cpumap.c b/tools/perf/tests/cpumap.c
index 4478773cdb97..199702252270 100644
--- a/tools/perf/tests/cpumap.c
+++ b/tools/perf/tests/cpumap.c
@@ -72,7 +72,7 @@ static int process_event_cpus(struct perf_tool *tool __maybe_unused,
72} 72}
73 73
74 74
75int test__cpu_map_synthesize(int subtest __maybe_unused) 75int test__cpu_map_synthesize(struct test *test __maybe_unused, int subtest __maybe_unused)
76{ 76{
77 struct cpu_map *cpus; 77 struct cpu_map *cpus;
78 78
@@ -106,7 +106,7 @@ static int cpu_map_print(const char *str)
106 return !strcmp(buf, str); 106 return !strcmp(buf, str);
107} 107}
108 108
109int test__cpu_map_print(int subtest __maybe_unused) 109int test__cpu_map_print(struct test *test __maybe_unused, int subtest __maybe_unused)
110{ 110{
111 TEST_ASSERT_VAL("failed to convert map", cpu_map_print("1")); 111 TEST_ASSERT_VAL("failed to convert map", cpu_map_print("1"));
112 TEST_ASSERT_VAL("failed to convert map", cpu_map_print("1,5")); 112 TEST_ASSERT_VAL("failed to convert map", cpu_map_print("1,5"));
diff --git a/tools/perf/tests/dso-data.c b/tools/perf/tests/dso-data.c
index 8f08df5861cb..30aead42d136 100644
--- a/tools/perf/tests/dso-data.c
+++ b/tools/perf/tests/dso-data.c
@@ -112,7 +112,7 @@ static int dso__data_fd(struct dso *dso, struct machine *machine)
112 return fd; 112 return fd;
113} 113}
114 114
115int test__dso_data(int subtest __maybe_unused) 115int test__dso_data(struct test *test __maybe_unused, int subtest __maybe_unused)
116{ 116{
117 struct machine machine; 117 struct machine machine;
118 struct dso *dso; 118 struct dso *dso;
@@ -247,7 +247,7 @@ static int set_fd_limit(int n)
247 return setrlimit(RLIMIT_NOFILE, &rlim); 247 return setrlimit(RLIMIT_NOFILE, &rlim);
248} 248}
249 249
250int test__dso_data_cache(int subtest __maybe_unused) 250int test__dso_data_cache(struct test *test __maybe_unused, int subtest __maybe_unused)
251{ 251{
252 struct machine machine; 252 struct machine machine;
253 long nr_end, nr = open_files_cnt(); 253 long nr_end, nr = open_files_cnt();
@@ -307,7 +307,7 @@ int test__dso_data_cache(int subtest __maybe_unused)
307 return 0; 307 return 0;
308} 308}
309 309
310int test__dso_data_reopen(int subtest __maybe_unused) 310int test__dso_data_reopen(struct test *test __maybe_unused, int subtest __maybe_unused)
311{ 311{
312 struct machine machine; 312 struct machine machine;
313 long nr_end, nr = open_files_cnt(); 313 long nr_end, nr = open_files_cnt();
diff --git a/tools/perf/tests/dwarf-unwind.c b/tools/perf/tests/dwarf-unwind.c
index 3e56d08f7995..9ba1d216a89f 100644
--- a/tools/perf/tests/dwarf-unwind.c
+++ b/tools/perf/tests/dwarf-unwind.c
@@ -6,7 +6,7 @@
6#include "debug.h" 6#include "debug.h"
7#include "machine.h" 7#include "machine.h"
8#include "event.h" 8#include "event.h"
9#include "unwind.h" 9#include "../util/unwind.h"
10#include "perf_regs.h" 10#include "perf_regs.h"
11#include "map.h" 11#include "map.h"
12#include "thread.h" 12#include "thread.h"
@@ -154,7 +154,7 @@ static noinline int krava_1(struct thread *thread)
154 return krava_2(thread); 154 return krava_2(thread);
155} 155}
156 156
157int test__dwarf_unwind(int subtest __maybe_unused) 157int test__dwarf_unwind(struct test *test __maybe_unused, int subtest __maybe_unused)
158{ 158{
159 struct machine *machine; 159 struct machine *machine;
160 struct thread *thread; 160 struct thread *thread;
diff --git a/tools/perf/tests/event-times.c b/tools/perf/tests/event-times.c
index 634f20c631d8..b82b981c3259 100644
--- a/tools/perf/tests/event-times.c
+++ b/tools/perf/tests/event-times.c
@@ -213,7 +213,7 @@ out_err:
213 * and checks that enabled and running times 213 * and checks that enabled and running times
214 * match. 214 * match.
215 */ 215 */
216int test__event_times(int subtest __maybe_unused) 216int test__event_times(struct test *test __maybe_unused, int subtest __maybe_unused)
217{ 217{
218 int err, ret = 0; 218 int err, ret = 0;
219 219
diff --git a/tools/perf/tests/event_update.c b/tools/perf/tests/event_update.c
index 63ecf21750eb..9484da2ec6b4 100644
--- a/tools/perf/tests/event_update.c
+++ b/tools/perf/tests/event_update.c
@@ -76,7 +76,7 @@ static int process_event_cpus(struct perf_tool *tool __maybe_unused,
76 return 0; 76 return 0;
77} 77}
78 78
79int test__event_update(int subtest __maybe_unused) 79int test__event_update(struct test *test __maybe_unused, int subtest __maybe_unused)
80{ 80{
81 struct perf_evlist *evlist; 81 struct perf_evlist *evlist;
82 struct perf_evsel *evsel; 82 struct perf_evsel *evsel;
diff --git a/tools/perf/tests/evsel-roundtrip-name.c b/tools/perf/tests/evsel-roundtrip-name.c
index d2bea6f780f8..d32759b6e38a 100644
--- a/tools/perf/tests/evsel-roundtrip-name.c
+++ b/tools/perf/tests/evsel-roundtrip-name.c
@@ -97,7 +97,7 @@ out_delete_evlist:
97#define perf_evsel__name_array_test(names) \ 97#define perf_evsel__name_array_test(names) \
98 __perf_evsel__name_array_test(names, ARRAY_SIZE(names)) 98 __perf_evsel__name_array_test(names, ARRAY_SIZE(names))
99 99
100int test__perf_evsel__roundtrip_name_test(int subtest __maybe_unused) 100int test__perf_evsel__roundtrip_name_test(struct test *test __maybe_unused, int subtest __maybe_unused)
101{ 101{
102 int err = 0, ret = 0; 102 int err = 0, ret = 0;
103 103
diff --git a/tools/perf/tests/evsel-tp-sched.c b/tools/perf/tests/evsel-tp-sched.c
index 1984b3bbfe15..5fc906d26c5c 100644
--- a/tools/perf/tests/evsel-tp-sched.c
+++ b/tools/perf/tests/evsel-tp-sched.c
@@ -32,7 +32,7 @@ static int perf_evsel__test_field(struct perf_evsel *evsel, const char *name,
32 return ret; 32 return ret;
33} 33}
34 34
35int test__perf_evsel__tp_sched_test(int subtest __maybe_unused) 35int test__perf_evsel__tp_sched_test(struct test *test __maybe_unused, int subtest __maybe_unused)
36{ 36{
37 struct perf_evsel *evsel = perf_evsel__newtp("sched", "sched_switch"); 37 struct perf_evsel *evsel = perf_evsel__newtp("sched", "sched_switch");
38 int ret = 0; 38 int ret = 0;
diff --git a/tools/perf/tests/expr.c b/tools/perf/tests/expr.c
index 6c6a3749aaf6..cb251bf523e7 100644
--- a/tools/perf/tests/expr.c
+++ b/tools/perf/tests/expr.c
@@ -13,7 +13,7 @@ static int test(struct parse_ctx *ctx, const char *e, double val2)
13 return 0; 13 return 0;
14} 14}
15 15
16int test__expr(int subtest __maybe_unused) 16int test__expr(struct test *t __maybe_unused, int subtest __maybe_unused)
17{ 17{
18 const char *p; 18 const char *p;
19 const char **other; 19 const char **other;
@@ -31,6 +31,11 @@ int test__expr(int subtest __maybe_unused)
31 ret |= test(&ctx, "(BAR/2)%2", 1); 31 ret |= test(&ctx, "(BAR/2)%2", 1);
32 ret |= test(&ctx, "1 - -4", 5); 32 ret |= test(&ctx, "1 - -4", 5);
33 ret |= test(&ctx, "(FOO-1)*2 + (BAR/2)%2 - -4", 5); 33 ret |= test(&ctx, "(FOO-1)*2 + (BAR/2)%2 - -4", 5);
34 ret |= test(&ctx, "1-1 | 1", 1);
35 ret |= test(&ctx, "1-1 & 1", 0);
36 ret |= test(&ctx, "min(1,2) + 1", 2);
37 ret |= test(&ctx, "max(1,2) + 1", 3);
38 ret |= test(&ctx, "1+1 if 3*4 else 0", 2);
34 39
35 if (ret) 40 if (ret)
36 return ret; 41 return ret;
diff --git a/tools/perf/tests/fdarray.c b/tools/perf/tests/fdarray.c
index bc5982f42dc3..7d3a9e2ff897 100644
--- a/tools/perf/tests/fdarray.c
+++ b/tools/perf/tests/fdarray.c
@@ -26,7 +26,7 @@ static int fdarray__fprintf_prefix(struct fdarray *fda, const char *prefix, FILE
26 return printed + fdarray__fprintf(fda, fp); 26 return printed + fdarray__fprintf(fda, fp);
27} 27}
28 28
29int test__fdarray__filter(int subtest __maybe_unused) 29int test__fdarray__filter(struct test *test __maybe_unused, int subtest __maybe_unused)
30{ 30{
31 int nr_fds, expected_fd[2], fd, err = TEST_FAIL; 31 int nr_fds, expected_fd[2], fd, err = TEST_FAIL;
32 struct fdarray *fda = fdarray__new(5, 5); 32 struct fdarray *fda = fdarray__new(5, 5);
@@ -104,7 +104,7 @@ out:
104 return err; 104 return err;
105} 105}
106 106
107int test__fdarray__add(int subtest __maybe_unused) 107int test__fdarray__add(struct test *test __maybe_unused, int subtest __maybe_unused)
108{ 108{
109 int err = TEST_FAIL; 109 int err = TEST_FAIL;
110 struct fdarray *fda = fdarray__new(2, 2); 110 struct fdarray *fda = fdarray__new(2, 2);
diff --git a/tools/perf/tests/hists_cumulate.c b/tools/perf/tests/hists_cumulate.c
index d549a9f2c41b..8d19c0200cb7 100644
--- a/tools/perf/tests/hists_cumulate.c
+++ b/tools/perf/tests/hists_cumulate.c
@@ -687,7 +687,7 @@ out:
687 return err; 687 return err;
688} 688}
689 689
690int test__hists_cumulate(int subtest __maybe_unused) 690int test__hists_cumulate(struct test *test __maybe_unused, int subtest __maybe_unused)
691{ 691{
692 int err = TEST_FAIL; 692 int err = TEST_FAIL;
693 struct machines machines; 693 struct machines machines;
diff --git a/tools/perf/tests/hists_filter.c b/tools/perf/tests/hists_filter.c
index df9c91f49af1..755ca551b810 100644
--- a/tools/perf/tests/hists_filter.c
+++ b/tools/perf/tests/hists_filter.c
@@ -101,7 +101,7 @@ out:
101 return TEST_FAIL; 101 return TEST_FAIL;
102} 102}
103 103
104int test__hists_filter(int subtest __maybe_unused) 104int test__hists_filter(struct test *test __maybe_unused, int subtest __maybe_unused)
105{ 105{
106 int err = TEST_FAIL; 106 int err = TEST_FAIL;
107 struct machines machines; 107 struct machines machines;
diff --git a/tools/perf/tests/hists_link.c b/tools/perf/tests/hists_link.c
index a26cbb79e988..073c9c2856bc 100644
--- a/tools/perf/tests/hists_link.c
+++ b/tools/perf/tests/hists_link.c
@@ -264,7 +264,7 @@ static int validate_link(struct hists *leader, struct hists *other)
264 return __validate_link(leader, 0) || __validate_link(other, 1); 264 return __validate_link(leader, 0) || __validate_link(other, 1);
265} 265}
266 266
267int test__hists_link(int subtest __maybe_unused) 267int test__hists_link(struct test *test __maybe_unused, int subtest __maybe_unused)
268{ 268{
269 int err = -1; 269 int err = -1;
270 struct hists *hists, *first_hists; 270 struct hists *hists, *first_hists;
diff --git a/tools/perf/tests/hists_output.c b/tools/perf/tests/hists_output.c
index 06e5080182d3..282d62eaebe2 100644
--- a/tools/perf/tests/hists_output.c
+++ b/tools/perf/tests/hists_output.c
@@ -573,7 +573,7 @@ out:
573 return err; 573 return err;
574} 574}
575 575
576int test__hists_output(int subtest __maybe_unused) 576int test__hists_output(struct test *test __maybe_unused, int subtest __maybe_unused)
577{ 577{
578 int err = TEST_FAIL; 578 int err = TEST_FAIL;
579 struct machines machines; 579 struct machines machines;
diff --git a/tools/perf/tests/is_printable_array.c b/tools/perf/tests/is_printable_array.c
index a5192f6a20d7..38f765767587 100644
--- a/tools/perf/tests/is_printable_array.c
+++ b/tools/perf/tests/is_printable_array.c
@@ -4,7 +4,7 @@
4#include "debug.h" 4#include "debug.h"
5#include "print_binary.h" 5#include "print_binary.h"
6 6
7int test__is_printable_array(int subtest __maybe_unused) 7int test__is_printable_array(struct test *test __maybe_unused, int subtest __maybe_unused)
8{ 8{
9 char buf1[] = { 'k', 'r', 4, 'v', 'a', 0 }; 9 char buf1[] = { 'k', 'r', 4, 'v', 'a', 0 };
10 char buf2[] = { 'k', 'r', 'a', 'v', 4, 0 }; 10 char buf2[] = { 'k', 'r', 'a', 'v', 4, 0 };
diff --git a/tools/perf/tests/keep-tracking.c b/tools/perf/tests/keep-tracking.c
index 614e45a3c603..739428603b71 100644
--- a/tools/perf/tests/keep-tracking.c
+++ b/tools/perf/tests/keep-tracking.c
@@ -49,7 +49,7 @@ static int find_comm(struct perf_evlist *evlist, const char *comm)
49 * when an event is disabled but a dummy software event is not disabled. If the 49 * when an event is disabled but a dummy software event is not disabled. If the
50 * test passes %0 is returned, otherwise %-1 is returned. 50 * test passes %0 is returned, otherwise %-1 is returned.
51 */ 51 */
52int test__keep_tracking(int subtest __maybe_unused) 52int test__keep_tracking(struct test *test __maybe_unused, int subtest __maybe_unused)
53{ 53{
54 struct record_opts opts = { 54 struct record_opts opts = {
55 .mmap_pages = UINT_MAX, 55 .mmap_pages = UINT_MAX,
diff --git a/tools/perf/tests/kmod-path.c b/tools/perf/tests/kmod-path.c
index 6cd9e5107f77..8b9d4ba06c0e 100644
--- a/tools/perf/tests/kmod-path.c
+++ b/tools/perf/tests/kmod-path.c
@@ -50,7 +50,7 @@ static int test_is_kernel_module(const char *path, int cpumode, bool expect)
50#define M(path, c, e) \ 50#define M(path, c, e) \
51 TEST_ASSERT_VAL("failed", !test_is_kernel_module(path, c, e)) 51 TEST_ASSERT_VAL("failed", !test_is_kernel_module(path, c, e))
52 52
53int test__kmod_path__parse(int subtest __maybe_unused) 53int test__kmod_path__parse(struct test *t __maybe_unused, int subtest __maybe_unused)
54{ 54{
55 /* path alloc_name alloc_ext kmod comp name ext */ 55 /* path alloc_name alloc_ext kmod comp name ext */
56 T("/xxxx/xxxx/x-x.ko", true , true , true, false, "[x_x]", NULL); 56 T("/xxxx/xxxx/x-x.ko", true , true , true, false, "[x_x]", NULL);
diff --git a/tools/perf/tests/llvm.c b/tools/perf/tests/llvm.c
index 482b5365e68d..5187b50dbafe 100644
--- a/tools/perf/tests/llvm.c
+++ b/tools/perf/tests/llvm.c
@@ -132,7 +132,7 @@ out:
132 return ret; 132 return ret;
133} 133}
134 134
135int test__llvm(int subtest) 135int test__llvm(struct test *test __maybe_unused, int subtest)
136{ 136{
137 int ret; 137 int ret;
138 void *obj_buf = NULL; 138 void *obj_buf = NULL;
diff --git a/tools/perf/tests/mem.c b/tools/perf/tests/mem.c
new file mode 100644
index 000000000000..21952e1e6e6d
--- /dev/null
+++ b/tools/perf/tests/mem.c
@@ -0,0 +1,56 @@
1#include "util/mem-events.h"
2#include "util/symbol.h"
3#include "linux/perf_event.h"
4#include "util/debug.h"
5#include "tests.h"
6#include <string.h>
7
8static int check(union perf_mem_data_src data_src,
9 const char *string)
10{
11 char out[100];
12 char failure[100];
13 struct mem_info mi = { .data_src = data_src };
14
15 int n;
16
17 n = perf_mem__snp_scnprintf(out, sizeof out, &mi);
18 n += perf_mem__lvl_scnprintf(out + n, sizeof out - n, &mi);
19 snprintf(failure, sizeof failure, "unexpected %s", out);
20 TEST_ASSERT_VAL(failure, !strcmp(string, out));
21 return 0;
22}
23
24int test__mem(struct test *text __maybe_unused, int subtest __maybe_unused)
25{
26 int ret = 0;
27 union perf_mem_data_src src;
28
29 memset(&src, 0, sizeof(src));
30
31 src.mem_lvl = PERF_MEM_LVL_HIT;
32 src.mem_lvl_num = 4;
33
34 ret |= check(src, "N/AL4 hit");
35
36 src.mem_remote = 1;
37
38 ret |= check(src, "N/ARemote L4 hit");
39
40 src.mem_lvl = PERF_MEM_LVL_MISS;
41 src.mem_lvl_num = PERF_MEM_LVLNUM_PMEM;
42 src.mem_remote = 0;
43
44 ret |= check(src, "N/APMEM miss");
45
46 src.mem_remote = 1;
47
48 ret |= check(src, "N/ARemote PMEM miss");
49
50 src.mem_snoopx = PERF_MEM_SNOOPX_FWD;
51 src.mem_lvl_num = PERF_MEM_LVLNUM_RAM;
52
53 ret |= check(src , "FwdRemote RAM miss");
54
55 return ret;
56}
diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c
index 15c770856aac..bc8a70ee46d8 100644
--- a/tools/perf/tests/mmap-basic.c
+++ b/tools/perf/tests/mmap-basic.c
@@ -22,7 +22,7 @@
22 * Then it checks if the number of syscalls reported as perf events by 22 * Then it checks if the number of syscalls reported as perf events by
23 * the kernel corresponds to the number of syscalls made. 23 * the kernel corresponds to the number of syscalls made.
24 */ 24 */
25int test__basic_mmap(int subtest __maybe_unused) 25int test__basic_mmap(struct test *test __maybe_unused, int subtest __maybe_unused)
26{ 26{
27 int err = -1; 27 int err = -1;
28 union perf_event *event; 28 union perf_event *event;
diff --git a/tools/perf/tests/mmap-thread-lookup.c b/tools/perf/tests/mmap-thread-lookup.c
index 6ea4d8a5d26b..f94a4196e7c9 100644
--- a/tools/perf/tests/mmap-thread-lookup.c
+++ b/tools/perf/tests/mmap-thread-lookup.c
@@ -221,7 +221,7 @@ static int mmap_events(synth_cb synth)
221 * 221 *
222 * by using all thread objects. 222 * by using all thread objects.
223 */ 223 */
224int test__mmap_thread_lookup(int subtest __maybe_unused) 224int test__mmap_thread_lookup(struct test *test __maybe_unused, int subtest __maybe_unused)
225{ 225{
226 /* perf_event__synthesize_threads synthesize */ 226 /* perf_event__synthesize_threads synthesize */
227 TEST_ASSERT_VAL("failed with sythesizing all", 227 TEST_ASSERT_VAL("failed with sythesizing all",
diff --git a/tools/perf/tests/openat-syscall-all-cpus.c b/tools/perf/tests/openat-syscall-all-cpus.c
index 1a74dd9fd067..9cf1c35f2ad0 100644
--- a/tools/perf/tests/openat-syscall-all-cpus.c
+++ b/tools/perf/tests/openat-syscall-all-cpus.c
@@ -16,7 +16,7 @@
16#include "debug.h" 16#include "debug.h"
17#include "stat.h" 17#include "stat.h"
18 18
19int test__openat_syscall_event_on_all_cpus(int subtest __maybe_unused) 19int test__openat_syscall_event_on_all_cpus(struct test *test __maybe_unused, int subtest __maybe_unused)
20{ 20{
21 int err = -1, fd, cpu; 21 int err = -1, fd, cpu;
22 struct cpu_map *cpus; 22 struct cpu_map *cpus;
@@ -115,7 +115,7 @@ int test__openat_syscall_event_on_all_cpus(int subtest __maybe_unused)
115 115
116 perf_evsel__free_counts(evsel); 116 perf_evsel__free_counts(evsel);
117out_close_fd: 117out_close_fd:
118 perf_evsel__close_fd(evsel, 1, threads->nr); 118 perf_evsel__close_fd(evsel);
119out_evsel_delete: 119out_evsel_delete:
120 perf_evsel__delete(evsel); 120 perf_evsel__delete(evsel);
121out_thread_map_delete: 121out_thread_map_delete:
diff --git a/tools/perf/tests/openat-syscall-tp-fields.c b/tools/perf/tests/openat-syscall-tp-fields.c
index 9788fac91095..b6ee1c41f45d 100644
--- a/tools/perf/tests/openat-syscall-tp-fields.c
+++ b/tools/perf/tests/openat-syscall-tp-fields.c
@@ -14,7 +14,7 @@
14#define AT_FDCWD -100 14#define AT_FDCWD -100
15#endif 15#endif
16 16
17int test__syscall_openat_tp_fields(int subtest __maybe_unused) 17int test__syscall_openat_tp_fields(struct test *test __maybe_unused, int subtest __maybe_unused)
18{ 18{
19 struct record_opts opts = { 19 struct record_opts opts = {
20 .target = { 20 .target = {
diff --git a/tools/perf/tests/openat-syscall.c b/tools/perf/tests/openat-syscall.c
index e44506e21ee7..9dc5c5d37553 100644
--- a/tools/perf/tests/openat-syscall.c
+++ b/tools/perf/tests/openat-syscall.c
@@ -10,7 +10,7 @@
10#include "debug.h" 10#include "debug.h"
11#include "tests.h" 11#include "tests.h"
12 12
13int test__openat_syscall_event(int subtest __maybe_unused) 13int test__openat_syscall_event(struct test *test __maybe_unused, int subtest __maybe_unused)
14{ 14{
15 int err = -1, fd; 15 int err = -1, fd;
16 struct perf_evsel *evsel; 16 struct perf_evsel *evsel;
@@ -56,7 +56,7 @@ int test__openat_syscall_event(int subtest __maybe_unused)
56 56
57 err = 0; 57 err = 0;
58out_close_fd: 58out_close_fd:
59 perf_evsel__close_fd(evsel, 1, threads->nr); 59 perf_evsel__close_fd(evsel);
60out_evsel_delete: 60out_evsel_delete:
61 perf_evsel__delete(evsel); 61 perf_evsel__delete(evsel);
62out_thread_map_delete: 62out_thread_map_delete:
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index 812a053d1941..0f0b025faa4b 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -1810,7 +1810,7 @@ static int test_pmu_events(void)
1810 return ret; 1810 return ret;
1811} 1811}
1812 1812
1813int test__parse_events(int subtest __maybe_unused) 1813int test__parse_events(struct test *test __maybe_unused, int subtest __maybe_unused)
1814{ 1814{
1815 int ret1, ret2 = 0; 1815 int ret1, ret2 = 0;
1816 1816
diff --git a/tools/perf/tests/parse-no-sample-id-all.c b/tools/perf/tests/parse-no-sample-id-all.c
index c6207db09f12..91867dcc39f0 100644
--- a/tools/perf/tests/parse-no-sample-id-all.c
+++ b/tools/perf/tests/parse-no-sample-id-all.c
@@ -68,7 +68,7 @@ struct test_attr_event {
68 * 68 *
69 * Return: %0 on success, %-1 if the test fails. 69 * Return: %0 on success, %-1 if the test fails.
70 */ 70 */
71int test__parse_no_sample_id_all(int subtest __maybe_unused) 71int test__parse_no_sample_id_all(struct test *test __maybe_unused, int subtest __maybe_unused)
72{ 72{
73 int err; 73 int err;
74 74
diff --git a/tools/perf/tests/perf-hooks.c b/tools/perf/tests/perf-hooks.c
index 665ecc19671c..bf2517d6de70 100644
--- a/tools/perf/tests/perf-hooks.c
+++ b/tools/perf/tests/perf-hooks.c
@@ -27,7 +27,7 @@ static void the_hook(void *_hook_flags)
27 *p = 0; 27 *p = 0;
28} 28}
29 29
30int test__perf_hooks(int subtest __maybe_unused) 30int test__perf_hooks(struct test *test __maybe_unused, int subtest __maybe_unused)
31{ 31{
32 int hook_flags = 0; 32 int hook_flags = 0;
33 33
diff --git a/tools/perf/tests/perf-record.c b/tools/perf/tests/perf-record.c
index d37cd9588cc0..19b650064b70 100644
--- a/tools/perf/tests/perf-record.c
+++ b/tools/perf/tests/perf-record.c
@@ -37,7 +37,7 @@ realloc:
37 return cpu; 37 return cpu;
38} 38}
39 39
40int test__PERF_RECORD(int subtest __maybe_unused) 40int test__PERF_RECORD(struct test *test __maybe_unused, int subtest __maybe_unused)
41{ 41{
42 struct record_opts opts = { 42 struct record_opts opts = {
43 .target = { 43 .target = {
diff --git a/tools/perf/tests/pmu.c b/tools/perf/tests/pmu.c
index a6d7aef30030..9f7f589f9c54 100644
--- a/tools/perf/tests/pmu.c
+++ b/tools/perf/tests/pmu.c
@@ -135,7 +135,7 @@ static struct list_head *test_terms_list(void)
135 return &terms; 135 return &terms;
136} 136}
137 137
138int test__pmu(int subtest __maybe_unused) 138int test__pmu(struct test *test __maybe_unused, int subtest __maybe_unused)
139{ 139{
140 char *format = test_format_dir_get(); 140 char *format = test_format_dir_get();
141 LIST_HEAD(formats); 141 LIST_HEAD(formats);
diff --git a/tools/perf/tests/python-use.c b/tools/perf/tests/python-use.c
index fa79509da535..598a7e058ad4 100644
--- a/tools/perf/tests/python-use.c
+++ b/tools/perf/tests/python-use.c
@@ -9,7 +9,7 @@
9 9
10extern int verbose; 10extern int verbose;
11 11
12int test__python_use(int subtest __maybe_unused) 12int test__python_use(struct test *test __maybe_unused, int subtest __maybe_unused)
13{ 13{
14 char *cmd; 14 char *cmd;
15 int ret; 15 int ret;
diff --git a/tools/perf/tests/sample-parsing.c b/tools/perf/tests/sample-parsing.c
index bac5c3885b3b..c3858487159d 100644
--- a/tools/perf/tests/sample-parsing.c
+++ b/tools/perf/tests/sample-parsing.c
@@ -141,6 +141,9 @@ static bool samples_same(const struct perf_sample *s1,
141 } 141 }
142 } 142 }
143 143
144 if (type & PERF_SAMPLE_PHYS_ADDR)
145 COMP(phys_addr);
146
144 return true; 147 return true;
145} 148}
146 149
@@ -206,6 +209,7 @@ static int do_test(u64 sample_type, u64 sample_regs, u64 read_format)
206 .mask = sample_regs, 209 .mask = sample_regs,
207 .regs = regs, 210 .regs = regs,
208 }, 211 },
212 .phys_addr = 113,
209 }; 213 };
210 struct sample_read_value values[] = {{1, 5}, {9, 3}, {2, 7}, {6, 4},}; 214 struct sample_read_value values[] = {{1, 5}, {9, 3}, {2, 7}, {6, 4},};
211 struct perf_sample sample_out; 215 struct perf_sample sample_out;
@@ -292,7 +296,7 @@ out_free:
292 * checks sample format bits separately and together. If the test passes %0 is 296 * checks sample format bits separately and together. If the test passes %0 is
293 * returned, otherwise %-1 is returned. 297 * returned, otherwise %-1 is returned.
294 */ 298 */
295int test__sample_parsing(int subtest __maybe_unused) 299int test__sample_parsing(struct test *test __maybe_unused, int subtest __maybe_unused)
296{ 300{
297 const u64 rf[] = {4, 5, 6, 7, 12, 13, 14, 15}; 301 const u64 rf[] = {4, 5, 6, 7, 12, 13, 14, 15};
298 u64 sample_type; 302 u64 sample_type;
@@ -305,7 +309,7 @@ int test__sample_parsing(int subtest __maybe_unused)
305 * were added. Please actually update the test rather than just change 309 * were added. Please actually update the test rather than just change
306 * the condition below. 310 * the condition below.
307 */ 311 */
308 if (PERF_SAMPLE_MAX > PERF_SAMPLE_REGS_INTR << 1) { 312 if (PERF_SAMPLE_MAX > PERF_SAMPLE_PHYS_ADDR << 1) {
309 pr_debug("sample format has changed, some new PERF_SAMPLE_ bit was introduced - test needs updating\n"); 313 pr_debug("sample format has changed, some new PERF_SAMPLE_ bit was introduced - test needs updating\n");
310 return -1; 314 return -1;
311 } 315 }
diff --git a/tools/perf/tests/sdt.c b/tools/perf/tests/sdt.c
index 06eda675ae2c..a9903d9b8bc2 100644
--- a/tools/perf/tests/sdt.c
+++ b/tools/perf/tests/sdt.c
@@ -33,7 +33,7 @@ static int build_id_cache__add_file(const char *filename)
33 } 33 }
34 34
35 build_id__sprintf(build_id, sizeof(build_id), sbuild_id); 35 build_id__sprintf(build_id, sizeof(build_id), sbuild_id);
36 err = build_id_cache__add_s(sbuild_id, filename, false, false); 36 err = build_id_cache__add_s(sbuild_id, filename, NULL, false, false);
37 if (err < 0) 37 if (err < 0)
38 pr_debug("Failed to add build id cache of %s\n", filename); 38 pr_debug("Failed to add build id cache of %s\n", filename);
39 return err; 39 return err;
@@ -54,7 +54,7 @@ static char *get_self_path(void)
54static int search_cached_probe(const char *target, 54static int search_cached_probe(const char *target,
55 const char *group, const char *event) 55 const char *group, const char *event)
56{ 56{
57 struct probe_cache *cache = probe_cache__new(target); 57 struct probe_cache *cache = probe_cache__new(target, NULL);
58 int ret = 0; 58 int ret = 0;
59 59
60 if (!cache) { 60 if (!cache) {
@@ -71,7 +71,7 @@ static int search_cached_probe(const char *target,
71 return ret; 71 return ret;
72} 72}
73 73
74int test__sdt_event(int subtests __maybe_unused) 74int test__sdt_event(struct test *test __maybe_unused, int subtests __maybe_unused)
75{ 75{
76 int ret = TEST_FAIL; 76 int ret = TEST_FAIL;
77 char __tempdir[] = "./test-buildid-XXXXXX"; 77 char __tempdir[] = "./test-buildid-XXXXXX";
@@ -83,6 +83,8 @@ int test__sdt_event(int subtests __maybe_unused)
83 } 83 }
84 /* Note that buildid_dir must be an absolute path */ 84 /* Note that buildid_dir must be an absolute path */
85 tempdir = realpath(__tempdir, NULL); 85 tempdir = realpath(__tempdir, NULL);
86 if (tempdir == NULL)
87 goto error_rmdir;
86 88
87 /* At first, scan itself */ 89 /* At first, scan itself */
88 set_buildid_dir(tempdir); 90 set_buildid_dir(tempdir);
@@ -100,14 +102,14 @@ int test__sdt_event(int subtests __maybe_unused)
100 102
101error_rmdir: 103error_rmdir:
102 /* Cleanup temporary buildid dir */ 104 /* Cleanup temporary buildid dir */
103 rm_rf(tempdir); 105 rm_rf(__tempdir);
104error: 106error:
105 free(tempdir); 107 free(tempdir);
106 free(myself); 108 free(myself);
107 return ret; 109 return ret;
108} 110}
109#else 111#else
110int test__sdt_event(int subtests __maybe_unused) 112int test__sdt_event(struct test *test __maybe_unused, int subtests __maybe_unused)
111{ 113{
112 pr_debug("Skip SDT event test because SDT support is not compiled\n"); 114 pr_debug("Skip SDT event test because SDT support is not compiled\n");
113 return TEST_SKIP; 115 return TEST_SKIP;
diff --git a/tools/perf/tests/shell/lib/probe.sh b/tools/perf/tests/shell/lib/probe.sh
new file mode 100644
index 000000000000..6293cc660947
--- /dev/null
+++ b/tools/perf/tests/shell/lib/probe.sh
@@ -0,0 +1,6 @@
1# Arnaldo Carvalho de Melo <acme@kernel.org>, 2017
2
3skip_if_no_perf_probe() {
4 perf probe 2>&1 | grep -q 'is not a perf-command' && return 2
5 return 0
6}
diff --git a/tools/perf/tests/shell/lib/probe_vfs_getname.sh b/tools/perf/tests/shell/lib/probe_vfs_getname.sh
new file mode 100644
index 000000000000..30a950c9d407
--- /dev/null
+++ b/tools/perf/tests/shell/lib/probe_vfs_getname.sh
@@ -0,0 +1,23 @@
1# Arnaldo Carvalho de Melo <acme@kernel.org>, 2017
2
3perf probe -l 2>&1 | grep -q probe:vfs_getname
4had_vfs_getname=$?
5
6cleanup_probe_vfs_getname() {
7 if [ $had_vfs_getname -eq 1 ] ; then
8 perf probe -q -d probe:vfs_getname
9 fi
10}
11
12add_probe_vfs_getname() {
13 local verbose=$1
14 if [ $had_vfs_getname -eq 1 ] ; then
15 line=$(perf probe -L getname_flags 2>&1 | egrep 'result.*=.*filename;' | sed -r 's/[[:space:]]+([[:digit:]]+)[[:space:]]+result->uptr.*/\1/')
16 perf probe $verbose "vfs_getname=getname_flags:${line} pathname=result->name:string"
17 fi
18}
19
20skip_if_no_debuginfo() {
21 add_probe_vfs_getname -v 2>&1 | egrep -q "^(Failed to find the path for kernel|Debuginfo-analysis is not supported)" && return 2
22 return 1
23}
diff --git a/tools/perf/tests/shell/probe_vfs_getname.sh b/tools/perf/tests/shell/probe_vfs_getname.sh
new file mode 100755
index 000000000000..9b7635184dc2
--- /dev/null
+++ b/tools/perf/tests/shell/probe_vfs_getname.sh
@@ -0,0 +1,14 @@
1# Add vfs_getname probe to get syscall args filenames
2#
3# Arnaldo Carvalho de Melo <acme@kernel.org>, 2017
4
5. $(dirname $0)/lib/probe.sh
6
7skip_if_no_perf_probe || exit 2
8
9. $(dirname $0)/lib/probe_vfs_getname.sh
10
11add_probe_vfs_getname || skip_if_no_debuginfo
12err=$?
13cleanup_probe_vfs_getname
14exit $err
diff --git a/tools/perf/tests/shell/record+script_probe_vfs_getname.sh b/tools/perf/tests/shell/record+script_probe_vfs_getname.sh
new file mode 100755
index 000000000000..ba29535b8580
--- /dev/null
+++ b/tools/perf/tests/shell/record+script_probe_vfs_getname.sh
@@ -0,0 +1,41 @@
1# Use vfs_getname probe to get syscall args filenames
2
3# Uses the 'perf test shell' library to add probe:vfs_getname to the system
4# then use it with 'perf record' using 'touch' to write to a temp file, then
5# checks that that was captured by the vfs_getname probe in the generated
6# perf.data file, with the temp file name as the pathname argument.
7
8# Arnaldo Carvalho de Melo <acme@kernel.org>, 2017
9
10. $(dirname $0)/lib/probe.sh
11
12skip_if_no_perf_probe || exit 2
13
14. $(dirname $0)/lib/probe_vfs_getname.sh
15
16perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
17file=$(mktemp /tmp/temporary_file.XXXXX)
18
19record_open_file() {
20 echo "Recording open file:"
21 perf record -o ${perfdata} -e probe:vfs_getname touch $file
22}
23
24perf_script_filenames() {
25 echo "Looking at perf.data file for vfs_getname records for the file we touched:"
26 perf script -i ${perfdata} | \
27 egrep " +touch +[0-9]+ +\[[0-9]+\] +[0-9]+\.[0-9]+: +probe:vfs_getname: +\([[:xdigit:]]+\) +pathname=\"${file}\""
28}
29
30add_probe_vfs_getname || skip_if_no_debuginfo
31err=$?
32if [ $err -ne 0 ] ; then
33 exit $err
34fi
35
36record_open_file && perf_script_filenames
37err=$?
38rm -f ${perfdata}
39rm -f ${file}
40cleanup_probe_vfs_getname
41exit $err
diff --git a/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh b/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh
new file mode 100755
index 000000000000..462fc755092e
--- /dev/null
+++ b/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh
@@ -0,0 +1,43 @@
1# probe libc's inet_pton & backtrace it with ping
2
3# Installs a probe on libc's inet_pton function, that will use uprobes,
4# then use 'perf trace' on a ping to localhost asking for just one packet
5# with the a backtrace 3 levels deep, check that it is what we expect.
6# This needs no debuginfo package, all is done using the libc ELF symtab
7# and the CFI info in the binaries.
8
9# Arnaldo Carvalho de Melo <acme@kernel.org>, 2017
10
11. $(dirname $0)/lib/probe.sh
12
13trace_libc_inet_pton_backtrace() {
14 idx=0
15 expected[0]="PING.*bytes"
16 expected[1]="64 bytes from ::1.*"
17 expected[2]=".*ping statistics.*"
18 expected[3]=".*packets transmitted.*"
19 expected[4]="rtt min.*"
20 expected[5]="[0-9]+\.[0-9]+[[:space:]]+probe_libc:inet_pton:\([[:xdigit:]]+\)"
21 expected[6]=".*inet_pton[[:space:]]\(/usr/lib.*/libc-[0-9]+\.[0-9]+\.so\)$"
22 expected[7]="getaddrinfo[[:space:]]\(/usr/lib.*/libc-[0-9]+\.[0-9]+\.so\)$"
23 expected[8]=".*\(.*/bin/ping.*\)$"
24
25 perf trace --no-syscalls -e probe_libc:inet_pton/max-stack=3/ ping -6 -c 1 ::1 2>&1 | grep -v ^$ | while read line ; do
26 echo $line
27 echo "$line" | egrep -q "${expected[$idx]}"
28 if [ $? -ne 0 ] ; then
29 printf "FAIL: expected backtrace entry %d \"%s\" got \"%s\"\n" $idx "${expected[$idx]}" "$line"
30 exit 1
31 fi
32 let idx+=1
33 [ $idx -eq 9 ] && break
34 done
35}
36
37skip_if_no_perf_probe && \
38perf probe -q /lib64/libc-*.so inet_pton && \
39trace_libc_inet_pton_backtrace
40err=$?
41rm -f ${file}
42perf probe -q -d probe_libc:inet_pton
43exit $err
diff --git a/tools/perf/tests/shell/trace+probe_vfs_getname.sh b/tools/perf/tests/shell/trace+probe_vfs_getname.sh
new file mode 100755
index 000000000000..2e68c5f120da
--- /dev/null
+++ b/tools/perf/tests/shell/trace+probe_vfs_getname.sh
@@ -0,0 +1,35 @@
1# Check open filename arg using perf trace + vfs_getname
2
3# Uses the 'perf test shell' library to add probe:vfs_getname to the system
4# then use it with 'perf trace' using 'touch' to write to a temp file, then
5# checks that that was captured by the vfs_getname was used by 'perf trace',
6# that already handles "probe:vfs_getname" if present, and used in the
7# "open" syscall "filename" argument beautifier.
8
9# Arnaldo Carvalho de Melo <acme@kernel.org>, 2017
10
11. $(dirname $0)/lib/probe.sh
12
13skip_if_no_perf_probe || exit 2
14
15. $(dirname $0)/lib/probe_vfs_getname.sh
16
17file=$(mktemp /tmp/temporary_file.XXXXX)
18
19trace_open_vfs_getname() {
20 perf trace -e open touch $file 2>&1 | \
21 egrep " +[0-9]+\.[0-9]+ +\( +[0-9]+\.[0-9]+ ms\): +touch\/[0-9]+ open\(filename: +${file}, +flags: CREAT\|NOCTTY\|NONBLOCK\|WRONLY, +mode: +IRUGO\|IWUGO\) += +[0-9]+$"
22}
23
24
25add_probe_vfs_getname || skip_if_no_debuginfo
26err=$?
27if [ $err -ne 0 ] ; then
28 exit $err
29fi
30
31trace_open_vfs_getname
32err=$?
33rm -f ${file}
34cleanup_probe_vfs_getname
35exit $err
diff --git a/tools/perf/tests/stat.c b/tools/perf/tests/stat.c
index 6a20ff2326bb..7f988a939036 100644
--- a/tools/perf/tests/stat.c
+++ b/tools/perf/tests/stat.c
@@ -45,7 +45,7 @@ static int process_stat_config_event(struct perf_tool *tool __maybe_unused,
45 return 0; 45 return 0;
46} 46}
47 47
48int test__synthesize_stat_config(int subtest __maybe_unused) 48int test__synthesize_stat_config(struct test *test __maybe_unused, int subtest __maybe_unused)
49{ 49{
50 struct perf_stat_config stat_config = { 50 struct perf_stat_config stat_config = {
51 .aggr_mode = AGGR_CORE, 51 .aggr_mode = AGGR_CORE,
@@ -75,7 +75,7 @@ static int process_stat_event(struct perf_tool *tool __maybe_unused,
75 return 0; 75 return 0;
76} 76}
77 77
78int test__synthesize_stat(int subtest __maybe_unused) 78int test__synthesize_stat(struct test *test __maybe_unused, int subtest __maybe_unused)
79{ 79{
80 struct perf_counts_values count; 80 struct perf_counts_values count;
81 81
@@ -101,7 +101,7 @@ static int process_stat_round_event(struct perf_tool *tool __maybe_unused,
101 return 0; 101 return 0;
102} 102}
103 103
104int test__synthesize_stat_round(int subtest __maybe_unused) 104int test__synthesize_stat_round(struct test *test __maybe_unused, int subtest __maybe_unused)
105{ 105{
106 TEST_ASSERT_VAL("failed to synthesize stat_config", 106 TEST_ASSERT_VAL("failed to synthesize stat_config",
107 !perf_event__synthesize_stat_round(NULL, 0xdeadbeef, PERF_STAT_ROUND_TYPE__INTERVAL, 107 !perf_event__synthesize_stat_round(NULL, 0xdeadbeef, PERF_STAT_ROUND_TYPE__INTERVAL,
diff --git a/tools/perf/tests/sw-clock.c b/tools/perf/tests/sw-clock.c
index 828494db4a19..d88511f6072c 100644
--- a/tools/perf/tests/sw-clock.c
+++ b/tools/perf/tests/sw-clock.c
@@ -124,7 +124,7 @@ out_delete_evlist:
124 return err; 124 return err;
125} 125}
126 126
127int test__sw_clock_freq(int subtest __maybe_unused) 127int test__sw_clock_freq(struct test *test __maybe_unused, int subtest __maybe_unused)
128{ 128{
129 int ret; 129 int ret;
130 130
diff --git a/tools/perf/tests/switch-tracking.c b/tools/perf/tests/switch-tracking.c
index 65474fd80da7..2acd78555192 100644
--- a/tools/perf/tests/switch-tracking.c
+++ b/tools/perf/tests/switch-tracking.c
@@ -306,7 +306,7 @@ out_free_nodes:
306 * evsel->system_wide and evsel->tracking flags (respectively) with other events 306 * evsel->system_wide and evsel->tracking flags (respectively) with other events
307 * sometimes enabled or disabled. 307 * sometimes enabled or disabled.
308 */ 308 */
309int test__switch_tracking(int subtest __maybe_unused) 309int test__switch_tracking(struct test *test __maybe_unused, int subtest __maybe_unused)
310{ 310{
311 const char *sched_switch = "sched:sched_switch"; 311 const char *sched_switch = "sched:sched_switch";
312 struct switch_tracking switch_tracking = { .tids = NULL, }; 312 struct switch_tracking switch_tracking = { .tids = NULL, };
diff --git a/tools/perf/tests/task-exit.c b/tools/perf/tests/task-exit.c
index cf00ebad2ef5..f0881d0dd9c9 100644
--- a/tools/perf/tests/task-exit.c
+++ b/tools/perf/tests/task-exit.c
@@ -32,7 +32,7 @@ static void workload_exec_failed_signal(int signo __maybe_unused,
32 * if the number of exit event reported by the kernel is 1 or not 32 * if the number of exit event reported by the kernel is 1 or not
33 * in order to check the kernel returns correct number of event. 33 * in order to check the kernel returns correct number of event.
34 */ 34 */
35int test__task_exit(int subtest __maybe_unused) 35int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused)
36{ 36{
37 int err = -1; 37 int err = -1;
38 union perf_event *event; 38 union perf_event *event;
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index 577363809c9b..921412a6a880 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -28,77 +28,79 @@ enum {
28 28
29struct test { 29struct test {
30 const char *desc; 30 const char *desc;
31 int (*func)(int subtest); 31 int (*func)(struct test *test, int subtest);
32 struct { 32 struct {
33 bool skip_if_fail; 33 bool skip_if_fail;
34 int (*get_nr)(void); 34 int (*get_nr)(void);
35 const char *(*get_desc)(int subtest); 35 const char *(*get_desc)(int subtest);
36 } subtest; 36 } subtest;
37 bool (*is_supported)(void); 37 bool (*is_supported)(void);
38 void *priv;
38}; 39};
39 40
40/* Tests */ 41/* Tests */
41int test__vmlinux_matches_kallsyms(int subtest); 42int test__vmlinux_matches_kallsyms(struct test *test, int subtest);
42int test__openat_syscall_event(int subtest); 43int test__openat_syscall_event(struct test *test, int subtest);
43int test__openat_syscall_event_on_all_cpus(int subtest); 44int test__openat_syscall_event_on_all_cpus(struct test *test, int subtest);
44int test__basic_mmap(int subtest); 45int test__basic_mmap(struct test *test, int subtest);
45int test__PERF_RECORD(int subtest); 46int test__PERF_RECORD(struct test *test, int subtest);
46int test__perf_evsel__roundtrip_name_test(int subtest); 47int test__perf_evsel__roundtrip_name_test(struct test *test, int subtest);
47int test__perf_evsel__tp_sched_test(int subtest); 48int test__perf_evsel__tp_sched_test(struct test *test, int subtest);
48int test__syscall_openat_tp_fields(int subtest); 49int test__syscall_openat_tp_fields(struct test *test, int subtest);
49int test__pmu(int subtest); 50int test__pmu(struct test *test, int subtest);
50int test__attr(int subtest); 51int test__attr(struct test *test, int subtest);
51int test__dso_data(int subtest); 52int test__dso_data(struct test *test, int subtest);
52int test__dso_data_cache(int subtest); 53int test__dso_data_cache(struct test *test, int subtest);
53int test__dso_data_reopen(int subtest); 54int test__dso_data_reopen(struct test *test, int subtest);
54int test__parse_events(int subtest); 55int test__parse_events(struct test *test, int subtest);
55int test__hists_link(int subtest); 56int test__hists_link(struct test *test, int subtest);
56int test__python_use(int subtest); 57int test__python_use(struct test *test, int subtest);
57int test__bp_signal(int subtest); 58int test__bp_signal(struct test *test, int subtest);
58int test__bp_signal_overflow(int subtest); 59int test__bp_signal_overflow(struct test *test, int subtest);
59int test__task_exit(int subtest); 60int test__task_exit(struct test *test, int subtest);
60int test__sw_clock_freq(int subtest); 61int test__mem(struct test *test, int subtest);
61int test__code_reading(int subtest); 62int test__sw_clock_freq(struct test *test, int subtest);
62int test__sample_parsing(int subtest); 63int test__code_reading(struct test *test, int subtest);
63int test__keep_tracking(int subtest); 64int test__sample_parsing(struct test *test, int subtest);
64int test__parse_no_sample_id_all(int subtest); 65int test__keep_tracking(struct test *test, int subtest);
65int test__dwarf_unwind(int subtest); 66int test__parse_no_sample_id_all(struct test *test, int subtest);
66int test__expr(int subtest); 67int test__dwarf_unwind(struct test *test, int subtest);
67int test__hists_filter(int subtest); 68int test__expr(struct test *test, int subtest);
68int test__mmap_thread_lookup(int subtest); 69int test__hists_filter(struct test *test, int subtest);
69int test__thread_mg_share(int subtest); 70int test__mmap_thread_lookup(struct test *test, int subtest);
70int test__hists_output(int subtest); 71int test__thread_mg_share(struct test *test, int subtest);
71int test__hists_cumulate(int subtest); 72int test__hists_output(struct test *test, int subtest);
72int test__switch_tracking(int subtest); 73int test__hists_cumulate(struct test *test, int subtest);
73int test__fdarray__filter(int subtest); 74int test__switch_tracking(struct test *test, int subtest);
74int test__fdarray__add(int subtest); 75int test__fdarray__filter(struct test *test, int subtest);
75int test__kmod_path__parse(int subtest); 76int test__fdarray__add(struct test *test, int subtest);
76int test__thread_map(int subtest); 77int test__kmod_path__parse(struct test *test, int subtest);
77int test__llvm(int subtest); 78int test__thread_map(struct test *test, int subtest);
79int test__llvm(struct test *test, int subtest);
78const char *test__llvm_subtest_get_desc(int subtest); 80const char *test__llvm_subtest_get_desc(int subtest);
79int test__llvm_subtest_get_nr(void); 81int test__llvm_subtest_get_nr(void);
80int test__bpf(int subtest); 82int test__bpf(struct test *test, int subtest);
81const char *test__bpf_subtest_get_desc(int subtest); 83const char *test__bpf_subtest_get_desc(int subtest);
82int test__bpf_subtest_get_nr(void); 84int test__bpf_subtest_get_nr(void);
83int test_session_topology(int subtest); 85int test__session_topology(struct test *test, int subtest);
84int test__thread_map_synthesize(int subtest); 86int test__thread_map_synthesize(struct test *test, int subtest);
85int test__thread_map_remove(int subtest); 87int test__thread_map_remove(struct test *test, int subtest);
86int test__cpu_map_synthesize(int subtest); 88int test__cpu_map_synthesize(struct test *test, int subtest);
87int test__synthesize_stat_config(int subtest); 89int test__synthesize_stat_config(struct test *test, int subtest);
88int test__synthesize_stat(int subtest); 90int test__synthesize_stat(struct test *test, int subtest);
89int test__synthesize_stat_round(int subtest); 91int test__synthesize_stat_round(struct test *test, int subtest);
90int test__event_update(int subtest); 92int test__event_update(struct test *test, int subtest);
91int test__event_times(int subtest); 93int test__event_times(struct test *test, int subtest);
92int test__backward_ring_buffer(int subtest); 94int test__backward_ring_buffer(struct test *test, int subtest);
93int test__cpu_map_print(int subtest); 95int test__cpu_map_print(struct test *test, int subtest);
94int test__sdt_event(int subtest); 96int test__sdt_event(struct test *test, int subtest);
95int test__is_printable_array(int subtest); 97int test__is_printable_array(struct test *test, int subtest);
96int test__bitmap_print(int subtest); 98int test__bitmap_print(struct test *test, int subtest);
97int test__perf_hooks(int subtest); 99int test__perf_hooks(struct test *test, int subtest);
98int test__clang(int subtest); 100int test__clang(struct test *test, int subtest);
99const char *test__clang_subtest_get_desc(int subtest); 101const char *test__clang_subtest_get_desc(int subtest);
100int test__clang_subtest_get_nr(void); 102int test__clang_subtest_get_nr(void);
101int test__unit_number__scnprint(int subtest); 103int test__unit_number__scnprint(struct test *test, int subtest);
102 104
103bool test__bp_signal_is_supported(void); 105bool test__bp_signal_is_supported(void);
104 106
diff --git a/tools/perf/tests/thread-map.c b/tools/perf/tests/thread-map.c
index a63d6945807b..b3423c744f46 100644
--- a/tools/perf/tests/thread-map.c
+++ b/tools/perf/tests/thread-map.c
@@ -9,7 +9,7 @@
9#define NAME (const char *) "perf" 9#define NAME (const char *) "perf"
10#define NAMEUL (unsigned long) NAME 10#define NAMEUL (unsigned long) NAME
11 11
12int test__thread_map(int subtest __maybe_unused) 12int test__thread_map(struct test *test __maybe_unused, int subtest __maybe_unused)
13{ 13{
14 struct thread_map *map; 14 struct thread_map *map;
15 15
@@ -76,7 +76,7 @@ static int process_event(struct perf_tool *tool __maybe_unused,
76 return 0; 76 return 0;
77} 77}
78 78
79int test__thread_map_synthesize(int subtest __maybe_unused) 79int test__thread_map_synthesize(struct test *test __maybe_unused, int subtest __maybe_unused)
80{ 80{
81 struct thread_map *threads; 81 struct thread_map *threads;
82 82
@@ -95,7 +95,7 @@ int test__thread_map_synthesize(int subtest __maybe_unused)
95 return 0; 95 return 0;
96} 96}
97 97
98int test__thread_map_remove(int subtest __maybe_unused) 98int test__thread_map_remove(struct test *test __maybe_unused, int subtest __maybe_unused)
99{ 99{
100 struct thread_map *threads; 100 struct thread_map *threads;
101 char *str; 101 char *str;
diff --git a/tools/perf/tests/thread-mg-share.c b/tools/perf/tests/thread-mg-share.c
index 76686dd6f5ec..b9c7f58db6c4 100644
--- a/tools/perf/tests/thread-mg-share.c
+++ b/tools/perf/tests/thread-mg-share.c
@@ -4,7 +4,7 @@
4#include "map.h" 4#include "map.h"
5#include "debug.h" 5#include "debug.h"
6 6
7int test__thread_mg_share(int subtest __maybe_unused) 7int test__thread_mg_share(struct test *test __maybe_unused, int subtest __maybe_unused)
8{ 8{
9 struct machines machines; 9 struct machines machines;
10 struct machine *machine; 10 struct machine *machine;
diff --git a/tools/perf/tests/topology.c b/tools/perf/tests/topology.c
index 803f893550d6..19b0561fd6f6 100644
--- a/tools/perf/tests/topology.c
+++ b/tools/perf/tests/topology.c
@@ -86,7 +86,7 @@ static int check_cpu_topology(char *path, struct cpu_map *map)
86 return 0; 86 return 0;
87} 87}
88 88
89int test_session_topology(int subtest __maybe_unused) 89int test__session_topology(struct test *test __maybe_unused, int subtest __maybe_unused)
90{ 90{
91 char path[PATH_MAX]; 91 char path[PATH_MAX];
92 struct cpu_map *map; 92 struct cpu_map *map;
diff --git a/tools/perf/tests/unit_number__scnprintf.c b/tools/perf/tests/unit_number__scnprintf.c
index 44589de084b8..15cd1cf8c129 100644
--- a/tools/perf/tests/unit_number__scnprintf.c
+++ b/tools/perf/tests/unit_number__scnprintf.c
@@ -5,7 +5,7 @@
5#include "units.h" 5#include "units.h"
6#include "debug.h" 6#include "debug.h"
7 7
8int test__unit_number__scnprint(int subtest __maybe_unused) 8int test__unit_number__scnprint(struct test *t __maybe_unused, int subtest __maybe_unused)
9{ 9{
10 struct { 10 struct {
11 u64 n; 11 u64 n;
diff --git a/tools/perf/tests/vmlinux-kallsyms.c b/tools/perf/tests/vmlinux-kallsyms.c
index 8456175fc234..86cb8868f67f 100644
--- a/tools/perf/tests/vmlinux-kallsyms.c
+++ b/tools/perf/tests/vmlinux-kallsyms.c
@@ -11,7 +11,7 @@
11 11
12#define UM(x) kallsyms_map->unmap_ip(kallsyms_map, (x)) 12#define UM(x) kallsyms_map->unmap_ip(kallsyms_map, (x))
13 13
14int test__vmlinux_matches_kallsyms(int subtest __maybe_unused) 14int test__vmlinux_matches_kallsyms(struct test *test __maybe_unused, int subtest __maybe_unused)
15{ 15{
16 int err = -1; 16 int err = -1;
17 struct rb_node *nd; 17 struct rb_node *nd;
diff --git a/tools/perf/trace/beauty/Build b/tools/perf/trace/beauty/Build
index be95ac6ce845..175d633c6b49 100644
--- a/tools/perf/trace/beauty/Build
+++ b/tools/perf/trace/beauty/Build
@@ -1 +1,7 @@
1libperf-y += clone.o
2libperf-y += fcntl.o
3ifeq ($(SRCARCH),$(filter $(SRCARCH),x86))
4libperf-y += ioctl.o
5endif
6libperf-y += pkey_alloc.o
1libperf-y += statx.o 7libperf-y += statx.o
diff --git a/tools/perf/trace/beauty/beauty.h b/tools/perf/trace/beauty/beauty.h
index cf50be3f17a4..4b58581a6053 100644
--- a/tools/perf/trace/beauty/beauty.h
+++ b/tools/perf/trace/beauty/beauty.h
@@ -1,13 +1,44 @@
1#ifndef _PERF_TRACE_BEAUTY_H 1#ifndef _PERF_TRACE_BEAUTY_H
2#define _PERF_TRACE_BEAUTY_H 2#define _PERF_TRACE_BEAUTY_H
3 3
4#include <linux/kernel.h>
4#include <linux/types.h> 5#include <linux/types.h>
5 6
7struct strarray {
8 int offset;
9 int nr_entries;
10 const char **entries;
11};
12
13#define DEFINE_STRARRAY(array) struct strarray strarray__##array = { \
14 .nr_entries = ARRAY_SIZE(array), \
15 .entries = array, \
16}
17
18#define DEFINE_STRARRAY_OFFSET(array, off) struct strarray strarray__##array = { \
19 .offset = off, \
20 .nr_entries = ARRAY_SIZE(array), \
21 .entries = array, \
22}
23
24size_t strarray__scnprintf(struct strarray *sa, char *bf, size_t size, const char *intfmt, int val);
25
6struct trace; 26struct trace;
7struct thread; 27struct thread;
8 28
29/**
30 * @val: value of syscall argument being formatted
31 * @args: All the args, use syscall_args__val(arg, nth) to access one
32 * @thread: tid state (maps, pid, tid, etc)
33 * @trace: 'perf trace' internals: all threads, etc
34 * @parm: private area, may be an strarray, for instance
35 * @idx: syscall arg idx (is this the first?)
36 * @mask: a syscall arg may mask another arg, see syscall_arg__scnprintf_futex_op
37 */
38
9struct syscall_arg { 39struct syscall_arg {
10 unsigned long val; 40 unsigned long val;
41 unsigned char *args;
11 struct thread *thread; 42 struct thread *thread;
12 struct trace *trace; 43 struct trace *trace;
13 void *parm; 44 void *parm;
@@ -15,10 +46,53 @@ struct syscall_arg {
15 u8 mask; 46 u8 mask;
16}; 47};
17 48
49unsigned long syscall_arg__val(struct syscall_arg *arg, u8 idx);
50
51size_t syscall_arg__scnprintf_strarrays(char *bf, size_t size, struct syscall_arg *arg);
52#define SCA_STRARRAYS syscall_arg__scnprintf_strarrays
53
54size_t syscall_arg__scnprintf_fd(char *bf, size_t size, struct syscall_arg *arg);
55#define SCA_FD syscall_arg__scnprintf_fd
56
57size_t syscall_arg__scnprintf_hex(char *bf, size_t size, struct syscall_arg *arg);
58#define SCA_HEX syscall_arg__scnprintf_hex
59
60size_t syscall_arg__scnprintf_int(char *bf, size_t size, struct syscall_arg *arg);
61#define SCA_INT syscall_arg__scnprintf_int
62
63size_t syscall_arg__scnprintf_long(char *bf, size_t size, struct syscall_arg *arg);
64#define SCA_LONG syscall_arg__scnprintf_long
65
66size_t syscall_arg__scnprintf_pid(char *bf, size_t size, struct syscall_arg *arg);
67#define SCA_PID syscall_arg__scnprintf_pid
68
69size_t syscall_arg__scnprintf_clone_flags(char *bf, size_t size, struct syscall_arg *arg);
70#define SCA_CLONE_FLAGS syscall_arg__scnprintf_clone_flags
71
72size_t syscall_arg__scnprintf_fcntl_cmd(char *bf, size_t size, struct syscall_arg *arg);
73#define SCA_FCNTL_CMD syscall_arg__scnprintf_fcntl_cmd
74
75size_t syscall_arg__scnprintf_fcntl_arg(char *bf, size_t size, struct syscall_arg *arg);
76#define SCA_FCNTL_ARG syscall_arg__scnprintf_fcntl_arg
77
78size_t syscall_arg__scnprintf_ioctl_cmd(char *bf, size_t size, struct syscall_arg *arg);
79#define SCA_IOCTL_CMD syscall_arg__scnprintf_ioctl_cmd
80
81size_t syscall_arg__scnprintf_pkey_alloc_access_rights(char *bf, size_t size, struct syscall_arg *arg);
82#define SCA_PKEY_ALLOC_ACCESS_RIGHTS syscall_arg__scnprintf_pkey_alloc_access_rights
83
84size_t syscall_arg__scnprintf_open_flags(char *bf, size_t size, struct syscall_arg *arg);
85#define SCA_OPEN_FLAGS syscall_arg__scnprintf_open_flags
86
18size_t syscall_arg__scnprintf_statx_flags(char *bf, size_t size, struct syscall_arg *arg); 87size_t syscall_arg__scnprintf_statx_flags(char *bf, size_t size, struct syscall_arg *arg);
19#define SCA_STATX_FLAGS syscall_arg__scnprintf_statx_flags 88#define SCA_STATX_FLAGS syscall_arg__scnprintf_statx_flags
20 89
21size_t syscall_arg__scnprintf_statx_mask(char *bf, size_t size, struct syscall_arg *arg); 90size_t syscall_arg__scnprintf_statx_mask(char *bf, size_t size, struct syscall_arg *arg);
22#define SCA_STATX_MASK syscall_arg__scnprintf_statx_mask 91#define SCA_STATX_MASK syscall_arg__scnprintf_statx_mask
23 92
93size_t open__scnprintf_flags(unsigned long flags, char *bf, size_t size);
94
95void syscall_arg__set_ret_scnprintf(struct syscall_arg *arg,
96 size_t (*ret_scnprintf)(char *bf, size_t size, struct syscall_arg *arg));
97
24#endif /* _PERF_TRACE_BEAUTY_H */ 98#endif /* _PERF_TRACE_BEAUTY_H */
diff --git a/tools/perf/trace/beauty/clone.c b/tools/perf/trace/beauty/clone.c
new file mode 100644
index 000000000000..d64d049ab991
--- /dev/null
+++ b/tools/perf/trace/beauty/clone.c
@@ -0,0 +1,75 @@
1/*
2 * trace/beauty/cone.c
3 *
4 * Copyright (C) 2017, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
5 *
6 * Released under the GPL v2. (and only v2, not any later version)
7 */
8
9#include "trace/beauty/beauty.h"
10#include <linux/kernel.h>
11#include <sys/types.h>
12#include <uapi/linux/sched.h>
13
14static size_t clone__scnprintf_flags(unsigned long flags, char *bf, size_t size)
15{
16 int printed = 0;
17
18#define P_FLAG(n) \
19 if (flags & CLONE_##n) { \
20 printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \
21 flags &= ~CLONE_##n; \
22 }
23
24 P_FLAG(VM);
25 P_FLAG(FS);
26 P_FLAG(FILES);
27 P_FLAG(SIGHAND);
28 P_FLAG(PTRACE);
29 P_FLAG(VFORK);
30 P_FLAG(PARENT);
31 P_FLAG(THREAD);
32 P_FLAG(NEWNS);
33 P_FLAG(SYSVSEM);
34 P_FLAG(SETTLS);
35 P_FLAG(PARENT_SETTID);
36 P_FLAG(CHILD_CLEARTID);
37 P_FLAG(DETACHED);
38 P_FLAG(UNTRACED);
39 P_FLAG(CHILD_SETTID);
40 P_FLAG(NEWCGROUP);
41 P_FLAG(NEWUTS);
42 P_FLAG(NEWIPC);
43 P_FLAG(NEWUSER);
44 P_FLAG(NEWPID);
45 P_FLAG(NEWNET);
46 P_FLAG(IO);
47#undef P_FLAG
48
49 if (flags)
50 printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags);
51
52 return printed;
53}
54
55size_t syscall_arg__scnprintf_clone_flags(char *bf, size_t size, struct syscall_arg *arg)
56{
57 unsigned long flags = arg->val;
58 enum syscall_clone_args {
59 SCC_FLAGS = (1 << 0),
60 SCC_CHILD_STACK = (1 << 1),
61 SCC_PARENT_TIDPTR = (1 << 2),
62 SCC_CHILD_TIDPTR = (1 << 3),
63 SCC_TLS = (1 << 4),
64 };
65 if (!(flags & CLONE_PARENT_SETTID))
66 arg->mask |= SCC_PARENT_TIDPTR;
67
68 if (!(flags & (CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID)))
69 arg->mask |= SCC_CHILD_TIDPTR;
70
71 if (!(flags & CLONE_SETTLS))
72 arg->mask |= SCC_TLS;
73
74 return clone__scnprintf_flags(flags, bf, size);
75}
diff --git a/tools/perf/trace/beauty/drm_ioctl.sh b/tools/perf/trace/beauty/drm_ioctl.sh
new file mode 100755
index 000000000000..2149d3a98e42
--- /dev/null
+++ b/tools/perf/trace/beauty/drm_ioctl.sh
@@ -0,0 +1,13 @@
1#!/bin/sh
2
3drm_header_dir=$1
4printf "#ifndef DRM_COMMAND_BASE\n"
5grep "#define DRM_COMMAND_BASE" $drm_header_dir/drm.h
6printf "#endif\n"
7
8printf "static const char *drm_ioctl_cmds[] = {\n"
9grep "^#define DRM_IOCTL.*DRM_IO" $drm_header_dir/drm.h | \
10 sed -r 's/^#define +DRM_IOCTL_([A-Z0-9_]+)[ ]+DRM_IO[A-Z]* *\( *(0x[[:xdigit:]]+),*.*/ [\2] = "\1",/g'
11grep "^#define DRM_I915_[A-Z_0-9]\+[ ]\+0x" $drm_header_dir/i915_drm.h | \
12 sed -r 's/^#define +DRM_I915_([A-Z0-9_]+)[ ]+(0x[[:xdigit:]]+)/\t[DRM_COMMAND_BASE + \2] = "I915_\1",/g'
13printf "};\n"
diff --git a/tools/perf/trace/beauty/fcntl.c b/tools/perf/trace/beauty/fcntl.c
new file mode 100644
index 000000000000..9e8900c13cb1
--- /dev/null
+++ b/tools/perf/trace/beauty/fcntl.c
@@ -0,0 +1,100 @@
1/*
2 * trace/beauty/fcntl.c
3 *
4 * Copyright (C) 2017, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
5 *
6 * Released under the GPL v2. (and only v2, not any later version)
7 */
8
9#include "trace/beauty/beauty.h"
10#include <linux/kernel.h>
11#include <uapi/linux/fcntl.h>
12
13static size_t fcntl__scnprintf_getfd(unsigned long val, char *bf, size_t size)
14{
15 return scnprintf(bf, size, "%s", val ? "CLOEXEC" : "0");
16}
17
18static size_t syscall_arg__scnprintf_fcntl_getfd(char *bf, size_t size, struct syscall_arg *arg)
19{
20 return fcntl__scnprintf_getfd(arg->val, bf, size);
21}
22
23static size_t fcntl__scnprintf_getlease(unsigned long val, char *bf, size_t size)
24{
25 static const char *fcntl_setlease[] = { "RDLCK", "WRLCK", "UNLCK", };
26 static DEFINE_STRARRAY(fcntl_setlease);
27
28 return strarray__scnprintf(&strarray__fcntl_setlease, bf, size, "%x", val);
29}
30
31static size_t syscall_arg__scnprintf_fcntl_getlease(char *bf, size_t size, struct syscall_arg *arg)
32{
33 return fcntl__scnprintf_getlease(arg->val, bf, size);
34}
35
36size_t syscall_arg__scnprintf_fcntl_cmd(char *bf, size_t size, struct syscall_arg *arg)
37{
38 if (arg->val == F_GETFL) {
39 syscall_arg__set_ret_scnprintf(arg, syscall_arg__scnprintf_open_flags);
40 goto mask_arg;
41 }
42 if (arg->val == F_GETFD) {
43 syscall_arg__set_ret_scnprintf(arg, syscall_arg__scnprintf_fcntl_getfd);
44 goto mask_arg;
45 }
46 if (arg->val == F_DUPFD_CLOEXEC || arg->val == F_DUPFD) {
47 syscall_arg__set_ret_scnprintf(arg, syscall_arg__scnprintf_fd);
48 goto out;
49 }
50 if (arg->val == F_GETOWN) {
51 syscall_arg__set_ret_scnprintf(arg, syscall_arg__scnprintf_pid);
52 goto mask_arg;
53 }
54 if (arg->val == F_GETLEASE) {
55 syscall_arg__set_ret_scnprintf(arg, syscall_arg__scnprintf_fcntl_getlease);
56 goto mask_arg;
57 }
58 /*
59 * Some commands ignore the third fcntl argument, "arg", so mask it
60 */
61 if (arg->val == F_GET_SEALS ||
62 arg->val == F_GETSIG) {
63mask_arg:
64 arg->mask |= (1 << 2);
65 }
66out:
67 return syscall_arg__scnprintf_strarrays(bf, size, arg);
68}
69
70size_t syscall_arg__scnprintf_fcntl_arg(char *bf, size_t size, struct syscall_arg *arg)
71{
72 int cmd = syscall_arg__val(arg, 1);
73
74 if (cmd == F_DUPFD)
75 return syscall_arg__scnprintf_fd(bf, size, arg);
76
77 if (cmd == F_SETFD)
78 return fcntl__scnprintf_getfd(arg->val, bf, size);
79
80 if (cmd == F_SETFL)
81 return open__scnprintf_flags(arg->val, bf, size);
82
83 if (cmd == F_SETOWN)
84 return syscall_arg__scnprintf_pid(bf, size, arg);
85
86 if (cmd == F_SETLEASE)
87 return fcntl__scnprintf_getlease(arg->val, bf, size);
88 /*
89 * We still don't grab the contents of pointers on entry or exit,
90 * so just print them as hex numbers
91 */
92 if (cmd == F_SETLK || cmd == F_SETLKW || cmd == F_GETLK ||
93 cmd == F_OFD_SETLK || cmd == F_OFD_SETLKW || cmd == F_OFD_GETLK ||
94 cmd == F_GETOWN_EX || cmd == F_SETOWN_EX ||
95 cmd == F_GET_RW_HINT || cmd == F_SET_RW_HINT ||
96 cmd == F_GET_FILE_RW_HINT || cmd == F_SET_FILE_RW_HINT)
97 return syscall_arg__scnprintf_hex(bf, size, arg);
98
99 return syscall_arg__scnprintf_long(bf, size, arg);
100}
diff --git a/tools/perf/trace/beauty/ioctl.c b/tools/perf/trace/beauty/ioctl.c
new file mode 100644
index 000000000000..1be3b4cf0827
--- /dev/null
+++ b/tools/perf/trace/beauty/ioctl.c
@@ -0,0 +1,162 @@
1/*
2 * trace/beauty/ioctl.c
3 *
4 * Copyright (C) 2017, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
5 *
6 * Released under the GPL v2. (and only v2, not any later version)
7 */
8
9#include "trace/beauty/beauty.h"
10#include <linux/kernel.h>
11
12/*
13 * FIXME: to support all arches we have to improve this, for
14 * now, to build on older systems without things like TIOCGEXCL,
15 * get it directly from our copy.
16 *
17 * Right now only x86 is being supported for beautifying ioctl args
18 * in 'perf trace', see tools/perf/trace/beauty/Build and builtin-trace.c
19 */
20#include <uapi/asm-generic/ioctls.h>
21
22static size_t ioctl__scnprintf_tty_cmd(int nr, int dir, char *bf, size_t size)
23{
24 static const char *ioctl_tty_cmd[] = {
25 "TCGETS", "TCSETS", "TCSETSW", "TCSETSF", "TCGETA", "TCSETA", "TCSETAW",
26 "TCSETAF", "TCSBRK", "TCXONC", "TCFLSH", "TIOCEXCL", "TIOCNXCL", "TIOCSCTTY",
27 "TIOCGPGRP", "TIOCSPGRP", "TIOCOUTQ", "TIOCSTI", "TIOCGWINSZ", "TIOCSWINSZ",
28 "TIOCMGET", "TIOCMBIS", "TIOCMBIC", "TIOCMSET", "TIOCGSOFTCAR", "TIOCSSOFTCAR",
29 "FIONREAD", "TIOCLINUX", "TIOCCONS", "TIOCGSERIAL", "TIOCSSERIAL", "TIOCPKT",
30 "FIONBIO", "TIOCNOTTY", "TIOCSETD", "TIOCGETD", "TCSBRKP",
31 [_IOC_NR(TIOCSBRK)] = "TIOCSBRK", "TIOCCBRK", "TIOCGSID", "TCGETS2", "TCSETS2",
32 "TCSETSW2", "TCSETSF2", "TIOCGRS48", "TIOCSRS485", "TIOCGPTN", "TIOCSPTLCK",
33 "TIOCGDEV", "TCSETX", "TCSETXF", "TCSETXW", "TIOCSIG", "TIOCVHANGUP", "TIOCGPKT",
34 "TIOCGPTLCK", [_IOC_NR(TIOCGEXCL)] = "TIOCGEXCL", "TIOCGPTPEER",
35 [_IOC_NR(FIONCLEX)] = "FIONCLEX", "FIOCLEX", "FIOASYNC", "TIOCSERCONFIG",
36 "TIOCSERGWILD", "TIOCSERSWILD", "TIOCGLCKTRMIOS", "TIOCSLCKTRMIOS",
37 "TIOCSERGSTRUCT", "TIOCSERGETLSR", "TIOCSERGETMULTI", "TIOCSERSETMULTI",
38 "TIOCMIWAIT", "TIOCGICOUNT", };
39 static DEFINE_STRARRAY(ioctl_tty_cmd);
40
41 if (nr < strarray__ioctl_tty_cmd.nr_entries && strarray__ioctl_tty_cmd.entries[nr] != NULL)
42 return scnprintf(bf, size, "%s", strarray__ioctl_tty_cmd.entries[nr]);
43
44 return scnprintf(bf, size, "(%#x, %#x, %#x)", 'T', nr, dir);
45}
46
47static size_t ioctl__scnprintf_drm_cmd(int nr, int dir, char *bf, size_t size)
48{
49#include "trace/beauty/generated/ioctl/drm_ioctl_array.c"
50 static DEFINE_STRARRAY(drm_ioctl_cmds);
51
52 if (nr < strarray__drm_ioctl_cmds.nr_entries && strarray__drm_ioctl_cmds.entries[nr] != NULL)
53 return scnprintf(bf, size, "DRM_%s", strarray__drm_ioctl_cmds.entries[nr]);
54
55 return scnprintf(bf, size, "(%#x, %#x, %#x)", 'd', nr, dir);
56}
57
58static size_t ioctl__scnprintf_sndrv_pcm_cmd(int nr, int dir, char *bf, size_t size)
59{
60#include "trace/beauty/generated/ioctl/sndrv_pcm_ioctl_array.c"
61 static DEFINE_STRARRAY(sndrv_pcm_ioctl_cmds);
62
63 if (nr < strarray__sndrv_pcm_ioctl_cmds.nr_entries && strarray__sndrv_pcm_ioctl_cmds.entries[nr] != NULL)
64 return scnprintf(bf, size, "SNDRV_PCM_%s", strarray__sndrv_pcm_ioctl_cmds.entries[nr]);
65
66 return scnprintf(bf, size, "(%#x, %#x, %#x)", 'A', nr, dir);
67}
68
69static size_t ioctl__scnprintf_sndrv_ctl_cmd(int nr, int dir, char *bf, size_t size)
70{
71#include "trace/beauty/generated/ioctl/sndrv_ctl_ioctl_array.c"
72 static DEFINE_STRARRAY(sndrv_ctl_ioctl_cmds);
73
74 if (nr < strarray__sndrv_ctl_ioctl_cmds.nr_entries && strarray__sndrv_ctl_ioctl_cmds.entries[nr] != NULL)
75 return scnprintf(bf, size, "SNDRV_CTL_%s", strarray__sndrv_ctl_ioctl_cmds.entries[nr]);
76
77 return scnprintf(bf, size, "(%#x, %#x, %#x)", 'U', nr, dir);
78}
79
80static size_t ioctl__scnprintf_kvm_cmd(int nr, int dir, char *bf, size_t size)
81{
82#include "trace/beauty/generated/ioctl/kvm_ioctl_array.c"
83 static DEFINE_STRARRAY(kvm_ioctl_cmds);
84
85 if (nr < strarray__kvm_ioctl_cmds.nr_entries && strarray__kvm_ioctl_cmds.entries[nr] != NULL)
86 return scnprintf(bf, size, "KVM_%s", strarray__kvm_ioctl_cmds.entries[nr]);
87
88 return scnprintf(bf, size, "(%#x, %#x, %#x)", 0xAE, nr, dir);
89}
90
91static size_t ioctl__scnprintf_vhost_virtio_cmd(int nr, int dir, char *bf, size_t size)
92{
93#include "trace/beauty/generated/ioctl/vhost_virtio_ioctl_array.c"
94 static DEFINE_STRARRAY(vhost_virtio_ioctl_cmds);
95 static DEFINE_STRARRAY(vhost_virtio_ioctl_read_cmds);
96 struct strarray *s = (dir & _IOC_READ) ? &strarray__vhost_virtio_ioctl_read_cmds : &strarray__vhost_virtio_ioctl_cmds;
97
98 if (nr < s->nr_entries && s->entries[nr] != NULL)
99 return scnprintf(bf, size, "VHOST_%s", s->entries[nr]);
100
101 return scnprintf(bf, size, "(%#x, %#x, %#x)", 0xAF, nr, dir);
102}
103
104static size_t ioctl__scnprintf_perf_cmd(int nr, int dir, char *bf, size_t size)
105{
106#include "trace/beauty/generated/ioctl/perf_ioctl_array.c"
107 static DEFINE_STRARRAY(perf_ioctl_cmds);
108
109 if (nr < strarray__perf_ioctl_cmds.nr_entries && strarray__perf_ioctl_cmds.entries[nr] != NULL)
110 return scnprintf(bf, size, "PERF_%s", strarray__perf_ioctl_cmds.entries[nr]);
111
112 return scnprintf(bf, size, "(%#x, %#x, %#x)", 0xAE, nr, dir);
113}
114
115static size_t ioctl__scnprintf_cmd(unsigned long cmd, char *bf, size_t size)
116{
117 int dir = _IOC_DIR(cmd),
118 type = _IOC_TYPE(cmd),
119 nr = _IOC_NR(cmd),
120 sz = _IOC_SIZE(cmd);
121 int printed = 0;
122 static const struct ioctl_type {
123 int type;
124 size_t (*scnprintf)(int nr, int dir, char *bf, size_t size);
125 } ioctl_types[] = { /* Must be ordered by type */
126 { .type = '$', .scnprintf = ioctl__scnprintf_perf_cmd, },
127 ['A' - '$'] = { .type = 'A', .scnprintf = ioctl__scnprintf_sndrv_pcm_cmd, },
128 ['T' - '$'] = { .type = 'T', .scnprintf = ioctl__scnprintf_tty_cmd, },
129 ['U' - '$'] = { .type = 'U', .scnprintf = ioctl__scnprintf_sndrv_ctl_cmd, },
130 ['d' - '$'] = { .type = 'd', .scnprintf = ioctl__scnprintf_drm_cmd, },
131 [0xAE - '$'] = { .type = 0xAE, .scnprintf = ioctl__scnprintf_kvm_cmd, },
132 [0xAF - '$'] = { .type = 0xAF, .scnprintf = ioctl__scnprintf_vhost_virtio_cmd, },
133 };
134 const int nr_types = ARRAY_SIZE(ioctl_types);
135
136 if (type >= ioctl_types[0].type && type <= ioctl_types[nr_types - 1].type) {
137 const int index = type - ioctl_types[0].type;
138
139 if (ioctl_types[index].scnprintf != NULL)
140 return ioctl_types[index].scnprintf(nr, dir, bf, size);
141 }
142
143 printed += scnprintf(bf + printed, size - printed, "%c", '(');
144
145 if (dir == _IOC_NONE) {
146 printed += scnprintf(bf + printed, size - printed, "%s", "NONE");
147 } else {
148 if (dir & _IOC_READ)
149 printed += scnprintf(bf + printed, size - printed, "%s", "READ");
150 if (dir & _IOC_WRITE)
151 printed += scnprintf(bf + printed, size - printed, "%s%s", dir & _IOC_READ ? "|" : "", "WRITE");
152 }
153
154 return printed + scnprintf(bf + printed, size - printed, ", %#x, %#x, %#x)", type, nr, sz);
155}
156
157size_t syscall_arg__scnprintf_ioctl_cmd(char *bf, size_t size, struct syscall_arg *arg)
158{
159 unsigned long cmd = arg->val;
160
161 return ioctl__scnprintf_cmd(cmd, bf, size);
162}
diff --git a/tools/perf/trace/beauty/kvm_ioctl.sh b/tools/perf/trace/beauty/kvm_ioctl.sh
new file mode 100755
index 000000000000..bd28817afced
--- /dev/null
+++ b/tools/perf/trace/beauty/kvm_ioctl.sh
@@ -0,0 +1,11 @@
1#!/bin/sh
2
3kvm_header_dir=$1
4
5printf "static const char *kvm_ioctl_cmds[] = {\n"
6regex='^#[[:space:]]*define[[:space:]]+KVM_(\w+)[[:space:]]+_IO[RW]*\([[:space:]]*KVMIO[[:space:]]*,[[:space:]]*(0x[[:xdigit:]]+).*'
7egrep $regex ${kvm_header_dir}/kvm.h | \
8 sed -r "s/$regex/\2 \1/g" | \
9 egrep -v " ((ARM|PPC|S390)_|[GS]ET_(DEBUGREGS|PIT2|XSAVE|TSC_KHZ)|CREATE_SPAPR_TCE_64)" | \
10 sort | xargs printf "\t[%s] = \"%s\",\n"
11printf "};\n"
diff --git a/tools/perf/trace/beauty/mmap.c b/tools/perf/trace/beauty/mmap.c
index af1cfde6b97b..754558f9009d 100644
--- a/tools/perf/trace/beauty/mmap.c
+++ b/tools/perf/trace/beauty/mmap.c
@@ -34,6 +34,9 @@ static size_t syscall_arg__scnprintf_mmap_flags(char *bf, size_t size,
34{ 34{
35 int printed = 0, flags = arg->val; 35 int printed = 0, flags = arg->val;
36 36
37 if (flags & MAP_ANONYMOUS)
38 arg->mask |= (1 << 4) | (1 << 5); /* Mask 4th ('fd') and 5th ('offset') args, ignored */
39
37#define P_MMAP_FLAG(n) \ 40#define P_MMAP_FLAG(n) \
38 if (flags & MAP_##n) { \ 41 if (flags & MAP_##n) { \
39 printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ 42 printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \
diff --git a/tools/perf/trace/beauty/open_flags.c b/tools/perf/trace/beauty/open_flags.c
index f55a4597fc38..e359e041dc0e 100644
--- a/tools/perf/trace/beauty/open_flags.c
+++ b/tools/perf/trace/beauty/open_flags.c
@@ -14,13 +14,16 @@
14#define O_NOATIME 01000000 14#define O_NOATIME 01000000
15#endif 15#endif
16 16
17static size_t syscall_arg__scnprintf_open_flags(char *bf, size_t size, 17#ifndef O_TMPFILE
18 struct syscall_arg *arg) 18#define O_TMPFILE 020000000
19{ 19#endif
20 int printed = 0, flags = arg->val;
21 20
22 if (!(flags & O_CREAT)) 21#undef O_LARGEFILE
23 arg->mask |= 1 << (arg->idx + 1); /* Mask the mode parm */ 22#define O_LARGEFILE 00100000
23
24size_t open__scnprintf_flags(unsigned long flags, char *bf, size_t size)
25{
26 int printed = 0;
24 27
25 if (flags == 0) 28 if (flags == 0)
26 return scnprintf(bf, size, "RDONLY"); 29 return scnprintf(bf, size, "RDONLY");
@@ -30,6 +33,7 @@ static size_t syscall_arg__scnprintf_open_flags(char *bf, size_t size,
30 flags &= ~O_##n; \ 33 flags &= ~O_##n; \
31 } 34 }
32 35
36 P_FLAG(RDWR);
33 P_FLAG(APPEND); 37 P_FLAG(APPEND);
34 P_FLAG(ASYNC); 38 P_FLAG(ASYNC);
35 P_FLAG(CLOEXEC); 39 P_FLAG(CLOEXEC);
@@ -38,6 +42,8 @@ static size_t syscall_arg__scnprintf_open_flags(char *bf, size_t size,
38 P_FLAG(DIRECTORY); 42 P_FLAG(DIRECTORY);
39 P_FLAG(EXCL); 43 P_FLAG(EXCL);
40 P_FLAG(LARGEFILE); 44 P_FLAG(LARGEFILE);
45 P_FLAG(NOFOLLOW);
46 P_FLAG(TMPFILE);
41 P_FLAG(NOATIME); 47 P_FLAG(NOATIME);
42 P_FLAG(NOCTTY); 48 P_FLAG(NOCTTY);
43#ifdef O_NONBLOCK 49#ifdef O_NONBLOCK
@@ -48,7 +54,6 @@ static size_t syscall_arg__scnprintf_open_flags(char *bf, size_t size,
48#ifdef O_PATH 54#ifdef O_PATH
49 P_FLAG(PATH); 55 P_FLAG(PATH);
50#endif 56#endif
51 P_FLAG(RDWR);
52#ifdef O_DSYNC 57#ifdef O_DSYNC
53 if ((flags & O_SYNC) == O_SYNC) 58 if ((flags & O_SYNC) == O_SYNC)
54 printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", "SYNC"); 59 printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", "SYNC");
@@ -68,4 +73,12 @@ static size_t syscall_arg__scnprintf_open_flags(char *bf, size_t size,
68 return printed; 73 return printed;
69} 74}
70 75
71#define SCA_OPEN_FLAGS syscall_arg__scnprintf_open_flags 76size_t syscall_arg__scnprintf_open_flags(char *bf, size_t size, struct syscall_arg *arg)
77{
78 int flags = arg->val;
79
80 if (!(flags & O_CREAT))
81 arg->mask |= 1 << (arg->idx + 1); /* Mask the mode parm */
82
83 return open__scnprintf_flags(flags, bf, size);
84}
diff --git a/tools/perf/trace/beauty/perf_ioctl.sh b/tools/perf/trace/beauty/perf_ioctl.sh
new file mode 100755
index 000000000000..faea4237c793
--- /dev/null
+++ b/tools/perf/trace/beauty/perf_ioctl.sh
@@ -0,0 +1,10 @@
1#!/bin/sh
2
3header_dir=$1
4
5printf "static const char *perf_ioctl_cmds[] = {\n"
6regex='^#[[:space:]]*define[[:space:]]+PERF_EVENT_IOC_(\w+)[[:space:]]+_IO[RW]*[[:space:]]*\([[:space:]]*.\$.[[:space:]]*,[[:space:]]*([[:digit:]]+).*'
7egrep $regex ${header_dir}/perf_event.h | \
8 sed -r "s/$regex/\2 \1/g" | \
9 sort | xargs printf "\t[%s] = \"%s\",\n"
10printf "};\n"
diff --git a/tools/perf/trace/beauty/pid.c b/tools/perf/trace/beauty/pid.c
index 07486ea65ae3..b6d419e16dcf 100644
--- a/tools/perf/trace/beauty/pid.c
+++ b/tools/perf/trace/beauty/pid.c
@@ -1,4 +1,4 @@
1static size_t syscall_arg__scnprintf_pid(char *bf, size_t size, struct syscall_arg *arg) 1size_t syscall_arg__scnprintf_pid(char *bf, size_t size, struct syscall_arg *arg)
2{ 2{
3 int pid = arg->val; 3 int pid = arg->val;
4 struct trace *trace = arg->trace; 4 struct trace *trace = arg->trace;
@@ -17,5 +17,3 @@ static size_t syscall_arg__scnprintf_pid(char *bf, size_t size, struct syscall_a
17 17
18 return printed; 18 return printed;
19} 19}
20
21#define SCA_PID syscall_arg__scnprintf_pid
diff --git a/tools/perf/trace/beauty/pkey_alloc.c b/tools/perf/trace/beauty/pkey_alloc.c
new file mode 100644
index 000000000000..2ba784a3734a
--- /dev/null
+++ b/tools/perf/trace/beauty/pkey_alloc.c
@@ -0,0 +1,50 @@
1/*
2 * trace/beauty/pkey_alloc.c
3 *
4 * Copyright (C) 2017, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
5 *
6 * Released under the GPL v2. (and only v2, not any later version)
7 */
8
9#include "trace/beauty/beauty.h"
10#include <linux/kernel.h>
11#include <linux/log2.h>
12
13static size_t pkey_alloc__scnprintf_access_rights(int access_rights, char *bf, size_t size)
14{
15 int i, printed = 0;
16
17#include "trace/beauty/generated/pkey_alloc_access_rights_array.c"
18 static DEFINE_STRARRAY(pkey_alloc_access_rights);
19
20 if (access_rights == 0) {
21 const char *s = strarray__pkey_alloc_access_rights.entries[0];
22 if (s)
23 return scnprintf(bf, size, "%s", s);
24 return scnprintf(bf, size, "%d", 0);
25 }
26
27 for (i = 1; i < strarray__pkey_alloc_access_rights.nr_entries; ++i) {
28 int bit = 1 << (i - 1);
29
30 if (!(access_rights & bit))
31 continue;
32
33 if (printed != 0)
34 printed += scnprintf(bf + printed, size - printed, "|");
35
36 if (strarray__pkey_alloc_access_rights.entries[i] != NULL)
37 printed += scnprintf(bf + printed, size - printed, "%s", strarray__pkey_alloc_access_rights.entries[i]);
38 else
39 printed += scnprintf(bf + printed, size - printed, "0x%#", bit);
40 }
41
42 return printed;
43}
44
45size_t syscall_arg__scnprintf_pkey_alloc_access_rights(char *bf, size_t size, struct syscall_arg *arg)
46{
47 unsigned long cmd = arg->val;
48
49 return pkey_alloc__scnprintf_access_rights(cmd, bf, size);
50}
diff --git a/tools/perf/trace/beauty/pkey_alloc_access_rights.sh b/tools/perf/trace/beauty/pkey_alloc_access_rights.sh
new file mode 100755
index 000000000000..62e51a02b839
--- /dev/null
+++ b/tools/perf/trace/beauty/pkey_alloc_access_rights.sh
@@ -0,0 +1,10 @@
1#!/bin/sh
2
3header_dir=$1
4
5printf "static const char *pkey_alloc_access_rights[] = {\n"
6regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+PKEY_([[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*'
7egrep $regex ${header_dir}/mman-common.h | \
8 sed -r "s/$regex/\2 \2 \1/g" | \
9 sort | xargs printf "\t[%s ? (ilog2(%s) + 1) : 0] = \"%s\",\n"
10printf "};\n"
diff --git a/tools/perf/trace/beauty/sndrv_ctl_ioctl.sh b/tools/perf/trace/beauty/sndrv_ctl_ioctl.sh
new file mode 100755
index 000000000000..aad5ab130539
--- /dev/null
+++ b/tools/perf/trace/beauty/sndrv_ctl_ioctl.sh
@@ -0,0 +1,8 @@
1#!/bin/sh
2
3sound_header_dir=$1
4
5printf "static const char *sndrv_ctl_ioctl_cmds[] = {\n"
6grep "^#define[\t ]\+SNDRV_CTL_IOCTL_" $sound_header_dir/asound.h | \
7 sed -r 's/^#define +SNDRV_CTL_IOCTL_([A-Z0-9_]+)[\t ]+_IO[RW]*\( *.U., *(0x[[:xdigit:]]+),?.*/\t[\2] = \"\1\",/g'
8printf "};\n"
diff --git a/tools/perf/trace/beauty/sndrv_pcm_ioctl.sh b/tools/perf/trace/beauty/sndrv_pcm_ioctl.sh
new file mode 100755
index 000000000000..b7e9ef6b2f55
--- /dev/null
+++ b/tools/perf/trace/beauty/sndrv_pcm_ioctl.sh
@@ -0,0 +1,8 @@
1#!/bin/sh
2
3sound_header_dir=$1
4
5printf "static const char *sndrv_pcm_ioctl_cmds[] = {\n"
6grep "^#define[\t ]\+SNDRV_PCM_IOCTL_" $sound_header_dir/asound.h | \
7 sed -r 's/^#define +SNDRV_PCM_IOCTL_([A-Z0-9_]+)[\t ]+_IO[RW]*\( *.A., *(0x[[:xdigit:]]+),?.*/\t[\2] = \"\1\",/g'
8printf "};\n"
diff --git a/tools/perf/trace/beauty/vhost_virtio_ioctl.sh b/tools/perf/trace/beauty/vhost_virtio_ioctl.sh
new file mode 100755
index 000000000000..76f1de697787
--- /dev/null
+++ b/tools/perf/trace/beauty/vhost_virtio_ioctl.sh
@@ -0,0 +1,17 @@
1#!/bin/sh
2
3vhost_virtio_header_dir=$1
4
5printf "static const char *vhost_virtio_ioctl_cmds[] = {\n"
6regex='^#[[:space:]]*define[[:space:]]+VHOST_(\w+)[[:space:]]+_IOW?\([[:space:]]*VHOST_VIRTIO[[:space:]]*,[[:space:]]*(0x[[:xdigit:]]+).*'
7egrep $regex ${vhost_virtio_header_dir}/vhost.h | \
8 sed -r "s/$regex/\2 \1/g" | \
9 sort | xargs printf "\t[%s] = \"%s\",\n"
10printf "};\n"
11
12printf "static const char *vhost_virtio_ioctl_read_cmds[] = {\n"
13regex='^#[[:space:]]*define[[:space:]]+VHOST_(\w+)[[:space:]]+_IOW?R\([[:space:]]*VHOST_VIRTIO[[:space:]]*,[[:space:]]*(0x[[:xdigit:]]+).*'
14egrep $regex ${vhost_virtio_header_dir}/vhost.h | \
15 sed -r "s/$regex/\2 \1/g" | \
16 sort | xargs printf "\t[%s] = \"%s\",\n"
17printf "};\n"
diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c
index 83874b0e266c..d0c2007c307b 100644
--- a/tools/perf/ui/browser.c
+++ b/tools/perf/ui/browser.c
@@ -8,6 +8,7 @@
8#include <linux/compiler.h> 8#include <linux/compiler.h>
9#include <linux/list.h> 9#include <linux/list.h>
10#include <linux/rbtree.h> 10#include <linux/rbtree.h>
11#include <linux/string.h>
11#include <stdlib.h> 12#include <stdlib.h>
12#include <sys/ttydefaults.h> 13#include <sys/ttydefaults.h>
13#include "browser.h" 14#include "browser.h"
@@ -563,7 +564,7 @@ static int ui_browser__color_config(const char *var, const char *value,
563 int i; 564 int i;
564 565
565 /* same dir for all commands */ 566 /* same dir for all commands */
566 if (prefixcmp(var, "colors.") != 0) 567 if (!strstarts(var, "colors.") != 0)
567 return 0; 568 return 0;
568 569
569 for (i = 0; ui_browser__colorsets[i].name != NULL; ++i) { 570 for (i = 0; ui_browser__colorsets[i].name != NULL; ++i) {
@@ -738,6 +739,35 @@ void __ui_browser__line_arrow(struct ui_browser *browser, unsigned int column,
738 __ui_browser__line_arrow_down(browser, column, start, end); 739 __ui_browser__line_arrow_down(browser, column, start, end);
739} 740}
740 741
742void ui_browser__mark_fused(struct ui_browser *browser, unsigned int column,
743 unsigned int row, bool arrow_down)
744{
745 unsigned int end_row;
746
747 if (row >= browser->top_idx)
748 end_row = row - browser->top_idx;
749 else
750 return;
751
752 SLsmg_set_char_set(1);
753
754 if (arrow_down) {
755 ui_browser__gotorc(browser, end_row, column - 1);
756 SLsmg_write_char(SLSMG_ULCORN_CHAR);
757 ui_browser__gotorc(browser, end_row, column);
758 SLsmg_draw_hline(2);
759 ui_browser__gotorc(browser, end_row + 1, column - 1);
760 SLsmg_write_char(SLSMG_LTEE_CHAR);
761 } else {
762 ui_browser__gotorc(browser, end_row, column - 1);
763 SLsmg_write_char(SLSMG_LTEE_CHAR);
764 ui_browser__gotorc(browser, end_row, column);
765 SLsmg_draw_hline(2);
766 }
767
768 SLsmg_set_char_set(0);
769}
770
741void ui_browser__init(void) 771void ui_browser__init(void)
742{ 772{
743 int i = 0; 773 int i = 0;
diff --git a/tools/perf/ui/browser.h b/tools/perf/ui/browser.h
index be3b70eb5fca..a12eff75638b 100644
--- a/tools/perf/ui/browser.h
+++ b/tools/perf/ui/browser.h
@@ -43,6 +43,8 @@ void ui_browser__printf(struct ui_browser *browser, const char *fmt, ...);
43void ui_browser__write_graph(struct ui_browser *browser, int graph); 43void ui_browser__write_graph(struct ui_browser *browser, int graph);
44void __ui_browser__line_arrow(struct ui_browser *browser, unsigned int column, 44void __ui_browser__line_arrow(struct ui_browser *browser, unsigned int column,
45 u64 start, u64 end); 45 u64 start, u64 end);
46void ui_browser__mark_fused(struct ui_browser *browser, unsigned int column,
47 unsigned int row, bool arrow_down);
46void __ui_browser__show_title(struct ui_browser *browser, const char *title); 48void __ui_browser__show_title(struct ui_browser *browser, const char *title);
47void ui_browser__show_title(struct ui_browser *browser, const char *title); 49void ui_browser__show_title(struct ui_browser *browser, const char *title);
48int ui_browser__show(struct ui_browser *browser, const char *title, 50int ui_browser__show(struct ui_browser *browser, const char *title,
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 27f41f28dcb4..786fecaf578e 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -9,14 +9,16 @@
9#include "../../util/symbol.h" 9#include "../../util/symbol.h"
10#include "../../util/evsel.h" 10#include "../../util/evsel.h"
11#include "../../util/config.h" 11#include "../../util/config.h"
12#include "../../util/evlist.h"
12#include <inttypes.h> 13#include <inttypes.h>
13#include <pthread.h> 14#include <pthread.h>
14#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/string.h>
15#include <sys/ttydefaults.h> 17#include <sys/ttydefaults.h>
16 18
17struct disasm_line_samples { 19struct disasm_line_samples {
18 double percent; 20 double percent;
19 u64 nr; 21 struct sym_hist_entry he;
20}; 22};
21 23
22#define IPC_WIDTH 6 24#define IPC_WIDTH 6
@@ -40,6 +42,7 @@ static struct annotate_browser_opt {
40 jump_arrows, 42 jump_arrows,
41 show_linenr, 43 show_linenr,
42 show_nr_jumps, 44 show_nr_jumps,
45 show_nr_samples,
43 show_total_period; 46 show_total_period;
44} annotate_browser__opts = { 47} annotate_browser__opts = {
45 .use_offset = true, 48 .use_offset = true,
@@ -108,11 +111,12 @@ static int annotate_browser__set_jumps_percent_color(struct annotate_browser *br
108 111
109static int annotate_browser__pcnt_width(struct annotate_browser *ab) 112static int annotate_browser__pcnt_width(struct annotate_browser *ab)
110{ 113{
111 int w = 7 * ab->nr_events; 114 return (annotate_browser__opts.show_total_period ? 12 : 7) * ab->nr_events;
115}
112 116
113 if (ab->have_cycles) 117static int annotate_browser__cycles_width(struct annotate_browser *ab)
114 w += IPC_WIDTH + CYCLES_WIDTH; 118{
115 return w; 119 return ab->have_cycles ? IPC_WIDTH + CYCLES_WIDTH : 0;
116} 120}
117 121
118static void annotate_browser__write(struct ui_browser *browser, void *entry, int row) 122static void annotate_browser__write(struct ui_browser *browser, void *entry, int row)
@@ -125,7 +129,8 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
125 (!current_entry || (browser->use_navkeypressed && 129 (!current_entry || (browser->use_navkeypressed &&
126 !browser->navkeypressed))); 130 !browser->navkeypressed)));
127 int width = browser->width, printed; 131 int width = browser->width, printed;
128 int i, pcnt_width = annotate_browser__pcnt_width(ab); 132 int i, pcnt_width = annotate_browser__pcnt_width(ab),
133 cycles_width = annotate_browser__cycles_width(ab);
129 double percent_max = 0.0; 134 double percent_max = 0.0;
130 char bf[256]; 135 char bf[256];
131 bool show_title = false; 136 bool show_title = false;
@@ -149,8 +154,11 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
149 bdl->samples[i].percent, 154 bdl->samples[i].percent,
150 current_entry); 155 current_entry);
151 if (annotate_browser__opts.show_total_period) { 156 if (annotate_browser__opts.show_total_period) {
157 ui_browser__printf(browser, "%11" PRIu64 " ",
158 bdl->samples[i].he.period);
159 } else if (annotate_browser__opts.show_nr_samples) {
152 ui_browser__printf(browser, "%6" PRIu64 " ", 160 ui_browser__printf(browser, "%6" PRIu64 " ",
153 bdl->samples[i].nr); 161 bdl->samples[i].he.nr_samples);
154 } else { 162 } else {
155 ui_browser__printf(browser, "%6.2f ", 163 ui_browser__printf(browser, "%6.2f ",
156 bdl->samples[i].percent); 164 bdl->samples[i].percent);
@@ -160,9 +168,12 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
160 ui_browser__set_percent_color(browser, 0, current_entry); 168 ui_browser__set_percent_color(browser, 0, current_entry);
161 169
162 if (!show_title) 170 if (!show_title)
163 ui_browser__write_nstring(browser, " ", 7 * ab->nr_events); 171 ui_browser__write_nstring(browser, " ", pcnt_width);
164 else 172 else {
165 ui_browser__printf(browser, "%*s", 7, "Percent"); 173 ui_browser__printf(browser, "%*s", pcnt_width,
174 annotate_browser__opts.show_total_period ? "Period" :
175 annotate_browser__opts.show_nr_samples ? "Samples" : "Percent");
176 }
166 } 177 }
167 if (ab->have_cycles) { 178 if (ab->have_cycles) {
168 if (dl->ipc) 179 if (dl->ipc)
@@ -188,7 +199,7 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
188 width += 1; 199 width += 1;
189 200
190 if (!*dl->line) 201 if (!*dl->line)
191 ui_browser__write_nstring(browser, " ", width - pcnt_width); 202 ui_browser__write_nstring(browser, " ", width - pcnt_width - cycles_width);
192 else if (dl->offset == -1) { 203 else if (dl->offset == -1) {
193 if (dl->line_nr && annotate_browser__opts.show_linenr) 204 if (dl->line_nr && annotate_browser__opts.show_linenr)
194 printed = scnprintf(bf, sizeof(bf), "%-*d ", 205 printed = scnprintf(bf, sizeof(bf), "%-*d ",
@@ -197,7 +208,7 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
197 printed = scnprintf(bf, sizeof(bf), "%*s ", 208 printed = scnprintf(bf, sizeof(bf), "%*s ",
198 ab->addr_width, " "); 209 ab->addr_width, " ");
199 ui_browser__write_nstring(browser, bf, printed); 210 ui_browser__write_nstring(browser, bf, printed);
200 ui_browser__write_nstring(browser, dl->line, width - printed - pcnt_width + 1); 211 ui_browser__write_nstring(browser, dl->line, width - printed - pcnt_width - cycles_width + 1);
201 } else { 212 } else {
202 u64 addr = dl->offset; 213 u64 addr = dl->offset;
203 int color = -1; 214 int color = -1;
@@ -254,7 +265,7 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
254 } 265 }
255 266
256 disasm_line__scnprintf(dl, bf, sizeof(bf), !annotate_browser__opts.use_offset); 267 disasm_line__scnprintf(dl, bf, sizeof(bf), !annotate_browser__opts.use_offset);
257 ui_browser__write_nstring(browser, bf, width - pcnt_width - 3 - printed); 268 ui_browser__write_nstring(browser, bf, width - pcnt_width - cycles_width - 3 - printed);
258 } 269 }
259 270
260 if (current_entry) 271 if (current_entry)
@@ -272,6 +283,25 @@ static bool disasm_line__is_valid_jump(struct disasm_line *dl, struct symbol *sy
272 return true; 283 return true;
273} 284}
274 285
286static bool is_fused(struct annotate_browser *ab, struct disasm_line *cursor)
287{
288 struct disasm_line *pos = list_prev_entry(cursor, node);
289 const char *name;
290
291 if (!pos)
292 return false;
293
294 if (ins__is_lock(&pos->ins))
295 name = pos->ops.locked.ins.name;
296 else
297 name = pos->ins.name;
298
299 if (!name || !cursor->ins.name)
300 return false;
301
302 return ins__is_fused(ab->arch, name, cursor->ins.name);
303}
304
275static void annotate_browser__draw_current_jump(struct ui_browser *browser) 305static void annotate_browser__draw_current_jump(struct ui_browser *browser)
276{ 306{
277 struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); 307 struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);
@@ -307,6 +337,13 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser)
307 ui_browser__set_color(browser, HE_COLORSET_JUMP_ARROWS); 337 ui_browser__set_color(browser, HE_COLORSET_JUMP_ARROWS);
308 __ui_browser__line_arrow(browser, pcnt_width + 2 + ab->addr_width, 338 __ui_browser__line_arrow(browser, pcnt_width + 2 + ab->addr_width,
309 from, to); 339 from, to);
340
341 if (is_fused(ab, cursor)) {
342 ui_browser__mark_fused(browser,
343 pcnt_width + 3 + ab->addr_width,
344 from - 1,
345 to > from ? true : false);
346 }
310} 347}
311 348
312static unsigned int annotate_browser__refresh(struct ui_browser *browser) 349static unsigned int annotate_browser__refresh(struct ui_browser *browser)
@@ -422,14 +459,14 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser,
422 next = disasm__get_next_ip_line(&notes->src->source, pos); 459 next = disasm__get_next_ip_line(&notes->src->source, pos);
423 460
424 for (i = 0; i < browser->nr_events; i++) { 461 for (i = 0; i < browser->nr_events; i++) {
425 u64 nr_samples; 462 struct sym_hist_entry sample;
426 463
427 bpos->samples[i].percent = disasm__calc_percent(notes, 464 bpos->samples[i].percent = disasm__calc_percent(notes,
428 evsel->idx + i, 465 evsel->idx + i,
429 pos->offset, 466 pos->offset,
430 next ? next->offset : len, 467 next ? next->offset : len,
431 &path, &nr_samples); 468 &path, &sample);
432 bpos->samples[i].nr = nr_samples; 469 bpos->samples[i].he = sample;
433 470
434 if (max_percent < bpos->samples[i].percent) 471 if (max_percent < bpos->samples[i].percent)
435 max_percent = bpos->samples[i].percent; 472 max_percent = bpos->samples[i].percent;
@@ -792,13 +829,14 @@ static int annotate_browser__run(struct annotate_browser *browser,
792 "q/ESC/CTRL+C Exit\n\n" 829 "q/ESC/CTRL+C Exit\n\n"
793 "ENTER Go to target\n" 830 "ENTER Go to target\n"
794 "ESC Exit\n" 831 "ESC Exit\n"
795 "H Cycle thru hottest instructions\n" 832 "H Go to hottest instruction\n"
833 "TAB/shift+TAB Cycle thru hottest instructions\n"
796 "j Toggle showing jump to target arrows\n" 834 "j Toggle showing jump to target arrows\n"
797 "J Toggle showing number of jump sources on targets\n" 835 "J Toggle showing number of jump sources on targets\n"
798 "n Search next string\n" 836 "n Search next string\n"
799 "o Toggle disassembler output/simplified view\n" 837 "o Toggle disassembler output/simplified view\n"
800 "s Toggle source code view\n" 838 "s Toggle source code view\n"
801 "t Toggle total period view\n" 839 "t Circulate percent, total period, samples view\n"
802 "/ Search string\n" 840 "/ Search string\n"
803 "k Toggle line numbers\n" 841 "k Toggle line numbers\n"
804 "r Run available scripts\n" 842 "r Run available scripts\n"
@@ -875,8 +913,13 @@ show_sup_ins:
875 } 913 }
876 continue; 914 continue;
877 case 't': 915 case 't':
878 annotate_browser__opts.show_total_period = 916 if (annotate_browser__opts.show_total_period) {
879 !annotate_browser__opts.show_total_period; 917 annotate_browser__opts.show_total_period = false;
918 annotate_browser__opts.show_nr_samples = true;
919 } else if (annotate_browser__opts.show_nr_samples)
920 annotate_browser__opts.show_nr_samples = false;
921 else
922 annotate_browser__opts.show_total_period = true;
880 annotate_browser__update_addr_width(browser); 923 annotate_browser__update_addr_width(browser);
881 continue; 924 continue;
882 case K_LEFT: 925 case K_LEFT:
@@ -899,9 +942,11 @@ out:
899int map_symbol__tui_annotate(struct map_symbol *ms, struct perf_evsel *evsel, 942int map_symbol__tui_annotate(struct map_symbol *ms, struct perf_evsel *evsel,
900 struct hist_browser_timer *hbt) 943 struct hist_browser_timer *hbt)
901{ 944{
902 /* Set default value for show_total_period. */ 945 /* Set default value for show_total_period and show_nr_samples */
903 annotate_browser__opts.show_total_period = 946 annotate_browser__opts.show_total_period =
904 symbol_conf.show_total_period; 947 symbol_conf.show_total_period;
948 annotate_browser__opts.show_nr_samples =
949 symbol_conf.show_nr_samples;
905 950
906 return symbol__tui_annotate(ms->sym, ms->map, evsel, hbt); 951 return symbol__tui_annotate(ms->sym, ms->map, evsel, hbt);
907} 952}
@@ -1074,7 +1119,8 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map,
1074 } 1119 }
1075 1120
1076 err = symbol__disassemble(sym, map, perf_evsel__env_arch(evsel), 1121 err = symbol__disassemble(sym, map, perf_evsel__env_arch(evsel),
1077 sizeof_bdl, &browser.arch); 1122 sizeof_bdl, &browser.arch,
1123 perf_evsel__env_cpuid(evsel));
1078 if (err) { 1124 if (err) {
1079 char msg[BUFSIZ]; 1125 char msg[BUFSIZ];
1080 symbol__strerror_disassemble(sym, map, err, msg, sizeof(msg)); 1126 symbol__strerror_disassemble(sym, map, err, msg, sizeof(msg));
@@ -1151,6 +1197,7 @@ static struct annotate_config {
1151 ANNOTATE_CFG(jump_arrows), 1197 ANNOTATE_CFG(jump_arrows),
1152 ANNOTATE_CFG(show_linenr), 1198 ANNOTATE_CFG(show_linenr),
1153 ANNOTATE_CFG(show_nr_jumps), 1199 ANNOTATE_CFG(show_nr_jumps),
1200 ANNOTATE_CFG(show_nr_samples),
1154 ANNOTATE_CFG(show_total_period), 1201 ANNOTATE_CFG(show_total_period),
1155 ANNOTATE_CFG(use_offset), 1202 ANNOTATE_CFG(use_offset),
1156}; 1203};
@@ -1170,7 +1217,7 @@ static int annotate__config(const char *var, const char *value,
1170 struct annotate_config *cfg; 1217 struct annotate_config *cfg;
1171 const char *name; 1218 const char *name;
1172 1219
1173 if (prefixcmp(var, "annotate.") != 0) 1220 if (!strstarts(var, "annotate."))
1174 return 0; 1221 return 0;
1175 1222
1176 name = var + 9; 1223 name = var + 9;
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 69f4570bd4f9..13dfb0a0bdeb 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -166,9 +166,6 @@ static struct inline_node *inline_node__create(struct map *map, u64 ip)
166 if (dso == NULL) 166 if (dso == NULL)
167 return NULL; 167 return NULL;
168 168
169 if (dso->kernel != DSO_TYPE_USER)
170 return NULL;
171
172 node = dso__parse_addr_inlines(dso, 169 node = dso__parse_addr_inlines(dso,
173 map__rip_2objdump(map, ip)); 170 map__rip_2objdump(map, ip));
174 171
@@ -934,12 +931,8 @@ static int hist_browser__show_callchain_list(struct hist_browser *browser,
934 browser->show_dso); 931 browser->show_dso);
935 932
936 if (symbol_conf.show_branchflag_count) { 933 if (symbol_conf.show_branchflag_count) {
937 if (need_percent) 934 callchain_list_counts__printf_value(chain, NULL,
938 callchain_list_counts__printf_value(node, chain, NULL, 935 buf, sizeof(buf));
939 buf, sizeof(buf));
940 else
941 callchain_list_counts__printf_value(NULL, chain, NULL,
942 buf, sizeof(buf));
943 936
944 if (asprintf(&alloc_str2, "%s%s", str, buf) < 0) 937 if (asprintf(&alloc_str2, "%s%s", str, buf) < 0)
945 str = "Not enough memory!"; 938 str = "Not enough memory!";
diff --git a/tools/perf/ui/gtk/annotate.c b/tools/perf/ui/gtk/annotate.c
index d903fd493416..02176193f427 100644
--- a/tools/perf/ui/gtk/annotate.c
+++ b/tools/perf/ui/gtk/annotate.c
@@ -34,10 +34,10 @@ static int perf_gtk__get_percent(char *buf, size_t size, struct symbol *sym,
34 return 0; 34 return 0;
35 35
36 symhist = annotation__histogram(symbol__annotation(sym), evidx); 36 symhist = annotation__histogram(symbol__annotation(sym), evidx);
37 if (!symbol_conf.event_group && !symhist->addr[dl->offset]) 37 if (!symbol_conf.event_group && !symhist->addr[dl->offset].nr_samples)
38 return 0; 38 return 0;
39 39
40 percent = 100.0 * symhist->addr[dl->offset] / symhist->sum; 40 percent = 100.0 * symhist->addr[dl->offset].nr_samples / symhist->nr_samples;
41 41
42 markup = perf_gtk__get_percent_color(percent); 42 markup = perf_gtk__get_percent_color(percent);
43 if (markup) 43 if (markup)
@@ -169,7 +169,7 @@ static int symbol__gtk_annotate(struct symbol *sym, struct map *map,
169 return -1; 169 return -1;
170 170
171 err = symbol__disassemble(sym, map, perf_evsel__env_arch(evsel), 171 err = symbol__disassemble(sym, map, perf_evsel__env_arch(evsel),
172 0, NULL); 172 0, NULL, NULL);
173 if (err) { 173 if (err) {
174 char msg[BUFSIZ]; 174 char msg[BUFSIZ];
175 symbol__strerror_disassemble(sym, map, err, msg, sizeof(msg)); 175 symbol__strerror_disassemble(sym, map, err, msg, sizeof(msg));
diff --git a/tools/perf/ui/progress.c b/tools/perf/ui/progress.c
index a0f24c7115c5..ae91c8148edf 100644
--- a/tools/perf/ui/progress.c
+++ b/tools/perf/ui/progress.c
@@ -1,3 +1,4 @@
1#include <linux/kernel.h>
1#include "../cache.h" 2#include "../cache.h"
2#include "progress.h" 3#include "progress.h"
3 4
@@ -14,10 +15,14 @@ struct ui_progress_ops *ui_progress__ops = &null_progress__ops;
14 15
15void ui_progress__update(struct ui_progress *p, u64 adv) 16void ui_progress__update(struct ui_progress *p, u64 adv)
16{ 17{
18 u64 last = p->curr;
19
17 p->curr += adv; 20 p->curr += adv;
18 21
19 if (p->curr >= p->next) { 22 if (p->curr >= p->next) {
20 p->next += p->step; 23 u64 nr = DIV_ROUND_UP(p->curr - last, p->step);
24
25 p->next += nr * p->step;
21 ui_progress__ops->update(p); 26 ui_progress__ops->update(p);
22 } 27 }
23} 28}
@@ -25,7 +30,7 @@ void ui_progress__update(struct ui_progress *p, u64 adv)
25void ui_progress__init(struct ui_progress *p, u64 total, const char *title) 30void ui_progress__init(struct ui_progress *p, u64 total, const char *title)
26{ 31{
27 p->curr = 0; 32 p->curr = 0;
28 p->next = p->step = total / 16; 33 p->next = p->step = total / 16 ?: 1;
29 p->total = total; 34 p->total = total;
30 p->title = title; 35 p->title = title;
31 36
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index 42e432bd2eb4..8bdb7a500181 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -1,4 +1,5 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <linux/string.h>
2 3
3#include "../../util/util.h" 4#include "../../util/util.h"
4#include "../../util/hist.h" 5#include "../../util/hist.h"
@@ -35,9 +36,6 @@ static size_t inline__fprintf(struct map *map, u64 ip, int left_margin,
35 if (dso == NULL) 36 if (dso == NULL)
36 return 0; 37 return 0;
37 38
38 if (dso->kernel != DSO_TYPE_USER)
39 return 0;
40
41 node = dso__parse_addr_inlines(dso, 39 node = dso__parse_addr_inlines(dso,
42 map__rip_2objdump(map, ip)); 40 map__rip_2objdump(map, ip));
43 if (node == NULL) 41 if (node == NULL)
@@ -126,12 +124,8 @@ static size_t ipchain__fprintf_graph(FILE *fp, struct callchain_node *node,
126 str = callchain_list__sym_name(chain, bf, sizeof(bf), false); 124 str = callchain_list__sym_name(chain, bf, sizeof(bf), false);
127 125
128 if (symbol_conf.show_branchflag_count) { 126 if (symbol_conf.show_branchflag_count) {
129 if (!period) 127 callchain_list_counts__printf_value(chain, NULL,
130 callchain_list_counts__printf_value(node, chain, NULL, 128 buf, sizeof(buf));
131 buf, sizeof(buf));
132 else
133 callchain_list_counts__printf_value(NULL, chain, NULL,
134 buf, sizeof(buf));
135 129
136 if (asprintf(&alloc_str, "%s%s", str, buf) < 0) 130 if (asprintf(&alloc_str, "%s%s", str, buf) < 0)
137 str = "Not enough memory!"; 131 str = "Not enough memory!";
@@ -295,7 +289,7 @@ static size_t callchain__fprintf_graph(FILE *fp, struct rb_root *root,
295 * displayed twice. 289 * displayed twice.
296 */ 290 */
297 if (!i++ && field_order == NULL && 291 if (!i++ && field_order == NULL &&
298 sort_order && !prefixcmp(sort_order, "sym")) 292 sort_order && strstarts(sort_order, "sym"))
299 continue; 293 continue;
300 294
301 if (!printed) { 295 if (!printed) {
@@ -315,7 +309,7 @@ static size_t callchain__fprintf_graph(FILE *fp, struct rb_root *root,
315 309
316 if (symbol_conf.show_branchflag_count) 310 if (symbol_conf.show_branchflag_count)
317 ret += callchain_list_counts__printf_value( 311 ret += callchain_list_counts__printf_value(
318 NULL, chain, fp, NULL, 0); 312 chain, fp, NULL, 0);
319 ret += fprintf(fp, "\n"); 313 ret += fprintf(fp, "\n");
320 314
321 if (++entries_printed == callchain_param.print_limit) 315 if (++entries_printed == callchain_param.print_limit)
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index 79dea95a7f68..94518c1bf8b6 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -22,6 +22,7 @@ libperf-y += rbtree.o
22libperf-y += libstring.o 22libperf-y += libstring.o
23libperf-y += bitmap.o 23libperf-y += bitmap.o
24libperf-y += hweight.o 24libperf-y += hweight.o
25libperf-y += smt.o
25libperf-y += quote.o 26libperf-y += quote.o
26libperf-y += strbuf.o 27libperf-y += strbuf.o
27libperf-y += string.o 28libperf-y += string.o
@@ -93,6 +94,7 @@ libperf-y += drv_configs.o
93libperf-y += units.o 94libperf-y += units.o
94libperf-y += time-utils.o 95libperf-y += time-utils.o
95libperf-y += expr-bison.o 96libperf-y += expr-bison.o
97libperf-y += branch.o
96 98
97libperf-$(CONFIG_LIBBPF) += bpf-loader.o 99libperf-$(CONFIG_LIBBPF) += bpf-loader.o
98libperf-$(CONFIG_BPF_PROLOGUE) += bpf-prologue.o 100libperf-$(CONFIG_BPF_PROLOGUE) += bpf-prologue.o
@@ -104,6 +106,10 @@ ifndef CONFIG_LIBELF
104libperf-y += symbol-minimal.o 106libperf-y += symbol-minimal.o
105endif 107endif
106 108
109ifndef CONFIG_SETNS
110libperf-y += setns.o
111endif
112
107libperf-$(CONFIG_DWARF) += probe-finder.o 113libperf-$(CONFIG_DWARF) += probe-finder.o
108libperf-$(CONFIG_DWARF) += dwarf-aux.o 114libperf-$(CONFIG_DWARF) += dwarf-aux.o
109libperf-$(CONFIG_DWARF) += dwarf-regs.o 115libperf-$(CONFIG_DWARF) += dwarf-regs.o
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index be1caabb9290..4397a8b6e6cd 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -47,7 +47,12 @@ struct arch {
47 bool sorted_instructions; 47 bool sorted_instructions;
48 bool initialized; 48 bool initialized;
49 void *priv; 49 void *priv;
50 unsigned int model;
51 unsigned int family;
50 int (*init)(struct arch *arch); 52 int (*init)(struct arch *arch);
53 bool (*ins_is_fused)(struct arch *arch, const char *ins1,
54 const char *ins2);
55 int (*cpuid_parse)(struct arch *arch, char *cpuid);
51 struct { 56 struct {
52 char comment_char; 57 char comment_char;
53 char skip_functions_char; 58 char skip_functions_char;
@@ -129,6 +134,8 @@ static struct arch architectures[] = {
129 .name = "x86", 134 .name = "x86",
130 .instructions = x86__instructions, 135 .instructions = x86__instructions,
131 .nr_instructions = ARRAY_SIZE(x86__instructions), 136 .nr_instructions = ARRAY_SIZE(x86__instructions),
137 .ins_is_fused = x86__ins_is_fused,
138 .cpuid_parse = x86__cpuid_parse,
132 .objdump = { 139 .objdump = {
133 .comment_char = '#', 140 .comment_char = '#',
134 }, 141 },
@@ -171,6 +178,14 @@ int ins__scnprintf(struct ins *ins, char *bf, size_t size,
171 return ins__raw_scnprintf(ins, bf, size, ops); 178 return ins__raw_scnprintf(ins, bf, size, ops);
172} 179}
173 180
181bool ins__is_fused(struct arch *arch, const char *ins1, const char *ins2)
182{
183 if (!arch || !arch->ins_is_fused)
184 return false;
185
186 return arch->ins_is_fused(arch, ins1, ins2);
187}
188
174static int call__parse(struct arch *arch, struct ins_operands *ops, struct map *map) 189static int call__parse(struct arch *arch, struct ins_operands *ops, struct map *map)
175{ 190{
176 char *endptr, *tok, *name; 191 char *endptr, *tok, *name;
@@ -502,6 +517,11 @@ bool ins__is_ret(const struct ins *ins)
502 return ins->ops == &ret_ops; 517 return ins->ops == &ret_ops;
503} 518}
504 519
520bool ins__is_lock(const struct ins *ins)
521{
522 return ins->ops == &lock_ops;
523}
524
505static int ins__key_cmp(const void *name, const void *insp) 525static int ins__key_cmp(const void *name, const void *insp)
506{ 526{
507 const struct ins *ins = insp; 527 const struct ins *ins = insp;
@@ -590,10 +610,10 @@ int symbol__alloc_hist(struct symbol *sym)
590 size_t sizeof_sym_hist; 610 size_t sizeof_sym_hist;
591 611
592 /* Check for overflow when calculating sizeof_sym_hist */ 612 /* Check for overflow when calculating sizeof_sym_hist */
593 if (size > (SIZE_MAX - sizeof(struct sym_hist)) / sizeof(u64)) 613 if (size > (SIZE_MAX - sizeof(struct sym_hist)) / sizeof(struct sym_hist_entry))
594 return -1; 614 return -1;
595 615
596 sizeof_sym_hist = (sizeof(struct sym_hist) + size * sizeof(u64)); 616 sizeof_sym_hist = (sizeof(struct sym_hist) + size * sizeof(struct sym_hist_entry));
597 617
598 /* Check for overflow in zalloc argument */ 618 /* Check for overflow in zalloc argument */
599 if (sizeof_sym_hist > (SIZE_MAX - sizeof(*notes->src)) 619 if (sizeof_sym_hist > (SIZE_MAX - sizeof(*notes->src))
@@ -677,7 +697,8 @@ static int __symbol__account_cycles(struct annotation *notes,
677} 697}
678 698
679static int __symbol__inc_addr_samples(struct symbol *sym, struct map *map, 699static int __symbol__inc_addr_samples(struct symbol *sym, struct map *map,
680 struct annotation *notes, int evidx, u64 addr) 700 struct annotation *notes, int evidx, u64 addr,
701 struct perf_sample *sample)
681{ 702{
682 unsigned offset; 703 unsigned offset;
683 struct sym_hist *h; 704 struct sym_hist *h;
@@ -693,12 +714,15 @@ static int __symbol__inc_addr_samples(struct symbol *sym, struct map *map,
693 714
694 offset = addr - sym->start; 715 offset = addr - sym->start;
695 h = annotation__histogram(notes, evidx); 716 h = annotation__histogram(notes, evidx);
696 h->sum++; 717 h->nr_samples++;
697 h->addr[offset]++; 718 h->addr[offset].nr_samples++;
719 h->period += sample->period;
720 h->addr[offset].period += sample->period;
698 721
699 pr_debug3("%#" PRIx64 " %s: period++ [addr: %#" PRIx64 ", %#" PRIx64 722 pr_debug3("%#" PRIx64 " %s: period++ [addr: %#" PRIx64 ", %#" PRIx64
700 ", evidx=%d] => %" PRIu64 "\n", sym->start, sym->name, 723 ", evidx=%d] => nr_samples: %" PRIu64 ", period: %" PRIu64 "\n",
701 addr, addr - sym->start, evidx, h->addr[offset]); 724 sym->start, sym->name, addr, addr - sym->start, evidx,
725 h->addr[offset].nr_samples, h->addr[offset].period);
702 return 0; 726 return 0;
703} 727}
704 728
@@ -718,7 +742,8 @@ static struct annotation *symbol__get_annotation(struct symbol *sym, bool cycles
718} 742}
719 743
720static int symbol__inc_addr_samples(struct symbol *sym, struct map *map, 744static int symbol__inc_addr_samples(struct symbol *sym, struct map *map,
721 int evidx, u64 addr) 745 int evidx, u64 addr,
746 struct perf_sample *sample)
722{ 747{
723 struct annotation *notes; 748 struct annotation *notes;
724 749
@@ -727,7 +752,7 @@ static int symbol__inc_addr_samples(struct symbol *sym, struct map *map,
727 notes = symbol__get_annotation(sym, false); 752 notes = symbol__get_annotation(sym, false);
728 if (notes == NULL) 753 if (notes == NULL)
729 return -ENOMEM; 754 return -ENOMEM;
730 return __symbol__inc_addr_samples(sym, map, notes, evidx, addr); 755 return __symbol__inc_addr_samples(sym, map, notes, evidx, addr, sample);
731} 756}
732 757
733static int symbol__account_cycles(u64 addr, u64 start, 758static int symbol__account_cycles(u64 addr, u64 start,
@@ -791,14 +816,16 @@ int addr_map_symbol__account_cycles(struct addr_map_symbol *ams,
791 return err; 816 return err;
792} 817}
793 818
794int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, int evidx) 819int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, struct perf_sample *sample,
820 int evidx)
795{ 821{
796 return symbol__inc_addr_samples(ams->sym, ams->map, evidx, ams->al_addr); 822 return symbol__inc_addr_samples(ams->sym, ams->map, evidx, ams->al_addr, sample);
797} 823}
798 824
799int hist_entry__inc_addr_samples(struct hist_entry *he, int evidx, u64 ip) 825int hist_entry__inc_addr_samples(struct hist_entry *he, struct perf_sample *sample,
826 int evidx, u64 ip)
800{ 827{
801 return symbol__inc_addr_samples(he->ms.sym, he->ms.map, evidx, ip); 828 return symbol__inc_addr_samples(he->ms.sym, he->ms.map, evidx, ip, sample);
802} 829}
803 830
804static void disasm_line__init_ins(struct disasm_line *dl, struct arch *arch, struct map *map) 831static void disasm_line__init_ins(struct disasm_line *dl, struct arch *arch, struct map *map)
@@ -908,11 +935,12 @@ struct disasm_line *disasm__get_next_ip_line(struct list_head *head, struct disa
908} 935}
909 936
910double disasm__calc_percent(struct annotation *notes, int evidx, s64 offset, 937double disasm__calc_percent(struct annotation *notes, int evidx, s64 offset,
911 s64 end, const char **path, u64 *nr_samples) 938 s64 end, const char **path, struct sym_hist_entry *sample)
912{ 939{
913 struct source_line *src_line = notes->src->lines; 940 struct source_line *src_line = notes->src->lines;
914 double percent = 0.0; 941 double percent = 0.0;
915 *nr_samples = 0; 942
943 sample->nr_samples = sample->period = 0;
916 944
917 if (src_line) { 945 if (src_line) {
918 size_t sizeof_src_line = sizeof(*src_line) + 946 size_t sizeof_src_line = sizeof(*src_line) +
@@ -926,19 +954,24 @@ double disasm__calc_percent(struct annotation *notes, int evidx, s64 offset,
926 *path = src_line->path; 954 *path = src_line->path;
927 955
928 percent += src_line->samples[evidx].percent; 956 percent += src_line->samples[evidx].percent;
929 *nr_samples += src_line->samples[evidx].nr; 957 sample->nr_samples += src_line->samples[evidx].nr;
930 offset++; 958 offset++;
931 } 959 }
932 } else { 960 } else {
933 struct sym_hist *h = annotation__histogram(notes, evidx); 961 struct sym_hist *h = annotation__histogram(notes, evidx);
934 unsigned int hits = 0; 962 unsigned int hits = 0;
963 u64 period = 0;
935 964
936 while (offset < end) 965 while (offset < end) {
937 hits += h->addr[offset++]; 966 hits += h->addr[offset].nr_samples;
967 period += h->addr[offset].period;
968 ++offset;
969 }
938 970
939 if (h->sum) { 971 if (h->nr_samples) {
940 *nr_samples = hits; 972 sample->period = period;
941 percent = 100.0 * hits / h->sum; 973 sample->nr_samples = hits;
974 percent = 100.0 * hits / h->nr_samples;
942 } 975 }
943 } 976 }
944 977
@@ -1037,10 +1070,10 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st
1037 1070
1038 if (dl->offset != -1) { 1071 if (dl->offset != -1) {
1039 const char *path = NULL; 1072 const char *path = NULL;
1040 u64 nr_samples;
1041 double percent, max_percent = 0.0; 1073 double percent, max_percent = 0.0;
1042 double *ppercents = &percent; 1074 double *ppercents = &percent;
1043 u64 *psamples = &nr_samples; 1075 struct sym_hist_entry sample;
1076 struct sym_hist_entry *psamples = &sample;
1044 int i, nr_percent = 1; 1077 int i, nr_percent = 1;
1045 const char *color; 1078 const char *color;
1046 struct annotation *notes = symbol__annotation(sym); 1079 struct annotation *notes = symbol__annotation(sym);
@@ -1054,7 +1087,7 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st
1054 if (perf_evsel__is_group_event(evsel)) { 1087 if (perf_evsel__is_group_event(evsel)) {
1055 nr_percent = evsel->nr_members; 1088 nr_percent = evsel->nr_members;
1056 ppercents = calloc(nr_percent, sizeof(double)); 1089 ppercents = calloc(nr_percent, sizeof(double));
1057 psamples = calloc(nr_percent, sizeof(u64)); 1090 psamples = calloc(nr_percent, sizeof(struct sym_hist_entry));
1058 if (ppercents == NULL || psamples == NULL) { 1091 if (ppercents == NULL || psamples == NULL) {
1059 return -1; 1092 return -1;
1060 } 1093 }
@@ -1065,10 +1098,10 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st
1065 notes->src->lines ? i : evsel->idx + i, 1098 notes->src->lines ? i : evsel->idx + i,
1066 offset, 1099 offset,
1067 next ? next->offset : (s64) len, 1100 next ? next->offset : (s64) len,
1068 &path, &nr_samples); 1101 &path, &sample);
1069 1102
1070 ppercents[i] = percent; 1103 ppercents[i] = percent;
1071 psamples[i] = nr_samples; 1104 psamples[i] = sample;
1072 if (percent > max_percent) 1105 if (percent > max_percent)
1073 max_percent = percent; 1106 max_percent = percent;
1074 } 1107 }
@@ -1106,12 +1139,15 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st
1106 1139
1107 for (i = 0; i < nr_percent; i++) { 1140 for (i = 0; i < nr_percent; i++) {
1108 percent = ppercents[i]; 1141 percent = ppercents[i];
1109 nr_samples = psamples[i]; 1142 sample = psamples[i];
1110 color = get_percent_color(percent); 1143 color = get_percent_color(percent);
1111 1144
1112 if (symbol_conf.show_total_period) 1145 if (symbol_conf.show_total_period)
1146 color_fprintf(stdout, color, " %11" PRIu64,
1147 sample.period);
1148 else if (symbol_conf.show_nr_samples)
1113 color_fprintf(stdout, color, " %7" PRIu64, 1149 color_fprintf(stdout, color, " %7" PRIu64,
1114 nr_samples); 1150 sample.nr_samples);
1115 else 1151 else
1116 color_fprintf(stdout, color, " %7.2f", percent); 1152 color_fprintf(stdout, color, " %7.2f", percent);
1117 } 1153 }
@@ -1127,13 +1163,13 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st
1127 if (ppercents != &percent) 1163 if (ppercents != &percent)
1128 free(ppercents); 1164 free(ppercents);
1129 1165
1130 if (psamples != &nr_samples) 1166 if (psamples != &sample)
1131 free(psamples); 1167 free(psamples);
1132 1168
1133 } else if (max_lines && printed >= max_lines) 1169 } else if (max_lines && printed >= max_lines)
1134 return 1; 1170 return 1;
1135 else { 1171 else {
1136 int width = 8; 1172 int width = symbol_conf.show_total_period ? 12 : 8;
1137 1173
1138 if (queue) 1174 if (queue)
1139 return -1; 1175 return -1;
@@ -1327,7 +1363,7 @@ static int dso__disassemble_filename(struct dso *dso, char *filename, size_t fil
1327 !dso__is_kcore(dso)) 1363 !dso__is_kcore(dso))
1328 return SYMBOL_ANNOTATE_ERRNO__NO_VMLINUX; 1364 return SYMBOL_ANNOTATE_ERRNO__NO_VMLINUX;
1329 1365
1330 build_id_filename = dso__build_id_filename(dso, NULL, 0); 1366 build_id_filename = dso__build_id_filename(dso, NULL, 0, false);
1331 if (build_id_filename) { 1367 if (build_id_filename) {
1332 __symbol__join_symfs(filename, filename_size, build_id_filename); 1368 __symbol__join_symfs(filename, filename_size, build_id_filename);
1333 free(build_id_filename); 1369 free(build_id_filename);
@@ -1381,7 +1417,7 @@ static const char *annotate__norm_arch(const char *arch_name)
1381 1417
1382int symbol__disassemble(struct symbol *sym, struct map *map, 1418int symbol__disassemble(struct symbol *sym, struct map *map,
1383 const char *arch_name, size_t privsize, 1419 const char *arch_name, size_t privsize,
1384 struct arch **parch) 1420 struct arch **parch, char *cpuid)
1385{ 1421{
1386 struct dso *dso = map->dso; 1422 struct dso *dso = map->dso;
1387 char command[PATH_MAX * 2]; 1423 char command[PATH_MAX * 2];
@@ -1418,6 +1454,9 @@ int symbol__disassemble(struct symbol *sym, struct map *map,
1418 } 1454 }
1419 } 1455 }
1420 1456
1457 if (arch->cpuid_parse && cpuid)
1458 arch->cpuid_parse(arch, cpuid);
1459
1421 pr_debug("%s: filename=%s, sym=%s, start=%#" PRIx64 ", end=%#" PRIx64 "\n", __func__, 1460 pr_debug("%s: filename=%s, sym=%s, start=%#" PRIx64 ", end=%#" PRIx64 "\n", __func__,
1422 symfs_filename, sym->name, map->unmap_ip(map, sym->start), 1461 symfs_filename, sym->name, map->unmap_ip(map, sym->start),
1423 map->unmap_ip(map, sym->end)); 1462 map->unmap_ip(map, sym->end));
@@ -1648,19 +1687,19 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map,
1648 struct sym_hist *h = annotation__histogram(notes, evidx); 1687 struct sym_hist *h = annotation__histogram(notes, evidx);
1649 struct rb_root tmp_root = RB_ROOT; 1688 struct rb_root tmp_root = RB_ROOT;
1650 int nr_pcnt = 1; 1689 int nr_pcnt = 1;
1651 u64 h_sum = h->sum; 1690 u64 nr_samples = h->nr_samples;
1652 size_t sizeof_src_line = sizeof(struct source_line); 1691 size_t sizeof_src_line = sizeof(struct source_line);
1653 1692
1654 if (perf_evsel__is_group_event(evsel)) { 1693 if (perf_evsel__is_group_event(evsel)) {
1655 for (i = 1; i < evsel->nr_members; i++) { 1694 for (i = 1; i < evsel->nr_members; i++) {
1656 h = annotation__histogram(notes, evidx + i); 1695 h = annotation__histogram(notes, evidx + i);
1657 h_sum += h->sum; 1696 nr_samples += h->nr_samples;
1658 } 1697 }
1659 nr_pcnt = evsel->nr_members; 1698 nr_pcnt = evsel->nr_members;
1660 sizeof_src_line += (nr_pcnt - 1) * sizeof(src_line->samples); 1699 sizeof_src_line += (nr_pcnt - 1) * sizeof(src_line->samples);
1661 } 1700 }
1662 1701
1663 if (!h_sum) 1702 if (!nr_samples)
1664 return 0; 1703 return 0;
1665 1704
1666 src_line = notes->src->lines = calloc(len, sizeof_src_line); 1705 src_line = notes->src->lines = calloc(len, sizeof_src_line);
@@ -1670,7 +1709,7 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map,
1670 start = map__rip_2objdump(map, sym->start); 1709 start = map__rip_2objdump(map, sym->start);
1671 1710
1672 for (i = 0; i < len; i++) { 1711 for (i = 0; i < len; i++) {
1673 u64 offset, nr_samples; 1712 u64 offset;
1674 double percent_max = 0.0; 1713 double percent_max = 0.0;
1675 1714
1676 src_line->nr_pcnt = nr_pcnt; 1715 src_line->nr_pcnt = nr_pcnt;
@@ -1679,9 +1718,9 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map,
1679 double percent = 0.0; 1718 double percent = 0.0;
1680 1719
1681 h = annotation__histogram(notes, evidx + k); 1720 h = annotation__histogram(notes, evidx + k);
1682 nr_samples = h->addr[i]; 1721 nr_samples = h->addr[i].nr_samples;
1683 if (h->sum) 1722 if (h->nr_samples)
1684 percent = 100.0 * nr_samples / h->sum; 1723 percent = 100.0 * nr_samples / h->nr_samples;
1685 1724
1686 if (percent > percent_max) 1725 if (percent > percent_max)
1687 percent_max = percent; 1726 percent_max = percent;
@@ -1750,10 +1789,10 @@ static void symbol__annotate_hits(struct symbol *sym, struct perf_evsel *evsel)
1750 u64 len = symbol__size(sym), offset; 1789 u64 len = symbol__size(sym), offset;
1751 1790
1752 for (offset = 0; offset < len; ++offset) 1791 for (offset = 0; offset < len; ++offset)
1753 if (h->addr[offset] != 0) 1792 if (h->addr[offset].nr_samples != 0)
1754 printf("%*" PRIx64 ": %" PRIu64 "\n", BITS_PER_LONG / 2, 1793 printf("%*" PRIx64 ": %" PRIu64 "\n", BITS_PER_LONG / 2,
1755 sym->start + offset, h->addr[offset]); 1794 sym->start + offset, h->addr[offset].nr_samples);
1756 printf("%*s: %" PRIu64 "\n", BITS_PER_LONG / 2, "h->sum", h->sum); 1795 printf("%*s: %" PRIu64 "\n", BITS_PER_LONG / 2, "h->nr_samples", h->nr_samples);
1757} 1796}
1758 1797
1759int symbol__annotate_printf(struct symbol *sym, struct map *map, 1798int symbol__annotate_printf(struct symbol *sym, struct map *map,
@@ -1771,7 +1810,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map,
1771 int printed = 2, queue_len = 0; 1810 int printed = 2, queue_len = 0;
1772 int more = 0; 1811 int more = 0;
1773 u64 len; 1812 u64 len;
1774 int width = 8; 1813 int width = symbol_conf.show_total_period ? 12 : 8;
1775 int graph_dotted_len; 1814 int graph_dotted_len;
1776 1815
1777 filename = strdup(dso->long_name); 1816 filename = strdup(dso->long_name);
@@ -1789,7 +1828,9 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map,
1789 width *= evsel->nr_members; 1828 width *= evsel->nr_members;
1790 1829
1791 graph_dotted_len = printf(" %-*.*s| Source code & Disassembly of %s for %s (%" PRIu64 " samples)\n", 1830 graph_dotted_len = printf(" %-*.*s| Source code & Disassembly of %s for %s (%" PRIu64 " samples)\n",
1792 width, width, "Percent", d_filename, evsel_name, h->sum); 1831 width, width, symbol_conf.show_total_period ? "Period" :
1832 symbol_conf.show_nr_samples ? "Samples" : "Percent",
1833 d_filename, evsel_name, h->nr_samples);
1793 1834
1794 printf("%-*.*s----\n", 1835 printf("%-*.*s----\n",
1795 graph_dotted_len, graph_dotted_len, graph_dotted_line); 1836 graph_dotted_len, graph_dotted_len, graph_dotted_line);
@@ -1853,10 +1894,10 @@ void symbol__annotate_decay_histogram(struct symbol *sym, int evidx)
1853 struct sym_hist *h = annotation__histogram(notes, evidx); 1894 struct sym_hist *h = annotation__histogram(notes, evidx);
1854 int len = symbol__size(sym), offset; 1895 int len = symbol__size(sym), offset;
1855 1896
1856 h->sum = 0; 1897 h->nr_samples = 0;
1857 for (offset = 0; offset < len; ++offset) { 1898 for (offset = 0; offset < len; ++offset) {
1858 h->addr[offset] = h->addr[offset] * 7 / 8; 1899 h->addr[offset].nr_samples = h->addr[offset].nr_samples * 7 / 8;
1859 h->sum += h->addr[offset]; 1900 h->nr_samples += h->addr[offset].nr_samples;
1860 } 1901 }
1861} 1902}
1862 1903
@@ -1907,7 +1948,7 @@ int symbol__tty_annotate(struct symbol *sym, struct map *map,
1907 u64 len; 1948 u64 len;
1908 1949
1909 if (symbol__disassemble(sym, map, perf_evsel__env_arch(evsel), 1950 if (symbol__disassemble(sym, map, perf_evsel__env_arch(evsel),
1910 0, NULL) < 0) 1951 0, NULL, NULL) < 0)
1911 return -1; 1952 return -1;
1912 1953
1913 len = symbol__size(sym); 1954 len = symbol__size(sym);
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index 21055034aedd..9ce575c25fd9 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -52,7 +52,9 @@ struct ins_ops {
52bool ins__is_jump(const struct ins *ins); 52bool ins__is_jump(const struct ins *ins);
53bool ins__is_call(const struct ins *ins); 53bool ins__is_call(const struct ins *ins);
54bool ins__is_ret(const struct ins *ins); 54bool ins__is_ret(const struct ins *ins);
55bool ins__is_lock(const struct ins *ins);
55int ins__scnprintf(struct ins *ins, char *bf, size_t size, struct ins_operands *ops); 56int ins__scnprintf(struct ins *ins, char *bf, size_t size, struct ins_operands *ops);
57bool ins__is_fused(struct arch *arch, const char *ins1, const char *ins2);
56 58
57struct annotation; 59struct annotation;
58 60
@@ -72,16 +74,22 @@ static inline bool disasm_line__has_offset(const struct disasm_line *dl)
72 return dl->ops.target.offset_avail; 74 return dl->ops.target.offset_avail;
73} 75}
74 76
77struct sym_hist_entry {
78 u64 nr_samples;
79 u64 period;
80};
81
75void disasm_line__free(struct disasm_line *dl); 82void disasm_line__free(struct disasm_line *dl);
76struct disasm_line *disasm__get_next_ip_line(struct list_head *head, struct disasm_line *pos); 83struct disasm_line *disasm__get_next_ip_line(struct list_head *head, struct disasm_line *pos);
77int disasm_line__scnprintf(struct disasm_line *dl, char *bf, size_t size, bool raw); 84int disasm_line__scnprintf(struct disasm_line *dl, char *bf, size_t size, bool raw);
78size_t disasm__fprintf(struct list_head *head, FILE *fp); 85size_t disasm__fprintf(struct list_head *head, FILE *fp);
79double disasm__calc_percent(struct annotation *notes, int evidx, s64 offset, 86double disasm__calc_percent(struct annotation *notes, int evidx, s64 offset,
80 s64 end, const char **path, u64 *nr_samples); 87 s64 end, const char **path, struct sym_hist_entry *sample);
81 88
82struct sym_hist { 89struct sym_hist {
83 u64 sum; 90 u64 nr_samples;
84 u64 addr[0]; 91 u64 period;
92 struct sym_hist_entry addr[0];
85}; 93};
86 94
87struct cyc_hist { 95struct cyc_hist {
@@ -147,20 +155,22 @@ static inline struct annotation *symbol__annotation(struct symbol *sym)
147 return (void *)sym - symbol_conf.priv_size; 155 return (void *)sym - symbol_conf.priv_size;
148} 156}
149 157
150int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, int evidx); 158int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, struct perf_sample *sample,
159 int evidx);
151 160
152int addr_map_symbol__account_cycles(struct addr_map_symbol *ams, 161int addr_map_symbol__account_cycles(struct addr_map_symbol *ams,
153 struct addr_map_symbol *start, 162 struct addr_map_symbol *start,
154 unsigned cycles); 163 unsigned cycles);
155 164
156int hist_entry__inc_addr_samples(struct hist_entry *he, int evidx, u64 addr); 165int hist_entry__inc_addr_samples(struct hist_entry *he, struct perf_sample *sample,
166 int evidx, u64 addr);
157 167
158int symbol__alloc_hist(struct symbol *sym); 168int symbol__alloc_hist(struct symbol *sym);
159void symbol__annotate_zero_histograms(struct symbol *sym); 169void symbol__annotate_zero_histograms(struct symbol *sym);
160 170
161int symbol__disassemble(struct symbol *sym, struct map *map, 171int symbol__disassemble(struct symbol *sym, struct map *map,
162 const char *arch_name, size_t privsize, 172 const char *arch_name, size_t privsize,
163 struct arch **parch); 173 struct arch **parch, char *cpuid);
164 174
165enum symbol_disassemble_errno { 175enum symbol_disassemble_errno {
166 SYMBOL_ANNOTATE_ERRNO__SUCCESS = 0, 176 SYMBOL_ANNOTATE_ERRNO__SUCCESS = 0,
diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
index 4bd2d1d882af..4a1264c66101 100644
--- a/tools/perf/util/bpf-loader.c
+++ b/tools/perf/util/bpf-loader.c
@@ -1246,7 +1246,7 @@ int bpf__config_obj(struct bpf_object *obj,
1246 if (!obj || !term || !term->config) 1246 if (!obj || !term || !term->config)
1247 return -EINVAL; 1247 return -EINVAL;
1248 1248
1249 if (!prefixcmp(term->config, "map:")) { 1249 if (strstarts(term->config, "map:")) {
1250 key_scan_pos = sizeof("map:") - 1; 1250 key_scan_pos = sizeof("map:") - 1;
1251 err = bpf__obj_config_map(obj, term, evlist, &key_scan_pos); 1251 err = bpf__obj_config_map(obj, term, evlist, &key_scan_pos);
1252 goto out; 1252 goto out;
diff --git a/tools/perf/util/bpf-prologue.c b/tools/perf/util/bpf-prologue.c
index 1356220a9f1b..827f9140f3b8 100644
--- a/tools/perf/util/bpf-prologue.c
+++ b/tools/perf/util/bpf-prologue.c
@@ -58,6 +58,46 @@ check_pos(struct bpf_insn_pos *pos)
58 return 0; 58 return 0;
59} 59}
60 60
61/*
62 * Convert type string (u8/u16/u32/u64/s8/s16/s32/s64 ..., see
63 * Documentation/trace/kprobetrace.txt) to size field of BPF_LDX_MEM
64 * instruction (BPF_{B,H,W,DW}).
65 */
66static int
67argtype_to_ldx_size(const char *type)
68{
69 int arg_size = type ? atoi(&type[1]) : 64;
70
71 switch (arg_size) {
72 case 8:
73 return BPF_B;
74 case 16:
75 return BPF_H;
76 case 32:
77 return BPF_W;
78 case 64:
79 default:
80 return BPF_DW;
81 }
82}
83
84static const char *
85insn_sz_to_str(int insn_sz)
86{
87 switch (insn_sz) {
88 case BPF_B:
89 return "BPF_B";
90 case BPF_H:
91 return "BPF_H";
92 case BPF_W:
93 return "BPF_W";
94 case BPF_DW:
95 return "BPF_DW";
96 default:
97 return "UNKNOWN";
98 }
99}
100
61/* Give it a shorter name */ 101/* Give it a shorter name */
62#define ins(i, p) append_insn((i), (p)) 102#define ins(i, p) append_insn((i), (p))
63 103
@@ -258,9 +298,14 @@ gen_prologue_slowpath(struct bpf_insn_pos *pos,
258 } 298 }
259 299
260 /* Final pass: read to registers */ 300 /* Final pass: read to registers */
261 for (i = 0; i < nargs; i++) 301 for (i = 0; i < nargs; i++) {
262 ins(BPF_LDX_MEM(BPF_DW, BPF_PROLOGUE_START_ARG_REG + i, 302 int insn_sz = (args[i].ref) ? argtype_to_ldx_size(args[i].type) : BPF_DW;
303
304 pr_debug("prologue: load arg %d, insn_sz is %s\n",
305 i, insn_sz_to_str(insn_sz));
306 ins(BPF_LDX_MEM(insn_sz, BPF_PROLOGUE_START_ARG_REG + i,
263 BPF_REG_FP, -BPF_REG_SIZE * (i + 1)), pos); 307 BPF_REG_FP, -BPF_REG_SIZE * (i + 1)), pos);
308 }
264 309
265 ins(BPF_JMP_IMM(BPF_JA, BPF_REG_0, 0, JMP_TO_SUCCESS_CODE), pos); 310 ins(BPF_JMP_IMM(BPF_JA, BPF_REG_0, 0, JMP_TO_SUCCESS_CODE), pos);
266 311
diff --git a/tools/perf/util/branch.c b/tools/perf/util/branch.c
new file mode 100644
index 000000000000..a4fce2729e50
--- /dev/null
+++ b/tools/perf/util/branch.c
@@ -0,0 +1,147 @@
1#include "perf.h"
2#include "util/util.h"
3#include "util/debug.h"
4#include "util/branch.h"
5
6static bool cross_area(u64 addr1, u64 addr2, int size)
7{
8 u64 align1, align2;
9
10 align1 = addr1 & ~(size - 1);
11 align2 = addr2 & ~(size - 1);
12
13 return (align1 != align2) ? true : false;
14}
15
16#define AREA_4K 4096
17#define AREA_2M (2 * 1024 * 1024)
18
19void branch_type_count(struct branch_type_stat *st, struct branch_flags *flags,
20 u64 from, u64 to)
21{
22 if (flags->type == PERF_BR_UNKNOWN || from == 0)
23 return;
24
25 st->counts[flags->type]++;
26
27 if (flags->type == PERF_BR_COND) {
28 if (to > from)
29 st->cond_fwd++;
30 else
31 st->cond_bwd++;
32 }
33
34 if (cross_area(from, to, AREA_2M))
35 st->cross_2m++;
36 else if (cross_area(from, to, AREA_4K))
37 st->cross_4k++;
38}
39
40const char *branch_type_name(int type)
41{
42 const char *branch_names[PERF_BR_MAX] = {
43 "N/A",
44 "COND",
45 "UNCOND",
46 "IND",
47 "CALL",
48 "IND_CALL",
49 "RET",
50 "SYSCALL",
51 "SYSRET",
52 "COND_CALL",
53 "COND_RET"
54 };
55
56 if (type >= 0 && type < PERF_BR_MAX)
57 return branch_names[type];
58
59 return NULL;
60}
61
62void branch_type_stat_display(FILE *fp, struct branch_type_stat *st)
63{
64 u64 total = 0;
65 int i;
66
67 for (i = 0; i < PERF_BR_MAX; i++)
68 total += st->counts[i];
69
70 if (total == 0)
71 return;
72
73 fprintf(fp, "\n#");
74 fprintf(fp, "\n# Branch Statistics:");
75 fprintf(fp, "\n#");
76
77 if (st->cond_fwd > 0) {
78 fprintf(fp, "\n%8s: %5.1f%%",
79 "COND_FWD",
80 100.0 * (double)st->cond_fwd / (double)total);
81 }
82
83 if (st->cond_bwd > 0) {
84 fprintf(fp, "\n%8s: %5.1f%%",
85 "COND_BWD",
86 100.0 * (double)st->cond_bwd / (double)total);
87 }
88
89 if (st->cross_4k > 0) {
90 fprintf(fp, "\n%8s: %5.1f%%",
91 "CROSS_4K",
92 100.0 * (double)st->cross_4k / (double)total);
93 }
94
95 if (st->cross_2m > 0) {
96 fprintf(fp, "\n%8s: %5.1f%%",
97 "CROSS_2M",
98 100.0 * (double)st->cross_2m / (double)total);
99 }
100
101 for (i = 0; i < PERF_BR_MAX; i++) {
102 if (st->counts[i] > 0)
103 fprintf(fp, "\n%8s: %5.1f%%",
104 branch_type_name(i),
105 100.0 *
106 (double)st->counts[i] / (double)total);
107 }
108}
109
110static int count_str_scnprintf(int idx, const char *str, char *bf, int size)
111{
112 return scnprintf(bf, size, "%s%s", (idx) ? " " : " (", str);
113}
114
115int branch_type_str(struct branch_type_stat *st, char *bf, int size)
116{
117 int i, j = 0, printed = 0;
118 u64 total = 0;
119
120 for (i = 0; i < PERF_BR_MAX; i++)
121 total += st->counts[i];
122
123 if (total == 0)
124 return 0;
125
126 if (st->cond_fwd > 0)
127 printed += count_str_scnprintf(j++, "COND_FWD", bf + printed, size - printed);
128
129 if (st->cond_bwd > 0)
130 printed += count_str_scnprintf(j++, "COND_BWD", bf + printed, size - printed);
131
132 for (i = 0; i < PERF_BR_MAX; i++) {
133 if (i == PERF_BR_COND)
134 continue;
135
136 if (st->counts[i] > 0)
137 printed += count_str_scnprintf(j++, branch_type_name(i), bf + printed, size - printed);
138 }
139
140 if (st->cross_4k > 0)
141 printed += count_str_scnprintf(j++, "CROSS_4K", bf + printed, size - printed);
142
143 if (st->cross_2m > 0)
144 printed += count_str_scnprintf(j++, "CROSS_2M", bf + printed, size - printed);
145
146 return printed;
147}
diff --git a/tools/perf/util/branch.h b/tools/perf/util/branch.h
new file mode 100644
index 000000000000..1e3c7c5cdc63
--- /dev/null
+++ b/tools/perf/util/branch.h
@@ -0,0 +1,25 @@
1#ifndef _PERF_BRANCH_H
2#define _PERF_BRANCH_H 1
3
4#include <stdint.h>
5#include "../perf.h"
6
7struct branch_type_stat {
8 bool branch_to;
9 u64 counts[PERF_BR_MAX];
10 u64 cond_fwd;
11 u64 cond_bwd;
12 u64 cross_4k;
13 u64 cross_2m;
14};
15
16struct branch_flags;
17
18void branch_type_count(struct branch_type_stat *st, struct branch_flags *flags,
19 u64 from, u64 to);
20
21const char *branch_type_name(int type);
22void branch_type_stat_display(FILE *fp, struct branch_type_stat *st);
23int branch_type_str(struct branch_type_stat *st, char *bf, int bfsize);
24
25#endif /* _PERF_BRANCH_H */
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index e0148b081bdf..c1a06fcd7e70 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -243,12 +243,15 @@ static bool build_id_cache__valid_id(char *sbuild_id)
243 return result; 243 return result;
244} 244}
245 245
246static const char *build_id_cache__basename(bool is_kallsyms, bool is_vdso) 246static const char *build_id_cache__basename(bool is_kallsyms, bool is_vdso,
247 bool is_debug)
247{ 248{
248 return is_kallsyms ? "kallsyms" : (is_vdso ? "vdso" : "elf"); 249 return is_kallsyms ? "kallsyms" : (is_vdso ? "vdso" : (is_debug ?
250 "debug" : "elf"));
249} 251}
250 252
251char *dso__build_id_filename(const struct dso *dso, char *bf, size_t size) 253char *dso__build_id_filename(const struct dso *dso, char *bf, size_t size,
254 bool is_debug)
252{ 255{
253 bool is_kallsyms = dso__is_kallsyms((struct dso *)dso); 256 bool is_kallsyms = dso__is_kallsyms((struct dso *)dso);
254 bool is_vdso = dso__is_vdso((struct dso *)dso); 257 bool is_vdso = dso__is_vdso((struct dso *)dso);
@@ -270,7 +273,8 @@ char *dso__build_id_filename(const struct dso *dso, char *bf, size_t size)
270 ret = asnprintf(&bf, size, "%s", linkname); 273 ret = asnprintf(&bf, size, "%s", linkname);
271 else 274 else
272 ret = asnprintf(&bf, size, "%s/%s", linkname, 275 ret = asnprintf(&bf, size, "%s/%s", linkname,
273 build_id_cache__basename(is_kallsyms, is_vdso)); 276 build_id_cache__basename(is_kallsyms, is_vdso,
277 is_debug));
274 if (ret < 0 || (!alloc && size < (unsigned int)ret)) 278 if (ret < 0 || (!alloc && size < (unsigned int)ret))
275 bf = NULL; 279 bf = NULL;
276 free(linkname); 280 free(linkname);
@@ -285,7 +289,7 @@ char *dso__build_id_filename(const struct dso *dso, char *bf, size_t size)
285 else 289 else
286 290
287static int write_buildid(const char *name, size_t name_len, u8 *build_id, 291static int write_buildid(const char *name, size_t name_len, u8 *build_id,
288 pid_t pid, u16 misc, int fd) 292 pid_t pid, u16 misc, struct feat_fd *fd)
289{ 293{
290 int err; 294 int err;
291 struct build_id_event b; 295 struct build_id_event b;
@@ -300,14 +304,15 @@ static int write_buildid(const char *name, size_t name_len, u8 *build_id,
300 b.header.misc = misc; 304 b.header.misc = misc;
301 b.header.size = sizeof(b) + len; 305 b.header.size = sizeof(b) + len;
302 306
303 err = writen(fd, &b, sizeof(b)); 307 err = do_write(fd, &b, sizeof(b));
304 if (err < 0) 308 if (err < 0)
305 return err; 309 return err;
306 310
307 return write_padded(fd, name, name_len + 1, len); 311 return write_padded(fd, name, name_len + 1, len);
308} 312}
309 313
310static int machine__write_buildid_table(struct machine *machine, int fd) 314static int machine__write_buildid_table(struct machine *machine,
315 struct feat_fd *fd)
311{ 316{
312 int err = 0; 317 int err = 0;
313 char nm[PATH_MAX]; 318 char nm[PATH_MAX];
@@ -352,7 +357,8 @@ static int machine__write_buildid_table(struct machine *machine, int fd)
352 return err; 357 return err;
353} 358}
354 359
355int perf_session__write_buildid_table(struct perf_session *session, int fd) 360int perf_session__write_buildid_table(struct perf_session *session,
361 struct feat_fd *fd)
356{ 362{
357 struct rb_node *nd; 363 struct rb_node *nd;
358 int err = machine__write_buildid_table(&session->machines.host, fd); 364 int err = machine__write_buildid_table(&session->machines.host, fd);
@@ -534,13 +540,14 @@ char *build_id_cache__complement(const char *incomplete_sbuild_id)
534} 540}
535 541
536char *build_id_cache__cachedir(const char *sbuild_id, const char *name, 542char *build_id_cache__cachedir(const char *sbuild_id, const char *name,
537 bool is_kallsyms, bool is_vdso) 543 struct nsinfo *nsi, bool is_kallsyms,
544 bool is_vdso)
538{ 545{
539 char *realname = (char *)name, *filename; 546 char *realname = (char *)name, *filename;
540 bool slash = is_kallsyms || is_vdso; 547 bool slash = is_kallsyms || is_vdso;
541 548
542 if (!slash) { 549 if (!slash) {
543 realname = realpath(name, NULL); 550 realname = nsinfo__realpath(name, nsi);
544 if (!realname) 551 if (!realname)
545 return NULL; 552 return NULL;
546 } 553 }
@@ -556,13 +563,13 @@ char *build_id_cache__cachedir(const char *sbuild_id, const char *name,
556 return filename; 563 return filename;
557} 564}
558 565
559int build_id_cache__list_build_ids(const char *pathname, 566int build_id_cache__list_build_ids(const char *pathname, struct nsinfo *nsi,
560 struct strlist **result) 567 struct strlist **result)
561{ 568{
562 char *dir_name; 569 char *dir_name;
563 int ret = 0; 570 int ret = 0;
564 571
565 dir_name = build_id_cache__cachedir(NULL, pathname, false, false); 572 dir_name = build_id_cache__cachedir(NULL, pathname, nsi, false, false);
566 if (!dir_name) 573 if (!dir_name)
567 return -ENOMEM; 574 return -ENOMEM;
568 575
@@ -576,16 +583,20 @@ int build_id_cache__list_build_ids(const char *pathname,
576 583
577#if defined(HAVE_LIBELF_SUPPORT) && defined(HAVE_GELF_GETNOTE_SUPPORT) 584#if defined(HAVE_LIBELF_SUPPORT) && defined(HAVE_GELF_GETNOTE_SUPPORT)
578static int build_id_cache__add_sdt_cache(const char *sbuild_id, 585static int build_id_cache__add_sdt_cache(const char *sbuild_id,
579 const char *realname) 586 const char *realname,
587 struct nsinfo *nsi)
580{ 588{
581 struct probe_cache *cache; 589 struct probe_cache *cache;
582 int ret; 590 int ret;
591 struct nscookie nsc;
583 592
584 cache = probe_cache__new(sbuild_id); 593 cache = probe_cache__new(sbuild_id, nsi);
585 if (!cache) 594 if (!cache)
586 return -1; 595 return -1;
587 596
597 nsinfo__mountns_enter(nsi, &nsc);
588 ret = probe_cache__scan_sdt(cache, realname); 598 ret = probe_cache__scan_sdt(cache, realname);
599 nsinfo__mountns_exit(&nsc);
589 if (ret >= 0) { 600 if (ret >= 0) {
590 pr_debug4("Found %d SDTs in %s\n", ret, realname); 601 pr_debug4("Found %d SDTs in %s\n", ret, realname);
591 if (probe_cache__commit(cache) < 0) 602 if (probe_cache__commit(cache) < 0)
@@ -595,25 +606,56 @@ static int build_id_cache__add_sdt_cache(const char *sbuild_id,
595 return ret; 606 return ret;
596} 607}
597#else 608#else
598#define build_id_cache__add_sdt_cache(sbuild_id, realname) (0) 609#define build_id_cache__add_sdt_cache(sbuild_id, realname, nsi) (0)
599#endif 610#endif
600 611
612static char *build_id_cache__find_debug(const char *sbuild_id,
613 struct nsinfo *nsi)
614{
615 char *realname = NULL;
616 char *debugfile;
617 struct nscookie nsc;
618 size_t len = 0;
619
620 debugfile = calloc(1, PATH_MAX);
621 if (!debugfile)
622 goto out;
623
624 len = __symbol__join_symfs(debugfile, PATH_MAX,
625 "/usr/lib/debug/.build-id/");
626 snprintf(debugfile + len, PATH_MAX - len, "%.2s/%s.debug", sbuild_id,
627 sbuild_id + 2);
628
629 nsinfo__mountns_enter(nsi, &nsc);
630 realname = realpath(debugfile, NULL);
631 if (realname && access(realname, R_OK))
632 zfree(&realname);
633 nsinfo__mountns_exit(&nsc);
634out:
635 free(debugfile);
636 return realname;
637}
638
601int build_id_cache__add_s(const char *sbuild_id, const char *name, 639int build_id_cache__add_s(const char *sbuild_id, const char *name,
602 bool is_kallsyms, bool is_vdso) 640 struct nsinfo *nsi, bool is_kallsyms, bool is_vdso)
603{ 641{
604 const size_t size = PATH_MAX; 642 const size_t size = PATH_MAX;
605 char *realname = NULL, *filename = NULL, *dir_name = NULL, 643 char *realname = NULL, *filename = NULL, *dir_name = NULL,
606 *linkname = zalloc(size), *tmp; 644 *linkname = zalloc(size), *tmp;
645 char *debugfile = NULL;
607 int err = -1; 646 int err = -1;
608 647
609 if (!is_kallsyms) { 648 if (!is_kallsyms) {
610 realname = realpath(name, NULL); 649 if (!is_vdso)
650 realname = nsinfo__realpath(name, nsi);
651 else
652 realname = realpath(name, NULL);
611 if (!realname) 653 if (!realname)
612 goto out_free; 654 goto out_free;
613 } 655 }
614 656
615 dir_name = build_id_cache__cachedir(sbuild_id, name, 657 dir_name = build_id_cache__cachedir(sbuild_id, name, nsi, is_kallsyms,
616 is_kallsyms, is_vdso); 658 is_vdso);
617 if (!dir_name) 659 if (!dir_name)
618 goto out_free; 660 goto out_free;
619 661
@@ -627,20 +669,52 @@ int build_id_cache__add_s(const char *sbuild_id, const char *name,
627 669
628 /* Save the allocated buildid dirname */ 670 /* Save the allocated buildid dirname */
629 if (asprintf(&filename, "%s/%s", dir_name, 671 if (asprintf(&filename, "%s/%s", dir_name,
630 build_id_cache__basename(is_kallsyms, is_vdso)) < 0) { 672 build_id_cache__basename(is_kallsyms, is_vdso,
673 false)) < 0) {
631 filename = NULL; 674 filename = NULL;
632 goto out_free; 675 goto out_free;
633 } 676 }
634 677
635 if (access(filename, F_OK)) { 678 if (access(filename, F_OK)) {
636 if (is_kallsyms) { 679 if (is_kallsyms) {
637 if (copyfile("/proc/kallsyms", filename)) 680 if (copyfile("/proc/kallsyms", filename))
681 goto out_free;
682 } else if (nsi && nsi->need_setns) {
683 if (copyfile_ns(name, filename, nsi))
638 goto out_free; 684 goto out_free;
639 } else if (link(realname, filename) && errno != EEXIST && 685 } else if (link(realname, filename) && errno != EEXIST &&
640 copyfile(name, filename)) 686 copyfile(name, filename))
641 goto out_free; 687 goto out_free;
642 } 688 }
643 689
690 /* Some binaries are stripped, but have .debug files with their symbol
691 * table. Check to see if we can locate one of those, since the elf
692 * file itself may not be very useful to users of our tools without a
693 * symtab.
694 */
695 if (!is_kallsyms && !is_vdso &&
696 strncmp(".ko", name + strlen(name) - 3, 3)) {
697 debugfile = build_id_cache__find_debug(sbuild_id, nsi);
698 if (debugfile) {
699 zfree(&filename);
700 if (asprintf(&filename, "%s/%s", dir_name,
701 build_id_cache__basename(false, false, true)) < 0) {
702 filename = NULL;
703 goto out_free;
704 }
705 if (access(filename, F_OK)) {
706 if (nsi && nsi->need_setns) {
707 if (copyfile_ns(debugfile, filename,
708 nsi))
709 goto out_free;
710 } else if (link(debugfile, filename) &&
711 errno != EEXIST &&
712 copyfile(debugfile, filename))
713 goto out_free;
714 }
715 }
716 }
717
644 if (!build_id_cache__linkname(sbuild_id, linkname, size)) 718 if (!build_id_cache__linkname(sbuild_id, linkname, size))
645 goto out_free; 719 goto out_free;
646 tmp = strrchr(linkname, '/'); 720 tmp = strrchr(linkname, '/');
@@ -657,27 +731,30 @@ int build_id_cache__add_s(const char *sbuild_id, const char *name,
657 err = 0; 731 err = 0;
658 732
659 /* Update SDT cache : error is just warned */ 733 /* Update SDT cache : error is just warned */
660 if (realname && build_id_cache__add_sdt_cache(sbuild_id, realname) < 0) 734 if (realname &&
735 build_id_cache__add_sdt_cache(sbuild_id, realname, nsi) < 0)
661 pr_debug4("Failed to update/scan SDT cache for %s\n", realname); 736 pr_debug4("Failed to update/scan SDT cache for %s\n", realname);
662 737
663out_free: 738out_free:
664 if (!is_kallsyms) 739 if (!is_kallsyms)
665 free(realname); 740 free(realname);
666 free(filename); 741 free(filename);
742 free(debugfile);
667 free(dir_name); 743 free(dir_name);
668 free(linkname); 744 free(linkname);
669 return err; 745 return err;
670} 746}
671 747
672static int build_id_cache__add_b(const u8 *build_id, size_t build_id_size, 748static int build_id_cache__add_b(const u8 *build_id, size_t build_id_size,
673 const char *name, bool is_kallsyms, 749 const char *name, struct nsinfo *nsi,
674 bool is_vdso) 750 bool is_kallsyms, bool is_vdso)
675{ 751{
676 char sbuild_id[SBUILD_ID_SIZE]; 752 char sbuild_id[SBUILD_ID_SIZE];
677 753
678 build_id__sprintf(build_id, build_id_size, sbuild_id); 754 build_id__sprintf(build_id, build_id_size, sbuild_id);
679 755
680 return build_id_cache__add_s(sbuild_id, name, is_kallsyms, is_vdso); 756 return build_id_cache__add_s(sbuild_id, name, nsi, is_kallsyms,
757 is_vdso);
681} 758}
682 759
683bool build_id_cache__cached(const char *sbuild_id) 760bool build_id_cache__cached(const char *sbuild_id)
@@ -743,7 +820,7 @@ static int dso__cache_build_id(struct dso *dso, struct machine *machine)
743 name = nm; 820 name = nm;
744 } 821 }
745 return build_id_cache__add_b(dso->build_id, sizeof(dso->build_id), name, 822 return build_id_cache__add_b(dso->build_id, sizeof(dso->build_id), name,
746 is_kallsyms, is_vdso); 823 dso->nsinfo, is_kallsyms, is_vdso);
747} 824}
748 825
749static int __dsos__cache_build_ids(struct list_head *head, 826static int __dsos__cache_build_ids(struct list_head *head,
diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h
index 96690a55c62c..c94b0dcbfd74 100644
--- a/tools/perf/util/build-id.h
+++ b/tools/perf/util/build-id.h
@@ -5,10 +5,12 @@
5#define SBUILD_ID_SIZE (BUILD_ID_SIZE * 2 + 1) 5#define SBUILD_ID_SIZE (BUILD_ID_SIZE * 2 + 1)
6 6
7#include "tool.h" 7#include "tool.h"
8#include "namespaces.h"
8#include <linux/types.h> 9#include <linux/types.h>
9 10
10extern struct perf_tool build_id__mark_dso_hit_ops; 11extern struct perf_tool build_id__mark_dso_hit_ops;
11struct dso; 12struct dso;
13struct feat_fd;
12 14
13int build_id__sprintf(const u8 *build_id, int len, char *bf); 15int build_id__sprintf(const u8 *build_id, int len, char *bf);
14int sysfs__sprintf_build_id(const char *root_dir, char *sbuild_id); 16int sysfs__sprintf_build_id(const char *root_dir, char *sbuild_id);
@@ -16,7 +18,8 @@ int filename__sprintf_build_id(const char *pathname, char *sbuild_id);
16char *build_id_cache__kallsyms_path(const char *sbuild_id, char *bf, 18char *build_id_cache__kallsyms_path(const char *sbuild_id, char *bf,
17 size_t size); 19 size_t size);
18 20
19char *dso__build_id_filename(const struct dso *dso, char *bf, size_t size); 21char *dso__build_id_filename(const struct dso *dso, char *bf, size_t size,
22 bool is_debug);
20 23
21int build_id__mark_dso_hit(struct perf_tool *tool, union perf_event *event, 24int build_id__mark_dso_hit(struct perf_tool *tool, union perf_event *event,
22 struct perf_sample *sample, struct perf_evsel *evsel, 25 struct perf_sample *sample, struct perf_evsel *evsel,
@@ -25,23 +28,26 @@ int build_id__mark_dso_hit(struct perf_tool *tool, union perf_event *event,
25int dsos__hit_all(struct perf_session *session); 28int dsos__hit_all(struct perf_session *session);
26 29
27bool perf_session__read_build_ids(struct perf_session *session, bool with_hits); 30bool perf_session__read_build_ids(struct perf_session *session, bool with_hits);
28int perf_session__write_buildid_table(struct perf_session *session, int fd); 31int perf_session__write_buildid_table(struct perf_session *session,
32 struct feat_fd *fd);
29int perf_session__cache_build_ids(struct perf_session *session); 33int perf_session__cache_build_ids(struct perf_session *session);
30 34
31char *build_id_cache__origname(const char *sbuild_id); 35char *build_id_cache__origname(const char *sbuild_id);
32char *build_id_cache__linkname(const char *sbuild_id, char *bf, size_t size); 36char *build_id_cache__linkname(const char *sbuild_id, char *bf, size_t size);
33char *build_id_cache__cachedir(const char *sbuild_id, const char *name, 37char *build_id_cache__cachedir(const char *sbuild_id, const char *name,
34 bool is_kallsyms, bool is_vdso); 38 struct nsinfo *nsi, bool is_kallsyms,
39 bool is_vdso);
35 40
36struct strlist; 41struct strlist;
37 42
38struct strlist *build_id_cache__list_all(bool validonly); 43struct strlist *build_id_cache__list_all(bool validonly);
39char *build_id_cache__complement(const char *incomplete_sbuild_id); 44char *build_id_cache__complement(const char *incomplete_sbuild_id);
40int build_id_cache__list_build_ids(const char *pathname, 45int build_id_cache__list_build_ids(const char *pathname, struct nsinfo *nsi,
41 struct strlist **result); 46 struct strlist **result);
42bool build_id_cache__cached(const char *sbuild_id); 47bool build_id_cache__cached(const char *sbuild_id);
43int build_id_cache__add_s(const char *sbuild_id, 48int build_id_cache__add_s(const char *sbuild_id,
44 const char *name, bool is_kallsyms, bool is_vdso); 49 const char *name, struct nsinfo *nsi,
50 bool is_kallsyms, bool is_vdso);
45int build_id_cache__remove_s(const char *sbuild_id); 51int build_id_cache__remove_s(const char *sbuild_id);
46 52
47extern char buildid_dir[]; 53extern char buildid_dir[];
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index b4204b43ed58..be09d77cade0 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -23,6 +23,7 @@
23#include "sort.h" 23#include "sort.h"
24#include "machine.h" 24#include "machine.h"
25#include "callchain.h" 25#include "callchain.h"
26#include "branch.h"
26 27
27#define CALLCHAIN_PARAM_DEFAULT \ 28#define CALLCHAIN_PARAM_DEFAULT \
28 .mode = CHAIN_GRAPH_ABS, \ 29 .mode = CHAIN_GRAPH_ABS, \
@@ -64,8 +65,6 @@ static int parse_callchain_mode(const char *value)
64 callchain_param.mode = CHAIN_FOLDED; 65 callchain_param.mode = CHAIN_FOLDED;
65 return 0; 66 return 0;
66 } 67 }
67
68 pr_err("Invalid callchain mode: %s\n", value);
69 return -1; 68 return -1;
70} 69}
71 70
@@ -81,8 +80,6 @@ static int parse_callchain_order(const char *value)
81 callchain_param.order_set = true; 80 callchain_param.order_set = true;
82 return 0; 81 return 0;
83 } 82 }
84
85 pr_err("Invalid callchain order: %s\n", value);
86 return -1; 83 return -1;
87} 84}
88 85
@@ -104,8 +101,6 @@ static int parse_callchain_sort_key(const char *value)
104 callchain_param.branch_callstack = 1; 101 callchain_param.branch_callstack = 1;
105 return 0; 102 return 0;
106 } 103 }
107
108 pr_err("Invalid callchain sort key: %s\n", value);
109 return -1; 104 return -1;
110} 105}
111 106
@@ -123,8 +118,6 @@ static int parse_callchain_value(const char *value)
123 callchain_param.value = CCVAL_COUNT; 118 callchain_param.value = CCVAL_COUNT;
124 return 0; 119 return 0;
125 } 120 }
126
127 pr_err("Invalid callchain config key: %s\n", value);
128 return -1; 121 return -1;
129} 122}
130 123
@@ -303,7 +296,7 @@ int perf_callchain_config(const char *var, const char *value)
303{ 296{
304 char *endptr; 297 char *endptr;
305 298
306 if (prefixcmp(var, "call-graph.")) 299 if (!strstarts(var, "call-graph."))
307 return 0; 300 return 0;
308 var += sizeof("call-graph.") - 1; 301 var += sizeof("call-graph.") - 1;
309 302
@@ -318,12 +311,27 @@ int perf_callchain_config(const char *var, const char *value)
318 311
319 return ret; 312 return ret;
320 } 313 }
321 if (!strcmp(var, "print-type")) 314 if (!strcmp(var, "print-type")){
322 return parse_callchain_mode(value); 315 int ret;
323 if (!strcmp(var, "order")) 316 ret = parse_callchain_mode(value);
324 return parse_callchain_order(value); 317 if (ret == -1)
325 if (!strcmp(var, "sort-key")) 318 pr_err("Invalid callchain mode: %s\n", value);
326 return parse_callchain_sort_key(value); 319 return ret;
320 }
321 if (!strcmp(var, "order")){
322 int ret;
323 ret = parse_callchain_order(value);
324 if (ret == -1)
325 pr_err("Invalid callchain order: %s\n", value);
326 return ret;
327 }
328 if (!strcmp(var, "sort-key")){
329 int ret;
330 ret = parse_callchain_sort_key(value);
331 if (ret == -1)
332 pr_err("Invalid callchain sort key: %s\n", value);
333 return ret;
334 }
327 if (!strcmp(var, "threshold")) { 335 if (!strcmp(var, "threshold")) {
328 callchain_param.min_percent = strtod(value, &endptr); 336 callchain_param.min_percent = strtod(value, &endptr);
329 if (value == endptr) { 337 if (value == endptr) {
@@ -562,15 +570,33 @@ fill_node(struct callchain_node *node, struct callchain_cursor *cursor)
562 if (cursor_node->branch) { 570 if (cursor_node->branch) {
563 call->branch_count = 1; 571 call->branch_count = 1;
564 572
565 if (cursor_node->branch_flags.predicted) 573 if (cursor_node->branch_from) {
566 call->predicted_count = 1; 574 /*
567 575 * branch_from is set with value somewhere else
568 if (cursor_node->branch_flags.abort) 576 * to imply it's "to" of a branch.
569 call->abort_count = 1; 577 */
570 578 call->brtype_stat.branch_to = true;
571 call->cycles_count = cursor_node->branch_flags.cycles; 579
572 call->iter_count = cursor_node->nr_loop_iter; 580 if (cursor_node->branch_flags.predicted)
573 call->samples_count = cursor_node->samples; 581 call->predicted_count = 1;
582
583 if (cursor_node->branch_flags.abort)
584 call->abort_count = 1;
585
586 branch_type_count(&call->brtype_stat,
587 &cursor_node->branch_flags,
588 cursor_node->branch_from,
589 cursor_node->ip);
590 } else {
591 /*
592 * It's "from" of a branch
593 */
594 call->brtype_stat.branch_to = false;
595 call->cycles_count =
596 cursor_node->branch_flags.cycles;
597 call->iter_count = cursor_node->nr_loop_iter;
598 call->iter_cycles = cursor_node->iter_cycles;
599 }
574 } 600 }
575 601
576 list_add_tail(&call->list, &node->val); 602 list_add_tail(&call->list, &node->val);
@@ -679,15 +705,32 @@ static enum match_result match_chain(struct callchain_cursor_node *node,
679 if (node->branch) { 705 if (node->branch) {
680 cnode->branch_count++; 706 cnode->branch_count++;
681 707
682 if (node->branch_flags.predicted) 708 if (node->branch_from) {
683 cnode->predicted_count++; 709 /*
684 710 * It's "to" of a branch
685 if (node->branch_flags.abort) 711 */
686 cnode->abort_count++; 712 cnode->brtype_stat.branch_to = true;
687 713
688 cnode->cycles_count += node->branch_flags.cycles; 714 if (node->branch_flags.predicted)
689 cnode->iter_count += node->nr_loop_iter; 715 cnode->predicted_count++;
690 cnode->samples_count += node->samples; 716
717 if (node->branch_flags.abort)
718 cnode->abort_count++;
719
720 branch_type_count(&cnode->brtype_stat,
721 &node->branch_flags,
722 node->branch_from,
723 node->ip);
724 } else {
725 /*
726 * It's "from" of a branch
727 */
728 cnode->brtype_stat.branch_to = false;
729 cnode->cycles_count +=
730 node->branch_flags.cycles;
731 cnode->iter_count += node->nr_loop_iter;
732 cnode->iter_cycles += node->iter_cycles;
733 }
691 } 734 }
692 735
693 return MATCH_EQ; 736 return MATCH_EQ;
@@ -922,7 +965,7 @@ merge_chain_branch(struct callchain_cursor *cursor,
922 list_for_each_entry_safe(list, next_list, &src->val, list) { 965 list_for_each_entry_safe(list, next_list, &src->val, list) {
923 callchain_cursor_append(cursor, list->ip, 966 callchain_cursor_append(cursor, list->ip,
924 list->ms.map, list->ms.sym, 967 list->ms.map, list->ms.sym,
925 false, NULL, 0, 0); 968 false, NULL, 0, 0, 0);
926 list_del(&list->list); 969 list_del(&list->list);
927 map__zput(list->ms.map); 970 map__zput(list->ms.map);
928 free(list); 971 free(list);
@@ -962,7 +1005,7 @@ int callchain_merge(struct callchain_cursor *cursor,
962int callchain_cursor_append(struct callchain_cursor *cursor, 1005int callchain_cursor_append(struct callchain_cursor *cursor,
963 u64 ip, struct map *map, struct symbol *sym, 1006 u64 ip, struct map *map, struct symbol *sym,
964 bool branch, struct branch_flags *flags, 1007 bool branch, struct branch_flags *flags,
965 int nr_loop_iter, int samples) 1008 int nr_loop_iter, u64 iter_cycles, u64 branch_from)
966{ 1009{
967 struct callchain_cursor_node *node = *cursor->last; 1010 struct callchain_cursor_node *node = *cursor->last;
968 1011
@@ -980,12 +1023,13 @@ int callchain_cursor_append(struct callchain_cursor *cursor,
980 node->sym = sym; 1023 node->sym = sym;
981 node->branch = branch; 1024 node->branch = branch;
982 node->nr_loop_iter = nr_loop_iter; 1025 node->nr_loop_iter = nr_loop_iter;
983 node->samples = samples; 1026 node->iter_cycles = iter_cycles;
984 1027
985 if (flags) 1028 if (flags)
986 memcpy(&node->branch_flags, flags, 1029 memcpy(&node->branch_flags, flags,
987 sizeof(struct branch_flags)); 1030 sizeof(struct branch_flags));
988 1031
1032 node->branch_from = branch_from;
989 cursor->nr++; 1033 cursor->nr++;
990 1034
991 cursor->last = &node->next; 1035 cursor->last = &node->next;
@@ -998,11 +1042,11 @@ int sample__resolve_callchain(struct perf_sample *sample,
998 struct perf_evsel *evsel, struct addr_location *al, 1042 struct perf_evsel *evsel, struct addr_location *al,
999 int max_stack) 1043 int max_stack)
1000{ 1044{
1001 if (sample->callchain == NULL) 1045 if (sample->callchain == NULL && !symbol_conf.show_branchflag_count)
1002 return 0; 1046 return 0;
1003 1047
1004 if (symbol_conf.use_callchain || symbol_conf.cumulate_callchain || 1048 if (symbol_conf.use_callchain || symbol_conf.cumulate_callchain ||
1005 perf_hpp_list.parent) { 1049 perf_hpp_list.parent || symbol_conf.show_branchflag_count) {
1006 return thread__resolve_callchain(al->thread, cursor, evsel, sample, 1050 return thread__resolve_callchain(al->thread, cursor, evsel, sample,
1007 parent, al, max_stack); 1051 parent, al, max_stack);
1008 } 1052 }
@@ -1011,7 +1055,8 @@ int sample__resolve_callchain(struct perf_sample *sample,
1011 1055
1012int hist_entry__append_callchain(struct hist_entry *he, struct perf_sample *sample) 1056int hist_entry__append_callchain(struct hist_entry *he, struct perf_sample *sample)
1013{ 1057{
1014 if (!symbol_conf.use_callchain || sample->callchain == NULL) 1058 if ((!symbol_conf.use_callchain || sample->callchain == NULL) &&
1059 !symbol_conf.show_branchflag_count)
1015 return 0; 1060 return 0;
1016 return callchain_append(he->callchain, &callchain_cursor, sample->period); 1061 return callchain_append(he->callchain, &callchain_cursor, sample->period);
1017} 1062}
@@ -1214,95 +1259,124 @@ int callchain_branch_counts(struct callchain_root *root,
1214 cycles_count); 1259 cycles_count);
1215} 1260}
1216 1261
1217static int counts_str_build(char *bf, int bfsize, 1262static int count_pri64_printf(int idx, const char *str, u64 value, char *bf, int bfsize)
1218 u64 branch_count, u64 predicted_count,
1219 u64 abort_count, u64 cycles_count,
1220 u64 iter_count, u64 samples_count)
1221{ 1263{
1222 double predicted_percent = 0.0; 1264 int printed;
1223 const char *null_str = "";
1224 char iter_str[32];
1225 char cycle_str[32];
1226 char *istr, *cstr;
1227 u64 cycles;
1228 1265
1229 if (branch_count == 0) 1266 printed = scnprintf(bf, bfsize, "%s%s:%" PRId64 "", (idx) ? " " : " (", str, value);
1230 return scnprintf(bf, bfsize, " (calltrace)");
1231 1267
1232 cycles = cycles_count / branch_count; 1268 return printed;
1269}
1233 1270
1234 if (iter_count && samples_count) { 1271static int count_float_printf(int idx, const char *str, float value,
1235 if (cycles > 0) 1272 char *bf, int bfsize, float threshold)
1236 scnprintf(iter_str, sizeof(iter_str), 1273{
1237 " iterations:%" PRId64 "", 1274 int printed;
1238 iter_count / samples_count);
1239 else
1240 scnprintf(iter_str, sizeof(iter_str),
1241 "iterations:%" PRId64 "",
1242 iter_count / samples_count);
1243 istr = iter_str;
1244 } else
1245 istr = (char *)null_str;
1246 1275
1247 if (cycles > 0) { 1276 if (threshold != 0.0 && value < threshold)
1248 scnprintf(cycle_str, sizeof(cycle_str), 1277 return 0;
1249 "cycles:%" PRId64 "", cycles);
1250 cstr = cycle_str;
1251 } else
1252 cstr = (char *)null_str;
1253 1278
1254 predicted_percent = predicted_count * 100.0 / branch_count; 1279 printed = scnprintf(bf, bfsize, "%s%s:%.1f%%", (idx) ? " " : " (", str, value);
1255 1280
1256 if ((predicted_count == branch_count) && (abort_count == 0)) { 1281 return printed;
1257 if ((cycles > 0) || (istr != (char *)null_str)) 1282}
1258 return scnprintf(bf, bfsize, " (%s%s)", cstr, istr); 1283
1259 else 1284static int branch_to_str(char *bf, int bfsize,
1260 return scnprintf(bf, bfsize, "%s", (char *)null_str); 1285 u64 branch_count, u64 predicted_count,
1261 } 1286 u64 abort_count,
1262 1287 struct branch_type_stat *brtype_stat)
1263 if ((predicted_count < branch_count) && (abort_count == 0)) { 1288{
1264 if ((cycles > 0) || (istr != (char *)null_str)) 1289 int printed, i = 0;
1265 return scnprintf(bf, bfsize, 1290
1266 " (predicted:%.1f%% %s%s)", 1291 printed = branch_type_str(brtype_stat, bf, bfsize);
1267 predicted_percent, cstr, istr); 1292 if (printed)
1268 else { 1293 i++;
1269 return scnprintf(bf, bfsize, 1294
1270 " (predicted:%.1f%%)", 1295 if (predicted_count < branch_count) {
1271 predicted_percent); 1296 printed += count_float_printf(i++, "predicted",
1272 } 1297 predicted_count * 100.0 / branch_count,
1298 bf + printed, bfsize - printed, 0.0);
1273 } 1299 }
1274 1300
1275 if ((predicted_count == branch_count) && (abort_count > 0)) { 1301 if (abort_count) {
1276 if ((cycles > 0) || (istr != (char *)null_str)) 1302 printed += count_float_printf(i++, "abort",
1277 return scnprintf(bf, bfsize, 1303 abort_count * 100.0 / branch_count,
1278 " (abort:%" PRId64 " %s%s)", 1304 bf + printed, bfsize - printed, 0.1);
1279 abort_count, cstr, istr);
1280 else
1281 return scnprintf(bf, bfsize,
1282 " (abort:%" PRId64 ")",
1283 abort_count);
1284 } 1305 }
1285 1306
1286 if ((cycles > 0) || (istr != (char *)null_str)) 1307 if (i)
1287 return scnprintf(bf, bfsize, 1308 printed += scnprintf(bf + printed, bfsize - printed, ")");
1288 " (predicted:%.1f%% abort:%" PRId64 " %s%s)",
1289 predicted_percent, abort_count, cstr, istr);
1290 1309
1291 return scnprintf(bf, bfsize, 1310 return printed;
1292 " (predicted:%.1f%% abort:%" PRId64 ")", 1311}
1293 predicted_percent, abort_count); 1312
1313static int branch_from_str(char *bf, int bfsize,
1314 u64 branch_count,
1315 u64 cycles_count, u64 iter_count,
1316 u64 iter_cycles)
1317{
1318 int printed = 0, i = 0;
1319 u64 cycles;
1320
1321 cycles = cycles_count / branch_count;
1322 if (cycles) {
1323 printed += count_pri64_printf(i++, "cycles",
1324 cycles,
1325 bf + printed, bfsize - printed);
1326 }
1327
1328 if (iter_count) {
1329 printed += count_pri64_printf(i++, "iter",
1330 iter_count,
1331 bf + printed, bfsize - printed);
1332
1333 printed += count_pri64_printf(i++, "avg_cycles",
1334 iter_cycles / iter_count,
1335 bf + printed, bfsize - printed);
1336 }
1337
1338 if (i)
1339 printed += scnprintf(bf + printed, bfsize - printed, ")");
1340
1341 return printed;
1342}
1343
1344static int counts_str_build(char *bf, int bfsize,
1345 u64 branch_count, u64 predicted_count,
1346 u64 abort_count, u64 cycles_count,
1347 u64 iter_count, u64 iter_cycles,
1348 struct branch_type_stat *brtype_stat)
1349{
1350 int printed;
1351
1352 if (branch_count == 0)
1353 return scnprintf(bf, bfsize, " (calltrace)");
1354
1355 if (brtype_stat->branch_to) {
1356 printed = branch_to_str(bf, bfsize, branch_count,
1357 predicted_count, abort_count, brtype_stat);
1358 } else {
1359 printed = branch_from_str(bf, bfsize, branch_count,
1360 cycles_count, iter_count, iter_cycles);
1361 }
1362
1363 if (!printed)
1364 bf[0] = 0;
1365
1366 return printed;
1294} 1367}
1295 1368
1296static int callchain_counts_printf(FILE *fp, char *bf, int bfsize, 1369static int callchain_counts_printf(FILE *fp, char *bf, int bfsize,
1297 u64 branch_count, u64 predicted_count, 1370 u64 branch_count, u64 predicted_count,
1298 u64 abort_count, u64 cycles_count, 1371 u64 abort_count, u64 cycles_count,
1299 u64 iter_count, u64 samples_count) 1372 u64 iter_count, u64 iter_cycles,
1373 struct branch_type_stat *brtype_stat)
1300{ 1374{
1301 char str[128]; 1375 char str[256];
1302 1376
1303 counts_str_build(str, sizeof(str), branch_count, 1377 counts_str_build(str, sizeof(str), branch_count,
1304 predicted_count, abort_count, cycles_count, 1378 predicted_count, abort_count, cycles_count,
1305 iter_count, samples_count); 1379 iter_count, iter_cycles, brtype_stat);
1306 1380
1307 if (fp) 1381 if (fp)
1308 return fprintf(fp, "%s", str); 1382 return fprintf(fp, "%s", str);
@@ -1310,31 +1384,24 @@ static int callchain_counts_printf(FILE *fp, char *bf, int bfsize,
1310 return scnprintf(bf, bfsize, "%s", str); 1384 return scnprintf(bf, bfsize, "%s", str);
1311} 1385}
1312 1386
1313int callchain_list_counts__printf_value(struct callchain_node *node, 1387int callchain_list_counts__printf_value(struct callchain_list *clist,
1314 struct callchain_list *clist,
1315 FILE *fp, char *bf, int bfsize) 1388 FILE *fp, char *bf, int bfsize)
1316{ 1389{
1317 u64 branch_count, predicted_count; 1390 u64 branch_count, predicted_count;
1318 u64 abort_count, cycles_count; 1391 u64 abort_count, cycles_count;
1319 u64 iter_count = 0, samples_count = 0; 1392 u64 iter_count, iter_cycles;
1320 1393
1321 branch_count = clist->branch_count; 1394 branch_count = clist->branch_count;
1322 predicted_count = clist->predicted_count; 1395 predicted_count = clist->predicted_count;
1323 abort_count = clist->abort_count; 1396 abort_count = clist->abort_count;
1324 cycles_count = clist->cycles_count; 1397 cycles_count = clist->cycles_count;
1325 1398 iter_count = clist->iter_count;
1326 if (node) { 1399 iter_cycles = clist->iter_cycles;
1327 struct callchain_list *call;
1328
1329 list_for_each_entry(call, &node->val, list) {
1330 iter_count += call->iter_count;
1331 samples_count += call->samples_count;
1332 }
1333 }
1334 1400
1335 return callchain_counts_printf(fp, bf, bfsize, branch_count, 1401 return callchain_counts_printf(fp, bf, bfsize, branch_count,
1336 predicted_count, abort_count, 1402 predicted_count, abort_count,
1337 cycles_count, iter_count, samples_count); 1403 cycles_count, iter_count, iter_cycles,
1404 &clist->brtype_stat);
1338} 1405}
1339 1406
1340static void free_callchain_node(struct callchain_node *node) 1407static void free_callchain_node(struct callchain_node *node)
@@ -1459,7 +1526,9 @@ int callchain_cursor__copy(struct callchain_cursor *dst,
1459 1526
1460 rc = callchain_cursor_append(dst, node->ip, node->map, node->sym, 1527 rc = callchain_cursor_append(dst, node->ip, node->map, node->sym,
1461 node->branch, &node->branch_flags, 1528 node->branch, &node->branch_flags,
1462 node->nr_loop_iter, node->samples); 1529 node->nr_loop_iter,
1530 node->iter_cycles,
1531 node->branch_from);
1463 if (rc) 1532 if (rc)
1464 break; 1533 break;
1465 1534
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
index c56c23dbbf72..1ed6fc61d0a5 100644
--- a/tools/perf/util/callchain.h
+++ b/tools/perf/util/callchain.h
@@ -7,6 +7,7 @@
7#include "event.h" 7#include "event.h"
8#include "map.h" 8#include "map.h"
9#include "symbol.h" 9#include "symbol.h"
10#include "branch.h"
10 11
11#define HELP_PAD "\t\t\t\t" 12#define HELP_PAD "\t\t\t\t"
12 13
@@ -118,7 +119,8 @@ struct callchain_list {
118 u64 abort_count; 119 u64 abort_count;
119 u64 cycles_count; 120 u64 cycles_count;
120 u64 iter_count; 121 u64 iter_count;
121 u64 samples_count; 122 u64 iter_cycles;
123 struct branch_type_stat brtype_stat;
122 char *srcline; 124 char *srcline;
123 struct list_head list; 125 struct list_head list;
124}; 126};
@@ -135,8 +137,9 @@ struct callchain_cursor_node {
135 struct symbol *sym; 137 struct symbol *sym;
136 bool branch; 138 bool branch;
137 struct branch_flags branch_flags; 139 struct branch_flags branch_flags;
140 u64 branch_from;
138 int nr_loop_iter; 141 int nr_loop_iter;
139 int samples; 142 u64 iter_cycles;
140 struct callchain_cursor_node *next; 143 struct callchain_cursor_node *next;
141}; 144};
142 145
@@ -198,7 +201,7 @@ static inline void callchain_cursor_reset(struct callchain_cursor *cursor)
198int callchain_cursor_append(struct callchain_cursor *cursor, u64 ip, 201int callchain_cursor_append(struct callchain_cursor *cursor, u64 ip,
199 struct map *map, struct symbol *sym, 202 struct map *map, struct symbol *sym,
200 bool branch, struct branch_flags *flags, 203 bool branch, struct branch_flags *flags,
201 int nr_loop_iter, int samples); 204 int nr_loop_iter, u64 iter_cycles, u64 branch_from);
202 205
203/* Close a cursor writing session. Initialize for the reader */ 206/* Close a cursor writing session. Initialize for the reader */
204static inline void callchain_cursor_commit(struct callchain_cursor *cursor) 207static inline void callchain_cursor_commit(struct callchain_cursor *cursor)
@@ -279,8 +282,7 @@ char *callchain_node__scnprintf_value(struct callchain_node *node,
279int callchain_node__fprintf_value(struct callchain_node *node, 282int callchain_node__fprintf_value(struct callchain_node *node,
280 FILE *fp, u64 total); 283 FILE *fp, u64 total);
281 284
282int callchain_list_counts__printf_value(struct callchain_node *node, 285int callchain_list_counts__printf_value(struct callchain_list *clist,
283 struct callchain_list *clist,
284 FILE *fp, char *bf, int bfsize); 286 FILE *fp, char *bf, int bfsize);
285 287
286void free_callchain(struct callchain_root *root); 288void free_callchain(struct callchain_root *root);
diff --git a/tools/perf/util/cgroup.c b/tools/perf/util/cgroup.c
index 03347748f3fa..0e77bc9e5f3c 100644
--- a/tools/perf/util/cgroup.c
+++ b/tools/perf/util/cgroup.c
@@ -98,8 +98,10 @@ static int add_cgroup(struct perf_evlist *evlist, char *str)
98 cgrp = counter->cgrp; 98 cgrp = counter->cgrp;
99 if (!cgrp) 99 if (!cgrp)
100 continue; 100 continue;
101 if (!strcmp(cgrp->name, str)) 101 if (!strcmp(cgrp->name, str)) {
102 refcount_inc(&cgrp->refcnt);
102 break; 103 break;
104 }
103 105
104 cgrp = NULL; 106 cgrp = NULL;
105 } 107 }
@@ -110,6 +112,7 @@ static int add_cgroup(struct perf_evlist *evlist, char *str)
110 return -1; 112 return -1;
111 113
112 cgrp->name = str; 114 cgrp->name = str;
115 refcount_set(&cgrp->refcnt, 1);
113 116
114 cgrp->fd = open_cgroup(str); 117 cgrp->fd = open_cgroup(str);
115 if (cgrp->fd == -1) { 118 if (cgrp->fd == -1) {
@@ -128,12 +131,11 @@ static int add_cgroup(struct perf_evlist *evlist, char *str)
128 goto found; 131 goto found;
129 n++; 132 n++;
130 } 133 }
131 if (refcount_read(&cgrp->refcnt) == 0) 134 if (refcount_dec_and_test(&cgrp->refcnt))
132 free(cgrp); 135 free(cgrp);
133 136
134 return -1; 137 return -1;
135found: 138found:
136 refcount_inc(&cgrp->refcnt);
137 counter->cgrp = cgrp; 139 counter->cgrp = cgrp;
138 return 0; 140 return 0;
139} 141}
diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
index 31a7dea248d0..bc75596f9e79 100644
--- a/tools/perf/util/config.c
+++ b/tools/perf/util/config.c
@@ -19,6 +19,7 @@
19#include <sys/types.h> 19#include <sys/types.h>
20#include <sys/stat.h> 20#include <sys/stat.h>
21#include <unistd.h> 21#include <unistd.h>
22#include <linux/string.h>
22 23
23#include "sane_ctype.h" 24#include "sane_ctype.h"
24 25
@@ -433,22 +434,22 @@ static int perf_ui_config(const char *var, const char *value)
433int perf_default_config(const char *var, const char *value, 434int perf_default_config(const char *var, const char *value,
434 void *dummy __maybe_unused) 435 void *dummy __maybe_unused)
435{ 436{
436 if (!prefixcmp(var, "core.")) 437 if (strstarts(var, "core."))
437 return perf_default_core_config(var, value); 438 return perf_default_core_config(var, value);
438 439
439 if (!prefixcmp(var, "hist.")) 440 if (strstarts(var, "hist."))
440 return perf_hist_config(var, value); 441 return perf_hist_config(var, value);
441 442
442 if (!prefixcmp(var, "ui.")) 443 if (strstarts(var, "ui."))
443 return perf_ui_config(var, value); 444 return perf_ui_config(var, value);
444 445
445 if (!prefixcmp(var, "call-graph.")) 446 if (strstarts(var, "call-graph."))
446 return perf_callchain_config(var, value); 447 return perf_callchain_config(var, value);
447 448
448 if (!prefixcmp(var, "llvm.")) 449 if (strstarts(var, "llvm."))
449 return perf_llvm_config(var, value); 450 return perf_llvm_config(var, value);
450 451
451 if (!prefixcmp(var, "buildid.")) 452 if (strstarts(var, "buildid."))
452 return perf_buildid_config(var, value); 453 return perf_buildid_config(var, value);
453 454
454 /* Add other config variables here. */ 455 /* Add other config variables here. */
diff --git a/tools/perf/util/counts.h b/tools/perf/util/counts.h
index 34d8baaf558a..cb45a6aecf9d 100644
--- a/tools/perf/util/counts.h
+++ b/tools/perf/util/counts.h
@@ -12,6 +12,7 @@ struct perf_counts_values {
12 }; 12 };
13 u64 values[3]; 13 u64 values[3];
14 }; 14 };
15 bool loaded;
15}; 16};
16 17
17struct perf_counts { 18struct perf_counts {
diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c
index 3149b70799fd..2346cecb8ea2 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -76,6 +76,8 @@ struct ctf_writer {
76 struct bt_ctf_event_class *comm_class; 76 struct bt_ctf_event_class *comm_class;
77 struct bt_ctf_event_class *exit_class; 77 struct bt_ctf_event_class *exit_class;
78 struct bt_ctf_event_class *fork_class; 78 struct bt_ctf_event_class *fork_class;
79 struct bt_ctf_event_class *mmap_class;
80 struct bt_ctf_event_class *mmap2_class;
79}; 81};
80 82
81struct convert { 83struct convert {
@@ -506,6 +508,81 @@ put_len_type:
506 return ret; 508 return ret;
507} 509}
508 510
511static int
512add_callchain_output_values(struct bt_ctf_event_class *event_class,
513 struct bt_ctf_event *event,
514 struct ip_callchain *callchain)
515{
516 struct bt_ctf_field_type *len_type, *seq_type;
517 struct bt_ctf_field *len_field, *seq_field;
518 unsigned int nr_elements = callchain->nr;
519 unsigned int i;
520 int ret;
521
522 len_type = bt_ctf_event_class_get_field_by_name(
523 event_class, "perf_callchain_size");
524 len_field = bt_ctf_field_create(len_type);
525 if (!len_field) {
526 pr_err("failed to create 'perf_callchain_size' for callchain output event\n");
527 ret = -1;
528 goto put_len_type;
529 }
530
531 ret = bt_ctf_field_unsigned_integer_set_value(len_field, nr_elements);
532 if (ret) {
533 pr_err("failed to set field value for perf_callchain_size\n");
534 goto put_len_field;
535 }
536 ret = bt_ctf_event_set_payload(event, "perf_callchain_size", len_field);
537 if (ret) {
538 pr_err("failed to set payload to perf_callchain_size\n");
539 goto put_len_field;
540 }
541
542 seq_type = bt_ctf_event_class_get_field_by_name(
543 event_class, "perf_callchain");
544 seq_field = bt_ctf_field_create(seq_type);
545 if (!seq_field) {
546 pr_err("failed to create 'perf_callchain' for callchain output event\n");
547 ret = -1;
548 goto put_seq_type;
549 }
550
551 ret = bt_ctf_field_sequence_set_length(seq_field, len_field);
552 if (ret) {
553 pr_err("failed to set length of 'perf_callchain'\n");
554 goto put_seq_field;
555 }
556
557 for (i = 0; i < nr_elements; i++) {
558 struct bt_ctf_field *elem_field =
559 bt_ctf_field_sequence_get_field(seq_field, i);
560
561 ret = bt_ctf_field_unsigned_integer_set_value(elem_field,
562 ((u64 *)(callchain->ips))[i]);
563
564 bt_ctf_field_put(elem_field);
565 if (ret) {
566 pr_err("failed to set callchain[%d]\n", i);
567 goto put_seq_field;
568 }
569 }
570
571 ret = bt_ctf_event_set_payload(event, "perf_callchain", seq_field);
572 if (ret)
573 pr_err("failed to set payload for raw_data\n");
574
575put_seq_field:
576 bt_ctf_field_put(seq_field);
577put_seq_type:
578 bt_ctf_field_type_put(seq_type);
579put_len_field:
580 bt_ctf_field_put(len_field);
581put_len_type:
582 bt_ctf_field_type_put(len_type);
583 return ret;
584}
585
509static int add_generic_values(struct ctf_writer *cw, 586static int add_generic_values(struct ctf_writer *cw,
510 struct bt_ctf_event *event, 587 struct bt_ctf_event *event,
511 struct perf_evsel *evsel, 588 struct perf_evsel *evsel,
@@ -519,7 +596,6 @@ static int add_generic_values(struct ctf_writer *cw,
519 * PERF_SAMPLE_TIME - not needed as we have it in 596 * PERF_SAMPLE_TIME - not needed as we have it in
520 * ctf event header 597 * ctf event header
521 * PERF_SAMPLE_READ - TODO 598 * PERF_SAMPLE_READ - TODO
522 * PERF_SAMPLE_CALLCHAIN - TODO
523 * PERF_SAMPLE_RAW - tracepoint fields are handled separately 599 * PERF_SAMPLE_RAW - tracepoint fields are handled separately
524 * PERF_SAMPLE_BRANCH_STACK - TODO 600 * PERF_SAMPLE_BRANCH_STACK - TODO
525 * PERF_SAMPLE_REGS_USER - TODO 601 * PERF_SAMPLE_REGS_USER - TODO
@@ -720,6 +796,7 @@ static int process_sample_event(struct perf_tool *tool,
720 struct bt_ctf_event_class *event_class; 796 struct bt_ctf_event_class *event_class;
721 struct bt_ctf_event *event; 797 struct bt_ctf_event *event;
722 int ret; 798 int ret;
799 unsigned long type = evsel->attr.sample_type;
723 800
724 if (WARN_ONCE(!priv, "Failed to setup all events.\n")) 801 if (WARN_ONCE(!priv, "Failed to setup all events.\n"))
725 return 0; 802 return 0;
@@ -751,6 +828,13 @@ static int process_sample_event(struct perf_tool *tool,
751 return -1; 828 return -1;
752 } 829 }
753 830
831 if (type & PERF_SAMPLE_CALLCHAIN) {
832 ret = add_callchain_output_values(event_class,
833 event, sample->callchain);
834 if (ret)
835 return -1;
836 }
837
754 if (perf_evsel__is_bpf_output(evsel)) { 838 if (perf_evsel__is_bpf_output(evsel)) {
755 ret = add_bpf_output_values(event_class, event, sample); 839 ret = add_bpf_output_values(event_class, event, sample);
756 if (ret) 840 if (ret)
@@ -833,6 +917,18 @@ __FUNC_PROCESS_NON_SAMPLE(exit,
833 __NON_SAMPLE_SET_FIELD(fork, u32, ptid); 917 __NON_SAMPLE_SET_FIELD(fork, u32, ptid);
834 __NON_SAMPLE_SET_FIELD(fork, u64, time); 918 __NON_SAMPLE_SET_FIELD(fork, u64, time);
835) 919)
920__FUNC_PROCESS_NON_SAMPLE(mmap,
921 __NON_SAMPLE_SET_FIELD(mmap, u32, pid);
922 __NON_SAMPLE_SET_FIELD(mmap, u32, tid);
923 __NON_SAMPLE_SET_FIELD(mmap, u64_hex, start);
924 __NON_SAMPLE_SET_FIELD(mmap, string, filename);
925)
926__FUNC_PROCESS_NON_SAMPLE(mmap2,
927 __NON_SAMPLE_SET_FIELD(mmap2, u32, pid);
928 __NON_SAMPLE_SET_FIELD(mmap2, u32, tid);
929 __NON_SAMPLE_SET_FIELD(mmap2, u64_hex, start);
930 __NON_SAMPLE_SET_FIELD(mmap2, string, filename);
931)
836#undef __NON_SAMPLE_SET_FIELD 932#undef __NON_SAMPLE_SET_FIELD
837#undef __FUNC_PROCESS_NON_SAMPLE 933#undef __FUNC_PROCESS_NON_SAMPLE
838 934
@@ -1043,6 +1139,14 @@ static int add_generic_types(struct ctf_writer *cw, struct perf_evsel *evsel,
1043 if (type & PERF_SAMPLE_TRANSACTION) 1139 if (type & PERF_SAMPLE_TRANSACTION)
1044 ADD_FIELD(event_class, cw->data.u64, "perf_transaction"); 1140 ADD_FIELD(event_class, cw->data.u64, "perf_transaction");
1045 1141
1142 if (type & PERF_SAMPLE_CALLCHAIN) {
1143 ADD_FIELD(event_class, cw->data.u32, "perf_callchain_size");
1144 ADD_FIELD(event_class,
1145 bt_ctf_field_type_sequence_create(
1146 cw->data.u64_hex, "perf_callchain_size"),
1147 "perf_callchain");
1148 }
1149
1046#undef ADD_FIELD 1150#undef ADD_FIELD
1047 return 0; 1151 return 0;
1048} 1152}
@@ -1164,6 +1268,19 @@ __FUNC_ADD_NON_SAMPLE_EVENT_CLASS(exit,
1164 __NON_SAMPLE_ADD_FIELD(u64, time); 1268 __NON_SAMPLE_ADD_FIELD(u64, time);
1165) 1269)
1166 1270
1271__FUNC_ADD_NON_SAMPLE_EVENT_CLASS(mmap,
1272 __NON_SAMPLE_ADD_FIELD(u32, pid);
1273 __NON_SAMPLE_ADD_FIELD(u32, tid);
1274 __NON_SAMPLE_ADD_FIELD(u64_hex, start);
1275 __NON_SAMPLE_ADD_FIELD(string, filename);
1276)
1277
1278__FUNC_ADD_NON_SAMPLE_EVENT_CLASS(mmap2,
1279 __NON_SAMPLE_ADD_FIELD(u32, pid);
1280 __NON_SAMPLE_ADD_FIELD(u32, tid);
1281 __NON_SAMPLE_ADD_FIELD(u64_hex, start);
1282 __NON_SAMPLE_ADD_FIELD(string, filename);
1283)
1167#undef __NON_SAMPLE_ADD_FIELD 1284#undef __NON_SAMPLE_ADD_FIELD
1168#undef __FUNC_ADD_NON_SAMPLE_EVENT_CLASS 1285#undef __FUNC_ADD_NON_SAMPLE_EVENT_CLASS
1169 1286
@@ -1181,6 +1298,12 @@ static int setup_non_sample_events(struct ctf_writer *cw,
1181 ret = add_fork_event(cw); 1298 ret = add_fork_event(cw);
1182 if (ret) 1299 if (ret)
1183 return ret; 1300 return ret;
1301 ret = add_mmap_event(cw);
1302 if (ret)
1303 return ret;
1304 ret = add_mmap2_event(cw);
1305 if (ret)
1306 return ret;
1184 return 0; 1307 return 0;
1185} 1308}
1186 1309
@@ -1482,6 +1605,8 @@ int bt_convert__perf2ctf(const char *input, const char *path,
1482 c.tool.comm = process_comm_event; 1605 c.tool.comm = process_comm_event;
1483 c.tool.exit = process_exit_event; 1606 c.tool.exit = process_exit_event;
1484 c.tool.fork = process_fork_event; 1607 c.tool.fork = process_fork_event;
1608 c.tool.mmap = process_mmap_event;
1609 c.tool.mmap2 = process_mmap2_event;
1485 } 1610 }
1486 1611
1487 err = perf_config(convert__config, &c); 1612 err = perf_config(convert__config, &c);
diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c
index e84bbc8ec058..263f5a906ba5 100644
--- a/tools/perf/util/data.c
+++ b/tools/perf/util/data.c
@@ -10,6 +10,16 @@
10#include "util.h" 10#include "util.h"
11#include "debug.h" 11#include "debug.h"
12 12
13#ifndef O_CLOEXEC
14#ifdef __sparc__
15#define O_CLOEXEC 0x400000
16#elif defined(__alpha__) || defined(__hppa__)
17#define O_CLOEXEC 010000000
18#else
19#define O_CLOEXEC 02000000
20#endif
21#endif
22
13static bool check_pipe(struct perf_data_file *file) 23static bool check_pipe(struct perf_data_file *file)
14{ 24{
15 struct stat st; 25 struct stat st;
@@ -96,7 +106,8 @@ static int open_file_write(struct perf_data_file *file)
96 if (check_backup(file)) 106 if (check_backup(file))
97 return -1; 107 return -1;
98 108
99 fd = open(file->path, O_CREAT|O_RDWR|O_TRUNC, S_IRUSR|S_IWUSR); 109 fd = open(file->path, O_CREAT|O_RDWR|O_TRUNC|O_CLOEXEC,
110 S_IRUSR|S_IWUSR);
100 111
101 if (fd < 0) 112 if (fd < 0)
102 pr_err("failed to open %s : %s\n", file->path, 113 pr_err("failed to open %s : %s\n", file->path,
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 4e7ab611377a..b9e087fb8247 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -32,6 +32,7 @@ char dso__symtab_origin(const struct dso *dso)
32 [DSO_BINARY_TYPE__JAVA_JIT] = 'j', 32 [DSO_BINARY_TYPE__JAVA_JIT] = 'j',
33 [DSO_BINARY_TYPE__DEBUGLINK] = 'l', 33 [DSO_BINARY_TYPE__DEBUGLINK] = 'l',
34 [DSO_BINARY_TYPE__BUILD_ID_CACHE] = 'B', 34 [DSO_BINARY_TYPE__BUILD_ID_CACHE] = 'B',
35 [DSO_BINARY_TYPE__BUILD_ID_CACHE_DEBUGINFO] = 'D',
35 [DSO_BINARY_TYPE__FEDORA_DEBUGINFO] = 'f', 36 [DSO_BINARY_TYPE__FEDORA_DEBUGINFO] = 'f',
36 [DSO_BINARY_TYPE__UBUNTU_DEBUGINFO] = 'u', 37 [DSO_BINARY_TYPE__UBUNTU_DEBUGINFO] = 'u',
37 [DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO] = 'o', 38 [DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO] = 'o',
@@ -97,7 +98,12 @@ int dso__read_binary_type_filename(const struct dso *dso,
97 break; 98 break;
98 } 99 }
99 case DSO_BINARY_TYPE__BUILD_ID_CACHE: 100 case DSO_BINARY_TYPE__BUILD_ID_CACHE:
100 if (dso__build_id_filename(dso, filename, size) == NULL) 101 if (dso__build_id_filename(dso, filename, size, false) == NULL)
102 ret = -1;
103 break;
104
105 case DSO_BINARY_TYPE__BUILD_ID_CACHE_DEBUGINFO:
106 if (dso__build_id_filename(dso, filename, size, true) == NULL)
101 ret = -1; 107 ret = -1;
102 break; 108 break;
103 109
@@ -504,7 +510,14 @@ static void check_data_close(void);
504 */ 510 */
505static int open_dso(struct dso *dso, struct machine *machine) 511static int open_dso(struct dso *dso, struct machine *machine)
506{ 512{
507 int fd = __open_dso(dso, machine); 513 int fd;
514 struct nscookie nsc;
515
516 if (dso->binary_type != DSO_BINARY_TYPE__BUILD_ID_CACHE)
517 nsinfo__mountns_enter(dso->nsinfo, &nsc);
518 fd = __open_dso(dso, machine);
519 if (dso->binary_type != DSO_BINARY_TYPE__BUILD_ID_CACHE)
520 nsinfo__mountns_exit(&nsc);
508 521
509 if (fd >= 0) { 522 if (fd >= 0) {
510 dso__list_add(dso); 523 dso__list_add(dso);
@@ -1236,6 +1249,7 @@ void dso__delete(struct dso *dso)
1236 dso_cache__free(dso); 1249 dso_cache__free(dso);
1237 dso__free_a2l(dso); 1250 dso__free_a2l(dso);
1238 zfree(&dso->symsrc_filename); 1251 zfree(&dso->symsrc_filename);
1252 nsinfo__zput(dso->nsinfo);
1239 pthread_mutex_destroy(&dso->lock); 1253 pthread_mutex_destroy(&dso->lock);
1240 free(dso); 1254 free(dso);
1241} 1255}
@@ -1301,6 +1315,7 @@ bool __dsos__read_build_ids(struct list_head *head, bool with_hits)
1301{ 1315{
1302 bool have_build_id = false; 1316 bool have_build_id = false;
1303 struct dso *pos; 1317 struct dso *pos;
1318 struct nscookie nsc;
1304 1319
1305 list_for_each_entry(pos, head, node) { 1320 list_for_each_entry(pos, head, node) {
1306 if (with_hits && !pos->hit && !dso__is_vdso(pos)) 1321 if (with_hits && !pos->hit && !dso__is_vdso(pos))
@@ -1309,11 +1324,13 @@ bool __dsos__read_build_ids(struct list_head *head, bool with_hits)
1309 have_build_id = true; 1324 have_build_id = true;
1310 continue; 1325 continue;
1311 } 1326 }
1327 nsinfo__mountns_enter(pos->nsinfo, &nsc);
1312 if (filename__read_build_id(pos->long_name, pos->build_id, 1328 if (filename__read_build_id(pos->long_name, pos->build_id,
1313 sizeof(pos->build_id)) > 0) { 1329 sizeof(pos->build_id)) > 0) {
1314 have_build_id = true; 1330 have_build_id = true;
1315 pos->has_build_id = true; 1331 pos->has_build_id = true;
1316 } 1332 }
1333 nsinfo__mountns_exit(&nsc);
1317 } 1334 }
1318 1335
1319 return have_build_id; 1336 return have_build_id;
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index bd061ba7b47c..f886141678eb 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -10,6 +10,7 @@
10#include <linux/types.h> 10#include <linux/types.h>
11#include <linux/bitops.h> 11#include <linux/bitops.h>
12#include "map.h" 12#include "map.h"
13#include "namespaces.h"
13#include "build-id.h" 14#include "build-id.h"
14 15
15enum dso_binary_type { 16enum dso_binary_type {
@@ -20,6 +21,7 @@ enum dso_binary_type {
20 DSO_BINARY_TYPE__JAVA_JIT, 21 DSO_BINARY_TYPE__JAVA_JIT,
21 DSO_BINARY_TYPE__DEBUGLINK, 22 DSO_BINARY_TYPE__DEBUGLINK,
22 DSO_BINARY_TYPE__BUILD_ID_CACHE, 23 DSO_BINARY_TYPE__BUILD_ID_CACHE,
24 DSO_BINARY_TYPE__BUILD_ID_CACHE_DEBUGINFO,
23 DSO_BINARY_TYPE__FEDORA_DEBUGINFO, 25 DSO_BINARY_TYPE__FEDORA_DEBUGINFO,
24 DSO_BINARY_TYPE__UBUNTU_DEBUGINFO, 26 DSO_BINARY_TYPE__UBUNTU_DEBUGINFO,
25 DSO_BINARY_TYPE__BUILDID_DEBUGINFO, 27 DSO_BINARY_TYPE__BUILDID_DEBUGINFO,
@@ -187,6 +189,7 @@ struct dso {
187 void *priv; 189 void *priv;
188 u64 db_id; 190 u64 db_id;
189 }; 191 };
192 struct nsinfo *nsinfo;
190 refcount_t refcnt; 193 refcount_t refcnt;
191 char name[0]; 194 char name[0];
192}; 195};
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index dc5c3bb69d73..1c905ba3641b 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -57,6 +57,7 @@ static const char *perf_event__names[] = {
57 [PERF_RECORD_STAT_ROUND] = "STAT_ROUND", 57 [PERF_RECORD_STAT_ROUND] = "STAT_ROUND",
58 [PERF_RECORD_EVENT_UPDATE] = "EVENT_UPDATE", 58 [PERF_RECORD_EVENT_UPDATE] = "EVENT_UPDATE",
59 [PERF_RECORD_TIME_CONV] = "TIME_CONV", 59 [PERF_RECORD_TIME_CONV] = "TIME_CONV",
60 [PERF_RECORD_HEADER_FEATURE] = "FEATURE",
60}; 61};
61 62
62static const char *perf_ns__names[] = { 63static const char *perf_ns__names[] = {
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 9967c87af7a6..ee7bcc898d35 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -142,7 +142,8 @@ struct branch_flags {
142 u64 in_tx:1; 142 u64 in_tx:1;
143 u64 abort:1; 143 u64 abort:1;
144 u64 cycles:16; 144 u64 cycles:16;
145 u64 reserved:44; 145 u64 type:4;
146 u64 reserved:40;
146}; 147};
147 148
148struct branch_entry { 149struct branch_entry {
@@ -199,6 +200,7 @@ struct perf_sample {
199 u32 cpu; 200 u32 cpu;
200 u32 raw_size; 201 u32 raw_size;
201 u64 data_src; 202 u64 data_src;
203 u64 phys_addr;
202 u32 flags; 204 u32 flags;
203 u16 insn_len; 205 u16 insn_len;
204 u8 cpumode; 206 u8 cpumode;
@@ -244,6 +246,7 @@ enum perf_user_event_type { /* above any possible kernel type */
244 PERF_RECORD_STAT_ROUND = 77, 246 PERF_RECORD_STAT_ROUND = 77,
245 PERF_RECORD_EVENT_UPDATE = 78, 247 PERF_RECORD_EVENT_UPDATE = 78,
246 PERF_RECORD_TIME_CONV = 79, 248 PERF_RECORD_TIME_CONV = 79,
249 PERF_RECORD_HEADER_FEATURE = 80,
247 PERF_RECORD_HEADER_MAX 250 PERF_RECORD_HEADER_MAX
248}; 251};
249 252
@@ -609,6 +612,12 @@ struct time_conv_event {
609 u64 time_zero; 612 u64 time_zero;
610}; 613};
611 614
615struct feature_event {
616 struct perf_event_header header;
617 u64 feat_id;
618 char data[];
619};
620
612union perf_event { 621union perf_event {
613 struct perf_event_header header; 622 struct perf_event_header header;
614 struct mmap_event mmap; 623 struct mmap_event mmap;
@@ -639,6 +648,7 @@ union perf_event {
639 struct stat_event stat; 648 struct stat_event stat;
640 struct stat_round_event stat_round; 649 struct stat_round_event stat_round;
641 struct time_conv_event time_conv; 650 struct time_conv_event time_conv;
651 struct feature_event feat;
642}; 652};
643 653
644void perf_event__print_totals(void); 654void perf_event__print_totals(void);
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 46c0faf6c502..6a0d7ffbeba0 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -242,9 +242,9 @@ void perf_event_attr__set_max_precise_ip(struct perf_event_attr *attr)
242 } 242 }
243} 243}
244 244
245int perf_evlist__add_default(struct perf_evlist *evlist) 245int __perf_evlist__add_default(struct perf_evlist *evlist, bool precise)
246{ 246{
247 struct perf_evsel *evsel = perf_evsel__new_cycles(); 247 struct perf_evsel *evsel = perf_evsel__new_cycles(precise);
248 248
249 if (evsel == NULL) 249 if (evsel == NULL)
250 return -ENOMEM; 250 return -ENOMEM;
@@ -1419,8 +1419,6 @@ int perf_evlist__apply_filters(struct perf_evlist *evlist, struct perf_evsel **e
1419{ 1419{
1420 struct perf_evsel *evsel; 1420 struct perf_evsel *evsel;
1421 int err = 0; 1421 int err = 0;
1422 const int ncpus = cpu_map__nr(evlist->cpus),
1423 nthreads = thread_map__nr(evlist->threads);
1424 1422
1425 evlist__for_each_entry(evlist, evsel) { 1423 evlist__for_each_entry(evlist, evsel) {
1426 if (evsel->filter == NULL) 1424 if (evsel->filter == NULL)
@@ -1430,7 +1428,7 @@ int perf_evlist__apply_filters(struct perf_evlist *evlist, struct perf_evsel **e
1430 * filters only work for tracepoint event, which doesn't have cpu limit. 1428 * filters only work for tracepoint event, which doesn't have cpu limit.
1431 * So evlist and evsel should always be same. 1429 * So evlist and evsel should always be same.
1432 */ 1430 */
1433 err = perf_evsel__apply_filter(evsel, ncpus, nthreads, evsel->filter); 1431 err = perf_evsel__apply_filter(evsel, evsel->filter);
1434 if (err) { 1432 if (err) {
1435 *err_evsel = evsel; 1433 *err_evsel = evsel;
1436 break; 1434 break;
@@ -1623,13 +1621,9 @@ void perf_evlist__set_selected(struct perf_evlist *evlist,
1623void perf_evlist__close(struct perf_evlist *evlist) 1621void perf_evlist__close(struct perf_evlist *evlist)
1624{ 1622{
1625 struct perf_evsel *evsel; 1623 struct perf_evsel *evsel;
1626 int ncpus = cpu_map__nr(evlist->cpus);
1627 int nthreads = thread_map__nr(evlist->threads);
1628 1624
1629 evlist__for_each_entry_reverse(evlist, evsel) { 1625 evlist__for_each_entry_reverse(evlist, evsel)
1630 int n = evsel->cpus ? evsel->cpus->nr : ncpus; 1626 perf_evsel__close(evsel);
1631 perf_evsel__close(evsel, n, nthreads);
1632 }
1633} 1627}
1634 1628
1635static int perf_evlist__create_syswide_maps(struct perf_evlist *evlist) 1629static int perf_evlist__create_syswide_maps(struct perf_evlist *evlist)
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 8d601fbdd8d6..bf2c4936e35f 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -115,7 +115,14 @@ void perf_evlist__delete(struct perf_evlist *evlist);
115 115
116void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry); 116void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry);
117void perf_evlist__remove(struct perf_evlist *evlist, struct perf_evsel *evsel); 117void perf_evlist__remove(struct perf_evlist *evlist, struct perf_evsel *evsel);
118int perf_evlist__add_default(struct perf_evlist *evlist); 118
119int __perf_evlist__add_default(struct perf_evlist *evlist, bool precise);
120
121static inline int perf_evlist__add_default(struct perf_evlist *evlist)
122{
123 return __perf_evlist__add_default(evlist, true);
124}
125
119int __perf_evlist__add_default_attrs(struct perf_evlist *evlist, 126int __perf_evlist__add_default_attrs(struct perf_evlist *evlist,
120 struct perf_event_attr *attrs, size_t nr_attrs); 127 struct perf_event_attr *attrs, size_t nr_attrs);
121 128
@@ -258,6 +265,11 @@ bool perf_evlist__valid_read_format(struct perf_evlist *evlist);
258void perf_evlist__splice_list_tail(struct perf_evlist *evlist, 265void perf_evlist__splice_list_tail(struct perf_evlist *evlist,
259 struct list_head *list); 266 struct list_head *list);
260 267
268static inline bool perf_evlist__empty(struct perf_evlist *evlist)
269{
270 return list_empty(&evlist->entries);
271}
272
261static inline struct perf_evsel *perf_evlist__first(struct perf_evlist *evlist) 273static inline struct perf_evsel *perf_evlist__first(struct perf_evlist *evlist)
262{ 274{
263 return list_entry(evlist->entries.next, struct perf_evsel, node); 275 return list_entry(evlist->entries.next, struct perf_evsel, node);
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 413f74df08de..0dccdb89572c 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -49,6 +49,7 @@ static struct {
49 bool clockid_wrong; 49 bool clockid_wrong;
50 bool lbr_flags; 50 bool lbr_flags;
51 bool write_backward; 51 bool write_backward;
52 bool group_read;
52} perf_missing_features; 53} perf_missing_features;
53 54
54static clockid_t clockid; 55static clockid_t clockid;
@@ -58,6 +59,8 @@ static int perf_evsel__no_extra_init(struct perf_evsel *evsel __maybe_unused)
58 return 0; 59 return 0;
59} 60}
60 61
62void __weak test_attr__ready(void) { }
63
61static void perf_evsel__no_extra_fini(struct perf_evsel *evsel __maybe_unused) 64static void perf_evsel__no_extra_fini(struct perf_evsel *evsel __maybe_unused)
62{ 65{
63} 66}
@@ -268,16 +271,24 @@ struct perf_evsel *perf_evsel__new_idx(struct perf_event_attr *attr, int idx)
268 return evsel; 271 return evsel;
269} 272}
270 273
271struct perf_evsel *perf_evsel__new_cycles(void) 274static bool perf_event_can_profile_kernel(void)
275{
276 return geteuid() == 0 || perf_event_paranoid() == -1;
277}
278
279struct perf_evsel *perf_evsel__new_cycles(bool precise)
272{ 280{
273 struct perf_event_attr attr = { 281 struct perf_event_attr attr = {
274 .type = PERF_TYPE_HARDWARE, 282 .type = PERF_TYPE_HARDWARE,
275 .config = PERF_COUNT_HW_CPU_CYCLES, 283 .config = PERF_COUNT_HW_CPU_CYCLES,
276 .exclude_kernel = geteuid() != 0, 284 .exclude_kernel = !perf_event_can_profile_kernel(),
277 }; 285 };
278 struct perf_evsel *evsel; 286 struct perf_evsel *evsel;
279 287
280 event_attr_init(&attr); 288 event_attr_init(&attr);
289
290 if (!precise)
291 goto new_event;
281 /* 292 /*
282 * Unnamed union member, not supported as struct member named 293 * Unnamed union member, not supported as struct member named
283 * initializer in older compilers such as gcc 4.4.7 294 * initializer in older compilers such as gcc 4.4.7
@@ -292,7 +303,7 @@ struct perf_evsel *perf_evsel__new_cycles(void)
292 * to kick in when we return and before perf_evsel__open() is called. 303 * to kick in when we return and before perf_evsel__open() is called.
293 */ 304 */
294 attr.sample_period = 0; 305 attr.sample_period = 0;
295 306new_event:
296 evsel = perf_evsel__new(&attr); 307 evsel = perf_evsel__new(&attr);
297 if (evsel == NULL) 308 if (evsel == NULL)
298 goto out; 309 goto out;
@@ -896,8 +907,13 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts,
896 if (opts->no_samples) 907 if (opts->no_samples)
897 attr->sample_freq = 0; 908 attr->sample_freq = 0;
898 909
899 if (opts->inherit_stat) 910 if (opts->inherit_stat) {
911 evsel->attr.read_format |=
912 PERF_FORMAT_TOTAL_TIME_ENABLED |
913 PERF_FORMAT_TOTAL_TIME_RUNNING |
914 PERF_FORMAT_ID;
900 attr->inherit_stat = 1; 915 attr->inherit_stat = 1;
916 }
901 917
902 if (opts->sample_address) { 918 if (opts->sample_address) {
903 perf_evsel__set_sample_bit(evsel, ADDR); 919 perf_evsel__set_sample_bit(evsel, ADDR);
@@ -944,6 +960,9 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts,
944 if (opts->sample_address) 960 if (opts->sample_address)
945 perf_evsel__set_sample_bit(evsel, DATA_SRC); 961 perf_evsel__set_sample_bit(evsel, DATA_SRC);
946 962
963 if (opts->sample_phys_addr)
964 perf_evsel__set_sample_bit(evsel, PHYS_ADDR);
965
947 if (opts->no_buffering) { 966 if (opts->no_buffering) {
948 attr->watermark = 0; 967 attr->watermark = 0;
949 attr->wakeup_events = 1; 968 attr->wakeup_events = 1;
@@ -1045,16 +1064,13 @@ static int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthread
1045 return evsel->fd != NULL ? 0 : -ENOMEM; 1064 return evsel->fd != NULL ? 0 : -ENOMEM;
1046} 1065}
1047 1066
1048static int perf_evsel__run_ioctl(struct perf_evsel *evsel, int ncpus, int nthreads, 1067static int perf_evsel__run_ioctl(struct perf_evsel *evsel,
1049 int ioc, void *arg) 1068 int ioc, void *arg)
1050{ 1069{
1051 int cpu, thread; 1070 int cpu, thread;
1052 1071
1053 if (evsel->system_wide) 1072 for (cpu = 0; cpu < xyarray__max_x(evsel->fd); cpu++) {
1054 nthreads = 1; 1073 for (thread = 0; thread < xyarray__max_y(evsel->fd); thread++) {
1055
1056 for (cpu = 0; cpu < ncpus; cpu++) {
1057 for (thread = 0; thread < nthreads; thread++) {
1058 int fd = FD(evsel, cpu, thread), 1074 int fd = FD(evsel, cpu, thread),
1059 err = ioctl(fd, ioc, arg); 1075 err = ioctl(fd, ioc, arg);
1060 1076
@@ -1066,10 +1082,9 @@ static int perf_evsel__run_ioctl(struct perf_evsel *evsel, int ncpus, int nthrea
1066 return 0; 1082 return 0;
1067} 1083}
1068 1084
1069int perf_evsel__apply_filter(struct perf_evsel *evsel, int ncpus, int nthreads, 1085int perf_evsel__apply_filter(struct perf_evsel *evsel, const char *filter)
1070 const char *filter)
1071{ 1086{
1072 return perf_evsel__run_ioctl(evsel, ncpus, nthreads, 1087 return perf_evsel__run_ioctl(evsel,
1073 PERF_EVENT_IOC_SET_FILTER, 1088 PERF_EVENT_IOC_SET_FILTER,
1074 (void *)filter); 1089 (void *)filter);
1075} 1090}
@@ -1116,20 +1131,14 @@ int perf_evsel__append_addr_filter(struct perf_evsel *evsel, const char *filter)
1116 1131
1117int perf_evsel__enable(struct perf_evsel *evsel) 1132int perf_evsel__enable(struct perf_evsel *evsel)
1118{ 1133{
1119 int nthreads = thread_map__nr(evsel->threads); 1134 return perf_evsel__run_ioctl(evsel,
1120 int ncpus = cpu_map__nr(evsel->cpus);
1121
1122 return perf_evsel__run_ioctl(evsel, ncpus, nthreads,
1123 PERF_EVENT_IOC_ENABLE, 1135 PERF_EVENT_IOC_ENABLE,
1124 0); 1136 0);
1125} 1137}
1126 1138
1127int perf_evsel__disable(struct perf_evsel *evsel) 1139int perf_evsel__disable(struct perf_evsel *evsel)
1128{ 1140{
1129 int nthreads = thread_map__nr(evsel->threads); 1141 return perf_evsel__run_ioctl(evsel,
1130 int ncpus = cpu_map__nr(evsel->cpus);
1131
1132 return perf_evsel__run_ioctl(evsel, ncpus, nthreads,
1133 PERF_EVENT_IOC_DISABLE, 1142 PERF_EVENT_IOC_DISABLE,
1134 0); 1143 0);
1135} 1144}
@@ -1179,15 +1188,12 @@ static void perf_evsel__free_config_terms(struct perf_evsel *evsel)
1179 } 1188 }
1180} 1189}
1181 1190
1182void perf_evsel__close_fd(struct perf_evsel *evsel, int ncpus, int nthreads) 1191void perf_evsel__close_fd(struct perf_evsel *evsel)
1183{ 1192{
1184 int cpu, thread; 1193 int cpu, thread;
1185 1194
1186 if (evsel->system_wide) 1195 for (cpu = 0; cpu < xyarray__max_x(evsel->fd); cpu++)
1187 nthreads = 1; 1196 for (thread = 0; thread < xyarray__max_y(evsel->fd); ++thread) {
1188
1189 for (cpu = 0; cpu < ncpus; cpu++)
1190 for (thread = 0; thread < nthreads; ++thread) {
1191 close(FD(evsel, cpu, thread)); 1197 close(FD(evsel, cpu, thread));
1192 FD(evsel, cpu, thread) = -1; 1198 FD(evsel, cpu, thread) = -1;
1193 } 1199 }
@@ -1256,20 +1262,148 @@ void perf_counts_values__scale(struct perf_counts_values *count,
1256 *pscaled = scaled; 1262 *pscaled = scaled;
1257} 1263}
1258 1264
1265static int perf_evsel__read_size(struct perf_evsel *evsel)
1266{
1267 u64 read_format = evsel->attr.read_format;
1268 int entry = sizeof(u64); /* value */
1269 int size = 0;
1270 int nr = 1;
1271
1272 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED)
1273 size += sizeof(u64);
1274
1275 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING)
1276 size += sizeof(u64);
1277
1278 if (read_format & PERF_FORMAT_ID)
1279 entry += sizeof(u64);
1280
1281 if (read_format & PERF_FORMAT_GROUP) {
1282 nr = evsel->nr_members;
1283 size += sizeof(u64);
1284 }
1285
1286 size += entry * nr;
1287 return size;
1288}
1289
1259int perf_evsel__read(struct perf_evsel *evsel, int cpu, int thread, 1290int perf_evsel__read(struct perf_evsel *evsel, int cpu, int thread,
1260 struct perf_counts_values *count) 1291 struct perf_counts_values *count)
1261{ 1292{
1293 size_t size = perf_evsel__read_size(evsel);
1294
1262 memset(count, 0, sizeof(*count)); 1295 memset(count, 0, sizeof(*count));
1263 1296
1264 if (FD(evsel, cpu, thread) < 0) 1297 if (FD(evsel, cpu, thread) < 0)
1265 return -EINVAL; 1298 return -EINVAL;
1266 1299
1267 if (readn(FD(evsel, cpu, thread), count, sizeof(*count)) <= 0) 1300 if (readn(FD(evsel, cpu, thread), count->values, size) <= 0)
1268 return -errno; 1301 return -errno;
1269 1302
1270 return 0; 1303 return 0;
1271} 1304}
1272 1305
1306static int
1307perf_evsel__read_one(struct perf_evsel *evsel, int cpu, int thread)
1308{
1309 struct perf_counts_values *count = perf_counts(evsel->counts, cpu, thread);
1310
1311 return perf_evsel__read(evsel, cpu, thread, count);
1312}
1313
1314static void
1315perf_evsel__set_count(struct perf_evsel *counter, int cpu, int thread,
1316 u64 val, u64 ena, u64 run)
1317{
1318 struct perf_counts_values *count;
1319
1320 count = perf_counts(counter->counts, cpu, thread);
1321
1322 count->val = val;
1323 count->ena = ena;
1324 count->run = run;
1325 count->loaded = true;
1326}
1327
1328static int
1329perf_evsel__process_group_data(struct perf_evsel *leader,
1330 int cpu, int thread, u64 *data)
1331{
1332 u64 read_format = leader->attr.read_format;
1333 struct sample_read_value *v;
1334 u64 nr, ena = 0, run = 0, i;
1335
1336 nr = *data++;
1337
1338 if (nr != (u64) leader->nr_members)
1339 return -EINVAL;
1340
1341 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED)
1342 ena = *data++;
1343
1344 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING)
1345 run = *data++;
1346
1347 v = (struct sample_read_value *) data;
1348
1349 perf_evsel__set_count(leader, cpu, thread,
1350 v[0].value, ena, run);
1351
1352 for (i = 1; i < nr; i++) {
1353 struct perf_evsel *counter;
1354
1355 counter = perf_evlist__id2evsel(leader->evlist, v[i].id);
1356 if (!counter)
1357 return -EINVAL;
1358
1359 perf_evsel__set_count(counter, cpu, thread,
1360 v[i].value, ena, run);
1361 }
1362
1363 return 0;
1364}
1365
1366static int
1367perf_evsel__read_group(struct perf_evsel *leader, int cpu, int thread)
1368{
1369 struct perf_stat_evsel *ps = leader->priv;
1370 u64 read_format = leader->attr.read_format;
1371 int size = perf_evsel__read_size(leader);
1372 u64 *data = ps->group_data;
1373
1374 if (!(read_format & PERF_FORMAT_ID))
1375 return -EINVAL;
1376
1377 if (!perf_evsel__is_group_leader(leader))
1378 return -EINVAL;
1379
1380 if (!data) {
1381 data = zalloc(size);
1382 if (!data)
1383 return -ENOMEM;
1384
1385 ps->group_data = data;
1386 }
1387
1388 if (FD(leader, cpu, thread) < 0)
1389 return -EINVAL;
1390
1391 if (readn(FD(leader, cpu, thread), data, size) <= 0)
1392 return -errno;
1393
1394 return perf_evsel__process_group_data(leader, cpu, thread, data);
1395}
1396
1397int perf_evsel__read_counter(struct perf_evsel *evsel, int cpu, int thread)
1398{
1399 u64 read_format = evsel->attr.read_format;
1400
1401 if (read_format & PERF_FORMAT_GROUP)
1402 return perf_evsel__read_group(evsel, cpu, thread);
1403 else
1404 return perf_evsel__read_one(evsel, cpu, thread);
1405}
1406
1273int __perf_evsel__read_on_cpu(struct perf_evsel *evsel, 1407int __perf_evsel__read_on_cpu(struct perf_evsel *evsel,
1274 int cpu, int thread, bool scale) 1408 int cpu, int thread, bool scale)
1275{ 1409{
@@ -1338,7 +1472,7 @@ static void __p_sample_type(char *buf, size_t size, u64 value)
1338 bit_name(PERIOD), bit_name(STREAM_ID), bit_name(RAW), 1472 bit_name(PERIOD), bit_name(STREAM_ID), bit_name(RAW),
1339 bit_name(BRANCH_STACK), bit_name(REGS_USER), bit_name(STACK_USER), 1473 bit_name(BRANCH_STACK), bit_name(REGS_USER), bit_name(STACK_USER),
1340 bit_name(IDENTIFIER), bit_name(REGS_INTR), bit_name(DATA_SRC), 1474 bit_name(IDENTIFIER), bit_name(REGS_INTR), bit_name(DATA_SRC),
1341 bit_name(WEIGHT), 1475 bit_name(WEIGHT), bit_name(PHYS_ADDR),
1342 { .name = NULL, } 1476 { .name = NULL, }
1343 }; 1477 };
1344#undef bit_name 1478#undef bit_name
@@ -1545,6 +1679,8 @@ fallback_missing_features:
1545 if (perf_missing_features.lbr_flags) 1679 if (perf_missing_features.lbr_flags)
1546 evsel->attr.branch_sample_type &= ~(PERF_SAMPLE_BRANCH_NO_FLAGS | 1680 evsel->attr.branch_sample_type &= ~(PERF_SAMPLE_BRANCH_NO_FLAGS |
1547 PERF_SAMPLE_BRANCH_NO_CYCLES); 1681 PERF_SAMPLE_BRANCH_NO_CYCLES);
1682 if (perf_missing_features.group_read && evsel->attr.inherit)
1683 evsel->attr.read_format &= ~(PERF_FORMAT_GROUP|PERF_FORMAT_ID);
1548retry_sample_id: 1684retry_sample_id:
1549 if (perf_missing_features.sample_id_all) 1685 if (perf_missing_features.sample_id_all)
1550 evsel->attr.sample_id_all = 0; 1686 evsel->attr.sample_id_all = 0;
@@ -1569,6 +1705,8 @@ retry_open:
1569 pr_debug2("sys_perf_event_open: pid %d cpu %d group_fd %d flags %#lx", 1705 pr_debug2("sys_perf_event_open: pid %d cpu %d group_fd %d flags %#lx",
1570 pid, cpus->map[cpu], group_fd, flags); 1706 pid, cpus->map[cpu], group_fd, flags);
1571 1707
1708 test_attr__ready();
1709
1572 fd = sys_perf_event_open(&evsel->attr, pid, cpus->map[cpu], 1710 fd = sys_perf_event_open(&evsel->attr, pid, cpus->map[cpu],
1573 group_fd, flags); 1711 group_fd, flags);
1574 1712
@@ -1664,31 +1802,45 @@ try_fallback:
1664 */ 1802 */
1665 if (!perf_missing_features.write_backward && evsel->attr.write_backward) { 1803 if (!perf_missing_features.write_backward && evsel->attr.write_backward) {
1666 perf_missing_features.write_backward = true; 1804 perf_missing_features.write_backward = true;
1805 pr_debug2("switching off write_backward\n");
1667 goto out_close; 1806 goto out_close;
1668 } else if (!perf_missing_features.clockid_wrong && evsel->attr.use_clockid) { 1807 } else if (!perf_missing_features.clockid_wrong && evsel->attr.use_clockid) {
1669 perf_missing_features.clockid_wrong = true; 1808 perf_missing_features.clockid_wrong = true;
1809 pr_debug2("switching off clockid\n");
1670 goto fallback_missing_features; 1810 goto fallback_missing_features;
1671 } else if (!perf_missing_features.clockid && evsel->attr.use_clockid) { 1811 } else if (!perf_missing_features.clockid && evsel->attr.use_clockid) {
1672 perf_missing_features.clockid = true; 1812 perf_missing_features.clockid = true;
1813 pr_debug2("switching off use_clockid\n");
1673 goto fallback_missing_features; 1814 goto fallback_missing_features;
1674 } else if (!perf_missing_features.cloexec && (flags & PERF_FLAG_FD_CLOEXEC)) { 1815 } else if (!perf_missing_features.cloexec && (flags & PERF_FLAG_FD_CLOEXEC)) {
1675 perf_missing_features.cloexec = true; 1816 perf_missing_features.cloexec = true;
1817 pr_debug2("switching off cloexec flag\n");
1676 goto fallback_missing_features; 1818 goto fallback_missing_features;
1677 } else if (!perf_missing_features.mmap2 && evsel->attr.mmap2) { 1819 } else if (!perf_missing_features.mmap2 && evsel->attr.mmap2) {
1678 perf_missing_features.mmap2 = true; 1820 perf_missing_features.mmap2 = true;
1821 pr_debug2("switching off mmap2\n");
1679 goto fallback_missing_features; 1822 goto fallback_missing_features;
1680 } else if (!perf_missing_features.exclude_guest && 1823 } else if (!perf_missing_features.exclude_guest &&
1681 (evsel->attr.exclude_guest || evsel->attr.exclude_host)) { 1824 (evsel->attr.exclude_guest || evsel->attr.exclude_host)) {
1682 perf_missing_features.exclude_guest = true; 1825 perf_missing_features.exclude_guest = true;
1826 pr_debug2("switching off exclude_guest, exclude_host\n");
1683 goto fallback_missing_features; 1827 goto fallback_missing_features;
1684 } else if (!perf_missing_features.sample_id_all) { 1828 } else if (!perf_missing_features.sample_id_all) {
1685 perf_missing_features.sample_id_all = true; 1829 perf_missing_features.sample_id_all = true;
1830 pr_debug2("switching off sample_id_all\n");
1686 goto retry_sample_id; 1831 goto retry_sample_id;
1687 } else if (!perf_missing_features.lbr_flags && 1832 } else if (!perf_missing_features.lbr_flags &&
1688 (evsel->attr.branch_sample_type & 1833 (evsel->attr.branch_sample_type &
1689 (PERF_SAMPLE_BRANCH_NO_CYCLES | 1834 (PERF_SAMPLE_BRANCH_NO_CYCLES |
1690 PERF_SAMPLE_BRANCH_NO_FLAGS))) { 1835 PERF_SAMPLE_BRANCH_NO_FLAGS))) {
1691 perf_missing_features.lbr_flags = true; 1836 perf_missing_features.lbr_flags = true;
1837 pr_debug2("switching off branch sample type no (cycles/flags)\n");
1838 goto fallback_missing_features;
1839 } else if (!perf_missing_features.group_read &&
1840 evsel->attr.inherit &&
1841 (evsel->attr.read_format & PERF_FORMAT_GROUP)) {
1842 perf_missing_features.group_read = true;
1843 pr_debug2("switching off group read\n");
1692 goto fallback_missing_features; 1844 goto fallback_missing_features;
1693 } 1845 }
1694out_close: 1846out_close:
@@ -1702,12 +1854,12 @@ out_close:
1702 return err; 1854 return err;
1703} 1855}
1704 1856
1705void perf_evsel__close(struct perf_evsel *evsel, int ncpus, int nthreads) 1857void perf_evsel__close(struct perf_evsel *evsel)
1706{ 1858{
1707 if (evsel->fd == NULL) 1859 if (evsel->fd == NULL)
1708 return; 1860 return;
1709 1861
1710 perf_evsel__close_fd(evsel, ncpus, nthreads); 1862 perf_evsel__close_fd(evsel);
1711 perf_evsel__free_fd(evsel); 1863 perf_evsel__free_fd(evsel);
1712} 1864}
1713 1865
@@ -2062,6 +2214,12 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event,
2062 } 2214 }
2063 } 2215 }
2064 2216
2217 data->phys_addr = 0;
2218 if (type & PERF_SAMPLE_PHYS_ADDR) {
2219 data->phys_addr = *array;
2220 array++;
2221 }
2222
2065 return 0; 2223 return 0;
2066} 2224}
2067 2225
@@ -2167,6 +2325,9 @@ size_t perf_event__sample_event_size(const struct perf_sample *sample, u64 type,
2167 } 2325 }
2168 } 2326 }
2169 2327
2328 if (type & PERF_SAMPLE_PHYS_ADDR)
2329 result += sizeof(u64);
2330
2170 return result; 2331 return result;
2171} 2332}
2172 2333
@@ -2356,6 +2517,11 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type,
2356 } 2517 }
2357 } 2518 }
2358 2519
2520 if (type & PERF_SAMPLE_PHYS_ADDR) {
2521 *array = sample->phys_addr;
2522 array++;
2523 }
2524
2359 return 0; 2525 return 0;
2360} 2526}
2361 2527
@@ -2535,7 +2701,9 @@ int perf_evsel__open_strerror(struct perf_evsel *evsel, struct target *target,
2535 "unprivileged users (without CAP_SYS_ADMIN).\n\n" 2701 "unprivileged users (without CAP_SYS_ADMIN).\n\n"
2536 "The current value is %d:\n\n" 2702 "The current value is %d:\n\n"
2537 " -1: Allow use of (almost) all events by all users\n" 2703 " -1: Allow use of (almost) all events by all users\n"
2538 ">= 0: Disallow raw tracepoint access by users without CAP_IOC_LOCK\n" 2704 " Ignore mlock limit after perf_event_mlock_kb without CAP_IPC_LOCK\n"
2705 ">= 0: Disallow ftrace function tracepoint by users without CAP_SYS_ADMIN\n"
2706 " Disallow raw tracepoint access by users without CAP_SYS_ADMIN\n"
2539 ">= 1: Disallow CPU event access by users without CAP_SYS_ADMIN\n" 2707 ">= 1: Disallow CPU event access by users without CAP_SYS_ADMIN\n"
2540 ">= 2: Disallow kernel profiling by users without CAP_SYS_ADMIN\n\n" 2708 ">= 2: Disallow kernel profiling by users without CAP_SYS_ADMIN\n\n"
2541 "To make this setting permanent, edit /etc/sysctl.conf too, e.g.:\n\n" 2709 "To make this setting permanent, edit /etc/sysctl.conf too, e.g.:\n\n"
@@ -2610,3 +2778,10 @@ char *perf_evsel__env_arch(struct perf_evsel *evsel)
2610 return evsel->evlist->env->arch; 2778 return evsel->evlist->env->arch;
2611 return NULL; 2779 return NULL;
2612} 2780}
2781
2782char *perf_evsel__env_cpuid(struct perf_evsel *evsel)
2783{
2784 if (evsel && evsel->evlist && evsel->evlist->env)
2785 return evsel->evlist->env->cpuid;
2786 return NULL;
2787}
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index d101695c482c..dd2c4b5112a5 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -131,6 +131,7 @@ struct perf_evsel {
131 bool cmdline_group_boundary; 131 bool cmdline_group_boundary;
132 struct list_head config_terms; 132 struct list_head config_terms;
133 int bpf_fd; 133 int bpf_fd;
134 bool auto_merge_stats;
134 bool merged_stat; 135 bool merged_stat;
135 const char * metric_expr; 136 const char * metric_expr;
136 const char * metric_name; 137 const char * metric_name;
@@ -185,7 +186,7 @@ static inline struct perf_evsel *perf_evsel__newtp(const char *sys, const char *
185 return perf_evsel__newtp_idx(sys, name, 0); 186 return perf_evsel__newtp_idx(sys, name, 0);
186} 187}
187 188
188struct perf_evsel *perf_evsel__new_cycles(void); 189struct perf_evsel *perf_evsel__new_cycles(bool precise);
189 190
190struct event_format *event_format__new(const char *sys, const char *name); 191struct event_format *event_format__new(const char *sys, const char *name);
191 192
@@ -226,7 +227,7 @@ const char *perf_evsel__group_name(struct perf_evsel *evsel);
226int perf_evsel__group_desc(struct perf_evsel *evsel, char *buf, size_t size); 227int perf_evsel__group_desc(struct perf_evsel *evsel, char *buf, size_t size);
227 228
228int perf_evsel__alloc_id(struct perf_evsel *evsel, int ncpus, int nthreads); 229int perf_evsel__alloc_id(struct perf_evsel *evsel, int ncpus, int nthreads);
229void perf_evsel__close_fd(struct perf_evsel *evsel, int ncpus, int nthreads); 230void perf_evsel__close_fd(struct perf_evsel *evsel);
230 231
231void __perf_evsel__set_sample_bit(struct perf_evsel *evsel, 232void __perf_evsel__set_sample_bit(struct perf_evsel *evsel,
232 enum perf_event_sample_format bit); 233 enum perf_event_sample_format bit);
@@ -246,8 +247,7 @@ int perf_evsel__set_filter(struct perf_evsel *evsel, const char *filter);
246int perf_evsel__append_tp_filter(struct perf_evsel *evsel, const char *filter); 247int perf_evsel__append_tp_filter(struct perf_evsel *evsel, const char *filter);
247int perf_evsel__append_addr_filter(struct perf_evsel *evsel, 248int perf_evsel__append_addr_filter(struct perf_evsel *evsel,
248 const char *filter); 249 const char *filter);
249int perf_evsel__apply_filter(struct perf_evsel *evsel, int ncpus, int nthreads, 250int perf_evsel__apply_filter(struct perf_evsel *evsel, const char *filter);
250 const char *filter);
251int perf_evsel__enable(struct perf_evsel *evsel); 251int perf_evsel__enable(struct perf_evsel *evsel);
252int perf_evsel__disable(struct perf_evsel *evsel); 252int perf_evsel__disable(struct perf_evsel *evsel);
253 253
@@ -257,7 +257,7 @@ int perf_evsel__open_per_thread(struct perf_evsel *evsel,
257 struct thread_map *threads); 257 struct thread_map *threads);
258int perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, 258int perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
259 struct thread_map *threads); 259 struct thread_map *threads);
260void perf_evsel__close(struct perf_evsel *evsel, int ncpus, int nthreads); 260void perf_evsel__close(struct perf_evsel *evsel);
261 261
262struct perf_sample; 262struct perf_sample;
263 263
@@ -299,6 +299,8 @@ static inline bool perf_evsel__match2(struct perf_evsel *e1,
299int perf_evsel__read(struct perf_evsel *evsel, int cpu, int thread, 299int perf_evsel__read(struct perf_evsel *evsel, int cpu, int thread,
300 struct perf_counts_values *count); 300 struct perf_counts_values *count);
301 301
302int perf_evsel__read_counter(struct perf_evsel *evsel, int cpu, int thread);
303
302int __perf_evsel__read_on_cpu(struct perf_evsel *evsel, 304int __perf_evsel__read_on_cpu(struct perf_evsel *evsel,
303 int cpu, int thread, bool scale); 305 int cpu, int thread, bool scale);
304 306
@@ -436,5 +438,6 @@ int perf_event_attr__fprintf(FILE *fp, struct perf_event_attr *attr,
436 attr__fprintf_f attr__fprintf, void *priv); 438 attr__fprintf_f attr__fprintf, void *priv);
437 439
438char *perf_evsel__env_arch(struct perf_evsel *evsel); 440char *perf_evsel__env_arch(struct perf_evsel *evsel);
441char *perf_evsel__env_cpuid(struct perf_evsel *evsel);
439 442
440#endif /* __PERF_EVSEL_H */ 443#endif /* __PERF_EVSEL_H */
diff --git a/tools/perf/util/expr.h b/tools/perf/util/expr.h
index 9c2760a1a96e..400ef9eab00a 100644
--- a/tools/perf/util/expr.h
+++ b/tools/perf/util/expr.h
@@ -1,7 +1,7 @@
1#ifndef PARSE_CTX_H 1#ifndef PARSE_CTX_H
2#define PARSE_CTX_H 1 2#define PARSE_CTX_H 1
3 3
4#define EXPR_MAX_OTHER 8 4#define EXPR_MAX_OTHER 15
5#define MAX_PARSE_ID EXPR_MAX_OTHER 5#define MAX_PARSE_ID EXPR_MAX_OTHER
6 6
7struct parse_id { 7struct parse_id {
diff --git a/tools/perf/util/expr.y b/tools/perf/util/expr.y
index 954556bea36e..432b8560cf51 100644
--- a/tools/perf/util/expr.y
+++ b/tools/perf/util/expr.y
@@ -4,6 +4,7 @@
4#include "util/debug.h" 4#include "util/debug.h"
5#define IN_EXPR_Y 1 5#define IN_EXPR_Y 1
6#include "expr.h" 6#include "expr.h"
7#include "smt.h"
7#include <string.h> 8#include <string.h>
8 9
9#define MAXIDLEN 256 10#define MAXIDLEN 256
@@ -22,13 +23,15 @@
22 23
23%token <num> NUMBER 24%token <num> NUMBER
24%token <id> ID 25%token <id> ID
26%token MIN MAX IF ELSE SMT_ON
27%left MIN MAX IF
25%left '|' 28%left '|'
26%left '^' 29%left '^'
27%left '&' 30%left '&'
28%left '-' '+' 31%left '-' '+'
29%left '*' '/' '%' 32%left '*' '/' '%'
30%left NEG NOT 33%left NEG NOT
31%type <num> expr 34%type <num> expr if_expr
32 35
33%{ 36%{
34static int expr__lex(YYSTYPE *res, const char **pp); 37static int expr__lex(YYSTYPE *res, const char **pp);
@@ -57,22 +60,33 @@ static int lookup_id(struct parse_ctx *ctx, char *id, double *val)
57%} 60%}
58%% 61%%
59 62
60all_expr: expr { *final_val = $1; } 63all_expr: if_expr { *final_val = $1; }
64 ;
65
66if_expr:
67 expr IF expr ELSE expr { $$ = $3 ? $1 : $5; }
68 | expr
61 ; 69 ;
62 70
63expr: NUMBER 71expr: NUMBER
64 | ID { if (lookup_id(ctx, $1, &$$) < 0) { 72 | ID { if (lookup_id(ctx, $1, &$$) < 0) {
65 pr_debug("%s not found", $1); 73 pr_debug("%s not found\n", $1);
66 YYABORT; 74 YYABORT;
67 } 75 }
68 } 76 }
77 | expr '|' expr { $$ = (long)$1 | (long)$3; }
78 | expr '&' expr { $$ = (long)$1 & (long)$3; }
79 | expr '^' expr { $$ = (long)$1 ^ (long)$3; }
69 | expr '+' expr { $$ = $1 + $3; } 80 | expr '+' expr { $$ = $1 + $3; }
70 | expr '-' expr { $$ = $1 - $3; } 81 | expr '-' expr { $$ = $1 - $3; }
71 | expr '*' expr { $$ = $1 * $3; } 82 | expr '*' expr { $$ = $1 * $3; }
72 | expr '/' expr { if ($3 == 0) YYABORT; $$ = $1 / $3; } 83 | expr '/' expr { if ($3 == 0) YYABORT; $$ = $1 / $3; }
73 | expr '%' expr { if ((long)$3 == 0) YYABORT; $$ = (long)$1 % (long)$3; } 84 | expr '%' expr { if ((long)$3 == 0) YYABORT; $$ = (long)$1 % (long)$3; }
74 | '-' expr %prec NEG { $$ = -$2; } 85 | '-' expr %prec NEG { $$ = -$2; }
75 | '(' expr ')' { $$ = $2; } 86 | '(' if_expr ')' { $$ = $2; }
87 | MIN '(' expr ',' expr ')' { $$ = $3 < $5 ? $3 : $5; }
88 | MAX '(' expr ',' expr ')' { $$ = $3 > $5 ? $3 : $5; }
89 | SMT_ON { $$ = smt_on() > 0; }
76 ; 90 ;
77 91
78%% 92%%
@@ -82,13 +96,47 @@ static int expr__symbol(YYSTYPE *res, const char *p, const char **pp)
82 char *dst = res->id; 96 char *dst = res->id;
83 const char *s = p; 97 const char *s = p;
84 98
85 while (isalnum(*p) || *p == '_' || *p == '.') { 99 if (*p == '#')
100 *dst++ = *p++;
101
102 while (isalnum(*p) || *p == '_' || *p == '.' || *p == ':' || *p == '@' || *p == '\\') {
86 if (p - s >= MAXIDLEN) 103 if (p - s >= MAXIDLEN)
87 return -1; 104 return -1;
88 *dst++ = *p++; 105 /*
106 * Allow @ instead of / to be able to specify pmu/event/ without
107 * conflicts with normal division.
108 */
109 if (*p == '@')
110 *dst++ = '/';
111 else if (*p == '\\')
112 *dst++ = *++p;
113 else
114 *dst++ = *p;
115 p++;
89 } 116 }
90 *dst = 0; 117 *dst = 0;
91 *pp = p; 118 *pp = p;
119 dst = res->id;
120 switch (dst[0]) {
121 case 'm':
122 if (!strcmp(dst, "min"))
123 return MIN;
124 if (!strcmp(dst, "max"))
125 return MAX;
126 break;
127 case 'i':
128 if (!strcmp(dst, "if"))
129 return IF;
130 break;
131 case 'e':
132 if (!strcmp(dst, "else"))
133 return ELSE;
134 break;
135 case '#':
136 if (!strcasecmp(dst, "#smt_on"))
137 return SMT_ON;
138 break;
139 }
92 return ID; 140 return ID;
93} 141}
94 142
@@ -102,6 +150,7 @@ static int expr__lex(YYSTYPE *res, const char **pp)
102 p++; 150 p++;
103 s = p; 151 s = p;
104 switch (*p++) { 152 switch (*p++) {
153 case '#':
105 case 'a' ... 'z': 154 case 'a' ... 'z':
106 case 'A' ... 'Z': 155 case 'A' ... 'Z':
107 return expr__symbol(res, p - 1, pp); 156 return expr__symbol(res, p - 1, pp);
@@ -132,6 +181,19 @@ void expr__ctx_init(struct parse_ctx *ctx)
132 ctx->num_ids = 0; 181 ctx->num_ids = 0;
133} 182}
134 183
184static bool already_seen(const char *val, const char *one, const char **other,
185 int num_other)
186{
187 int i;
188
189 if (one && !strcasecmp(one, val))
190 return true;
191 for (i = 0; i < num_other; i++)
192 if (!strcasecmp(other[i], val))
193 return true;
194 return false;
195}
196
135int expr__find_other(const char *p, const char *one, const char ***other, 197int expr__find_other(const char *p, const char *one, const char ***other,
136 int *num_otherp) 198 int *num_otherp)
137{ 199{
@@ -151,7 +213,7 @@ int expr__find_other(const char *p, const char *one, const char ***other,
151 err = 0; 213 err = 0;
152 break; 214 break;
153 } 215 }
154 if (tok == ID && strcasecmp(one, val.id)) { 216 if (tok == ID && !already_seen(val.id, one, *other, num_other)) {
155 if (num_other >= EXPR_MAX_OTHER - 1) { 217 if (num_other >= EXPR_MAX_OTHER - 1) {
156 pr_debug("Too many extra events in %s\n", orig); 218 pr_debug("Too many extra events in %s\n", orig);
157 break; 219 break;
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 76ed7d03e500..605bbd5404fb 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -12,6 +12,7 @@
12#include <linux/list.h> 12#include <linux/list.h>
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/bitops.h> 14#include <linux/bitops.h>
15#include <linux/stringify.h>
15#include <sys/stat.h> 16#include <sys/stat.h>
16#include <sys/types.h> 17#include <sys/types.h>
17#include <sys/utsname.h> 18#include <sys/utsname.h>
@@ -34,6 +35,7 @@
34#include "data.h" 35#include "data.h"
35#include <api/fs/fs.h> 36#include <api/fs/fs.h>
36#include "asm/bug.h" 37#include "asm/bug.h"
38#include "tool.h"
37 39
38#include "sane_ctype.h" 40#include "sane_ctype.h"
39 41
@@ -59,6 +61,15 @@ struct perf_file_attr {
59 struct perf_file_section ids; 61 struct perf_file_section ids;
60}; 62};
61 63
64struct feat_fd {
65 struct perf_header *ph;
66 int fd;
67 void *buf; /* Either buf != NULL or fd >= 0 */
68 ssize_t offset;
69 size_t size;
70 struct perf_evsel *events;
71};
72
62void perf_header__set_feat(struct perf_header *header, int feat) 73void perf_header__set_feat(struct perf_header *header, int feat)
63{ 74{
64 set_bit(feat, header->adds_features); 75 set_bit(feat, header->adds_features);
@@ -74,28 +85,60 @@ bool perf_header__has_feat(const struct perf_header *header, int feat)
74 return test_bit(feat, header->adds_features); 85 return test_bit(feat, header->adds_features);
75} 86}
76 87
77static int do_write(int fd, const void *buf, size_t size) 88static int __do_write_fd(struct feat_fd *ff, const void *buf, size_t size)
78{ 89{
79 while (size) { 90 ssize_t ret = writen(ff->fd, buf, size);
80 int ret = write(fd, buf, size);
81 91
82 if (ret < 0) 92 if (ret != (ssize_t)size)
83 return -errno; 93 return ret < 0 ? (int)ret : -1;
94 return 0;
95}
96
97static int __do_write_buf(struct feat_fd *ff, const void *buf, size_t size)
98{
99 /* struct perf_event_header::size is u16 */
100 const size_t max_size = 0xffff - sizeof(struct perf_event_header);
101 size_t new_size = ff->size;
102 void *addr;
84 103
85 size -= ret; 104 if (size + ff->offset > max_size)
86 buf += ret; 105 return -E2BIG;
106
107 while (size > (new_size - ff->offset))
108 new_size <<= 1;
109 new_size = min(max_size, new_size);
110
111 if (ff->size < new_size) {
112 addr = realloc(ff->buf, new_size);
113 if (!addr)
114 return -ENOMEM;
115 ff->buf = addr;
116 ff->size = new_size;
87 } 117 }
88 118
119 memcpy(ff->buf + ff->offset, buf, size);
120 ff->offset += size;
121
89 return 0; 122 return 0;
90} 123}
91 124
92int write_padded(int fd, const void *bf, size_t count, size_t count_aligned) 125/* Return: 0 if succeded, -ERR if failed. */
126int do_write(struct feat_fd *ff, const void *buf, size_t size)
127{
128 if (!ff->buf)
129 return __do_write_fd(ff, buf, size);
130 return __do_write_buf(ff, buf, size);
131}
132
133/* Return: 0 if succeded, -ERR if failed. */
134int write_padded(struct feat_fd *ff, const void *bf,
135 size_t count, size_t count_aligned)
93{ 136{
94 static const char zero_buf[NAME_ALIGN]; 137 static const char zero_buf[NAME_ALIGN];
95 int err = do_write(fd, bf, count); 138 int err = do_write(ff, bf, count);
96 139
97 if (!err) 140 if (!err)
98 err = do_write(fd, zero_buf, count_aligned - count); 141 err = do_write(ff, zero_buf, count_aligned - count);
99 142
100 return err; 143 return err;
101} 144}
@@ -103,7 +146,8 @@ int write_padded(int fd, const void *bf, size_t count, size_t count_aligned)
103#define string_size(str) \ 146#define string_size(str) \
104 (PERF_ALIGN((strlen(str) + 1), NAME_ALIGN) + sizeof(u32)) 147 (PERF_ALIGN((strlen(str) + 1), NAME_ALIGN) + sizeof(u32))
105 148
106static int do_write_string(int fd, const char *str) 149/* Return: 0 if succeded, -ERR if failed. */
150static int do_write_string(struct feat_fd *ff, const char *str)
107{ 151{
108 u32 len, olen; 152 u32 len, olen;
109 int ret; 153 int ret;
@@ -112,32 +156,80 @@ static int do_write_string(int fd, const char *str)
112 len = PERF_ALIGN(olen, NAME_ALIGN); 156 len = PERF_ALIGN(olen, NAME_ALIGN);
113 157
114 /* write len, incl. \0 */ 158 /* write len, incl. \0 */
115 ret = do_write(fd, &len, sizeof(len)); 159 ret = do_write(ff, &len, sizeof(len));
116 if (ret < 0) 160 if (ret < 0)
117 return ret; 161 return ret;
118 162
119 return write_padded(fd, str, olen, len); 163 return write_padded(ff, str, olen, len);
120} 164}
121 165
122static char *do_read_string(int fd, struct perf_header *ph) 166static int __do_read_fd(struct feat_fd *ff, void *addr, ssize_t size)
167{
168 ssize_t ret = readn(ff->fd, addr, size);
169
170 if (ret != size)
171 return ret < 0 ? (int)ret : -1;
172 return 0;
173}
174
175static int __do_read_buf(struct feat_fd *ff, void *addr, ssize_t size)
176{
177 if (size > (ssize_t)ff->size - ff->offset)
178 return -1;
179
180 memcpy(addr, ff->buf + ff->offset, size);
181 ff->offset += size;
182
183 return 0;
184
185}
186
187static int __do_read(struct feat_fd *ff, void *addr, ssize_t size)
188{
189 if (!ff->buf)
190 return __do_read_fd(ff, addr, size);
191 return __do_read_buf(ff, addr, size);
192}
193
194static int do_read_u32(struct feat_fd *ff, u32 *addr)
195{
196 int ret;
197
198 ret = __do_read(ff, addr, sizeof(*addr));
199 if (ret)
200 return ret;
201
202 if (ff->ph->needs_swap)
203 *addr = bswap_32(*addr);
204 return 0;
205}
206
207static int do_read_u64(struct feat_fd *ff, u64 *addr)
208{
209 int ret;
210
211 ret = __do_read(ff, addr, sizeof(*addr));
212 if (ret)
213 return ret;
214
215 if (ff->ph->needs_swap)
216 *addr = bswap_64(*addr);
217 return 0;
218}
219
220static char *do_read_string(struct feat_fd *ff)
123{ 221{
124 ssize_t sz, ret;
125 u32 len; 222 u32 len;
126 char *buf; 223 char *buf;
127 224
128 sz = readn(fd, &len, sizeof(len)); 225 if (do_read_u32(ff, &len))
129 if (sz < (ssize_t)sizeof(len))
130 return NULL; 226 return NULL;
131 227
132 if (ph->needs_swap)
133 len = bswap_32(len);
134
135 buf = malloc(len); 228 buf = malloc(len);
136 if (!buf) 229 if (!buf)
137 return NULL; 230 return NULL;
138 231
139 ret = readn(fd, buf, len); 232 if (!__do_read(ff, buf, len)) {
140 if (ret == (ssize_t)len) {
141 /* 233 /*
142 * strings are padded by zeroes 234 * strings are padded by zeroes
143 * thus the actual strlen of buf 235 * thus the actual strlen of buf
@@ -150,25 +242,30 @@ static char *do_read_string(int fd, struct perf_header *ph)
150 return NULL; 242 return NULL;
151} 243}
152 244
153static int write_tracing_data(int fd, struct perf_header *h __maybe_unused, 245static int write_tracing_data(struct feat_fd *ff,
154 struct perf_evlist *evlist) 246 struct perf_evlist *evlist)
155{ 247{
156 return read_tracing_data(fd, &evlist->entries); 248 if (WARN(ff->buf, "Error: calling %s in pipe-mode.\n", __func__))
157} 249 return -1;
158 250
251 return read_tracing_data(ff->fd, &evlist->entries);
252}
159 253
160static int write_build_id(int fd, struct perf_header *h, 254static int write_build_id(struct feat_fd *ff,
161 struct perf_evlist *evlist __maybe_unused) 255 struct perf_evlist *evlist __maybe_unused)
162{ 256{
163 struct perf_session *session; 257 struct perf_session *session;
164 int err; 258 int err;
165 259
166 session = container_of(h, struct perf_session, header); 260 session = container_of(ff->ph, struct perf_session, header);
167 261
168 if (!perf_session__read_build_ids(session, true)) 262 if (!perf_session__read_build_ids(session, true))
169 return -1; 263 return -1;
170 264
171 err = perf_session__write_buildid_table(session, fd); 265 if (WARN(ff->buf, "Error: calling %s in pipe-mode.\n", __func__))
266 return -1;
267
268 err = perf_session__write_buildid_table(session, ff);
172 if (err < 0) { 269 if (err < 0) {
173 pr_debug("failed to write buildid table\n"); 270 pr_debug("failed to write buildid table\n");
174 return err; 271 return err;
@@ -178,7 +275,7 @@ static int write_build_id(int fd, struct perf_header *h,
178 return 0; 275 return 0;
179} 276}
180 277
181static int write_hostname(int fd, struct perf_header *h __maybe_unused, 278static int write_hostname(struct feat_fd *ff,
182 struct perf_evlist *evlist __maybe_unused) 279 struct perf_evlist *evlist __maybe_unused)
183{ 280{
184 struct utsname uts; 281 struct utsname uts;
@@ -188,10 +285,10 @@ static int write_hostname(int fd, struct perf_header *h __maybe_unused,
188 if (ret < 0) 285 if (ret < 0)
189 return -1; 286 return -1;
190 287
191 return do_write_string(fd, uts.nodename); 288 return do_write_string(ff, uts.nodename);
192} 289}
193 290
194static int write_osrelease(int fd, struct perf_header *h __maybe_unused, 291static int write_osrelease(struct feat_fd *ff,
195 struct perf_evlist *evlist __maybe_unused) 292 struct perf_evlist *evlist __maybe_unused)
196{ 293{
197 struct utsname uts; 294 struct utsname uts;
@@ -201,10 +298,10 @@ static int write_osrelease(int fd, struct perf_header *h __maybe_unused,
201 if (ret < 0) 298 if (ret < 0)
202 return -1; 299 return -1;
203 300
204 return do_write_string(fd, uts.release); 301 return do_write_string(ff, uts.release);
205} 302}
206 303
207static int write_arch(int fd, struct perf_header *h __maybe_unused, 304static int write_arch(struct feat_fd *ff,
208 struct perf_evlist *evlist __maybe_unused) 305 struct perf_evlist *evlist __maybe_unused)
209{ 306{
210 struct utsname uts; 307 struct utsname uts;
@@ -214,16 +311,16 @@ static int write_arch(int fd, struct perf_header *h __maybe_unused,
214 if (ret < 0) 311 if (ret < 0)
215 return -1; 312 return -1;
216 313
217 return do_write_string(fd, uts.machine); 314 return do_write_string(ff, uts.machine);
218} 315}
219 316
220static int write_version(int fd, struct perf_header *h __maybe_unused, 317static int write_version(struct feat_fd *ff,
221 struct perf_evlist *evlist __maybe_unused) 318 struct perf_evlist *evlist __maybe_unused)
222{ 319{
223 return do_write_string(fd, perf_version_string); 320 return do_write_string(ff, perf_version_string);
224} 321}
225 322
226static int __write_cpudesc(int fd, const char *cpuinfo_proc) 323static int __write_cpudesc(struct feat_fd *ff, const char *cpuinfo_proc)
227{ 324{
228 FILE *file; 325 FILE *file;
229 char *buf = NULL; 326 char *buf = NULL;
@@ -273,25 +370,22 @@ static int __write_cpudesc(int fd, const char *cpuinfo_proc)
273 } 370 }
274 p++; 371 p++;
275 } 372 }
276 ret = do_write_string(fd, s); 373 ret = do_write_string(ff, s);
277done: 374done:
278 free(buf); 375 free(buf);
279 fclose(file); 376 fclose(file);
280 return ret; 377 return ret;
281} 378}
282 379
283static int write_cpudesc(int fd, struct perf_header *h __maybe_unused, 380static int write_cpudesc(struct feat_fd *ff,
284 struct perf_evlist *evlist __maybe_unused) 381 struct perf_evlist *evlist __maybe_unused)
285{ 382{
286#ifndef CPUINFO_PROC
287#define CPUINFO_PROC {"model name", }
288#endif
289 const char *cpuinfo_procs[] = CPUINFO_PROC; 383 const char *cpuinfo_procs[] = CPUINFO_PROC;
290 unsigned int i; 384 unsigned int i;
291 385
292 for (i = 0; i < ARRAY_SIZE(cpuinfo_procs); i++) { 386 for (i = 0; i < ARRAY_SIZE(cpuinfo_procs); i++) {
293 int ret; 387 int ret;
294 ret = __write_cpudesc(fd, cpuinfo_procs[i]); 388 ret = __write_cpudesc(ff, cpuinfo_procs[i]);
295 if (ret >= 0) 389 if (ret >= 0)
296 return ret; 390 return ret;
297 } 391 }
@@ -299,7 +393,7 @@ static int write_cpudesc(int fd, struct perf_header *h __maybe_unused,
299} 393}
300 394
301 395
302static int write_nrcpus(int fd, struct perf_header *h __maybe_unused, 396static int write_nrcpus(struct feat_fd *ff,
303 struct perf_evlist *evlist __maybe_unused) 397 struct perf_evlist *evlist __maybe_unused)
304{ 398{
305 long nr; 399 long nr;
@@ -314,14 +408,14 @@ static int write_nrcpus(int fd, struct perf_header *h __maybe_unused,
314 408
315 nra = (u32)(nr & UINT_MAX); 409 nra = (u32)(nr & UINT_MAX);
316 410
317 ret = do_write(fd, &nrc, sizeof(nrc)); 411 ret = do_write(ff, &nrc, sizeof(nrc));
318 if (ret < 0) 412 if (ret < 0)
319 return ret; 413 return ret;
320 414
321 return do_write(fd, &nra, sizeof(nra)); 415 return do_write(ff, &nra, sizeof(nra));
322} 416}
323 417
324static int write_event_desc(int fd, struct perf_header *h __maybe_unused, 418static int write_event_desc(struct feat_fd *ff,
325 struct perf_evlist *evlist) 419 struct perf_evlist *evlist)
326{ 420{
327 struct perf_evsel *evsel; 421 struct perf_evsel *evsel;
@@ -333,7 +427,7 @@ static int write_event_desc(int fd, struct perf_header *h __maybe_unused,
333 /* 427 /*
334 * write number of events 428 * write number of events
335 */ 429 */
336 ret = do_write(fd, &nre, sizeof(nre)); 430 ret = do_write(ff, &nre, sizeof(nre));
337 if (ret < 0) 431 if (ret < 0)
338 return ret; 432 return ret;
339 433
@@ -341,12 +435,12 @@ static int write_event_desc(int fd, struct perf_header *h __maybe_unused,
341 * size of perf_event_attr struct 435 * size of perf_event_attr struct
342 */ 436 */
343 sz = (u32)sizeof(evsel->attr); 437 sz = (u32)sizeof(evsel->attr);
344 ret = do_write(fd, &sz, sizeof(sz)); 438 ret = do_write(ff, &sz, sizeof(sz));
345 if (ret < 0) 439 if (ret < 0)
346 return ret; 440 return ret;
347 441
348 evlist__for_each_entry(evlist, evsel) { 442 evlist__for_each_entry(evlist, evsel) {
349 ret = do_write(fd, &evsel->attr, sz); 443 ret = do_write(ff, &evsel->attr, sz);
350 if (ret < 0) 444 if (ret < 0)
351 return ret; 445 return ret;
352 /* 446 /*
@@ -357,27 +451,27 @@ static int write_event_desc(int fd, struct perf_header *h __maybe_unused,
357 * type of ids, 451 * type of ids,
358 */ 452 */
359 nri = evsel->ids; 453 nri = evsel->ids;
360 ret = do_write(fd, &nri, sizeof(nri)); 454 ret = do_write(ff, &nri, sizeof(nri));
361 if (ret < 0) 455 if (ret < 0)
362 return ret; 456 return ret;
363 457
364 /* 458 /*
365 * write event string as passed on cmdline 459 * write event string as passed on cmdline
366 */ 460 */
367 ret = do_write_string(fd, perf_evsel__name(evsel)); 461 ret = do_write_string(ff, perf_evsel__name(evsel));
368 if (ret < 0) 462 if (ret < 0)
369 return ret; 463 return ret;
370 /* 464 /*
371 * write unique ids for this event 465 * write unique ids for this event
372 */ 466 */
373 ret = do_write(fd, evsel->id, evsel->ids * sizeof(u64)); 467 ret = do_write(ff, evsel->id, evsel->ids * sizeof(u64));
374 if (ret < 0) 468 if (ret < 0)
375 return ret; 469 return ret;
376 } 470 }
377 return 0; 471 return 0;
378} 472}
379 473
380static int write_cmdline(int fd, struct perf_header *h __maybe_unused, 474static int write_cmdline(struct feat_fd *ff,
381 struct perf_evlist *evlist __maybe_unused) 475 struct perf_evlist *evlist __maybe_unused)
382{ 476{
383 char buf[MAXPATHLEN]; 477 char buf[MAXPATHLEN];
@@ -395,16 +489,16 @@ static int write_cmdline(int fd, struct perf_header *h __maybe_unused,
395 /* account for binary path */ 489 /* account for binary path */
396 n = perf_env.nr_cmdline + 1; 490 n = perf_env.nr_cmdline + 1;
397 491
398 ret = do_write(fd, &n, sizeof(n)); 492 ret = do_write(ff, &n, sizeof(n));
399 if (ret < 0) 493 if (ret < 0)
400 return ret; 494 return ret;
401 495
402 ret = do_write_string(fd, buf); 496 ret = do_write_string(ff, buf);
403 if (ret < 0) 497 if (ret < 0)
404 return ret; 498 return ret;
405 499
406 for (i = 0 ; i < perf_env.nr_cmdline; i++) { 500 for (i = 0 ; i < perf_env.nr_cmdline; i++) {
407 ret = do_write_string(fd, perf_env.cmdline_argv[i]); 501 ret = do_write_string(ff, perf_env.cmdline_argv[i]);
408 if (ret < 0) 502 if (ret < 0)
409 return ret; 503 return ret;
410 } 504 }
@@ -557,8 +651,8 @@ out_free:
557 return tp; 651 return tp;
558} 652}
559 653
560static int write_cpu_topology(int fd, struct perf_header *h __maybe_unused, 654static int write_cpu_topology(struct feat_fd *ff,
561 struct perf_evlist *evlist __maybe_unused) 655 struct perf_evlist *evlist __maybe_unused)
562{ 656{
563 struct cpu_topo *tp; 657 struct cpu_topo *tp;
564 u32 i; 658 u32 i;
@@ -568,21 +662,21 @@ static int write_cpu_topology(int fd, struct perf_header *h __maybe_unused,
568 if (!tp) 662 if (!tp)
569 return -1; 663 return -1;
570 664
571 ret = do_write(fd, &tp->core_sib, sizeof(tp->core_sib)); 665 ret = do_write(ff, &tp->core_sib, sizeof(tp->core_sib));
572 if (ret < 0) 666 if (ret < 0)
573 goto done; 667 goto done;
574 668
575 for (i = 0; i < tp->core_sib; i++) { 669 for (i = 0; i < tp->core_sib; i++) {
576 ret = do_write_string(fd, tp->core_siblings[i]); 670 ret = do_write_string(ff, tp->core_siblings[i]);
577 if (ret < 0) 671 if (ret < 0)
578 goto done; 672 goto done;
579 } 673 }
580 ret = do_write(fd, &tp->thread_sib, sizeof(tp->thread_sib)); 674 ret = do_write(ff, &tp->thread_sib, sizeof(tp->thread_sib));
581 if (ret < 0) 675 if (ret < 0)
582 goto done; 676 goto done;
583 677
584 for (i = 0; i < tp->thread_sib; i++) { 678 for (i = 0; i < tp->thread_sib; i++) {
585 ret = do_write_string(fd, tp->thread_siblings[i]); 679 ret = do_write_string(ff, tp->thread_siblings[i]);
586 if (ret < 0) 680 if (ret < 0)
587 break; 681 break;
588 } 682 }
@@ -592,11 +686,11 @@ static int write_cpu_topology(int fd, struct perf_header *h __maybe_unused,
592 goto done; 686 goto done;
593 687
594 for (j = 0; j < perf_env.nr_cpus_avail; j++) { 688 for (j = 0; j < perf_env.nr_cpus_avail; j++) {
595 ret = do_write(fd, &perf_env.cpu[j].core_id, 689 ret = do_write(ff, &perf_env.cpu[j].core_id,
596 sizeof(perf_env.cpu[j].core_id)); 690 sizeof(perf_env.cpu[j].core_id));
597 if (ret < 0) 691 if (ret < 0)
598 return ret; 692 return ret;
599 ret = do_write(fd, &perf_env.cpu[j].socket_id, 693 ret = do_write(ff, &perf_env.cpu[j].socket_id,
600 sizeof(perf_env.cpu[j].socket_id)); 694 sizeof(perf_env.cpu[j].socket_id));
601 if (ret < 0) 695 if (ret < 0)
602 return ret; 696 return ret;
@@ -608,8 +702,8 @@ done:
608 702
609 703
610 704
611static int write_total_mem(int fd, struct perf_header *h __maybe_unused, 705static int write_total_mem(struct feat_fd *ff,
612 struct perf_evlist *evlist __maybe_unused) 706 struct perf_evlist *evlist __maybe_unused)
613{ 707{
614 char *buf = NULL; 708 char *buf = NULL;
615 FILE *fp; 709 FILE *fp;
@@ -629,7 +723,7 @@ static int write_total_mem(int fd, struct perf_header *h __maybe_unused,
629 if (!ret) { 723 if (!ret) {
630 n = sscanf(buf, "%*s %"PRIu64, &mem); 724 n = sscanf(buf, "%*s %"PRIu64, &mem);
631 if (n == 1) 725 if (n == 1)
632 ret = do_write(fd, &mem, sizeof(mem)); 726 ret = do_write(ff, &mem, sizeof(mem));
633 } else 727 } else
634 ret = -1; 728 ret = -1;
635 free(buf); 729 free(buf);
@@ -637,7 +731,7 @@ static int write_total_mem(int fd, struct perf_header *h __maybe_unused,
637 return ret; 731 return ret;
638} 732}
639 733
640static int write_topo_node(int fd, int node) 734static int write_topo_node(struct feat_fd *ff, int node)
641{ 735{
642 char str[MAXPATHLEN]; 736 char str[MAXPATHLEN];
643 char field[32]; 737 char field[32];
@@ -667,11 +761,11 @@ static int write_topo_node(int fd, int node)
667 fclose(fp); 761 fclose(fp);
668 fp = NULL; 762 fp = NULL;
669 763
670 ret = do_write(fd, &mem_total, sizeof(u64)); 764 ret = do_write(ff, &mem_total, sizeof(u64));
671 if (ret) 765 if (ret)
672 goto done; 766 goto done;
673 767
674 ret = do_write(fd, &mem_free, sizeof(u64)); 768 ret = do_write(ff, &mem_free, sizeof(u64));
675 if (ret) 769 if (ret)
676 goto done; 770 goto done;
677 771
@@ -689,7 +783,7 @@ static int write_topo_node(int fd, int node)
689 if (p) 783 if (p)
690 *p = '\0'; 784 *p = '\0';
691 785
692 ret = do_write_string(fd, buf); 786 ret = do_write_string(ff, buf);
693done: 787done:
694 free(buf); 788 free(buf);
695 if (fp) 789 if (fp)
@@ -697,8 +791,8 @@ done:
697 return ret; 791 return ret;
698} 792}
699 793
700static int write_numa_topology(int fd, struct perf_header *h __maybe_unused, 794static int write_numa_topology(struct feat_fd *ff,
701 struct perf_evlist *evlist __maybe_unused) 795 struct perf_evlist *evlist __maybe_unused)
702{ 796{
703 char *buf = NULL; 797 char *buf = NULL;
704 size_t len = 0; 798 size_t len = 0;
@@ -725,17 +819,17 @@ static int write_numa_topology(int fd, struct perf_header *h __maybe_unused,
725 819
726 nr = (u32)node_map->nr; 820 nr = (u32)node_map->nr;
727 821
728 ret = do_write(fd, &nr, sizeof(nr)); 822 ret = do_write(ff, &nr, sizeof(nr));
729 if (ret < 0) 823 if (ret < 0)
730 goto done; 824 goto done;
731 825
732 for (i = 0; i < nr; i++) { 826 for (i = 0; i < nr; i++) {
733 j = (u32)node_map->map[i]; 827 j = (u32)node_map->map[i];
734 ret = do_write(fd, &j, sizeof(j)); 828 ret = do_write(ff, &j, sizeof(j));
735 if (ret < 0) 829 if (ret < 0)
736 break; 830 break;
737 831
738 ret = write_topo_node(fd, i); 832 ret = write_topo_node(ff, i);
739 if (ret < 0) 833 if (ret < 0)
740 break; 834 break;
741 } 835 }
@@ -758,39 +852,40 @@ done:
758 * }; 852 * };
759 */ 853 */
760 854
761static int write_pmu_mappings(int fd, struct perf_header *h __maybe_unused, 855static int write_pmu_mappings(struct feat_fd *ff,
762 struct perf_evlist *evlist __maybe_unused) 856 struct perf_evlist *evlist __maybe_unused)
763{ 857{
764 struct perf_pmu *pmu = NULL; 858 struct perf_pmu *pmu = NULL;
765 off_t offset = lseek(fd, 0, SEEK_CUR); 859 u32 pmu_num = 0;
766 __u32 pmu_num = 0;
767 int ret; 860 int ret;
768 861
769 /* write real pmu_num later */ 862 /*
770 ret = do_write(fd, &pmu_num, sizeof(pmu_num)); 863 * Do a first pass to count number of pmu to avoid lseek so this
864 * works in pipe mode as well.
865 */
866 while ((pmu = perf_pmu__scan(pmu))) {
867 if (!pmu->name)
868 continue;
869 pmu_num++;
870 }
871
872 ret = do_write(ff, &pmu_num, sizeof(pmu_num));
771 if (ret < 0) 873 if (ret < 0)
772 return ret; 874 return ret;
773 875
774 while ((pmu = perf_pmu__scan(pmu))) { 876 while ((pmu = perf_pmu__scan(pmu))) {
775 if (!pmu->name) 877 if (!pmu->name)
776 continue; 878 continue;
777 pmu_num++;
778 879
779 ret = do_write(fd, &pmu->type, sizeof(pmu->type)); 880 ret = do_write(ff, &pmu->type, sizeof(pmu->type));
780 if (ret < 0) 881 if (ret < 0)
781 return ret; 882 return ret;
782 883
783 ret = do_write_string(fd, pmu->name); 884 ret = do_write_string(ff, pmu->name);
784 if (ret < 0) 885 if (ret < 0)
785 return ret; 886 return ret;
786 } 887 }
787 888
788 if (pwrite(fd, &pmu_num, sizeof(pmu_num), offset) != sizeof(pmu_num)) {
789 /* discard all */
790 lseek(fd, offset, SEEK_SET);
791 return -1;
792 }
793
794 return 0; 889 return 0;
795} 890}
796 891
@@ -806,14 +901,14 @@ static int write_pmu_mappings(int fd, struct perf_header *h __maybe_unused,
806 * }[nr_groups]; 901 * }[nr_groups];
807 * }; 902 * };
808 */ 903 */
809static int write_group_desc(int fd, struct perf_header *h __maybe_unused, 904static int write_group_desc(struct feat_fd *ff,
810 struct perf_evlist *evlist) 905 struct perf_evlist *evlist)
811{ 906{
812 u32 nr_groups = evlist->nr_groups; 907 u32 nr_groups = evlist->nr_groups;
813 struct perf_evsel *evsel; 908 struct perf_evsel *evsel;
814 int ret; 909 int ret;
815 910
816 ret = do_write(fd, &nr_groups, sizeof(nr_groups)); 911 ret = do_write(ff, &nr_groups, sizeof(nr_groups));
817 if (ret < 0) 912 if (ret < 0)
818 return ret; 913 return ret;
819 914
@@ -824,15 +919,15 @@ static int write_group_desc(int fd, struct perf_header *h __maybe_unused,
824 u32 leader_idx = evsel->idx; 919 u32 leader_idx = evsel->idx;
825 u32 nr_members = evsel->nr_members; 920 u32 nr_members = evsel->nr_members;
826 921
827 ret = do_write_string(fd, name); 922 ret = do_write_string(ff, name);
828 if (ret < 0) 923 if (ret < 0)
829 return ret; 924 return ret;
830 925
831 ret = do_write(fd, &leader_idx, sizeof(leader_idx)); 926 ret = do_write(ff, &leader_idx, sizeof(leader_idx));
832 if (ret < 0) 927 if (ret < 0)
833 return ret; 928 return ret;
834 929
835 ret = do_write(fd, &nr_members, sizeof(nr_members)); 930 ret = do_write(ff, &nr_members, sizeof(nr_members));
836 if (ret < 0) 931 if (ret < 0)
837 return ret; 932 return ret;
838 } 933 }
@@ -849,7 +944,7 @@ int __weak get_cpuid(char *buffer __maybe_unused, size_t sz __maybe_unused)
849 return -1; 944 return -1;
850} 945}
851 946
852static int write_cpuid(int fd, struct perf_header *h __maybe_unused, 947static int write_cpuid(struct feat_fd *ff,
853 struct perf_evlist *evlist __maybe_unused) 948 struct perf_evlist *evlist __maybe_unused)
854{ 949{
855 char buffer[64]; 950 char buffer[64];
@@ -861,25 +956,27 @@ static int write_cpuid(int fd, struct perf_header *h __maybe_unused,
861 956
862 return -1; 957 return -1;
863write_it: 958write_it:
864 return do_write_string(fd, buffer); 959 return do_write_string(ff, buffer);
865} 960}
866 961
867static int write_branch_stack(int fd __maybe_unused, 962static int write_branch_stack(struct feat_fd *ff __maybe_unused,
868 struct perf_header *h __maybe_unused, 963 struct perf_evlist *evlist __maybe_unused)
869 struct perf_evlist *evlist __maybe_unused)
870{ 964{
871 return 0; 965 return 0;
872} 966}
873 967
874static int write_auxtrace(int fd, struct perf_header *h, 968static int write_auxtrace(struct feat_fd *ff,
875 struct perf_evlist *evlist __maybe_unused) 969 struct perf_evlist *evlist __maybe_unused)
876{ 970{
877 struct perf_session *session; 971 struct perf_session *session;
878 int err; 972 int err;
879 973
880 session = container_of(h, struct perf_session, header); 974 if (WARN(ff->buf, "Error: calling %s in pipe-mode.\n", __func__))
975 return -1;
976
977 session = container_of(ff->ph, struct perf_session, header);
881 978
882 err = auxtrace_index__write(fd, &session->auxtrace_index); 979 err = auxtrace_index__write(ff->fd, &session->auxtrace_index);
883 if (err < 0) 980 if (err < 0)
884 pr_err("Failed to write auxtrace index\n"); 981 pr_err("Failed to write auxtrace index\n");
885 return err; 982 return err;
@@ -1026,8 +1123,8 @@ static int build_caches(struct cpu_cache_level caches[], u32 size, u32 *cntp)
1026 1123
1027#define MAX_CACHES 2000 1124#define MAX_CACHES 2000
1028 1125
1029static int write_cache(int fd, struct perf_header *h __maybe_unused, 1126static int write_cache(struct feat_fd *ff,
1030 struct perf_evlist *evlist __maybe_unused) 1127 struct perf_evlist *evlist __maybe_unused)
1031{ 1128{
1032 struct cpu_cache_level caches[MAX_CACHES]; 1129 struct cpu_cache_level caches[MAX_CACHES];
1033 u32 cnt = 0, i, version = 1; 1130 u32 cnt = 0, i, version = 1;
@@ -1039,11 +1136,11 @@ static int write_cache(int fd, struct perf_header *h __maybe_unused,
1039 1136
1040 qsort(&caches, cnt, sizeof(struct cpu_cache_level), cpu_cache_level__sort); 1137 qsort(&caches, cnt, sizeof(struct cpu_cache_level), cpu_cache_level__sort);
1041 1138
1042 ret = do_write(fd, &version, sizeof(u32)); 1139 ret = do_write(ff, &version, sizeof(u32));
1043 if (ret < 0) 1140 if (ret < 0)
1044 goto out; 1141 goto out;
1045 1142
1046 ret = do_write(fd, &cnt, sizeof(u32)); 1143 ret = do_write(ff, &cnt, sizeof(u32));
1047 if (ret < 0) 1144 if (ret < 0)
1048 goto out; 1145 goto out;
1049 1146
@@ -1051,7 +1148,7 @@ static int write_cache(int fd, struct perf_header *h __maybe_unused,
1051 struct cpu_cache_level *c = &caches[i]; 1148 struct cpu_cache_level *c = &caches[i];
1052 1149
1053 #define _W(v) \ 1150 #define _W(v) \
1054 ret = do_write(fd, &c->v, sizeof(u32)); \ 1151 ret = do_write(ff, &c->v, sizeof(u32)); \
1055 if (ret < 0) \ 1152 if (ret < 0) \
1056 goto out; 1153 goto out;
1057 1154
@@ -1062,7 +1159,7 @@ static int write_cache(int fd, struct perf_header *h __maybe_unused,
1062 #undef _W 1159 #undef _W
1063 1160
1064 #define _W(v) \ 1161 #define _W(v) \
1065 ret = do_write_string(fd, (const char *) c->v); \ 1162 ret = do_write_string(ff, (const char *) c->v); \
1066 if (ret < 0) \ 1163 if (ret < 0) \
1067 goto out; 1164 goto out;
1068 1165
@@ -1078,69 +1175,62 @@ out:
1078 return ret; 1175 return ret;
1079} 1176}
1080 1177
1081static int write_stat(int fd __maybe_unused, 1178static int write_stat(struct feat_fd *ff __maybe_unused,
1082 struct perf_header *h __maybe_unused,
1083 struct perf_evlist *evlist __maybe_unused) 1179 struct perf_evlist *evlist __maybe_unused)
1084{ 1180{
1085 return 0; 1181 return 0;
1086} 1182}
1087 1183
1088static void print_hostname(struct perf_header *ph, int fd __maybe_unused, 1184static void print_hostname(struct feat_fd *ff, FILE *fp)
1089 FILE *fp)
1090{ 1185{
1091 fprintf(fp, "# hostname : %s\n", ph->env.hostname); 1186 fprintf(fp, "# hostname : %s\n", ff->ph->env.hostname);
1092} 1187}
1093 1188
1094static void print_osrelease(struct perf_header *ph, int fd __maybe_unused, 1189static void print_osrelease(struct feat_fd *ff, FILE *fp)
1095 FILE *fp)
1096{ 1190{
1097 fprintf(fp, "# os release : %s\n", ph->env.os_release); 1191 fprintf(fp, "# os release : %s\n", ff->ph->env.os_release);
1098} 1192}
1099 1193
1100static void print_arch(struct perf_header *ph, int fd __maybe_unused, FILE *fp) 1194static void print_arch(struct feat_fd *ff, FILE *fp)
1101{ 1195{
1102 fprintf(fp, "# arch : %s\n", ph->env.arch); 1196 fprintf(fp, "# arch : %s\n", ff->ph->env.arch);
1103} 1197}
1104 1198
1105static void print_cpudesc(struct perf_header *ph, int fd __maybe_unused, 1199static void print_cpudesc(struct feat_fd *ff, FILE *fp)
1106 FILE *fp)
1107{ 1200{
1108 fprintf(fp, "# cpudesc : %s\n", ph->env.cpu_desc); 1201 fprintf(fp, "# cpudesc : %s\n", ff->ph->env.cpu_desc);
1109} 1202}
1110 1203
1111static void print_nrcpus(struct perf_header *ph, int fd __maybe_unused, 1204static void print_nrcpus(struct feat_fd *ff, FILE *fp)
1112 FILE *fp)
1113{ 1205{
1114 fprintf(fp, "# nrcpus online : %u\n", ph->env.nr_cpus_online); 1206 fprintf(fp, "# nrcpus online : %u\n", ff->ph->env.nr_cpus_online);
1115 fprintf(fp, "# nrcpus avail : %u\n", ph->env.nr_cpus_avail); 1207 fprintf(fp, "# nrcpus avail : %u\n", ff->ph->env.nr_cpus_avail);
1116} 1208}
1117 1209
1118static void print_version(struct perf_header *ph, int fd __maybe_unused, 1210static void print_version(struct feat_fd *ff, FILE *fp)
1119 FILE *fp)
1120{ 1211{
1121 fprintf(fp, "# perf version : %s\n", ph->env.version); 1212 fprintf(fp, "# perf version : %s\n", ff->ph->env.version);
1122} 1213}
1123 1214
1124static void print_cmdline(struct perf_header *ph, int fd __maybe_unused, 1215static void print_cmdline(struct feat_fd *ff, FILE *fp)
1125 FILE *fp)
1126{ 1216{
1127 int nr, i; 1217 int nr, i;
1128 1218
1129 nr = ph->env.nr_cmdline; 1219 nr = ff->ph->env.nr_cmdline;
1130 1220
1131 fprintf(fp, "# cmdline : "); 1221 fprintf(fp, "# cmdline : ");
1132 1222
1133 for (i = 0; i < nr; i++) 1223 for (i = 0; i < nr; i++)
1134 fprintf(fp, "%s ", ph->env.cmdline_argv[i]); 1224 fprintf(fp, "%s ", ff->ph->env.cmdline_argv[i]);
1135 fputc('\n', fp); 1225 fputc('\n', fp);
1136} 1226}
1137 1227
1138static void print_cpu_topology(struct perf_header *ph, int fd __maybe_unused, 1228static void print_cpu_topology(struct feat_fd *ff, FILE *fp)
1139 FILE *fp)
1140{ 1229{
1230 struct perf_header *ph = ff->ph;
1231 int cpu_nr = ph->env.nr_cpus_avail;
1141 int nr, i; 1232 int nr, i;
1142 char *str; 1233 char *str;
1143 int cpu_nr = ph->env.nr_cpus_avail;
1144 1234
1145 nr = ph->env.nr_sibling_cores; 1235 nr = ph->env.nr_sibling_cores;
1146 str = ph->env.sibling_cores; 1236 str = ph->env.sibling_cores;
@@ -1181,31 +1271,21 @@ static void free_event_desc(struct perf_evsel *events)
1181 free(events); 1271 free(events);
1182} 1272}
1183 1273
1184static struct perf_evsel * 1274static struct perf_evsel *read_event_desc(struct feat_fd *ff)
1185read_event_desc(struct perf_header *ph, int fd)
1186{ 1275{
1187 struct perf_evsel *evsel, *events = NULL; 1276 struct perf_evsel *evsel, *events = NULL;
1188 u64 *id; 1277 u64 *id;
1189 void *buf = NULL; 1278 void *buf = NULL;
1190 u32 nre, sz, nr, i, j; 1279 u32 nre, sz, nr, i, j;
1191 ssize_t ret;
1192 size_t msz; 1280 size_t msz;
1193 1281
1194 /* number of events */ 1282 /* number of events */
1195 ret = readn(fd, &nre, sizeof(nre)); 1283 if (do_read_u32(ff, &nre))
1196 if (ret != (ssize_t)sizeof(nre))
1197 goto error; 1284 goto error;
1198 1285
1199 if (ph->needs_swap) 1286 if (do_read_u32(ff, &sz))
1200 nre = bswap_32(nre);
1201
1202 ret = readn(fd, &sz, sizeof(sz));
1203 if (ret != (ssize_t)sizeof(sz))
1204 goto error; 1287 goto error;
1205 1288
1206 if (ph->needs_swap)
1207 sz = bswap_32(sz);
1208
1209 /* buffer to hold on file attr struct */ 1289 /* buffer to hold on file attr struct */
1210 buf = malloc(sz); 1290 buf = malloc(sz);
1211 if (!buf) 1291 if (!buf)
@@ -1227,25 +1307,23 @@ read_event_desc(struct perf_header *ph, int fd)
1227 * must read entire on-file attr struct to 1307 * must read entire on-file attr struct to
1228 * sync up with layout. 1308 * sync up with layout.
1229 */ 1309 */
1230 ret = readn(fd, buf, sz); 1310 if (__do_read(ff, buf, sz))
1231 if (ret != (ssize_t)sz)
1232 goto error; 1311 goto error;
1233 1312
1234 if (ph->needs_swap) 1313 if (ff->ph->needs_swap)
1235 perf_event__attr_swap(buf); 1314 perf_event__attr_swap(buf);
1236 1315
1237 memcpy(&evsel->attr, buf, msz); 1316 memcpy(&evsel->attr, buf, msz);
1238 1317
1239 ret = readn(fd, &nr, sizeof(nr)); 1318 if (do_read_u32(ff, &nr))
1240 if (ret != (ssize_t)sizeof(nr))
1241 goto error; 1319 goto error;
1242 1320
1243 if (ph->needs_swap) { 1321 if (ff->ph->needs_swap)
1244 nr = bswap_32(nr);
1245 evsel->needs_swap = true; 1322 evsel->needs_swap = true;
1246 }
1247 1323
1248 evsel->name = do_read_string(fd, ph); 1324 evsel->name = do_read_string(ff);
1325 if (!evsel->name)
1326 goto error;
1249 1327
1250 if (!nr) 1328 if (!nr)
1251 continue; 1329 continue;
@@ -1257,11 +1335,8 @@ read_event_desc(struct perf_header *ph, int fd)
1257 evsel->id = id; 1335 evsel->id = id;
1258 1336
1259 for (j = 0 ; j < nr; j++) { 1337 for (j = 0 ; j < nr; j++) {
1260 ret = readn(fd, id, sizeof(*id)); 1338 if (do_read_u64(ff, id))
1261 if (ret != (ssize_t)sizeof(*id))
1262 goto error; 1339 goto error;
1263 if (ph->needs_swap)
1264 *id = bswap_64(*id);
1265 id++; 1340 id++;
1266 } 1341 }
1267 } 1342 }
@@ -1280,12 +1355,17 @@ static int __desc_attr__fprintf(FILE *fp, const char *name, const char *val,
1280 return fprintf(fp, ", %s = %s", name, val); 1355 return fprintf(fp, ", %s = %s", name, val);
1281} 1356}
1282 1357
1283static void print_event_desc(struct perf_header *ph, int fd, FILE *fp) 1358static void print_event_desc(struct feat_fd *ff, FILE *fp)
1284{ 1359{
1285 struct perf_evsel *evsel, *events = read_event_desc(ph, fd); 1360 struct perf_evsel *evsel, *events;
1286 u32 j; 1361 u32 j;
1287 u64 *id; 1362 u64 *id;
1288 1363
1364 if (ff->events)
1365 events = ff->events;
1366 else
1367 events = read_event_desc(ff);
1368
1289 if (!events) { 1369 if (!events) {
1290 fprintf(fp, "# event desc: not available or unable to read\n"); 1370 fprintf(fp, "# event desc: not available or unable to read\n");
1291 return; 1371 return;
@@ -1310,22 +1390,21 @@ static void print_event_desc(struct perf_header *ph, int fd, FILE *fp)
1310 } 1390 }
1311 1391
1312 free_event_desc(events); 1392 free_event_desc(events);
1393 ff->events = NULL;
1313} 1394}
1314 1395
1315static void print_total_mem(struct perf_header *ph, int fd __maybe_unused, 1396static void print_total_mem(struct feat_fd *ff, FILE *fp)
1316 FILE *fp)
1317{ 1397{
1318 fprintf(fp, "# total memory : %Lu kB\n", ph->env.total_mem); 1398 fprintf(fp, "# total memory : %llu kB\n", ff->ph->env.total_mem);
1319} 1399}
1320 1400
1321static void print_numa_topology(struct perf_header *ph, int fd __maybe_unused, 1401static void print_numa_topology(struct feat_fd *ff, FILE *fp)
1322 FILE *fp)
1323{ 1402{
1324 int i; 1403 int i;
1325 struct numa_node *n; 1404 struct numa_node *n;
1326 1405
1327 for (i = 0; i < ph->env.nr_numa_nodes; i++) { 1406 for (i = 0; i < ff->ph->env.nr_numa_nodes; i++) {
1328 n = &ph->env.numa_nodes[i]; 1407 n = &ff->ph->env.numa_nodes[i];
1329 1408
1330 fprintf(fp, "# node%u meminfo : total = %"PRIu64" kB," 1409 fprintf(fp, "# node%u meminfo : total = %"PRIu64" kB,"
1331 " free = %"PRIu64" kB\n", 1410 " free = %"PRIu64" kB\n",
@@ -1336,56 +1415,51 @@ static void print_numa_topology(struct perf_header *ph, int fd __maybe_unused,
1336 } 1415 }
1337} 1416}
1338 1417
1339static void print_cpuid(struct perf_header *ph, int fd __maybe_unused, FILE *fp) 1418static void print_cpuid(struct feat_fd *ff, FILE *fp)
1340{ 1419{
1341 fprintf(fp, "# cpuid : %s\n", ph->env.cpuid); 1420 fprintf(fp, "# cpuid : %s\n", ff->ph->env.cpuid);
1342} 1421}
1343 1422
1344static void print_branch_stack(struct perf_header *ph __maybe_unused, 1423static void print_branch_stack(struct feat_fd *ff __maybe_unused, FILE *fp)
1345 int fd __maybe_unused, FILE *fp)
1346{ 1424{
1347 fprintf(fp, "# contains samples with branch stack\n"); 1425 fprintf(fp, "# contains samples with branch stack\n");
1348} 1426}
1349 1427
1350static void print_auxtrace(struct perf_header *ph __maybe_unused, 1428static void print_auxtrace(struct feat_fd *ff __maybe_unused, FILE *fp)
1351 int fd __maybe_unused, FILE *fp)
1352{ 1429{
1353 fprintf(fp, "# contains AUX area data (e.g. instruction trace)\n"); 1430 fprintf(fp, "# contains AUX area data (e.g. instruction trace)\n");
1354} 1431}
1355 1432
1356static void print_stat(struct perf_header *ph __maybe_unused, 1433static void print_stat(struct feat_fd *ff __maybe_unused, FILE *fp)
1357 int fd __maybe_unused, FILE *fp)
1358{ 1434{
1359 fprintf(fp, "# contains stat data\n"); 1435 fprintf(fp, "# contains stat data\n");
1360} 1436}
1361 1437
1362static void print_cache(struct perf_header *ph __maybe_unused, 1438static void print_cache(struct feat_fd *ff, FILE *fp __maybe_unused)
1363 int fd __maybe_unused, FILE *fp __maybe_unused)
1364{ 1439{
1365 int i; 1440 int i;
1366 1441
1367 fprintf(fp, "# CPU cache info:\n"); 1442 fprintf(fp, "# CPU cache info:\n");
1368 for (i = 0; i < ph->env.caches_cnt; i++) { 1443 for (i = 0; i < ff->ph->env.caches_cnt; i++) {
1369 fprintf(fp, "# "); 1444 fprintf(fp, "# ");
1370 cpu_cache_level__fprintf(fp, &ph->env.caches[i]); 1445 cpu_cache_level__fprintf(fp, &ff->ph->env.caches[i]);
1371 } 1446 }
1372} 1447}
1373 1448
1374static void print_pmu_mappings(struct perf_header *ph, int fd __maybe_unused, 1449static void print_pmu_mappings(struct feat_fd *ff, FILE *fp)
1375 FILE *fp)
1376{ 1450{
1377 const char *delimiter = "# pmu mappings: "; 1451 const char *delimiter = "# pmu mappings: ";
1378 char *str, *tmp; 1452 char *str, *tmp;
1379 u32 pmu_num; 1453 u32 pmu_num;
1380 u32 type; 1454 u32 type;
1381 1455
1382 pmu_num = ph->env.nr_pmu_mappings; 1456 pmu_num = ff->ph->env.nr_pmu_mappings;
1383 if (!pmu_num) { 1457 if (!pmu_num) {
1384 fprintf(fp, "# pmu mappings: not available\n"); 1458 fprintf(fp, "# pmu mappings: not available\n");
1385 return; 1459 return;
1386 } 1460 }
1387 1461
1388 str = ph->env.pmu_mappings; 1462 str = ff->ph->env.pmu_mappings;
1389 1463
1390 while (pmu_num) { 1464 while (pmu_num) {
1391 type = strtoul(str, &tmp, 0); 1465 type = strtoul(str, &tmp, 0);
@@ -1408,14 +1482,13 @@ error:
1408 fprintf(fp, "# pmu mappings: unable to read\n"); 1482 fprintf(fp, "# pmu mappings: unable to read\n");
1409} 1483}
1410 1484
1411static void print_group_desc(struct perf_header *ph, int fd __maybe_unused, 1485static void print_group_desc(struct feat_fd *ff, FILE *fp)
1412 FILE *fp)
1413{ 1486{
1414 struct perf_session *session; 1487 struct perf_session *session;
1415 struct perf_evsel *evsel; 1488 struct perf_evsel *evsel;
1416 u32 nr = 0; 1489 u32 nr = 0;
1417 1490
1418 session = container_of(ph, struct perf_session, header); 1491 session = container_of(ff->ph, struct perf_session, header);
1419 1492
1420 evlist__for_each_entry(session->evlist, evsel) { 1493 evlist__for_each_entry(session->evlist, evsel) {
1421 if (perf_evsel__is_group_leader(evsel) && 1494 if (perf_evsel__is_group_leader(evsel) &&
@@ -1588,113 +1661,61 @@ out:
1588 return err; 1661 return err;
1589} 1662}
1590 1663
1591static int process_tracing_data(struct perf_file_section *section __maybe_unused, 1664/* Macro for features that simply need to read and store a string. */
1592 struct perf_header *ph __maybe_unused, 1665#define FEAT_PROCESS_STR_FUN(__feat, __feat_env) \
1593 int fd, void *data) 1666static int process_##__feat(struct feat_fd *ff, void *data __maybe_unused) \
1594{ 1667{\
1595 ssize_t ret = trace_report(fd, data, false); 1668 ff->ph->env.__feat_env = do_read_string(ff); \
1596 return ret < 0 ? -1 : 0; 1669 return ff->ph->env.__feat_env ? 0 : -ENOMEM; \
1597}
1598
1599static int process_build_id(struct perf_file_section *section,
1600 struct perf_header *ph, int fd,
1601 void *data __maybe_unused)
1602{
1603 if (perf_header__read_build_ids(ph, fd, section->offset, section->size))
1604 pr_debug("Failed to read buildids, continuing...\n");
1605 return 0;
1606} 1670}
1607 1671
1608static int process_hostname(struct perf_file_section *section __maybe_unused, 1672FEAT_PROCESS_STR_FUN(hostname, hostname);
1609 struct perf_header *ph, int fd, 1673FEAT_PROCESS_STR_FUN(osrelease, os_release);
1610 void *data __maybe_unused) 1674FEAT_PROCESS_STR_FUN(version, version);
1611{ 1675FEAT_PROCESS_STR_FUN(arch, arch);
1612 ph->env.hostname = do_read_string(fd, ph); 1676FEAT_PROCESS_STR_FUN(cpudesc, cpu_desc);
1613 return ph->env.hostname ? 0 : -ENOMEM; 1677FEAT_PROCESS_STR_FUN(cpuid, cpuid);
1614}
1615 1678
1616static int process_osrelease(struct perf_file_section *section __maybe_unused, 1679static int process_tracing_data(struct feat_fd *ff, void *data)
1617 struct perf_header *ph, int fd,
1618 void *data __maybe_unused)
1619{ 1680{
1620 ph->env.os_release = do_read_string(fd, ph); 1681 ssize_t ret = trace_report(ff->fd, data, false);
1621 return ph->env.os_release ? 0 : -ENOMEM;
1622}
1623 1682
1624static int process_version(struct perf_file_section *section __maybe_unused, 1683 return ret < 0 ? -1 : 0;
1625 struct perf_header *ph, int fd,
1626 void *data __maybe_unused)
1627{
1628 ph->env.version = do_read_string(fd, ph);
1629 return ph->env.version ? 0 : -ENOMEM;
1630} 1684}
1631 1685
1632static int process_arch(struct perf_file_section *section __maybe_unused, 1686static int process_build_id(struct feat_fd *ff, void *data __maybe_unused)
1633 struct perf_header *ph, int fd,
1634 void *data __maybe_unused)
1635{ 1687{
1636 ph->env.arch = do_read_string(fd, ph); 1688 if (perf_header__read_build_ids(ff->ph, ff->fd, ff->offset, ff->size))
1637 return ph->env.arch ? 0 : -ENOMEM; 1689 pr_debug("Failed to read buildids, continuing...\n");
1690 return 0;
1638} 1691}
1639 1692
1640static int process_nrcpus(struct perf_file_section *section __maybe_unused, 1693static int process_nrcpus(struct feat_fd *ff, void *data __maybe_unused)
1641 struct perf_header *ph, int fd,
1642 void *data __maybe_unused)
1643{ 1694{
1644 ssize_t ret; 1695 int ret;
1645 u32 nr; 1696 u32 nr_cpus_avail, nr_cpus_online;
1646
1647 ret = readn(fd, &nr, sizeof(nr));
1648 if (ret != sizeof(nr))
1649 return -1;
1650
1651 if (ph->needs_swap)
1652 nr = bswap_32(nr);
1653
1654 ph->env.nr_cpus_avail = nr;
1655
1656 ret = readn(fd, &nr, sizeof(nr));
1657 if (ret != sizeof(nr))
1658 return -1;
1659 1697
1660 if (ph->needs_swap) 1698 ret = do_read_u32(ff, &nr_cpus_avail);
1661 nr = bswap_32(nr); 1699 if (ret)
1700 return ret;
1662 1701
1663 ph->env.nr_cpus_online = nr; 1702 ret = do_read_u32(ff, &nr_cpus_online);
1703 if (ret)
1704 return ret;
1705 ff->ph->env.nr_cpus_avail = (int)nr_cpus_avail;
1706 ff->ph->env.nr_cpus_online = (int)nr_cpus_online;
1664 return 0; 1707 return 0;
1665} 1708}
1666 1709
1667static int process_cpudesc(struct perf_file_section *section __maybe_unused, 1710static int process_total_mem(struct feat_fd *ff, void *data __maybe_unused)
1668 struct perf_header *ph, int fd,
1669 void *data __maybe_unused)
1670{
1671 ph->env.cpu_desc = do_read_string(fd, ph);
1672 return ph->env.cpu_desc ? 0 : -ENOMEM;
1673}
1674
1675static int process_cpuid(struct perf_file_section *section __maybe_unused,
1676 struct perf_header *ph, int fd,
1677 void *data __maybe_unused)
1678{
1679 ph->env.cpuid = do_read_string(fd, ph);
1680 return ph->env.cpuid ? 0 : -ENOMEM;
1681}
1682
1683static int process_total_mem(struct perf_file_section *section __maybe_unused,
1684 struct perf_header *ph, int fd,
1685 void *data __maybe_unused)
1686{ 1711{
1687 uint64_t mem; 1712 u64 total_mem;
1688 ssize_t ret; 1713 int ret;
1689 1714
1690 ret = readn(fd, &mem, sizeof(mem)); 1715 ret = do_read_u64(ff, &total_mem);
1691 if (ret != sizeof(mem)) 1716 if (ret)
1692 return -1; 1717 return -1;
1693 1718 ff->ph->env.total_mem = (unsigned long long)total_mem;
1694 if (ph->needs_swap)
1695 mem = bswap_64(mem);
1696
1697 ph->env.total_mem = mem;
1698 return 0; 1719 return 0;
1699} 1720}
1700 1721
@@ -1731,43 +1752,42 @@ perf_evlist__set_event_name(struct perf_evlist *evlist,
1731} 1752}
1732 1753
1733static int 1754static int
1734process_event_desc(struct perf_file_section *section __maybe_unused, 1755process_event_desc(struct feat_fd *ff, void *data __maybe_unused)
1735 struct perf_header *header, int fd,
1736 void *data __maybe_unused)
1737{ 1756{
1738 struct perf_session *session; 1757 struct perf_session *session;
1739 struct perf_evsel *evsel, *events = read_event_desc(header, fd); 1758 struct perf_evsel *evsel, *events = read_event_desc(ff);
1740 1759
1741 if (!events) 1760 if (!events)
1742 return 0; 1761 return 0;
1743 1762
1744 session = container_of(header, struct perf_session, header); 1763 session = container_of(ff->ph, struct perf_session, header);
1764
1765 if (session->file->is_pipe) {
1766 /* Save events for reading later by print_event_desc,
1767 * since they can't be read again in pipe mode. */
1768 ff->events = events;
1769 }
1770
1745 for (evsel = events; evsel->attr.size; evsel++) 1771 for (evsel = events; evsel->attr.size; evsel++)
1746 perf_evlist__set_event_name(session->evlist, evsel); 1772 perf_evlist__set_event_name(session->evlist, evsel);
1747 1773
1748 free_event_desc(events); 1774 if (!session->file->is_pipe)
1775 free_event_desc(events);
1749 1776
1750 return 0; 1777 return 0;
1751} 1778}
1752 1779
1753static int process_cmdline(struct perf_file_section *section, 1780static int process_cmdline(struct feat_fd *ff, void *data __maybe_unused)
1754 struct perf_header *ph, int fd,
1755 void *data __maybe_unused)
1756{ 1781{
1757 ssize_t ret;
1758 char *str, *cmdline = NULL, **argv = NULL; 1782 char *str, *cmdline = NULL, **argv = NULL;
1759 u32 nr, i, len = 0; 1783 u32 nr, i, len = 0;
1760 1784
1761 ret = readn(fd, &nr, sizeof(nr)); 1785 if (do_read_u32(ff, &nr))
1762 if (ret != sizeof(nr))
1763 return -1; 1786 return -1;
1764 1787
1765 if (ph->needs_swap) 1788 ff->ph->env.nr_cmdline = nr;
1766 nr = bswap_32(nr);
1767
1768 ph->env.nr_cmdline = nr;
1769 1789
1770 cmdline = zalloc(section->size + nr + 1); 1790 cmdline = zalloc(ff->size + nr + 1);
1771 if (!cmdline) 1791 if (!cmdline)
1772 return -1; 1792 return -1;
1773 1793
@@ -1776,7 +1796,7 @@ static int process_cmdline(struct perf_file_section *section,
1776 goto error; 1796 goto error;
1777 1797
1778 for (i = 0; i < nr; i++) { 1798 for (i = 0; i < nr; i++) {
1779 str = do_read_string(fd, ph); 1799 str = do_read_string(ff);
1780 if (!str) 1800 if (!str)
1781 goto error; 1801 goto error;
1782 1802
@@ -1785,8 +1805,8 @@ static int process_cmdline(struct perf_file_section *section,
1785 len += strlen(str) + 1; 1805 len += strlen(str) + 1;
1786 free(str); 1806 free(str);
1787 } 1807 }
1788 ph->env.cmdline = cmdline; 1808 ff->ph->env.cmdline = cmdline;
1789 ph->env.cmdline_argv = (const char **) argv; 1809 ff->ph->env.cmdline_argv = (const char **) argv;
1790 return 0; 1810 return 0;
1791 1811
1792error: 1812error:
@@ -1795,35 +1815,29 @@ error:
1795 return -1; 1815 return -1;
1796} 1816}
1797 1817
1798static int process_cpu_topology(struct perf_file_section *section, 1818static int process_cpu_topology(struct feat_fd *ff, void *data __maybe_unused)
1799 struct perf_header *ph, int fd,
1800 void *data __maybe_unused)
1801{ 1819{
1802 ssize_t ret;
1803 u32 nr, i; 1820 u32 nr, i;
1804 char *str; 1821 char *str;
1805 struct strbuf sb; 1822 struct strbuf sb;
1806 int cpu_nr = ph->env.nr_cpus_avail; 1823 int cpu_nr = ff->ph->env.nr_cpus_avail;
1807 u64 size = 0; 1824 u64 size = 0;
1825 struct perf_header *ph = ff->ph;
1808 1826
1809 ph->env.cpu = calloc(cpu_nr, sizeof(*ph->env.cpu)); 1827 ph->env.cpu = calloc(cpu_nr, sizeof(*ph->env.cpu));
1810 if (!ph->env.cpu) 1828 if (!ph->env.cpu)
1811 return -1; 1829 return -1;
1812 1830
1813 ret = readn(fd, &nr, sizeof(nr)); 1831 if (do_read_u32(ff, &nr))
1814 if (ret != sizeof(nr))
1815 goto free_cpu; 1832 goto free_cpu;
1816 1833
1817 if (ph->needs_swap)
1818 nr = bswap_32(nr);
1819
1820 ph->env.nr_sibling_cores = nr; 1834 ph->env.nr_sibling_cores = nr;
1821 size += sizeof(u32); 1835 size += sizeof(u32);
1822 if (strbuf_init(&sb, 128) < 0) 1836 if (strbuf_init(&sb, 128) < 0)
1823 goto free_cpu; 1837 goto free_cpu;
1824 1838
1825 for (i = 0; i < nr; i++) { 1839 for (i = 0; i < nr; i++) {
1826 str = do_read_string(fd, ph); 1840 str = do_read_string(ff);
1827 if (!str) 1841 if (!str)
1828 goto error; 1842 goto error;
1829 1843
@@ -1835,18 +1849,14 @@ static int process_cpu_topology(struct perf_file_section *section,
1835 } 1849 }
1836 ph->env.sibling_cores = strbuf_detach(&sb, NULL); 1850 ph->env.sibling_cores = strbuf_detach(&sb, NULL);
1837 1851
1838 ret = readn(fd, &nr, sizeof(nr)); 1852 if (do_read_u32(ff, &nr))
1839 if (ret != sizeof(nr))
1840 return -1; 1853 return -1;
1841 1854
1842 if (ph->needs_swap)
1843 nr = bswap_32(nr);
1844
1845 ph->env.nr_sibling_threads = nr; 1855 ph->env.nr_sibling_threads = nr;
1846 size += sizeof(u32); 1856 size += sizeof(u32);
1847 1857
1848 for (i = 0; i < nr; i++) { 1858 for (i = 0; i < nr; i++) {
1849 str = do_read_string(fd, ph); 1859 str = do_read_string(ff);
1850 if (!str) 1860 if (!str)
1851 goto error; 1861 goto error;
1852 1862
@@ -1862,28 +1872,20 @@ static int process_cpu_topology(struct perf_file_section *section,
1862 * The header may be from old perf, 1872 * The header may be from old perf,
1863 * which doesn't include core id and socket id information. 1873 * which doesn't include core id and socket id information.
1864 */ 1874 */
1865 if (section->size <= size) { 1875 if (ff->size <= size) {
1866 zfree(&ph->env.cpu); 1876 zfree(&ph->env.cpu);
1867 return 0; 1877 return 0;
1868 } 1878 }
1869 1879
1870 for (i = 0; i < (u32)cpu_nr; i++) { 1880 for (i = 0; i < (u32)cpu_nr; i++) {
1871 ret = readn(fd, &nr, sizeof(nr)); 1881 if (do_read_u32(ff, &nr))
1872 if (ret != sizeof(nr))
1873 goto free_cpu; 1882 goto free_cpu;
1874 1883
1875 if (ph->needs_swap)
1876 nr = bswap_32(nr);
1877
1878 ph->env.cpu[i].core_id = nr; 1884 ph->env.cpu[i].core_id = nr;
1879 1885
1880 ret = readn(fd, &nr, sizeof(nr)); 1886 if (do_read_u32(ff, &nr))
1881 if (ret != sizeof(nr))
1882 goto free_cpu; 1887 goto free_cpu;
1883 1888
1884 if (ph->needs_swap)
1885 nr = bswap_32(nr);
1886
1887 if (nr != (u32)-1 && nr > (u32)cpu_nr) { 1889 if (nr != (u32)-1 && nr > (u32)cpu_nr) {
1888 pr_debug("socket_id number is too big." 1890 pr_debug("socket_id number is too big."
1889 "You may need to upgrade the perf tool.\n"); 1891 "You may need to upgrade the perf tool.\n");
@@ -1902,23 +1904,16 @@ free_cpu:
1902 return -1; 1904 return -1;
1903} 1905}
1904 1906
1905static int process_numa_topology(struct perf_file_section *section __maybe_unused, 1907static int process_numa_topology(struct feat_fd *ff, void *data __maybe_unused)
1906 struct perf_header *ph, int fd,
1907 void *data __maybe_unused)
1908{ 1908{
1909 struct numa_node *nodes, *n; 1909 struct numa_node *nodes, *n;
1910 ssize_t ret;
1911 u32 nr, i; 1910 u32 nr, i;
1912 char *str; 1911 char *str;
1913 1912
1914 /* nr nodes */ 1913 /* nr nodes */
1915 ret = readn(fd, &nr, sizeof(nr)); 1914 if (do_read_u32(ff, &nr))
1916 if (ret != sizeof(nr))
1917 return -1; 1915 return -1;
1918 1916
1919 if (ph->needs_swap)
1920 nr = bswap_32(nr);
1921
1922 nodes = zalloc(sizeof(*nodes) * nr); 1917 nodes = zalloc(sizeof(*nodes) * nr);
1923 if (!nodes) 1918 if (!nodes)
1924 return -ENOMEM; 1919 return -ENOMEM;
@@ -1927,25 +1922,16 @@ static int process_numa_topology(struct perf_file_section *section __maybe_unuse
1927 n = &nodes[i]; 1922 n = &nodes[i];
1928 1923
1929 /* node number */ 1924 /* node number */
1930 ret = readn(fd, &n->node, sizeof(u32)); 1925 if (do_read_u32(ff, &n->node))
1931 if (ret != sizeof(n->node))
1932 goto error; 1926 goto error;
1933 1927
1934 ret = readn(fd, &n->mem_total, sizeof(u64)); 1928 if (do_read_u64(ff, &n->mem_total))
1935 if (ret != sizeof(u64))
1936 goto error; 1929 goto error;
1937 1930
1938 ret = readn(fd, &n->mem_free, sizeof(u64)); 1931 if (do_read_u64(ff, &n->mem_free))
1939 if (ret != sizeof(u64))
1940 goto error; 1932 goto error;
1941 1933
1942 if (ph->needs_swap) { 1934 str = do_read_string(ff);
1943 n->node = bswap_32(n->node);
1944 n->mem_total = bswap_64(n->mem_total);
1945 n->mem_free = bswap_64(n->mem_free);
1946 }
1947
1948 str = do_read_string(fd, ph);
1949 if (!str) 1935 if (!str)
1950 goto error; 1936 goto error;
1951 1937
@@ -1955,8 +1941,8 @@ static int process_numa_topology(struct perf_file_section *section __maybe_unuse
1955 1941
1956 free(str); 1942 free(str);
1957 } 1943 }
1958 ph->env.nr_numa_nodes = nr; 1944 ff->ph->env.nr_numa_nodes = nr;
1959 ph->env.numa_nodes = nodes; 1945 ff->ph->env.numa_nodes = nodes;
1960 return 0; 1946 return 0;
1961 1947
1962error: 1948error:
@@ -1964,39 +1950,30 @@ error:
1964 return -1; 1950 return -1;
1965} 1951}
1966 1952
1967static int process_pmu_mappings(struct perf_file_section *section __maybe_unused, 1953static int process_pmu_mappings(struct feat_fd *ff, void *data __maybe_unused)
1968 struct perf_header *ph, int fd,
1969 void *data __maybe_unused)
1970{ 1954{
1971 ssize_t ret;
1972 char *name; 1955 char *name;
1973 u32 pmu_num; 1956 u32 pmu_num;
1974 u32 type; 1957 u32 type;
1975 struct strbuf sb; 1958 struct strbuf sb;
1976 1959
1977 ret = readn(fd, &pmu_num, sizeof(pmu_num)); 1960 if (do_read_u32(ff, &pmu_num))
1978 if (ret != sizeof(pmu_num))
1979 return -1; 1961 return -1;
1980 1962
1981 if (ph->needs_swap)
1982 pmu_num = bswap_32(pmu_num);
1983
1984 if (!pmu_num) { 1963 if (!pmu_num) {
1985 pr_debug("pmu mappings not available\n"); 1964 pr_debug("pmu mappings not available\n");
1986 return 0; 1965 return 0;
1987 } 1966 }
1988 1967
1989 ph->env.nr_pmu_mappings = pmu_num; 1968 ff->ph->env.nr_pmu_mappings = pmu_num;
1990 if (strbuf_init(&sb, 128) < 0) 1969 if (strbuf_init(&sb, 128) < 0)
1991 return -1; 1970 return -1;
1992 1971
1993 while (pmu_num) { 1972 while (pmu_num) {
1994 if (readn(fd, &type, sizeof(type)) != sizeof(type)) 1973 if (do_read_u32(ff, &type))
1995 goto error; 1974 goto error;
1996 if (ph->needs_swap)
1997 type = bswap_32(type);
1998 1975
1999 name = do_read_string(fd, ph); 1976 name = do_read_string(ff);
2000 if (!name) 1977 if (!name)
2001 goto error; 1978 goto error;
2002 1979
@@ -2007,12 +1984,12 @@ static int process_pmu_mappings(struct perf_file_section *section __maybe_unused
2007 goto error; 1984 goto error;
2008 1985
2009 if (!strcmp(name, "msr")) 1986 if (!strcmp(name, "msr"))
2010 ph->env.msr_pmu_type = type; 1987 ff->ph->env.msr_pmu_type = type;
2011 1988
2012 free(name); 1989 free(name);
2013 pmu_num--; 1990 pmu_num--;
2014 } 1991 }
2015 ph->env.pmu_mappings = strbuf_detach(&sb, NULL); 1992 ff->ph->env.pmu_mappings = strbuf_detach(&sb, NULL);
2016 return 0; 1993 return 0;
2017 1994
2018error: 1995error:
@@ -2020,9 +1997,7 @@ error:
2020 return -1; 1997 return -1;
2021} 1998}
2022 1999
2023static int process_group_desc(struct perf_file_section *section __maybe_unused, 2000static int process_group_desc(struct feat_fd *ff, void *data __maybe_unused)
2024 struct perf_header *ph, int fd,
2025 void *data __maybe_unused)
2026{ 2001{
2027 size_t ret = -1; 2002 size_t ret = -1;
2028 u32 i, nr, nr_groups; 2003 u32 i, nr, nr_groups;
@@ -2034,13 +2009,10 @@ static int process_group_desc(struct perf_file_section *section __maybe_unused,
2034 u32 nr_members; 2009 u32 nr_members;
2035 } *desc; 2010 } *desc;
2036 2011
2037 if (readn(fd, &nr_groups, sizeof(nr_groups)) != sizeof(nr_groups)) 2012 if (do_read_u32(ff, &nr_groups))
2038 return -1; 2013 return -1;
2039 2014
2040 if (ph->needs_swap) 2015 ff->ph->env.nr_groups = nr_groups;
2041 nr_groups = bswap_32(nr_groups);
2042
2043 ph->env.nr_groups = nr_groups;
2044 if (!nr_groups) { 2016 if (!nr_groups) {
2045 pr_debug("group desc not available\n"); 2017 pr_debug("group desc not available\n");
2046 return 0; 2018 return 0;
@@ -2051,26 +2023,21 @@ static int process_group_desc(struct perf_file_section *section __maybe_unused,
2051 return -1; 2023 return -1;
2052 2024
2053 for (i = 0; i < nr_groups; i++) { 2025 for (i = 0; i < nr_groups; i++) {
2054 desc[i].name = do_read_string(fd, ph); 2026 desc[i].name = do_read_string(ff);
2055 if (!desc[i].name) 2027 if (!desc[i].name)
2056 goto out_free; 2028 goto out_free;
2057 2029
2058 if (readn(fd, &desc[i].leader_idx, sizeof(u32)) != sizeof(u32)) 2030 if (do_read_u32(ff, &desc[i].leader_idx))
2059 goto out_free; 2031 goto out_free;
2060 2032
2061 if (readn(fd, &desc[i].nr_members, sizeof(u32)) != sizeof(u32)) 2033 if (do_read_u32(ff, &desc[i].nr_members))
2062 goto out_free; 2034 goto out_free;
2063
2064 if (ph->needs_swap) {
2065 desc[i].leader_idx = bswap_32(desc[i].leader_idx);
2066 desc[i].nr_members = bswap_32(desc[i].nr_members);
2067 }
2068 } 2035 }
2069 2036
2070 /* 2037 /*
2071 * Rebuild group relationship based on the group_desc 2038 * Rebuild group relationship based on the group_desc
2072 */ 2039 */
2073 session = container_of(ph, struct perf_session, header); 2040 session = container_of(ff->ph, struct perf_session, header);
2074 session->evlist->nr_groups = nr_groups; 2041 session->evlist->nr_groups = nr_groups;
2075 2042
2076 i = nr = 0; 2043 i = nr = 0;
@@ -2114,44 +2081,34 @@ out_free:
2114 return ret; 2081 return ret;
2115} 2082}
2116 2083
2117static int process_auxtrace(struct perf_file_section *section, 2084static int process_auxtrace(struct feat_fd *ff, void *data __maybe_unused)
2118 struct perf_header *ph, int fd,
2119 void *data __maybe_unused)
2120{ 2085{
2121 struct perf_session *session; 2086 struct perf_session *session;
2122 int err; 2087 int err;
2123 2088
2124 session = container_of(ph, struct perf_session, header); 2089 session = container_of(ff->ph, struct perf_session, header);
2125 2090
2126 err = auxtrace_index__process(fd, section->size, session, 2091 err = auxtrace_index__process(ff->fd, ff->size, session,
2127 ph->needs_swap); 2092 ff->ph->needs_swap);
2128 if (err < 0) 2093 if (err < 0)
2129 pr_err("Failed to process auxtrace index\n"); 2094 pr_err("Failed to process auxtrace index\n");
2130 return err; 2095 return err;
2131} 2096}
2132 2097
2133static int process_cache(struct perf_file_section *section __maybe_unused, 2098static int process_cache(struct feat_fd *ff, void *data __maybe_unused)
2134 struct perf_header *ph __maybe_unused, int fd __maybe_unused,
2135 void *data __maybe_unused)
2136{ 2099{
2137 struct cpu_cache_level *caches; 2100 struct cpu_cache_level *caches;
2138 u32 cnt, i, version; 2101 u32 cnt, i, version;
2139 2102
2140 if (readn(fd, &version, sizeof(version)) != sizeof(version)) 2103 if (do_read_u32(ff, &version))
2141 return -1; 2104 return -1;
2142 2105
2143 if (ph->needs_swap)
2144 version = bswap_32(version);
2145
2146 if (version != 1) 2106 if (version != 1)
2147 return -1; 2107 return -1;
2148 2108
2149 if (readn(fd, &cnt, sizeof(cnt)) != sizeof(cnt)) 2109 if (do_read_u32(ff, &cnt))
2150 return -1; 2110 return -1;
2151 2111
2152 if (ph->needs_swap)
2153 cnt = bswap_32(cnt);
2154
2155 caches = zalloc(sizeof(*caches) * cnt); 2112 caches = zalloc(sizeof(*caches) * cnt);
2156 if (!caches) 2113 if (!caches)
2157 return -1; 2114 return -1;
@@ -2160,10 +2117,8 @@ static int process_cache(struct perf_file_section *section __maybe_unused,
2160 struct cpu_cache_level c; 2117 struct cpu_cache_level c;
2161 2118
2162 #define _R(v) \ 2119 #define _R(v) \
2163 if (readn(fd, &c.v, sizeof(u32)) != sizeof(u32))\ 2120 if (do_read_u32(ff, &c.v))\
2164 goto out_free_caches; \ 2121 goto out_free_caches; \
2165 if (ph->needs_swap) \
2166 c.v = bswap_32(c.v); \
2167 2122
2168 _R(level) 2123 _R(level)
2169 _R(line_size) 2124 _R(line_size)
@@ -2171,9 +2126,9 @@ static int process_cache(struct perf_file_section *section __maybe_unused,
2171 _R(ways) 2126 _R(ways)
2172 #undef _R 2127 #undef _R
2173 2128
2174 #define _R(v) \ 2129 #define _R(v) \
2175 c.v = do_read_string(fd, ph); \ 2130 c.v = do_read_string(ff); \
2176 if (!c.v) \ 2131 if (!c.v) \
2177 goto out_free_caches; 2132 goto out_free_caches;
2178 2133
2179 _R(type) 2134 _R(type)
@@ -2184,8 +2139,8 @@ static int process_cache(struct perf_file_section *section __maybe_unused,
2184 caches[i] = c; 2139 caches[i] = c;
2185 } 2140 }
2186 2141
2187 ph->env.caches = caches; 2142 ff->ph->env.caches = caches;
2188 ph->env.caches_cnt = cnt; 2143 ff->ph->env.caches_cnt = cnt;
2189 return 0; 2144 return 0;
2190out_free_caches: 2145out_free_caches:
2191 free(caches); 2146 free(caches);
@@ -2193,48 +2148,62 @@ out_free_caches:
2193} 2148}
2194 2149
2195struct feature_ops { 2150struct feature_ops {
2196 int (*write)(int fd, struct perf_header *h, struct perf_evlist *evlist); 2151 int (*write)(struct feat_fd *ff, struct perf_evlist *evlist);
2197 void (*print)(struct perf_header *h, int fd, FILE *fp); 2152 void (*print)(struct feat_fd *ff, FILE *fp);
2198 int (*process)(struct perf_file_section *section, 2153 int (*process)(struct feat_fd *ff, void *data);
2199 struct perf_header *h, int fd, void *data);
2200 const char *name; 2154 const char *name;
2201 bool full_only; 2155 bool full_only;
2156 bool synthesize;
2202}; 2157};
2203 2158
2204#define FEAT_OPA(n, func) \ 2159#define FEAT_OPR(n, func, __full_only) \
2205 [n] = { .name = #n, .write = write_##func, .print = print_##func } 2160 [HEADER_##n] = { \
2206#define FEAT_OPP(n, func) \ 2161 .name = __stringify(n), \
2207 [n] = { .name = #n, .write = write_##func, .print = print_##func, \ 2162 .write = write_##func, \
2208 .process = process_##func } 2163 .print = print_##func, \
2209#define FEAT_OPF(n, func) \ 2164 .full_only = __full_only, \
2210 [n] = { .name = #n, .write = write_##func, .print = print_##func, \ 2165 .process = process_##func, \
2211 .process = process_##func, .full_only = true } 2166 .synthesize = true \
2167 }
2168
2169#define FEAT_OPN(n, func, __full_only) \
2170 [HEADER_##n] = { \
2171 .name = __stringify(n), \
2172 .write = write_##func, \
2173 .print = print_##func, \
2174 .full_only = __full_only, \
2175 .process = process_##func \
2176 }
2212 2177
2213/* feature_ops not implemented: */ 2178/* feature_ops not implemented: */
2214#define print_tracing_data NULL 2179#define print_tracing_data NULL
2215#define print_build_id NULL 2180#define print_build_id NULL
2216 2181
2182#define process_branch_stack NULL
2183#define process_stat NULL
2184
2185
2217static const struct feature_ops feat_ops[HEADER_LAST_FEATURE] = { 2186static const struct feature_ops feat_ops[HEADER_LAST_FEATURE] = {
2218 FEAT_OPP(HEADER_TRACING_DATA, tracing_data), 2187 FEAT_OPN(TRACING_DATA, tracing_data, false),
2219 FEAT_OPP(HEADER_BUILD_ID, build_id), 2188 FEAT_OPN(BUILD_ID, build_id, false),
2220 FEAT_OPP(HEADER_HOSTNAME, hostname), 2189 FEAT_OPR(HOSTNAME, hostname, false),
2221 FEAT_OPP(HEADER_OSRELEASE, osrelease), 2190 FEAT_OPR(OSRELEASE, osrelease, false),
2222 FEAT_OPP(HEADER_VERSION, version), 2191 FEAT_OPR(VERSION, version, false),
2223 FEAT_OPP(HEADER_ARCH, arch), 2192 FEAT_OPR(ARCH, arch, false),
2224 FEAT_OPP(HEADER_NRCPUS, nrcpus), 2193 FEAT_OPR(NRCPUS, nrcpus, false),
2225 FEAT_OPP(HEADER_CPUDESC, cpudesc), 2194 FEAT_OPR(CPUDESC, cpudesc, false),
2226 FEAT_OPP(HEADER_CPUID, cpuid), 2195 FEAT_OPR(CPUID, cpuid, false),
2227 FEAT_OPP(HEADER_TOTAL_MEM, total_mem), 2196 FEAT_OPR(TOTAL_MEM, total_mem, false),
2228 FEAT_OPP(HEADER_EVENT_DESC, event_desc), 2197 FEAT_OPR(EVENT_DESC, event_desc, false),
2229 FEAT_OPP(HEADER_CMDLINE, cmdline), 2198 FEAT_OPR(CMDLINE, cmdline, false),
2230 FEAT_OPF(HEADER_CPU_TOPOLOGY, cpu_topology), 2199 FEAT_OPR(CPU_TOPOLOGY, cpu_topology, true),
2231 FEAT_OPF(HEADER_NUMA_TOPOLOGY, numa_topology), 2200 FEAT_OPR(NUMA_TOPOLOGY, numa_topology, true),
2232 FEAT_OPA(HEADER_BRANCH_STACK, branch_stack), 2201 FEAT_OPN(BRANCH_STACK, branch_stack, false),
2233 FEAT_OPP(HEADER_PMU_MAPPINGS, pmu_mappings), 2202 FEAT_OPR(PMU_MAPPINGS, pmu_mappings, false),
2234 FEAT_OPP(HEADER_GROUP_DESC, group_desc), 2203 FEAT_OPN(GROUP_DESC, group_desc, false),
2235 FEAT_OPP(HEADER_AUXTRACE, auxtrace), 2204 FEAT_OPN(AUXTRACE, auxtrace, false),
2236 FEAT_OPA(HEADER_STAT, stat), 2205 FEAT_OPN(STAT, stat, false),
2237 FEAT_OPF(HEADER_CACHE, cache), 2206 FEAT_OPN(CACHE, cache, true),
2238}; 2207};
2239 2208
2240struct header_print_data { 2209struct header_print_data {
@@ -2247,6 +2216,7 @@ static int perf_file_section__fprintf_info(struct perf_file_section *section,
2247 int feat, int fd, void *data) 2216 int feat, int fd, void *data)
2248{ 2217{
2249 struct header_print_data *hd = data; 2218 struct header_print_data *hd = data;
2219 struct feat_fd ff;
2250 2220
2251 if (lseek(fd, section->offset, SEEK_SET) == (off_t)-1) { 2221 if (lseek(fd, section->offset, SEEK_SET) == (off_t)-1) {
2252 pr_debug("Failed to lseek to %" PRIu64 " offset for feature " 2222 pr_debug("Failed to lseek to %" PRIu64 " offset for feature "
@@ -2260,8 +2230,13 @@ static int perf_file_section__fprintf_info(struct perf_file_section *section,
2260 if (!feat_ops[feat].print) 2230 if (!feat_ops[feat].print)
2261 return 0; 2231 return 0;
2262 2232
2233 ff = (struct feat_fd) {
2234 .fd = fd,
2235 .ph = ph,
2236 };
2237
2263 if (!feat_ops[feat].full_only || hd->full) 2238 if (!feat_ops[feat].full_only || hd->full)
2264 feat_ops[feat].print(ph, fd, hd->fp); 2239 feat_ops[feat].print(&ff, hd->fp);
2265 else 2240 else
2266 fprintf(hd->fp, "# %s info available, use -I to display\n", 2241 fprintf(hd->fp, "# %s info available, use -I to display\n",
2267 feat_ops[feat].name); 2242 feat_ops[feat].name);
@@ -2302,29 +2277,32 @@ int perf_header__fprintf_info(struct perf_session *session, FILE *fp, bool full)
2302 return 0; 2277 return 0;
2303} 2278}
2304 2279
2305static int do_write_feat(int fd, struct perf_header *h, int type, 2280static int do_write_feat(struct feat_fd *ff, int type,
2306 struct perf_file_section **p, 2281 struct perf_file_section **p,
2307 struct perf_evlist *evlist) 2282 struct perf_evlist *evlist)
2308{ 2283{
2309 int err; 2284 int err;
2310 int ret = 0; 2285 int ret = 0;
2311 2286
2312 if (perf_header__has_feat(h, type)) { 2287 if (perf_header__has_feat(ff->ph, type)) {
2313 if (!feat_ops[type].write) 2288 if (!feat_ops[type].write)
2314 return -1; 2289 return -1;
2315 2290
2316 (*p)->offset = lseek(fd, 0, SEEK_CUR); 2291 if (WARN(ff->buf, "Error: calling %s in pipe-mode.\n", __func__))
2292 return -1;
2317 2293
2318 err = feat_ops[type].write(fd, h, evlist); 2294 (*p)->offset = lseek(ff->fd, 0, SEEK_CUR);
2295
2296 err = feat_ops[type].write(ff, evlist);
2319 if (err < 0) { 2297 if (err < 0) {
2320 pr_debug("failed to write feature %s\n", feat_ops[type].name); 2298 pr_debug("failed to write feature %s\n", feat_ops[type].name);
2321 2299
2322 /* undo anything written */ 2300 /* undo anything written */
2323 lseek(fd, (*p)->offset, SEEK_SET); 2301 lseek(ff->fd, (*p)->offset, SEEK_SET);
2324 2302
2325 return -1; 2303 return -1;
2326 } 2304 }
2327 (*p)->size = lseek(fd, 0, SEEK_CUR) - (*p)->offset; 2305 (*p)->size = lseek(ff->fd, 0, SEEK_CUR) - (*p)->offset;
2328 (*p)++; 2306 (*p)++;
2329 } 2307 }
2330 return ret; 2308 return ret;
@@ -2334,12 +2312,18 @@ static int perf_header__adds_write(struct perf_header *header,
2334 struct perf_evlist *evlist, int fd) 2312 struct perf_evlist *evlist, int fd)
2335{ 2313{
2336 int nr_sections; 2314 int nr_sections;
2315 struct feat_fd ff;
2337 struct perf_file_section *feat_sec, *p; 2316 struct perf_file_section *feat_sec, *p;
2338 int sec_size; 2317 int sec_size;
2339 u64 sec_start; 2318 u64 sec_start;
2340 int feat; 2319 int feat;
2341 int err; 2320 int err;
2342 2321
2322 ff = (struct feat_fd){
2323 .fd = fd,
2324 .ph = header,
2325 };
2326
2343 nr_sections = bitmap_weight(header->adds_features, HEADER_FEAT_BITS); 2327 nr_sections = bitmap_weight(header->adds_features, HEADER_FEAT_BITS);
2344 if (!nr_sections) 2328 if (!nr_sections)
2345 return 0; 2329 return 0;
@@ -2354,7 +2338,7 @@ static int perf_header__adds_write(struct perf_header *header,
2354 lseek(fd, sec_start + sec_size, SEEK_SET); 2338 lseek(fd, sec_start + sec_size, SEEK_SET);
2355 2339
2356 for_each_set_bit(feat, header->adds_features, HEADER_FEAT_BITS) { 2340 for_each_set_bit(feat, header->adds_features, HEADER_FEAT_BITS) {
2357 if (do_write_feat(fd, header, feat, &p, evlist)) 2341 if (do_write_feat(&ff, feat, &p, evlist))
2358 perf_header__clear_feat(header, feat); 2342 perf_header__clear_feat(header, feat);
2359 } 2343 }
2360 2344
@@ -2363,7 +2347,7 @@ static int perf_header__adds_write(struct perf_header *header,
2363 * may write more than needed due to dropped feature, but 2347 * may write more than needed due to dropped feature, but
2364 * this is okay, reader will skip the mising entries 2348 * this is okay, reader will skip the mising entries
2365 */ 2349 */
2366 err = do_write(fd, feat_sec, sec_size); 2350 err = do_write(&ff, feat_sec, sec_size);
2367 if (err < 0) 2351 if (err < 0)
2368 pr_debug("failed to write feature section\n"); 2352 pr_debug("failed to write feature section\n");
2369 free(feat_sec); 2353 free(feat_sec);
@@ -2373,14 +2357,17 @@ static int perf_header__adds_write(struct perf_header *header,
2373int perf_header__write_pipe(int fd) 2357int perf_header__write_pipe(int fd)
2374{ 2358{
2375 struct perf_pipe_file_header f_header; 2359 struct perf_pipe_file_header f_header;
2360 struct feat_fd ff;
2376 int err; 2361 int err;
2377 2362
2363 ff = (struct feat_fd){ .fd = fd };
2364
2378 f_header = (struct perf_pipe_file_header){ 2365 f_header = (struct perf_pipe_file_header){
2379 .magic = PERF_MAGIC, 2366 .magic = PERF_MAGIC,
2380 .size = sizeof(f_header), 2367 .size = sizeof(f_header),
2381 }; 2368 };
2382 2369
2383 err = do_write(fd, &f_header, sizeof(f_header)); 2370 err = do_write(&ff, &f_header, sizeof(f_header));
2384 if (err < 0) { 2371 if (err < 0) {
2385 pr_debug("failed to write perf pipe header\n"); 2372 pr_debug("failed to write perf pipe header\n");
2386 return err; 2373 return err;
@@ -2397,21 +2384,23 @@ int perf_session__write_header(struct perf_session *session,
2397 struct perf_file_attr f_attr; 2384 struct perf_file_attr f_attr;
2398 struct perf_header *header = &session->header; 2385 struct perf_header *header = &session->header;
2399 struct perf_evsel *evsel; 2386 struct perf_evsel *evsel;
2387 struct feat_fd ff;
2400 u64 attr_offset; 2388 u64 attr_offset;
2401 int err; 2389 int err;
2402 2390
2391 ff = (struct feat_fd){ .fd = fd};
2403 lseek(fd, sizeof(f_header), SEEK_SET); 2392 lseek(fd, sizeof(f_header), SEEK_SET);
2404 2393
2405 evlist__for_each_entry(session->evlist, evsel) { 2394 evlist__for_each_entry(session->evlist, evsel) {
2406 evsel->id_offset = lseek(fd, 0, SEEK_CUR); 2395 evsel->id_offset = lseek(fd, 0, SEEK_CUR);
2407 err = do_write(fd, evsel->id, evsel->ids * sizeof(u64)); 2396 err = do_write(&ff, evsel->id, evsel->ids * sizeof(u64));
2408 if (err < 0) { 2397 if (err < 0) {
2409 pr_debug("failed to write perf header\n"); 2398 pr_debug("failed to write perf header\n");
2410 return err; 2399 return err;
2411 } 2400 }
2412 } 2401 }
2413 2402
2414 attr_offset = lseek(fd, 0, SEEK_CUR); 2403 attr_offset = lseek(ff.fd, 0, SEEK_CUR);
2415 2404
2416 evlist__for_each_entry(evlist, evsel) { 2405 evlist__for_each_entry(evlist, evsel) {
2417 f_attr = (struct perf_file_attr){ 2406 f_attr = (struct perf_file_attr){
@@ -2421,7 +2410,7 @@ int perf_session__write_header(struct perf_session *session,
2421 .size = evsel->ids * sizeof(u64), 2410 .size = evsel->ids * sizeof(u64),
2422 } 2411 }
2423 }; 2412 };
2424 err = do_write(fd, &f_attr, sizeof(f_attr)); 2413 err = do_write(&ff, &f_attr, sizeof(f_attr));
2425 if (err < 0) { 2414 if (err < 0) {
2426 pr_debug("failed to write perf header attribute\n"); 2415 pr_debug("failed to write perf header attribute\n");
2427 return err; 2416 return err;
@@ -2456,7 +2445,7 @@ int perf_session__write_header(struct perf_session *session,
2456 memcpy(&f_header.adds_features, &header->adds_features, sizeof(header->adds_features)); 2445 memcpy(&f_header.adds_features, &header->adds_features, sizeof(header->adds_features));
2457 2446
2458 lseek(fd, 0, SEEK_SET); 2447 lseek(fd, 0, SEEK_SET);
2459 err = do_write(fd, &f_header, sizeof(f_header)); 2448 err = do_write(&ff, &f_header, sizeof(f_header));
2460 if (err < 0) { 2449 if (err < 0) {
2461 pr_debug("failed to write perf header\n"); 2450 pr_debug("failed to write perf header\n");
2462 return err; 2451 return err;
@@ -2710,6 +2699,13 @@ static int perf_file_section__process(struct perf_file_section *section,
2710 struct perf_header *ph, 2699 struct perf_header *ph,
2711 int feat, int fd, void *data) 2700 int feat, int fd, void *data)
2712{ 2701{
2702 struct feat_fd fdd = {
2703 .fd = fd,
2704 .ph = ph,
2705 .size = section->size,
2706 .offset = section->offset,
2707 };
2708
2713 if (lseek(fd, section->offset, SEEK_SET) == (off_t)-1) { 2709 if (lseek(fd, section->offset, SEEK_SET) == (off_t)-1) {
2714 pr_debug("Failed to lseek to %" PRIu64 " offset for feature " 2710 pr_debug("Failed to lseek to %" PRIu64 " offset for feature "
2715 "%d, continuing...\n", section->offset, feat); 2711 "%d, continuing...\n", section->offset, feat);
@@ -2724,13 +2720,17 @@ static int perf_file_section__process(struct perf_file_section *section,
2724 if (!feat_ops[feat].process) 2720 if (!feat_ops[feat].process)
2725 return 0; 2721 return 0;
2726 2722
2727 return feat_ops[feat].process(section, ph, fd, data); 2723 return feat_ops[feat].process(&fdd, data);
2728} 2724}
2729 2725
2730static int perf_file_header__read_pipe(struct perf_pipe_file_header *header, 2726static int perf_file_header__read_pipe(struct perf_pipe_file_header *header,
2731 struct perf_header *ph, int fd, 2727 struct perf_header *ph, int fd,
2732 bool repipe) 2728 bool repipe)
2733{ 2729{
2730 struct feat_fd ff = {
2731 .fd = STDOUT_FILENO,
2732 .ph = ph,
2733 };
2734 ssize_t ret; 2734 ssize_t ret;
2735 2735
2736 ret = readn(fd, header, sizeof(*header)); 2736 ret = readn(fd, header, sizeof(*header));
@@ -2745,7 +2745,7 @@ static int perf_file_header__read_pipe(struct perf_pipe_file_header *header,
2745 if (ph->needs_swap) 2745 if (ph->needs_swap)
2746 header->size = bswap_64(header->size); 2746 header->size = bswap_64(header->size);
2747 2747
2748 if (repipe && do_write(STDOUT_FILENO, header, sizeof(*header)) < 0) 2748 if (repipe && do_write(&ff, header, sizeof(*header)) < 0)
2749 return -1; 2749 return -1;
2750 2750
2751 return 0; 2751 return 0;
@@ -2995,6 +2995,103 @@ int perf_event__synthesize_attr(struct perf_tool *tool,
2995 return err; 2995 return err;
2996} 2996}
2997 2997
2998int perf_event__synthesize_features(struct perf_tool *tool,
2999 struct perf_session *session,
3000 struct perf_evlist *evlist,
3001 perf_event__handler_t process)
3002{
3003 struct perf_header *header = &session->header;
3004 struct feat_fd ff;
3005 struct feature_event *fe;
3006 size_t sz, sz_hdr;
3007 int feat, ret;
3008
3009 sz_hdr = sizeof(fe->header);
3010 sz = sizeof(union perf_event);
3011 /* get a nice alignment */
3012 sz = PERF_ALIGN(sz, page_size);
3013
3014 memset(&ff, 0, sizeof(ff));
3015
3016 ff.buf = malloc(sz);
3017 if (!ff.buf)
3018 return -ENOMEM;
3019
3020 ff.size = sz - sz_hdr;
3021
3022 for_each_set_bit(feat, header->adds_features, HEADER_FEAT_BITS) {
3023 if (!feat_ops[feat].synthesize) {
3024 pr_debug("No record header feature for header :%d\n", feat);
3025 continue;
3026 }
3027
3028 ff.offset = sizeof(*fe);
3029
3030 ret = feat_ops[feat].write(&ff, evlist);
3031 if (ret || ff.offset <= (ssize_t)sizeof(*fe)) {
3032 pr_debug("Error writing feature\n");
3033 continue;
3034 }
3035 /* ff.buf may have changed due to realloc in do_write() */
3036 fe = ff.buf;
3037 memset(fe, 0, sizeof(*fe));
3038
3039 fe->feat_id = feat;
3040 fe->header.type = PERF_RECORD_HEADER_FEATURE;
3041 fe->header.size = ff.offset;
3042
3043 ret = process(tool, ff.buf, NULL, NULL);
3044 if (ret) {
3045 free(ff.buf);
3046 return ret;
3047 }
3048 }
3049 free(ff.buf);
3050 return 0;
3051}
3052
3053int perf_event__process_feature(struct perf_tool *tool,
3054 union perf_event *event,
3055 struct perf_session *session __maybe_unused)
3056{
3057 struct feat_fd ff = { .fd = 0 };
3058 struct feature_event *fe = (struct feature_event *)event;
3059 int type = fe->header.type;
3060 u64 feat = fe->feat_id;
3061
3062 if (type < 0 || type >= PERF_RECORD_HEADER_MAX) {
3063 pr_warning("invalid record type %d in pipe-mode\n", type);
3064 return 0;
3065 }
3066 if (feat == HEADER_RESERVED || feat > HEADER_LAST_FEATURE) {
3067 pr_warning("invalid record type %d in pipe-mode\n", type);
3068 return -1;
3069 }
3070
3071 if (!feat_ops[feat].process)
3072 return 0;
3073
3074 ff.buf = (void *)fe->data;
3075 ff.size = event->header.size - sizeof(event->header);
3076 ff.ph = &session->header;
3077
3078 if (feat_ops[feat].process(&ff, NULL))
3079 return -1;
3080
3081 if (!feat_ops[feat].print || !tool->show_feat_hdr)
3082 return 0;
3083
3084 if (!feat_ops[feat].full_only ||
3085 tool->show_feat_hdr >= SHOW_FEAT_HEADER_FULL_INFO) {
3086 feat_ops[feat].print(&ff, stdout);
3087 } else {
3088 fprintf(stdout, "# %s info available, use -I to display\n",
3089 feat_ops[feat].name);
3090 }
3091
3092 return 0;
3093}
3094
2998static struct event_update_event * 3095static struct event_update_event *
2999event_update_event__new(size_t size, u64 type, u64 id) 3096event_update_event__new(size_t size, u64 type, u64 id)
3000{ 3097{
@@ -3253,6 +3350,7 @@ int perf_event__synthesize_tracing_data(struct perf_tool *tool, int fd,
3253 union perf_event ev; 3350 union perf_event ev;
3254 struct tracing_data *tdata; 3351 struct tracing_data *tdata;
3255 ssize_t size = 0, aligned_size = 0, padding; 3352 ssize_t size = 0, aligned_size = 0, padding;
3353 struct feat_fd ff;
3256 int err __maybe_unused = 0; 3354 int err __maybe_unused = 0;
3257 3355
3258 /* 3356 /*
@@ -3287,7 +3385,9 @@ int perf_event__synthesize_tracing_data(struct perf_tool *tool, int fd,
3287 */ 3385 */
3288 tracing_data_put(tdata); 3386 tracing_data_put(tdata);
3289 3387
3290 write_padded(fd, NULL, 0, padding); 3388 ff = (struct feat_fd){ .fd = fd };
3389 if (write_padded(&ff, NULL, 0, padding))
3390 return -1;
3291 3391
3292 return aligned_size; 3392 return aligned_size;
3293} 3393}
diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h
index d30109b421ee..f7a16ee527b8 100644
--- a/tools/perf/util/header.h
+++ b/tools/perf/util/header.h
@@ -101,6 +101,15 @@ int perf_header__process_sections(struct perf_header *header, int fd,
101 101
102int perf_header__fprintf_info(struct perf_session *s, FILE *fp, bool full); 102int perf_header__fprintf_info(struct perf_session *s, FILE *fp, bool full);
103 103
104int perf_event__synthesize_features(struct perf_tool *tool,
105 struct perf_session *session,
106 struct perf_evlist *evlist,
107 perf_event__handler_t process);
108
109int perf_event__process_feature(struct perf_tool *tool,
110 union perf_event *event,
111 struct perf_session *session);
112
104int perf_event__synthesize_attr(struct perf_tool *tool, 113int perf_event__synthesize_attr(struct perf_tool *tool,
105 struct perf_event_attr *attr, u32 ids, u64 *id, 114 struct perf_event_attr *attr, u32 ids, u64 *id,
106 perf_event__handler_t process); 115 perf_event__handler_t process);
@@ -144,7 +153,12 @@ bool is_perf_magic(u64 magic);
144 153
145#define NAME_ALIGN 64 154#define NAME_ALIGN 64
146 155
147int write_padded(int fd, const void *bf, size_t count, size_t count_aligned); 156struct feat_fd;
157
158int do_write(struct feat_fd *fd, const void *buf, size_t size);
159
160int write_padded(struct feat_fd *fd, const void *bf,
161 size_t count, size_t count_aligned);
148 162
149/* 163/*
150 * arch specific callback 164 * arch specific callback
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index cf0186a088c1..e60d8d8ea4c2 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -167,6 +167,10 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
167 symlen = unresolved_col_width + 4 + 2; 167 symlen = unresolved_col_width + 4 + 2;
168 hists__set_unres_dso_col_len(hists, HISTC_MEM_DADDR_DSO); 168 hists__set_unres_dso_col_len(hists, HISTC_MEM_DADDR_DSO);
169 } 169 }
170
171 hists__new_col_len(hists, HISTC_MEM_PHYS_DADDR,
172 unresolved_col_width + 4 + 2);
173
170 } else { 174 } else {
171 symlen = unresolved_col_width + 4 + 2; 175 symlen = unresolved_col_width + 4 + 2;
172 hists__new_col_len(hists, HISTC_MEM_DADDR_SYMBOL, symlen); 176 hists__new_col_len(hists, HISTC_MEM_DADDR_SYMBOL, symlen);
@@ -749,12 +753,9 @@ iter_prepare_branch_entry(struct hist_entry_iter *iter, struct addr_location *al
749} 753}
750 754
751static int 755static int
752iter_add_single_branch_entry(struct hist_entry_iter *iter, 756iter_add_single_branch_entry(struct hist_entry_iter *iter __maybe_unused,
753 struct addr_location *al __maybe_unused) 757 struct addr_location *al __maybe_unused)
754{ 758{
755 /* to avoid calling callback function */
756 iter->he = NULL;
757
758 return 0; 759 return 0;
759} 760}
760 761
@@ -1762,6 +1763,8 @@ void perf_evsel__output_resort(struct perf_evsel *evsel, struct ui_progress *pro
1762 else 1763 else
1763 use_callchain = symbol_conf.use_callchain; 1764 use_callchain = symbol_conf.use_callchain;
1764 1765
1766 use_callchain |= symbol_conf.show_branchflag_count;
1767
1765 output_resort(evsel__hists(evsel), prog, use_callchain, NULL); 1768 output_resort(evsel__hists(evsel), prog, use_callchain, NULL);
1766} 1769}
1767 1770
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index ee3670a388df..e60dda26a920 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -47,6 +47,7 @@ enum hist_column {
47 HISTC_GLOBAL_WEIGHT, 47 HISTC_GLOBAL_WEIGHT,
48 HISTC_MEM_DADDR_SYMBOL, 48 HISTC_MEM_DADDR_SYMBOL,
49 HISTC_MEM_DADDR_DSO, 49 HISTC_MEM_DADDR_DSO,
50 HISTC_MEM_PHYS_DADDR,
50 HISTC_MEM_LOCKED, 51 HISTC_MEM_LOCKED,
51 HISTC_MEM_TLB, 52 HISTC_MEM_TLB,
52 HISTC_MEM_LVL, 53 HISTC_MEM_LVL,
diff --git a/tools/perf/util/intel-pt-decoder/Build b/tools/perf/util/intel-pt-decoder/Build
index 7aca5d6d7e1f..10e0814bb8d2 100644
--- a/tools/perf/util/intel-pt-decoder/Build
+++ b/tools/perf/util/intel-pt-decoder/Build
@@ -25,6 +25,6 @@ $(OUTPUT)util/intel-pt-decoder/intel-pt-insn-decoder.o: util/intel-pt-decoder/in
25 25
26CFLAGS_intel-pt-insn-decoder.o += -I$(OUTPUT)util/intel-pt-decoder 26CFLAGS_intel-pt-insn-decoder.o += -I$(OUTPUT)util/intel-pt-decoder
27 27
28ifneq ($(CC), clang) 28ifeq ($(CC_NO_CLANG), 1)
29 CFLAGS_intel-pt-insn-decoder.o += -Wno-override-init 29 CFLAGS_intel-pt-insn-decoder.o += -Wno-override-init
30endif 30endif
diff --git a/tools/perf/util/llvm-utils.c b/tools/perf/util/llvm-utils.c
index c6a15f204c03..209b0c82eff4 100644
--- a/tools/perf/util/llvm-utils.c
+++ b/tools/perf/util/llvm-utils.c
@@ -33,7 +33,7 @@ struct llvm_param llvm_param = {
33 33
34int perf_llvm_config(const char *var, const char *value) 34int perf_llvm_config(const char *var, const char *value)
35{ 35{
36 if (prefixcmp(var, "llvm.")) 36 if (!strstarts(var, "llvm."))
37 return 0; 37 return 0;
38 var += sizeof("llvm.") - 1; 38 var += sizeof("llvm.") - 1;
39 39
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 2e9eb6aa3ce2..df709363ef69 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -705,7 +705,8 @@ size_t machine__fprintf_vmlinux_path(struct machine *machine, FILE *fp)
705 705
706 if (kdso->has_build_id) { 706 if (kdso->has_build_id) {
707 char filename[PATH_MAX]; 707 char filename[PATH_MAX];
708 if (dso__build_id_filename(kdso, filename, sizeof(filename))) 708 if (dso__build_id_filename(kdso, filename, sizeof(filename),
709 false))
709 printed += fprintf(fp, "[0] %s\n", filename); 710 printed += fprintf(fp, "[0] %s\n", filename);
710 } 711 }
711 712
@@ -1137,7 +1138,8 @@ int __weak arch__fix_module_text_start(u64 *start __maybe_unused,
1137 return 0; 1138 return 0;
1138} 1139}
1139 1140
1140static int machine__create_module(void *arg, const char *name, u64 start) 1141static int machine__create_module(void *arg, const char *name, u64 start,
1142 u64 size)
1141{ 1143{
1142 struct machine *machine = arg; 1144 struct machine *machine = arg;
1143 struct map *map; 1145 struct map *map;
@@ -1148,6 +1150,7 @@ static int machine__create_module(void *arg, const char *name, u64 start)
1148 map = machine__findnew_module_map(machine, start, name); 1150 map = machine__findnew_module_map(machine, start, name);
1149 if (map == NULL) 1151 if (map == NULL)
1150 return -1; 1152 return -1;
1153 map->end = start + size;
1151 1154
1152 dso__kernel_module_get_build_id(map->dso, machine->root_dir); 1155 dso__kernel_module_get_build_id(map->dso, machine->root_dir);
1153 1156
@@ -1392,7 +1395,7 @@ int machine__process_mmap2_event(struct machine *machine,
1392 1395
1393 map = map__new(machine, event->mmap2.start, 1396 map = map__new(machine, event->mmap2.start,
1394 event->mmap2.len, event->mmap2.pgoff, 1397 event->mmap2.len, event->mmap2.pgoff,
1395 event->mmap2.pid, event->mmap2.maj, 1398 event->mmap2.maj,
1396 event->mmap2.min, event->mmap2.ino, 1399 event->mmap2.min, event->mmap2.ino,
1397 event->mmap2.ino_generation, 1400 event->mmap2.ino_generation,
1398 event->mmap2.prot, 1401 event->mmap2.prot,
@@ -1450,7 +1453,7 @@ int machine__process_mmap_event(struct machine *machine, union perf_event *event
1450 1453
1451 map = map__new(machine, event->mmap.start, 1454 map = map__new(machine, event->mmap.start,
1452 event->mmap.len, event->mmap.pgoff, 1455 event->mmap.len, event->mmap.pgoff,
1453 event->mmap.pid, 0, 0, 0, 0, 0, 0, 1456 0, 0, 0, 0, 0, 0,
1454 event->mmap.filename, 1457 event->mmap.filename,
1455 type, thread); 1458 type, thread);
1456 1459
@@ -1632,10 +1635,12 @@ static void ip__resolve_ams(struct thread *thread,
1632 ams->al_addr = al.addr; 1635 ams->al_addr = al.addr;
1633 ams->sym = al.sym; 1636 ams->sym = al.sym;
1634 ams->map = al.map; 1637 ams->map = al.map;
1638 ams->phys_addr = 0;
1635} 1639}
1636 1640
1637static void ip__resolve_data(struct thread *thread, 1641static void ip__resolve_data(struct thread *thread,
1638 u8 m, struct addr_map_symbol *ams, u64 addr) 1642 u8 m, struct addr_map_symbol *ams,
1643 u64 addr, u64 phys_addr)
1639{ 1644{
1640 struct addr_location al; 1645 struct addr_location al;
1641 1646
@@ -1655,6 +1660,7 @@ static void ip__resolve_data(struct thread *thread,
1655 ams->al_addr = al.addr; 1660 ams->al_addr = al.addr;
1656 ams->sym = al.sym; 1661 ams->sym = al.sym;
1657 ams->map = al.map; 1662 ams->map = al.map;
1663 ams->phys_addr = phys_addr;
1658} 1664}
1659 1665
1660struct mem_info *sample__resolve_mem(struct perf_sample *sample, 1666struct mem_info *sample__resolve_mem(struct perf_sample *sample,
@@ -1666,12 +1672,18 @@ struct mem_info *sample__resolve_mem(struct perf_sample *sample,
1666 return NULL; 1672 return NULL;
1667 1673
1668 ip__resolve_ams(al->thread, &mi->iaddr, sample->ip); 1674 ip__resolve_ams(al->thread, &mi->iaddr, sample->ip);
1669 ip__resolve_data(al->thread, al->cpumode, &mi->daddr, sample->addr); 1675 ip__resolve_data(al->thread, al->cpumode, &mi->daddr,
1676 sample->addr, sample->phys_addr);
1670 mi->data_src.val = sample->data_src; 1677 mi->data_src.val = sample->data_src;
1671 1678
1672 return mi; 1679 return mi;
1673} 1680}
1674 1681
1682struct iterations {
1683 int nr_loop_iter;
1684 u64 cycles;
1685};
1686
1675static int add_callchain_ip(struct thread *thread, 1687static int add_callchain_ip(struct thread *thread,
1676 struct callchain_cursor *cursor, 1688 struct callchain_cursor *cursor,
1677 struct symbol **parent, 1689 struct symbol **parent,
@@ -1680,10 +1692,12 @@ static int add_callchain_ip(struct thread *thread,
1680 u64 ip, 1692 u64 ip,
1681 bool branch, 1693 bool branch,
1682 struct branch_flags *flags, 1694 struct branch_flags *flags,
1683 int nr_loop_iter, 1695 struct iterations *iter,
1684 int samples) 1696 u64 branch_from)
1685{ 1697{
1686 struct addr_location al; 1698 struct addr_location al;
1699 int nr_loop_iter = 0;
1700 u64 iter_cycles = 0;
1687 1701
1688 al.filtered = 0; 1702 al.filtered = 0;
1689 al.sym = NULL; 1703 al.sym = NULL;
@@ -1733,8 +1747,15 @@ static int add_callchain_ip(struct thread *thread,
1733 1747
1734 if (symbol_conf.hide_unresolved && al.sym == NULL) 1748 if (symbol_conf.hide_unresolved && al.sym == NULL)
1735 return 0; 1749 return 0;
1750
1751 if (iter) {
1752 nr_loop_iter = iter->nr_loop_iter;
1753 iter_cycles = iter->cycles;
1754 }
1755
1736 return callchain_cursor_append(cursor, al.addr, al.map, al.sym, 1756 return callchain_cursor_append(cursor, al.addr, al.map, al.sym,
1737 branch, flags, nr_loop_iter, samples); 1757 branch, flags, nr_loop_iter,
1758 iter_cycles, branch_from);
1738} 1759}
1739 1760
1740struct branch_info *sample__resolve_bstack(struct perf_sample *sample, 1761struct branch_info *sample__resolve_bstack(struct perf_sample *sample,
@@ -1755,6 +1776,18 @@ struct branch_info *sample__resolve_bstack(struct perf_sample *sample,
1755 return bi; 1776 return bi;
1756} 1777}
1757 1778
1779static void save_iterations(struct iterations *iter,
1780 struct branch_entry *be, int nr)
1781{
1782 int i;
1783
1784 iter->nr_loop_iter = nr;
1785 iter->cycles = 0;
1786
1787 for (i = 0; i < nr; i++)
1788 iter->cycles += be[i].flags.cycles;
1789}
1790
1758#define CHASHSZ 127 1791#define CHASHSZ 127
1759#define CHASHBITS 7 1792#define CHASHBITS 7
1760#define NO_ENTRY 0xff 1793#define NO_ENTRY 0xff
@@ -1762,7 +1795,8 @@ struct branch_info *sample__resolve_bstack(struct perf_sample *sample,
1762#define PERF_MAX_BRANCH_DEPTH 127 1795#define PERF_MAX_BRANCH_DEPTH 127
1763 1796
1764/* Remove loops. */ 1797/* Remove loops. */
1765static int remove_loops(struct branch_entry *l, int nr) 1798static int remove_loops(struct branch_entry *l, int nr,
1799 struct iterations *iter)
1766{ 1800{
1767 int i, j, off; 1801 int i, j, off;
1768 unsigned char chash[CHASHSZ]; 1802 unsigned char chash[CHASHSZ];
@@ -1787,8 +1821,18 @@ static int remove_loops(struct branch_entry *l, int nr)
1787 break; 1821 break;
1788 } 1822 }
1789 if (is_loop) { 1823 if (is_loop) {
1790 memmove(l + i, l + i + off, 1824 j = nr - (i + off);
1791 (nr - (i + off)) * sizeof(*l)); 1825 if (j > 0) {
1826 save_iterations(iter + i + off,
1827 l + i, off);
1828
1829 memmove(iter + i, iter + i + off,
1830 j * sizeof(*iter));
1831
1832 memmove(l + i, l + i + off,
1833 j * sizeof(*l));
1834 }
1835
1792 nr -= off; 1836 nr -= off;
1793 } 1837 }
1794 } 1838 }
@@ -1813,7 +1857,7 @@ static int resolve_lbr_callchain_sample(struct thread *thread,
1813 struct ip_callchain *chain = sample->callchain; 1857 struct ip_callchain *chain = sample->callchain;
1814 int chain_nr = min(max_stack, (int)chain->nr), i; 1858 int chain_nr = min(max_stack, (int)chain->nr), i;
1815 u8 cpumode = PERF_RECORD_MISC_USER; 1859 u8 cpumode = PERF_RECORD_MISC_USER;
1816 u64 ip; 1860 u64 ip, branch_from = 0;
1817 1861
1818 for (i = 0; i < chain_nr; i++) { 1862 for (i = 0; i < chain_nr; i++) {
1819 if (chain->ips[i] == PERF_CONTEXT_USER) 1863 if (chain->ips[i] == PERF_CONTEXT_USER)
@@ -1855,6 +1899,8 @@ static int resolve_lbr_callchain_sample(struct thread *thread,
1855 ip = lbr_stack->entries[0].to; 1899 ip = lbr_stack->entries[0].to;
1856 branch = true; 1900 branch = true;
1857 flags = &lbr_stack->entries[0].flags; 1901 flags = &lbr_stack->entries[0].flags;
1902 branch_from =
1903 lbr_stack->entries[0].from;
1858 } 1904 }
1859 } else { 1905 } else {
1860 if (j < lbr_nr) { 1906 if (j < lbr_nr) {
@@ -1869,12 +1915,15 @@ static int resolve_lbr_callchain_sample(struct thread *thread,
1869 ip = lbr_stack->entries[0].to; 1915 ip = lbr_stack->entries[0].to;
1870 branch = true; 1916 branch = true;
1871 flags = &lbr_stack->entries[0].flags; 1917 flags = &lbr_stack->entries[0].flags;
1918 branch_from =
1919 lbr_stack->entries[0].from;
1872 } 1920 }
1873 } 1921 }
1874 1922
1875 err = add_callchain_ip(thread, cursor, parent, 1923 err = add_callchain_ip(thread, cursor, parent,
1876 root_al, &cpumode, ip, 1924 root_al, &cpumode, ip,
1877 branch, flags, 0, 0); 1925 branch, flags, NULL,
1926 branch_from);
1878 if (err) 1927 if (err)
1879 return (err < 0) ? err : 0; 1928 return (err < 0) ? err : 0;
1880 } 1929 }
@@ -1894,12 +1943,14 @@ static int thread__resolve_callchain_sample(struct thread *thread,
1894{ 1943{
1895 struct branch_stack *branch = sample->branch_stack; 1944 struct branch_stack *branch = sample->branch_stack;
1896 struct ip_callchain *chain = sample->callchain; 1945 struct ip_callchain *chain = sample->callchain;
1897 int chain_nr = chain->nr; 1946 int chain_nr = 0;
1898 u8 cpumode = PERF_RECORD_MISC_USER; 1947 u8 cpumode = PERF_RECORD_MISC_USER;
1899 int i, j, err, nr_entries; 1948 int i, j, err, nr_entries;
1900 int skip_idx = -1; 1949 int skip_idx = -1;
1901 int first_call = 0; 1950 int first_call = 0;
1902 int nr_loop_iter; 1951
1952 if (chain)
1953 chain_nr = chain->nr;
1903 1954
1904 if (perf_evsel__has_branch_callstack(evsel)) { 1955 if (perf_evsel__has_branch_callstack(evsel)) {
1905 err = resolve_lbr_callchain_sample(thread, cursor, sample, parent, 1956 err = resolve_lbr_callchain_sample(thread, cursor, sample, parent,
@@ -1929,6 +1980,7 @@ static int thread__resolve_callchain_sample(struct thread *thread,
1929 if (branch && callchain_param.branch_callstack) { 1980 if (branch && callchain_param.branch_callstack) {
1930 int nr = min(max_stack, (int)branch->nr); 1981 int nr = min(max_stack, (int)branch->nr);
1931 struct branch_entry be[nr]; 1982 struct branch_entry be[nr];
1983 struct iterations iter[nr];
1932 1984
1933 if (branch->nr > PERF_MAX_BRANCH_DEPTH) { 1985 if (branch->nr > PERF_MAX_BRANCH_DEPTH) {
1934 pr_warning("corrupted branch chain. skipping...\n"); 1986 pr_warning("corrupted branch chain. skipping...\n");
@@ -1938,6 +1990,10 @@ static int thread__resolve_callchain_sample(struct thread *thread,
1938 for (i = 0; i < nr; i++) { 1990 for (i = 0; i < nr; i++) {
1939 if (callchain_param.order == ORDER_CALLEE) { 1991 if (callchain_param.order == ORDER_CALLEE) {
1940 be[i] = branch->entries[i]; 1992 be[i] = branch->entries[i];
1993
1994 if (chain == NULL)
1995 continue;
1996
1941 /* 1997 /*
1942 * Check for overlap into the callchain. 1998 * Check for overlap into the callchain.
1943 * The return address is one off compared to 1999 * The return address is one off compared to
@@ -1955,42 +2011,30 @@ static int thread__resolve_callchain_sample(struct thread *thread,
1955 be[i] = branch->entries[branch->nr - i - 1]; 2011 be[i] = branch->entries[branch->nr - i - 1];
1956 } 2012 }
1957 2013
1958 nr_loop_iter = nr; 2014 memset(iter, 0, sizeof(struct iterations) * nr);
1959 nr = remove_loops(be, nr); 2015 nr = remove_loops(be, nr, iter);
1960
1961 /*
1962 * Get the number of iterations.
1963 * It's only approximation, but good enough in practice.
1964 */
1965 if (nr_loop_iter > nr)
1966 nr_loop_iter = nr_loop_iter - nr + 1;
1967 else
1968 nr_loop_iter = 0;
1969 2016
1970 for (i = 0; i < nr; i++) { 2017 for (i = 0; i < nr; i++) {
1971 if (i == nr - 1) 2018 err = add_callchain_ip(thread, cursor, parent,
1972 err = add_callchain_ip(thread, cursor, parent, 2019 root_al,
1973 root_al, 2020 NULL, be[i].to,
1974 NULL, be[i].to, 2021 true, &be[i].flags,
1975 true, &be[i].flags, 2022 NULL, be[i].from);
1976 nr_loop_iter, 1);
1977 else
1978 err = add_callchain_ip(thread, cursor, parent,
1979 root_al,
1980 NULL, be[i].to,
1981 true, &be[i].flags,
1982 0, 0);
1983 2023
1984 if (!err) 2024 if (!err)
1985 err = add_callchain_ip(thread, cursor, parent, root_al, 2025 err = add_callchain_ip(thread, cursor, parent, root_al,
1986 NULL, be[i].from, 2026 NULL, be[i].from,
1987 true, &be[i].flags, 2027 true, &be[i].flags,
1988 0, 0); 2028 &iter[i], 0);
1989 if (err == -EINVAL) 2029 if (err == -EINVAL)
1990 break; 2030 break;
1991 if (err) 2031 if (err)
1992 return err; 2032 return err;
1993 } 2033 }
2034
2035 if (chain_nr == 0)
2036 return 0;
2037
1994 chain_nr -= nr; 2038 chain_nr -= nr;
1995 } 2039 }
1996 2040
@@ -2015,7 +2059,7 @@ check_calls:
2015 2059
2016 err = add_callchain_ip(thread, cursor, parent, 2060 err = add_callchain_ip(thread, cursor, parent,
2017 root_al, &cpumode, ip, 2061 root_al, &cpumode, ip,
2018 false, NULL, 0, 0); 2062 false, NULL, NULL, 0);
2019 2063
2020 if (err) 2064 if (err)
2021 return (err < 0) ? err : 0; 2065 return (err < 0) ? err : 0;
@@ -2032,7 +2076,7 @@ static int unwind_entry(struct unwind_entry *entry, void *arg)
2032 return 0; 2076 return 0;
2033 return callchain_cursor_append(cursor, entry->ip, 2077 return callchain_cursor_append(cursor, entry->ip,
2034 entry->map, entry->sym, 2078 entry->map, entry->sym,
2035 false, NULL, 0, 0); 2079 false, NULL, 0, 0, 0);
2036} 2080}
2037 2081
2038static int thread__resolve_callchain_unwind(struct thread *thread, 2082static int thread__resolve_callchain_unwind(struct thread *thread,
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 2179b2deb730..bdaa0a4edc17 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -16,6 +16,7 @@
16#include "machine.h" 16#include "machine.h"
17#include <linux/string.h> 17#include <linux/string.h>
18#include "srcline.h" 18#include "srcline.h"
19#include "namespaces.h"
19#include "unwind.h" 20#include "unwind.h"
20 21
21static void __maps__insert(struct maps *maps, struct map *map); 22static void __maps__insert(struct maps *maps, struct map *map);
@@ -145,11 +146,13 @@ void map__init(struct map *map, enum map_type type,
145} 146}
146 147
147struct map *map__new(struct machine *machine, u64 start, u64 len, 148struct map *map__new(struct machine *machine, u64 start, u64 len,
148 u64 pgoff, u32 pid, u32 d_maj, u32 d_min, u64 ino, 149 u64 pgoff, u32 d_maj, u32 d_min, u64 ino,
149 u64 ino_gen, u32 prot, u32 flags, char *filename, 150 u64 ino_gen, u32 prot, u32 flags, char *filename,
150 enum map_type type, struct thread *thread) 151 enum map_type type, struct thread *thread)
151{ 152{
152 struct map *map = malloc(sizeof(*map)); 153 struct map *map = malloc(sizeof(*map));
154 struct nsinfo *nsi = NULL;
155 struct nsinfo *nnsi;
153 156
154 if (map != NULL) { 157 if (map != NULL) {
155 char newfilename[PATH_MAX]; 158 char newfilename[PATH_MAX];
@@ -167,9 +170,11 @@ struct map *map__new(struct machine *machine, u64 start, u64 len,
167 map->ino_generation = ino_gen; 170 map->ino_generation = ino_gen;
168 map->prot = prot; 171 map->prot = prot;
169 map->flags = flags; 172 map->flags = flags;
173 nsi = nsinfo__get(thread->nsinfo);
170 174
171 if ((anon || no_dso) && type == MAP__FUNCTION) { 175 if ((anon || no_dso) && nsi && type == MAP__FUNCTION) {
172 snprintf(newfilename, sizeof(newfilename), "/tmp/perf-%d.map", pid); 176 snprintf(newfilename, sizeof(newfilename),
177 "/tmp/perf-%d.map", nsi->pid);
173 filename = newfilename; 178 filename = newfilename;
174 } 179 }
175 180
@@ -179,6 +184,16 @@ struct map *map__new(struct machine *machine, u64 start, u64 len,
179 } 184 }
180 185
181 if (vdso) { 186 if (vdso) {
187 /* The vdso maps are always on the host and not the
188 * container. Ensure that we don't use setns to look
189 * them up.
190 */
191 nnsi = nsinfo__copy(nsi);
192 if (nnsi) {
193 nsinfo__put(nsi);
194 nnsi->need_setns = false;
195 nsi = nnsi;
196 }
182 pgoff = 0; 197 pgoff = 0;
183 dso = machine__findnew_vdso(machine, thread); 198 dso = machine__findnew_vdso(machine, thread);
184 } else 199 } else
@@ -200,10 +215,12 @@ struct map *map__new(struct machine *machine, u64 start, u64 len,
200 if (type != MAP__FUNCTION) 215 if (type != MAP__FUNCTION)
201 dso__set_loaded(dso, map->type); 216 dso__set_loaded(dso, map->type);
202 } 217 }
218 dso->nsinfo = nsi;
203 dso__put(dso); 219 dso__put(dso);
204 } 220 }
205 return map; 221 return map;
206out_delete: 222out_delete:
223 nsinfo__put(nsi);
207 free(map); 224 free(map);
208 return NULL; 225 return NULL;
209} 226}
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index f9e8ac8a52cd..73aacf7a7dc4 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -141,7 +141,7 @@ struct thread;
141void map__init(struct map *map, enum map_type type, 141void map__init(struct map *map, enum map_type type,
142 u64 start, u64 end, u64 pgoff, struct dso *dso); 142 u64 start, u64 end, u64 pgoff, struct dso *dso);
143struct map *map__new(struct machine *machine, u64 start, u64 len, 143struct map *map__new(struct machine *machine, u64 start, u64 len,
144 u64 pgoff, u32 pid, u32 d_maj, u32 d_min, u64 ino, 144 u64 pgoff, u32 d_maj, u32 d_min, u64 ino,
145 u64 ino_gen, u32 prot, u32 flags, 145 u64 ino_gen, u32 prot, u32 flags,
146 char *filename, enum map_type type, struct thread *thread); 146 char *filename, enum map_type type, struct thread *thread);
147struct map *map__new2(u64 start, struct dso *dso, enum map_type type); 147struct map *map__new2(u64 start, struct dso *dso, enum map_type type);
diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c
index 06f5a3a4295c..28afe5fa84d6 100644
--- a/tools/perf/util/mem-events.c
+++ b/tools/perf/util/mem-events.c
@@ -166,11 +166,20 @@ static const char * const mem_lvl[] = {
166 "Uncached", 166 "Uncached",
167}; 167};
168 168
169static const char * const mem_lvlnum[] = {
170 [PERF_MEM_LVLNUM_ANY_CACHE] = "Any cache",
171 [PERF_MEM_LVLNUM_LFB] = "LFB",
172 [PERF_MEM_LVLNUM_RAM] = "RAM",
173 [PERF_MEM_LVLNUM_PMEM] = "PMEM",
174 [PERF_MEM_LVLNUM_NA] = "N/A",
175};
176
169int perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info) 177int perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
170{ 178{
171 size_t i, l = 0; 179 size_t i, l = 0;
172 u64 m = PERF_MEM_LVL_NA; 180 u64 m = PERF_MEM_LVL_NA;
173 u64 hit, miss; 181 u64 hit, miss;
182 int printed;
174 183
175 if (mem_info) 184 if (mem_info)
176 m = mem_info->data_src.mem_lvl; 185 m = mem_info->data_src.mem_lvl;
@@ -184,17 +193,37 @@ int perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
184 /* already taken care of */ 193 /* already taken care of */
185 m &= ~(PERF_MEM_LVL_HIT|PERF_MEM_LVL_MISS); 194 m &= ~(PERF_MEM_LVL_HIT|PERF_MEM_LVL_MISS);
186 195
196
197 if (mem_info && mem_info->data_src.mem_remote) {
198 strcat(out, "Remote ");
199 l += 7;
200 }
201
202 printed = 0;
187 for (i = 0; m && i < ARRAY_SIZE(mem_lvl); i++, m >>= 1) { 203 for (i = 0; m && i < ARRAY_SIZE(mem_lvl); i++, m >>= 1) {
188 if (!(m & 0x1)) 204 if (!(m & 0x1))
189 continue; 205 continue;
190 if (l) { 206 if (printed++) {
191 strcat(out, " or "); 207 strcat(out, " or ");
192 l += 4; 208 l += 4;
193 } 209 }
194 l += scnprintf(out + l, sz - l, mem_lvl[i]); 210 l += scnprintf(out + l, sz - l, mem_lvl[i]);
195 } 211 }
196 if (*out == '\0') 212
197 l += scnprintf(out, sz - l, "N/A"); 213 if (mem_info && mem_info->data_src.mem_lvl_num) {
214 int lvl = mem_info->data_src.mem_lvl_num;
215 if (printed++) {
216 strcat(out, " or ");
217 l += 4;
218 }
219 if (mem_lvlnum[lvl])
220 l += scnprintf(out + l, sz - l, mem_lvlnum[lvl]);
221 else
222 l += scnprintf(out + l, sz - l, "L%d", lvl);
223 }
224
225 if (l == 0)
226 l += scnprintf(out + l, sz - l, "N/A");
198 if (hit) 227 if (hit)
199 l += scnprintf(out + l, sz - l, " hit"); 228 l += scnprintf(out + l, sz - l, " hit");
200 if (miss) 229 if (miss)
@@ -231,6 +260,14 @@ int perf_mem__snp_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
231 } 260 }
232 l += scnprintf(out + l, sz - l, snoop_access[i]); 261 l += scnprintf(out + l, sz - l, snoop_access[i]);
233 } 262 }
263 if (mem_info &&
264 (mem_info->data_src.mem_snoopx & PERF_MEM_SNOOPX_FWD)) {
265 if (l) {
266 strcat(out, " or ");
267 l += 4;
268 }
269 l += scnprintf(out + l, sz - l, "Fwd");
270 }
234 271
235 if (*out == '\0') 272 if (*out == '\0')
236 l += scnprintf(out, sz - l, "N/A"); 273 l += scnprintf(out, sz - l, "N/A");
@@ -279,6 +316,11 @@ int c2c_decode_stats(struct c2c_stats *stats, struct mem_info *mi)
279 u64 lvl = data_src->mem_lvl; 316 u64 lvl = data_src->mem_lvl;
280 u64 snoop = data_src->mem_snoop; 317 u64 snoop = data_src->mem_snoop;
281 u64 lock = data_src->mem_lock; 318 u64 lock = data_src->mem_lock;
319 /*
320 * Skylake might report unknown remote level via this
321 * bit, consider it when evaluating remote HITMs.
322 */
323 bool mrem = data_src->mem_remote;
282 int err = 0; 324 int err = 0;
283 325
284#define HITM_INC(__f) \ 326#define HITM_INC(__f) \
@@ -324,7 +366,8 @@ do { \
324 } 366 }
325 367
326 if ((lvl & P(LVL, REM_RAM1)) || 368 if ((lvl & P(LVL, REM_RAM1)) ||
327 (lvl & P(LVL, REM_RAM2))) { 369 (lvl & P(LVL, REM_RAM2)) ||
370 mrem) {
328 stats->rmt_dram++; 371 stats->rmt_dram++;
329 if (snoop & P(SNOOP, HIT)) 372 if (snoop & P(SNOOP, HIT))
330 stats->ld_shared++; 373 stats->ld_shared++;
@@ -334,7 +377,8 @@ do { \
334 } 377 }
335 378
336 if ((lvl & P(LVL, REM_CCE1)) || 379 if ((lvl & P(LVL, REM_CCE1)) ||
337 (lvl & P(LVL, REM_CCE2))) { 380 (lvl & P(LVL, REM_CCE2)) ||
381 mrem) {
338 if (snoop & P(SNOOP, HIT)) 382 if (snoop & P(SNOOP, HIT))
339 stats->rmt_hit++; 383 stats->rmt_hit++;
340 else if (snoop & P(SNOOP, HITM)) 384 else if (snoop & P(SNOOP, HITM))
diff --git a/tools/perf/util/namespaces.c b/tools/perf/util/namespaces.c
index 67dcbcc73c7d..a58e91197729 100644
--- a/tools/perf/util/namespaces.c
+++ b/tools/perf/util/namespaces.c
@@ -9,9 +9,14 @@
9#include "namespaces.h" 9#include "namespaces.h"
10#include "util.h" 10#include "util.h"
11#include "event.h" 11#include "event.h"
12#include <sys/types.h>
13#include <sys/stat.h>
14#include <limits.h>
15#include <sched.h>
12#include <stdlib.h> 16#include <stdlib.h>
13#include <stdio.h> 17#include <stdio.h>
14#include <string.h> 18#include <string.h>
19#include <unistd.h>
15 20
16struct namespaces *namespaces__new(struct namespaces_event *event) 21struct namespaces *namespaces__new(struct namespaces_event *event)
17{ 22{
@@ -35,3 +40,209 @@ void namespaces__free(struct namespaces *namespaces)
35{ 40{
36 free(namespaces); 41 free(namespaces);
37} 42}
43
44int nsinfo__init(struct nsinfo *nsi)
45{
46 char oldns[PATH_MAX];
47 char spath[PATH_MAX];
48 char *newns = NULL;
49 char *statln = NULL;
50 struct stat old_stat;
51 struct stat new_stat;
52 FILE *f = NULL;
53 size_t linesz = 0;
54 int rv = -1;
55
56 if (snprintf(oldns, PATH_MAX, "/proc/self/ns/mnt") >= PATH_MAX)
57 return rv;
58
59 if (asprintf(&newns, "/proc/%d/ns/mnt", nsi->pid) == -1)
60 return rv;
61
62 if (stat(oldns, &old_stat) < 0)
63 goto out;
64
65 if (stat(newns, &new_stat) < 0)
66 goto out;
67
68 /* Check if the mount namespaces differ, if so then indicate that we
69 * want to switch as part of looking up dso/map data.
70 */
71 if (old_stat.st_ino != new_stat.st_ino) {
72 nsi->need_setns = true;
73 nsi->mntns_path = newns;
74 newns = NULL;
75 }
76
77 /* If we're dealing with a process that is in a different PID namespace,
78 * attempt to work out the innermost tgid for the process.
79 */
80 if (snprintf(spath, PATH_MAX, "/proc/%d/status", nsi->pid) >= PATH_MAX)
81 goto out;
82
83 f = fopen(spath, "r");
84 if (f == NULL)
85 goto out;
86
87 while (getline(&statln, &linesz, f) != -1) {
88 /* Use tgid if CONFIG_PID_NS is not defined. */
89 if (strstr(statln, "Tgid:") != NULL) {
90 nsi->tgid = (pid_t)strtol(strrchr(statln, '\t'),
91 NULL, 10);
92 nsi->nstgid = nsi->tgid;
93 }
94
95 if (strstr(statln, "NStgid:") != NULL) {
96 nsi->nstgid = (pid_t)strtol(strrchr(statln, '\t'),
97 NULL, 10);
98 break;
99 }
100 }
101 rv = 0;
102
103out:
104 if (f != NULL)
105 (void) fclose(f);
106 free(statln);
107 free(newns);
108 return rv;
109}
110
111struct nsinfo *nsinfo__new(pid_t pid)
112{
113 struct nsinfo *nsi;
114
115 if (pid == 0)
116 return NULL;
117
118 nsi = calloc(1, sizeof(*nsi));
119 if (nsi != NULL) {
120 nsi->pid = pid;
121 nsi->tgid = pid;
122 nsi->nstgid = pid;
123 nsi->need_setns = false;
124 /* Init may fail if the process exits while we're trying to look
125 * at its proc information. In that case, save the pid but
126 * don't try to enter the namespace.
127 */
128 if (nsinfo__init(nsi) == -1)
129 nsi->need_setns = false;
130
131 refcount_set(&nsi->refcnt, 1);
132 }
133
134 return nsi;
135}
136
137struct nsinfo *nsinfo__copy(struct nsinfo *nsi)
138{
139 struct nsinfo *nnsi;
140
141 nnsi = calloc(1, sizeof(*nnsi));
142 if (nnsi != NULL) {
143 nnsi->pid = nsi->pid;
144 nnsi->tgid = nsi->tgid;
145 nnsi->nstgid = nsi->nstgid;
146 nnsi->need_setns = nsi->need_setns;
147 if (nsi->mntns_path) {
148 nnsi->mntns_path = strdup(nsi->mntns_path);
149 if (!nnsi->mntns_path) {
150 free(nnsi);
151 return NULL;
152 }
153 }
154 refcount_set(&nnsi->refcnt, 1);
155 }
156
157 return nnsi;
158}
159
160void nsinfo__delete(struct nsinfo *nsi)
161{
162 zfree(&nsi->mntns_path);
163 free(nsi);
164}
165
166struct nsinfo *nsinfo__get(struct nsinfo *nsi)
167{
168 if (nsi)
169 refcount_inc(&nsi->refcnt);
170 return nsi;
171}
172
173void nsinfo__put(struct nsinfo *nsi)
174{
175 if (nsi && refcount_dec_and_test(&nsi->refcnt))
176 nsinfo__delete(nsi);
177}
178
179void nsinfo__mountns_enter(struct nsinfo *nsi,
180 struct nscookie *nc)
181{
182 char curpath[PATH_MAX];
183 int oldns = -1;
184 int newns = -1;
185
186 if (nc == NULL)
187 return;
188
189 nc->oldns = -1;
190 nc->newns = -1;
191
192 if (!nsi || !nsi->need_setns)
193 return;
194
195 if (snprintf(curpath, PATH_MAX, "/proc/self/ns/mnt") >= PATH_MAX)
196 return;
197
198 oldns = open(curpath, O_RDONLY);
199 if (oldns < 0)
200 return;
201
202 newns = open(nsi->mntns_path, O_RDONLY);
203 if (newns < 0)
204 goto errout;
205
206 if (setns(newns, CLONE_NEWNS) < 0)
207 goto errout;
208
209 nc->oldns = oldns;
210 nc->newns = newns;
211 return;
212
213errout:
214 if (oldns > -1)
215 close(oldns);
216 if (newns > -1)
217 close(newns);
218}
219
220void nsinfo__mountns_exit(struct nscookie *nc)
221{
222 if (nc == NULL || nc->oldns == -1 || nc->newns == -1)
223 return;
224
225 setns(nc->oldns, CLONE_NEWNS);
226
227 if (nc->oldns > -1) {
228 close(nc->oldns);
229 nc->oldns = -1;
230 }
231
232 if (nc->newns > -1) {
233 close(nc->newns);
234 nc->newns = -1;
235 }
236}
237
238char *nsinfo__realpath(const char *path, struct nsinfo *nsi)
239{
240 char *rpath;
241 struct nscookie nsc;
242
243 nsinfo__mountns_enter(nsi, &nsc);
244 rpath = realpath(path, NULL);
245 nsinfo__mountns_exit(&nsc);
246
247 return rpath;
248}
diff --git a/tools/perf/util/namespaces.h b/tools/perf/util/namespaces.h
index 468f1e9a1484..05d82601c9a6 100644
--- a/tools/perf/util/namespaces.h
+++ b/tools/perf/util/namespaces.h
@@ -11,6 +11,7 @@
11 11
12#include "../perf.h" 12#include "../perf.h"
13#include <linux/list.h> 13#include <linux/list.h>
14#include <linux/refcount.h>
14 15
15struct namespaces_event; 16struct namespaces_event;
16 17
@@ -23,4 +24,41 @@ struct namespaces {
23struct namespaces *namespaces__new(struct namespaces_event *event); 24struct namespaces *namespaces__new(struct namespaces_event *event);
24void namespaces__free(struct namespaces *namespaces); 25void namespaces__free(struct namespaces *namespaces);
25 26
27struct nsinfo {
28 pid_t pid;
29 pid_t tgid;
30 pid_t nstgid;
31 bool need_setns;
32 char *mntns_path;
33 refcount_t refcnt;
34};
35
36struct nscookie {
37 int oldns;
38 int newns;
39};
40
41int nsinfo__init(struct nsinfo *nsi);
42struct nsinfo *nsinfo__new(pid_t pid);
43struct nsinfo *nsinfo__copy(struct nsinfo *nsi);
44void nsinfo__delete(struct nsinfo *nsi);
45
46struct nsinfo *nsinfo__get(struct nsinfo *nsi);
47void nsinfo__put(struct nsinfo *nsi);
48
49void nsinfo__mountns_enter(struct nsinfo *nsi, struct nscookie *nc);
50void nsinfo__mountns_exit(struct nscookie *nc);
51
52char *nsinfo__realpath(const char *path, struct nsinfo *nsi);
53
54static inline void __nsinfo__zput(struct nsinfo **nsip)
55{
56 if (nsip) {
57 nsinfo__put(*nsip);
58 *nsip = NULL;
59 }
60}
61
62#define nsinfo__zput(nsi) __nsinfo__zput(&nsi)
63
26#endif /* __PERF_NAMESPACES_H */ 64#endif /* __PERF_NAMESPACES_H */
diff --git a/tools/perf/util/parse-branch-options.c b/tools/perf/util/parse-branch-options.c
index 38fd11504015..e71fb5f31e84 100644
--- a/tools/perf/util/parse-branch-options.c
+++ b/tools/perf/util/parse-branch-options.c
@@ -28,6 +28,7 @@ static const struct branch_mode branch_modes[] = {
28 BRANCH_OPT("cond", PERF_SAMPLE_BRANCH_COND), 28 BRANCH_OPT("cond", PERF_SAMPLE_BRANCH_COND),
29 BRANCH_OPT("ind_jmp", PERF_SAMPLE_BRANCH_IND_JUMP), 29 BRANCH_OPT("ind_jmp", PERF_SAMPLE_BRANCH_IND_JUMP),
30 BRANCH_OPT("call", PERF_SAMPLE_BRANCH_CALL), 30 BRANCH_OPT("call", PERF_SAMPLE_BRANCH_CALL),
31 BRANCH_OPT("save_type", PERF_SAMPLE_BRANCH_TYPE_SAVE),
31 BRANCH_END 32 BRANCH_END
32}; 33};
33 34
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 01e779b91c8e..f6257fb4f08c 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -34,7 +34,7 @@
34#ifdef PARSER_DEBUG 34#ifdef PARSER_DEBUG
35extern int parse_events_debug; 35extern int parse_events_debug;
36#endif 36#endif
37int parse_events_parse(void *data, void *scanner); 37int parse_events_parse(void *parse_state, void *scanner);
38static int get_config_terms(struct list_head *head_config, 38static int get_config_terms(struct list_head *head_config,
39 struct list_head *head_terms __maybe_unused); 39 struct list_head *head_terms __maybe_unused);
40 40
@@ -310,7 +310,7 @@ static struct perf_evsel *
310__add_event(struct list_head *list, int *idx, 310__add_event(struct list_head *list, int *idx,
311 struct perf_event_attr *attr, 311 struct perf_event_attr *attr,
312 char *name, struct cpu_map *cpus, 312 char *name, struct cpu_map *cpus,
313 struct list_head *config_terms) 313 struct list_head *config_terms, bool auto_merge_stats)
314{ 314{
315 struct perf_evsel *evsel; 315 struct perf_evsel *evsel;
316 316
@@ -324,6 +324,7 @@ __add_event(struct list_head *list, int *idx,
324 evsel->cpus = cpu_map__get(cpus); 324 evsel->cpus = cpu_map__get(cpus);
325 evsel->own_cpus = cpu_map__get(cpus); 325 evsel->own_cpus = cpu_map__get(cpus);
326 evsel->system_wide = !!cpus; 326 evsel->system_wide = !!cpus;
327 evsel->auto_merge_stats = auto_merge_stats;
327 328
328 if (name) 329 if (name)
329 evsel->name = strdup(name); 330 evsel->name = strdup(name);
@@ -339,7 +340,7 @@ static int add_event(struct list_head *list, int *idx,
339 struct perf_event_attr *attr, char *name, 340 struct perf_event_attr *attr, char *name,
340 struct list_head *config_terms) 341 struct list_head *config_terms)
341{ 342{
342 return __add_event(list, idx, attr, name, NULL, config_terms) ? 0 : -ENOMEM; 343 return __add_event(list, idx, attr, name, NULL, config_terms, false) ? 0 : -ENOMEM;
343} 344}
344 345
345static int parse_aliases(char *str, const char *names[][PERF_EVSEL__MAX_ALIASES], int size) 346static int parse_aliases(char *str, const char *names[][PERF_EVSEL__MAX_ALIASES], int size)
@@ -589,7 +590,7 @@ static int add_tracepoint_multi_sys(struct list_head *list, int *idx,
589} 590}
590 591
591struct __add_bpf_event_param { 592struct __add_bpf_event_param {
592 struct parse_events_evlist *data; 593 struct parse_events_state *parse_state;
593 struct list_head *list; 594 struct list_head *list;
594 struct list_head *head_config; 595 struct list_head *head_config;
595}; 596};
@@ -599,7 +600,7 @@ static int add_bpf_event(const char *group, const char *event, int fd,
599{ 600{
600 LIST_HEAD(new_evsels); 601 LIST_HEAD(new_evsels);
601 struct __add_bpf_event_param *param = _param; 602 struct __add_bpf_event_param *param = _param;
602 struct parse_events_evlist *evlist = param->data; 603 struct parse_events_state *parse_state = param->parse_state;
603 struct list_head *list = param->list; 604 struct list_head *list = param->list;
604 struct perf_evsel *pos; 605 struct perf_evsel *pos;
605 int err; 606 int err;
@@ -607,8 +608,8 @@ static int add_bpf_event(const char *group, const char *event, int fd,
607 pr_debug("add bpf event %s:%s and attach bpf program %d\n", 608 pr_debug("add bpf event %s:%s and attach bpf program %d\n",
608 group, event, fd); 609 group, event, fd);
609 610
610 err = parse_events_add_tracepoint(&new_evsels, &evlist->idx, group, 611 err = parse_events_add_tracepoint(&new_evsels, &parse_state->idx, group,
611 event, evlist->error, 612 event, parse_state->error,
612 param->head_config); 613 param->head_config);
613 if (err) { 614 if (err) {
614 struct perf_evsel *evsel, *tmp; 615 struct perf_evsel *evsel, *tmp;
@@ -632,14 +633,14 @@ static int add_bpf_event(const char *group, const char *event, int fd,
632 return 0; 633 return 0;
633} 634}
634 635
635int parse_events_load_bpf_obj(struct parse_events_evlist *data, 636int parse_events_load_bpf_obj(struct parse_events_state *parse_state,
636 struct list_head *list, 637 struct list_head *list,
637 struct bpf_object *obj, 638 struct bpf_object *obj,
638 struct list_head *head_config) 639 struct list_head *head_config)
639{ 640{
640 int err; 641 int err;
641 char errbuf[BUFSIZ]; 642 char errbuf[BUFSIZ];
642 struct __add_bpf_event_param param = {data, list, head_config}; 643 struct __add_bpf_event_param param = {parse_state, list, head_config};
643 static bool registered_unprobe_atexit = false; 644 static bool registered_unprobe_atexit = false;
644 645
645 if (IS_ERR(obj) || !obj) { 646 if (IS_ERR(obj) || !obj) {
@@ -680,13 +681,13 @@ int parse_events_load_bpf_obj(struct parse_events_evlist *data,
680 681
681 return 0; 682 return 0;
682errout: 683errout:
683 data->error->help = strdup("(add -v to see detail)"); 684 parse_state->error->help = strdup("(add -v to see detail)");
684 data->error->str = strdup(errbuf); 685 parse_state->error->str = strdup(errbuf);
685 return err; 686 return err;
686} 687}
687 688
688static int 689static int
689parse_events_config_bpf(struct parse_events_evlist *data, 690parse_events_config_bpf(struct parse_events_state *parse_state,
690 struct bpf_object *obj, 691 struct bpf_object *obj,
691 struct list_head *head_config) 692 struct list_head *head_config)
692{ 693{
@@ -705,28 +706,28 @@ parse_events_config_bpf(struct parse_events_evlist *data,
705 "Invalid config term for BPF object"); 706 "Invalid config term for BPF object");
706 errbuf[BUFSIZ - 1] = '\0'; 707 errbuf[BUFSIZ - 1] = '\0';
707 708
708 data->error->idx = term->err_term; 709 parse_state->error->idx = term->err_term;
709 data->error->str = strdup(errbuf); 710 parse_state->error->str = strdup(errbuf);
710 return -EINVAL; 711 return -EINVAL;
711 } 712 }
712 713
713 err = bpf__config_obj(obj, term, data->evlist, &error_pos); 714 err = bpf__config_obj(obj, term, parse_state->evlist, &error_pos);
714 if (err) { 715 if (err) {
715 bpf__strerror_config_obj(obj, term, data->evlist, 716 bpf__strerror_config_obj(obj, term, parse_state->evlist,
716 &error_pos, err, errbuf, 717 &error_pos, err, errbuf,
717 sizeof(errbuf)); 718 sizeof(errbuf));
718 data->error->help = strdup( 719 parse_state->error->help = strdup(
719"Hint:\tValid config terms:\n" 720"Hint:\tValid config terms:\n"
720" \tmap:[<arraymap>].value<indices>=[value]\n" 721" \tmap:[<arraymap>].value<indices>=[value]\n"
721" \tmap:[<eventmap>].event<indices>=[event]\n" 722" \tmap:[<eventmap>].event<indices>=[event]\n"
722"\n" 723"\n"
723" \twhere <indices> is something like [0,3...5] or [all]\n" 724" \twhere <indices> is something like [0,3...5] or [all]\n"
724" \t(add -v to see detail)"); 725" \t(add -v to see detail)");
725 data->error->str = strdup(errbuf); 726 parse_state->error->str = strdup(errbuf);
726 if (err == -BPF_LOADER_ERRNO__OBJCONF_MAP_VALUE) 727 if (err == -BPF_LOADER_ERRNO__OBJCONF_MAP_VALUE)
727 data->error->idx = term->err_val; 728 parse_state->error->idx = term->err_val;
728 else 729 else
729 data->error->idx = term->err_term + error_pos; 730 parse_state->error->idx = term->err_term + error_pos;
730 return err; 731 return err;
731 } 732 }
732 } 733 }
@@ -762,7 +763,7 @@ split_bpf_config_terms(struct list_head *evt_head_config,
762 list_move_tail(&term->list, obj_head_config); 763 list_move_tail(&term->list, obj_head_config);
763} 764}
764 765
765int parse_events_load_bpf(struct parse_events_evlist *data, 766int parse_events_load_bpf(struct parse_events_state *parse_state,
766 struct list_head *list, 767 struct list_head *list,
767 char *bpf_file_name, 768 char *bpf_file_name,
768 bool source, 769 bool source,
@@ -790,15 +791,15 @@ int parse_events_load_bpf(struct parse_events_evlist *data,
790 -err, errbuf, 791 -err, errbuf,
791 sizeof(errbuf)); 792 sizeof(errbuf));
792 793
793 data->error->help = strdup("(add -v to see detail)"); 794 parse_state->error->help = strdup("(add -v to see detail)");
794 data->error->str = strdup(errbuf); 795 parse_state->error->str = strdup(errbuf);
795 return err; 796 return err;
796 } 797 }
797 798
798 err = parse_events_load_bpf_obj(data, list, obj, head_config); 799 err = parse_events_load_bpf_obj(parse_state, list, obj, head_config);
799 if (err) 800 if (err)
800 return err; 801 return err;
801 err = parse_events_config_bpf(data, obj, &obj_head_config); 802 err = parse_events_config_bpf(parse_state, obj, &obj_head_config);
802 803
803 /* 804 /*
804 * Caller doesn't know anything about obj_head_config, 805 * Caller doesn't know anything about obj_head_config,
@@ -1184,7 +1185,7 @@ int parse_events_add_tracepoint(struct list_head *list, int *idx,
1184 err, head_config); 1185 err, head_config);
1185} 1186}
1186 1187
1187int parse_events_add_numeric(struct parse_events_evlist *data, 1188int parse_events_add_numeric(struct parse_events_state *parse_state,
1188 struct list_head *list, 1189 struct list_head *list,
1189 u32 type, u64 config, 1190 u32 type, u64 config,
1190 struct list_head *head_config) 1191 struct list_head *head_config)
@@ -1197,7 +1198,7 @@ int parse_events_add_numeric(struct parse_events_evlist *data,
1197 attr.config = config; 1198 attr.config = config;
1198 1199
1199 if (head_config) { 1200 if (head_config) {
1200 if (config_attr(&attr, head_config, data->error, 1201 if (config_attr(&attr, head_config, parse_state->error,
1201 config_term_common)) 1202 config_term_common))
1202 return -EINVAL; 1203 return -EINVAL;
1203 1204
@@ -1205,13 +1206,13 @@ int parse_events_add_numeric(struct parse_events_evlist *data,
1205 return -ENOMEM; 1206 return -ENOMEM;
1206 } 1207 }
1207 1208
1208 return add_event(list, &data->idx, &attr, 1209 return add_event(list, &parse_state->idx, &attr,
1209 get_config_name(head_config), &config_terms); 1210 get_config_name(head_config), &config_terms);
1210} 1211}
1211 1212
1212int parse_events_add_pmu(struct parse_events_evlist *data, 1213static int __parse_events_add_pmu(struct parse_events_state *parse_state,
1213 struct list_head *list, char *name, 1214 struct list_head *list, char *name,
1214 struct list_head *head_config) 1215 struct list_head *head_config, bool auto_merge_stats)
1215{ 1216{
1216 struct perf_event_attr attr; 1217 struct perf_event_attr attr;
1217 struct perf_pmu_info info; 1218 struct perf_pmu_info info;
@@ -1232,7 +1233,7 @@ int parse_events_add_pmu(struct parse_events_evlist *data,
1232 1233
1233 if (!head_config) { 1234 if (!head_config) {
1234 attr.type = pmu->type; 1235 attr.type = pmu->type;
1235 evsel = __add_event(list, &data->idx, &attr, NULL, pmu->cpus, NULL); 1236 evsel = __add_event(list, &parse_state->idx, &attr, NULL, pmu->cpus, NULL, auto_merge_stats);
1236 return evsel ? 0 : -ENOMEM; 1237 return evsel ? 0 : -ENOMEM;
1237 } 1238 }
1238 1239
@@ -1243,18 +1244,18 @@ int parse_events_add_pmu(struct parse_events_evlist *data,
1243 * Configure hardcoded terms first, no need to check 1244 * Configure hardcoded terms first, no need to check
1244 * return value when called with fail == 0 ;) 1245 * return value when called with fail == 0 ;)
1245 */ 1246 */
1246 if (config_attr(&attr, head_config, data->error, config_term_pmu)) 1247 if (config_attr(&attr, head_config, parse_state->error, config_term_pmu))
1247 return -EINVAL; 1248 return -EINVAL;
1248 1249
1249 if (get_config_terms(head_config, &config_terms)) 1250 if (get_config_terms(head_config, &config_terms))
1250 return -ENOMEM; 1251 return -ENOMEM;
1251 1252
1252 if (perf_pmu__config(pmu, &attr, head_config, data->error)) 1253 if (perf_pmu__config(pmu, &attr, head_config, parse_state->error))
1253 return -EINVAL; 1254 return -EINVAL;
1254 1255
1255 evsel = __add_event(list, &data->idx, &attr, 1256 evsel = __add_event(list, &parse_state->idx, &attr,
1256 get_config_name(head_config), pmu->cpus, 1257 get_config_name(head_config), pmu->cpus,
1257 &config_terms); 1258 &config_terms, auto_merge_stats);
1258 if (evsel) { 1259 if (evsel) {
1259 evsel->unit = info.unit; 1260 evsel->unit = info.unit;
1260 evsel->scale = info.scale; 1261 evsel->scale = info.scale;
@@ -1267,7 +1268,14 @@ int parse_events_add_pmu(struct parse_events_evlist *data,
1267 return evsel ? 0 : -ENOMEM; 1268 return evsel ? 0 : -ENOMEM;
1268} 1269}
1269 1270
1270int parse_events_multi_pmu_add(struct parse_events_evlist *data, 1271int parse_events_add_pmu(struct parse_events_state *parse_state,
1272 struct list_head *list, char *name,
1273 struct list_head *head_config)
1274{
1275 return __parse_events_add_pmu(parse_state, list, name, head_config, false);
1276}
1277
1278int parse_events_multi_pmu_add(struct parse_events_state *parse_state,
1271 char *str, struct list_head **listp) 1279 char *str, struct list_head **listp)
1272{ 1280{
1273 struct list_head *head; 1281 struct list_head *head;
@@ -1296,8 +1304,8 @@ int parse_events_multi_pmu_add(struct parse_events_evlist *data,
1296 return -1; 1304 return -1;
1297 list_add_tail(&term->list, head); 1305 list_add_tail(&term->list, head);
1298 1306
1299 if (!parse_events_add_pmu(data, list, 1307 if (!__parse_events_add_pmu(parse_state, list,
1300 pmu->name, head)) { 1308 pmu->name, head, true)) {
1301 pr_debug("%s -> %s/%s/\n", str, 1309 pr_debug("%s -> %s/%s/\n", str,
1302 pmu->name, alias->str); 1310 pmu->name, alias->str);
1303 ok++; 1311 ok++;
@@ -1628,7 +1636,7 @@ perf_pmu__parse_check(const char *name)
1628 return r ? r->type : PMU_EVENT_SYMBOL_ERR; 1636 return r ? r->type : PMU_EVENT_SYMBOL_ERR;
1629} 1637}
1630 1638
1631static int parse_events__scanner(const char *str, void *data, int start_token) 1639static int parse_events__scanner(const char *str, void *parse_state, int start_token)
1632{ 1640{
1633 YY_BUFFER_STATE buffer; 1641 YY_BUFFER_STATE buffer;
1634 void *scanner; 1642 void *scanner;
@@ -1643,7 +1651,7 @@ static int parse_events__scanner(const char *str, void *data, int start_token)
1643#ifdef PARSER_DEBUG 1651#ifdef PARSER_DEBUG
1644 parse_events_debug = 1; 1652 parse_events_debug = 1;
1645#endif 1653#endif
1646 ret = parse_events_parse(data, scanner); 1654 ret = parse_events_parse(parse_state, scanner);
1647 1655
1648 parse_events__flush_buffer(buffer, scanner); 1656 parse_events__flush_buffer(buffer, scanner);
1649 parse_events__delete_buffer(buffer, scanner); 1657 parse_events__delete_buffer(buffer, scanner);
@@ -1656,45 +1664,45 @@ static int parse_events__scanner(const char *str, void *data, int start_token)
1656 */ 1664 */
1657int parse_events_terms(struct list_head *terms, const char *str) 1665int parse_events_terms(struct list_head *terms, const char *str)
1658{ 1666{
1659 struct parse_events_terms data = { 1667 struct parse_events_state parse_state = {
1660 .terms = NULL, 1668 .terms = NULL,
1661 }; 1669 };
1662 int ret; 1670 int ret;
1663 1671
1664 ret = parse_events__scanner(str, &data, PE_START_TERMS); 1672 ret = parse_events__scanner(str, &parse_state, PE_START_TERMS);
1665 if (!ret) { 1673 if (!ret) {
1666 list_splice(data.terms, terms); 1674 list_splice(parse_state.terms, terms);
1667 zfree(&data.terms); 1675 zfree(&parse_state.terms);
1668 return 0; 1676 return 0;
1669 } 1677 }
1670 1678
1671 parse_events_terms__delete(data.terms); 1679 parse_events_terms__delete(parse_state.terms);
1672 return ret; 1680 return ret;
1673} 1681}
1674 1682
1675int parse_events(struct perf_evlist *evlist, const char *str, 1683int parse_events(struct perf_evlist *evlist, const char *str,
1676 struct parse_events_error *err) 1684 struct parse_events_error *err)
1677{ 1685{
1678 struct parse_events_evlist data = { 1686 struct parse_events_state parse_state = {
1679 .list = LIST_HEAD_INIT(data.list), 1687 .list = LIST_HEAD_INIT(parse_state.list),
1680 .idx = evlist->nr_entries, 1688 .idx = evlist->nr_entries,
1681 .error = err, 1689 .error = err,
1682 .evlist = evlist, 1690 .evlist = evlist,
1683 }; 1691 };
1684 int ret; 1692 int ret;
1685 1693
1686 ret = parse_events__scanner(str, &data, PE_START_EVENTS); 1694 ret = parse_events__scanner(str, &parse_state, PE_START_EVENTS);
1687 perf_pmu__parse_cleanup(); 1695 perf_pmu__parse_cleanup();
1688 if (!ret) { 1696 if (!ret) {
1689 struct perf_evsel *last; 1697 struct perf_evsel *last;
1690 1698
1691 if (list_empty(&data.list)) { 1699 if (list_empty(&parse_state.list)) {
1692 WARN_ONCE(true, "WARNING: event parser found nothing"); 1700 WARN_ONCE(true, "WARNING: event parser found nothing");
1693 return -1; 1701 return -1;
1694 } 1702 }
1695 1703
1696 perf_evlist__splice_list_tail(evlist, &data.list); 1704 perf_evlist__splice_list_tail(evlist, &parse_state.list);
1697 evlist->nr_groups += data.nr_groups; 1705 evlist->nr_groups += parse_state.nr_groups;
1698 last = perf_evlist__last(evlist); 1706 last = perf_evlist__last(evlist);
1699 last->cmdline_group_boundary = true; 1707 last->cmdline_group_boundary = true;
1700 1708
@@ -2124,7 +2132,7 @@ void print_sdt_events(const char *subsys_glob, const char *event_glob,
2124 return; 2132 return;
2125 } 2133 }
2126 strlist__for_each_entry(nd, bidlist) { 2134 strlist__for_each_entry(nd, bidlist) {
2127 pcache = probe_cache__new(nd->s); 2135 pcache = probe_cache__new(nd->s, NULL);
2128 if (!pcache) 2136 if (!pcache)
2129 continue; 2137 continue;
2130 list_for_each_entry(ent, &pcache->entries, node) { 2138 list_for_each_entry(ent, &pcache->entries, node) {
@@ -2520,10 +2528,10 @@ void parse_events__clear_array(struct parse_events_array *a)
2520 zfree(&a->ranges); 2528 zfree(&a->ranges);
2521} 2529}
2522 2530
2523void parse_events_evlist_error(struct parse_events_evlist *data, 2531void parse_events_evlist_error(struct parse_events_state *parse_state,
2524 int idx, const char *str) 2532 int idx, const char *str)
2525{ 2533{
2526 struct parse_events_error *err = data->error; 2534 struct parse_events_error *err = parse_state->error;
2527 2535
2528 if (!err) 2536 if (!err)
2529 return; 2537 return;
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index a235f4d6d5e5..635135125111 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -108,16 +108,13 @@ struct parse_events_error {
108 char *help; /* optional help string */ 108 char *help; /* optional help string */
109}; 109};
110 110
111struct parse_events_evlist { 111struct parse_events_state {
112 struct list_head list; 112 struct list_head list;
113 int idx; 113 int idx;
114 int nr_groups; 114 int nr_groups;
115 struct parse_events_error *error; 115 struct parse_events_error *error;
116 struct perf_evlist *evlist; 116 struct perf_evlist *evlist;
117}; 117 struct list_head *terms;
118
119struct parse_events_terms {
120 struct list_head *terms;
121}; 118};
122 119
123void parse_events__shrink_config_terms(void); 120void parse_events__shrink_config_terms(void);
@@ -143,18 +140,18 @@ int parse_events_add_tracepoint(struct list_head *list, int *idx,
143 const char *sys, const char *event, 140 const char *sys, const char *event,
144 struct parse_events_error *error, 141 struct parse_events_error *error,
145 struct list_head *head_config); 142 struct list_head *head_config);
146int parse_events_load_bpf(struct parse_events_evlist *data, 143int parse_events_load_bpf(struct parse_events_state *parse_state,
147 struct list_head *list, 144 struct list_head *list,
148 char *bpf_file_name, 145 char *bpf_file_name,
149 bool source, 146 bool source,
150 struct list_head *head_config); 147 struct list_head *head_config);
151/* Provide this function for perf test */ 148/* Provide this function for perf test */
152struct bpf_object; 149struct bpf_object;
153int parse_events_load_bpf_obj(struct parse_events_evlist *data, 150int parse_events_load_bpf_obj(struct parse_events_state *parse_state,
154 struct list_head *list, 151 struct list_head *list,
155 struct bpf_object *obj, 152 struct bpf_object *obj,
156 struct list_head *head_config); 153 struct list_head *head_config);
157int parse_events_add_numeric(struct parse_events_evlist *data, 154int parse_events_add_numeric(struct parse_events_state *parse_state,
158 struct list_head *list, 155 struct list_head *list,
159 u32 type, u64 config, 156 u32 type, u64 config,
160 struct list_head *head_config); 157 struct list_head *head_config);
@@ -164,11 +161,11 @@ int parse_events_add_cache(struct list_head *list, int *idx,
164 struct list_head *head_config); 161 struct list_head *head_config);
165int parse_events_add_breakpoint(struct list_head *list, int *idx, 162int parse_events_add_breakpoint(struct list_head *list, int *idx,
166 void *ptr, char *type, u64 len); 163 void *ptr, char *type, u64 len);
167int parse_events_add_pmu(struct parse_events_evlist *data, 164int parse_events_add_pmu(struct parse_events_state *parse_state,
168 struct list_head *list, char *name, 165 struct list_head *list, char *name,
169 struct list_head *head_config); 166 struct list_head *head_config);
170 167
171int parse_events_multi_pmu_add(struct parse_events_evlist *data, 168int parse_events_multi_pmu_add(struct parse_events_state *parse_state,
172 char *str, 169 char *str,
173 struct list_head **listp); 170 struct list_head **listp);
174 171
@@ -180,7 +177,7 @@ perf_pmu__parse_check(const char *name);
180void parse_events__set_leader(char *name, struct list_head *list); 177void parse_events__set_leader(char *name, struct list_head *list);
181void parse_events_update_lists(struct list_head *list_event, 178void parse_events_update_lists(struct list_head *list_event,
182 struct list_head *list_all); 179 struct list_head *list_all);
183void parse_events_evlist_error(struct parse_events_evlist *data, 180void parse_events_evlist_error(struct parse_events_state *parse_state,
184 int idx, const char *str); 181 int idx, const char *str);
185 182
186void print_events(const char *event_glob, bool name_only, bool quiet, 183void print_events(const char *event_glob, bool name_only, bool quiet,
diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l
index 660fca05bc93..c42edeac451f 100644
--- a/tools/perf/util/parse-events.l
+++ b/tools/perf/util/parse-events.l
@@ -53,6 +53,21 @@ static int str(yyscan_t scanner, int token)
53 return token; 53 return token;
54} 54}
55 55
56static bool isbpf(yyscan_t scanner)
57{
58 char *text = parse_events_get_text(scanner);
59 int len = strlen(text);
60
61 if (len < 2)
62 return false;
63 if ((text[len - 1] == 'c' || text[len - 1] == 'o') &&
64 text[len - 2] == '.')
65 return true;
66 if (len > 4 && !strcmp(text + len - 4, ".obj"))
67 return true;
68 return false;
69}
70
56/* 71/*
57 * This function is called when the parser gets two kind of input: 72 * This function is called when the parser gets two kind of input:
58 * 73 *
@@ -136,8 +151,8 @@ do { \
136group [^,{}/]*[{][^}]*[}][^,{}/]* 151group [^,{}/]*[{][^}]*[}][^,{}/]*
137event_pmu [^,{}/]+[/][^/]*[/][^,{}/]* 152event_pmu [^,{}/]+[/][^/]*[/][^,{}/]*
138event [^,{}/]+ 153event [^,{}/]+
139bpf_object [^,{}]+\.(o|bpf) 154bpf_object [^,{}]+\.(o|bpf)[a-zA-Z0-9._]*
140bpf_source [^,{}]+\.c 155bpf_source [^,{}]+\.c[a-zA-Z0-9._]*
141 156
142num_dec [0-9]+ 157num_dec [0-9]+
143num_hex 0x[a-fA-F0-9]+ 158num_hex 0x[a-fA-F0-9]+
@@ -307,8 +322,8 @@ r{num_raw_hex} { return raw(yyscanner); }
307{num_hex} { return value(yyscanner, 16); } 322{num_hex} { return value(yyscanner, 16); }
308 323
309{modifier_event} { return str(yyscanner, PE_MODIFIER_EVENT); } 324{modifier_event} { return str(yyscanner, PE_MODIFIER_EVENT); }
310{bpf_object} { return str(yyscanner, PE_BPF_OBJECT); } 325{bpf_object} { if (!isbpf(yyscanner)) REJECT; return str(yyscanner, PE_BPF_OBJECT); }
311{bpf_source} { return str(yyscanner, PE_BPF_SOURCE); } 326{bpf_source} { if (!isbpf(yyscanner)) REJECT; return str(yyscanner, PE_BPF_SOURCE); }
312{name} { return pmu_str_check(yyscanner); } 327{name} { return pmu_str_check(yyscanner); }
313"/" { BEGIN(config); return '/'; } 328"/" { BEGIN(config); return '/'; }
314- { return '-'; } 329- { return '-'; }
diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index 04fd8c9af9f9..e81a20ea8d7d 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -1,5 +1,5 @@
1%pure-parser 1%pure-parser
2%parse-param {void *_data} 2%parse-param {void *_parse_state}
3%parse-param {void *scanner} 3%parse-param {void *scanner}
4%lex-param {void* scanner} 4%lex-param {void* scanner}
5%locations 5%locations
@@ -17,7 +17,7 @@
17#include "parse-events.h" 17#include "parse-events.h"
18#include "parse-events-bison.h" 18#include "parse-events-bison.h"
19 19
20void parse_events_error(YYLTYPE *loc, void *data, void *scanner, char const *msg); 20void parse_events_error(YYLTYPE *loc, void *parse_state, void *scanner, char const *msg);
21 21
22#define ABORT_ON(val) \ 22#define ABORT_ON(val) \
23do { \ 23do { \
@@ -33,11 +33,11 @@ do { \
33} while (0) 33} while (0)
34 34
35static void inc_group_count(struct list_head *list, 35static void inc_group_count(struct list_head *list,
36 struct parse_events_evlist *data) 36 struct parse_events_state *parse_state)
37{ 37{
38 /* Count groups only have more than 1 members */ 38 /* Count groups only have more than 1 members */
39 if (!list_is_last(list->next, list)) 39 if (!list_is_last(list->next, list))
40 data->nr_groups++; 40 parse_state->nr_groups++;
41} 41}
42 42
43%} 43%}
@@ -115,9 +115,9 @@ PE_START_TERMS start_terms
115 115
116start_events: groups 116start_events: groups
117{ 117{
118 struct parse_events_evlist *data = _data; 118 struct parse_events_state *parse_state = _parse_state;
119 119
120 parse_events_update_lists($1, &data->list); 120 parse_events_update_lists($1, &parse_state->list);
121} 121}
122 122
123groups: 123groups:
@@ -159,7 +159,7 @@ PE_NAME '{' events '}'
159{ 159{
160 struct list_head *list = $3; 160 struct list_head *list = $3;
161 161
162 inc_group_count(list, _data); 162 inc_group_count(list, _parse_state);
163 parse_events__set_leader($1, list); 163 parse_events__set_leader($1, list);
164 $$ = list; 164 $$ = list;
165} 165}
@@ -168,7 +168,7 @@ PE_NAME '{' events '}'
168{ 168{
169 struct list_head *list = $2; 169 struct list_head *list = $2;
170 170
171 inc_group_count(list, _data); 171 inc_group_count(list, _parse_state);
172 parse_events__set_leader(NULL, list); 172 parse_events__set_leader(NULL, list);
173 $$ = list; 173 $$ = list;
174} 174}
@@ -225,14 +225,13 @@ event_def: event_pmu |
225event_pmu: 225event_pmu:
226PE_NAME opt_event_config 226PE_NAME opt_event_config
227{ 227{
228 struct parse_events_evlist *data = _data;
229 struct list_head *list, *orig_terms, *terms; 228 struct list_head *list, *orig_terms, *terms;
230 229
231 if (parse_events_copy_term_list($2, &orig_terms)) 230 if (parse_events_copy_term_list($2, &orig_terms))
232 YYABORT; 231 YYABORT;
233 232
234 ALLOC_LIST(list); 233 ALLOC_LIST(list);
235 if (parse_events_add_pmu(data, list, $1, $2)) { 234 if (parse_events_add_pmu(_parse_state, list, $1, $2)) {
236 struct perf_pmu *pmu = NULL; 235 struct perf_pmu *pmu = NULL;
237 int ok = 0; 236 int ok = 0;
238 237
@@ -245,7 +244,7 @@ PE_NAME opt_event_config
245 if (!strncmp($1, name, strlen($1))) { 244 if (!strncmp($1, name, strlen($1))) {
246 if (parse_events_copy_term_list(orig_terms, &terms)) 245 if (parse_events_copy_term_list(orig_terms, &terms))
247 YYABORT; 246 YYABORT;
248 if (!parse_events_add_pmu(data, list, pmu->name, terms)) 247 if (!parse_events_add_pmu(_parse_state, list, pmu->name, terms))
249 ok++; 248 ok++;
250 parse_events_terms__delete(terms); 249 parse_events_terms__delete(terms);
251 } 250 }
@@ -262,7 +261,7 @@ PE_KERNEL_PMU_EVENT sep_dc
262{ 261{
263 struct list_head *list; 262 struct list_head *list;
264 263
265 if (parse_events_multi_pmu_add(_data, $1, &list) < 0) 264 if (parse_events_multi_pmu_add(_parse_state, $1, &list) < 0)
266 YYABORT; 265 YYABORT;
267 $$ = list; 266 $$ = list;
268} 267}
@@ -273,7 +272,7 @@ PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF sep_dc
273 char pmu_name[128]; 272 char pmu_name[128];
274 273
275 snprintf(&pmu_name, 128, "%s-%s", $1, $3); 274 snprintf(&pmu_name, 128, "%s-%s", $1, $3);
276 if (parse_events_multi_pmu_add(_data, pmu_name, &list) < 0) 275 if (parse_events_multi_pmu_add(_parse_state, pmu_name, &list) < 0)
277 YYABORT; 276 YYABORT;
278 $$ = list; 277 $$ = list;
279} 278}
@@ -286,62 +285,60 @@ PE_VALUE_SYM_SW
286event_legacy_symbol: 285event_legacy_symbol:
287value_sym '/' event_config '/' 286value_sym '/' event_config '/'
288{ 287{
289 struct parse_events_evlist *data = _data;
290 struct list_head *list; 288 struct list_head *list;
291 int type = $1 >> 16; 289 int type = $1 >> 16;
292 int config = $1 & 255; 290 int config = $1 & 255;
293 291
294 ALLOC_LIST(list); 292 ALLOC_LIST(list);
295 ABORT_ON(parse_events_add_numeric(data, list, type, config, $3)); 293 ABORT_ON(parse_events_add_numeric(_parse_state, list, type, config, $3));
296 parse_events_terms__delete($3); 294 parse_events_terms__delete($3);
297 $$ = list; 295 $$ = list;
298} 296}
299| 297|
300value_sym sep_slash_dc 298value_sym sep_slash_dc
301{ 299{
302 struct parse_events_evlist *data = _data;
303 struct list_head *list; 300 struct list_head *list;
304 int type = $1 >> 16; 301 int type = $1 >> 16;
305 int config = $1 & 255; 302 int config = $1 & 255;
306 303
307 ALLOC_LIST(list); 304 ALLOC_LIST(list);
308 ABORT_ON(parse_events_add_numeric(data, list, type, config, NULL)); 305 ABORT_ON(parse_events_add_numeric(_parse_state, list, type, config, NULL));
309 $$ = list; 306 $$ = list;
310} 307}
311 308
312event_legacy_cache: 309event_legacy_cache:
313PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT opt_event_config 310PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT opt_event_config
314{ 311{
315 struct parse_events_evlist *data = _data; 312 struct parse_events_state *parse_state = _parse_state;
316 struct parse_events_error *error = data->error; 313 struct parse_events_error *error = parse_state->error;
317 struct list_head *list; 314 struct list_head *list;
318 315
319 ALLOC_LIST(list); 316 ALLOC_LIST(list);
320 ABORT_ON(parse_events_add_cache(list, &data->idx, $1, $3, $5, error, $6)); 317 ABORT_ON(parse_events_add_cache(list, &parse_state->idx, $1, $3, $5, error, $6));
321 parse_events_terms__delete($6); 318 parse_events_terms__delete($6);
322 $$ = list; 319 $$ = list;
323} 320}
324| 321|
325PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT opt_event_config 322PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT opt_event_config
326{ 323{
327 struct parse_events_evlist *data = _data; 324 struct parse_events_state *parse_state = _parse_state;
328 struct parse_events_error *error = data->error; 325 struct parse_events_error *error = parse_state->error;
329 struct list_head *list; 326 struct list_head *list;
330 327
331 ALLOC_LIST(list); 328 ALLOC_LIST(list);
332 ABORT_ON(parse_events_add_cache(list, &data->idx, $1, $3, NULL, error, $4)); 329 ABORT_ON(parse_events_add_cache(list, &parse_state->idx, $1, $3, NULL, error, $4));
333 parse_events_terms__delete($4); 330 parse_events_terms__delete($4);
334 $$ = list; 331 $$ = list;
335} 332}
336| 333|
337PE_NAME_CACHE_TYPE opt_event_config 334PE_NAME_CACHE_TYPE opt_event_config
338{ 335{
339 struct parse_events_evlist *data = _data; 336 struct parse_events_state *parse_state = _parse_state;
340 struct parse_events_error *error = data->error; 337 struct parse_events_error *error = parse_state->error;
341 struct list_head *list; 338 struct list_head *list;
342 339
343 ALLOC_LIST(list); 340 ALLOC_LIST(list);
344 ABORT_ON(parse_events_add_cache(list, &data->idx, $1, NULL, NULL, error, $2)); 341 ABORT_ON(parse_events_add_cache(list, &parse_state->idx, $1, NULL, NULL, error, $2));
345 parse_events_terms__delete($2); 342 parse_events_terms__delete($2);
346 $$ = list; 343 $$ = list;
347} 344}
@@ -349,44 +346,44 @@ PE_NAME_CACHE_TYPE opt_event_config
349event_legacy_mem: 346event_legacy_mem:
350PE_PREFIX_MEM PE_VALUE '/' PE_VALUE ':' PE_MODIFIER_BP sep_dc 347PE_PREFIX_MEM PE_VALUE '/' PE_VALUE ':' PE_MODIFIER_BP sep_dc
351{ 348{
352 struct parse_events_evlist *data = _data; 349 struct parse_events_state *parse_state = _parse_state;
353 struct list_head *list; 350 struct list_head *list;
354 351
355 ALLOC_LIST(list); 352 ALLOC_LIST(list);
356 ABORT_ON(parse_events_add_breakpoint(list, &data->idx, 353 ABORT_ON(parse_events_add_breakpoint(list, &parse_state->idx,
357 (void *) $2, $6, $4)); 354 (void *) $2, $6, $4));
358 $$ = list; 355 $$ = list;
359} 356}
360| 357|
361PE_PREFIX_MEM PE_VALUE '/' PE_VALUE sep_dc 358PE_PREFIX_MEM PE_VALUE '/' PE_VALUE sep_dc
362{ 359{
363 struct parse_events_evlist *data = _data; 360 struct parse_events_state *parse_state = _parse_state;
364 struct list_head *list; 361 struct list_head *list;
365 362
366 ALLOC_LIST(list); 363 ALLOC_LIST(list);
367 ABORT_ON(parse_events_add_breakpoint(list, &data->idx, 364 ABORT_ON(parse_events_add_breakpoint(list, &parse_state->idx,
368 (void *) $2, NULL, $4)); 365 (void *) $2, NULL, $4));
369 $$ = list; 366 $$ = list;
370} 367}
371| 368|
372PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc 369PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
373{ 370{
374 struct parse_events_evlist *data = _data; 371 struct parse_events_state *parse_state = _parse_state;
375 struct list_head *list; 372 struct list_head *list;
376 373
377 ALLOC_LIST(list); 374 ALLOC_LIST(list);
378 ABORT_ON(parse_events_add_breakpoint(list, &data->idx, 375 ABORT_ON(parse_events_add_breakpoint(list, &parse_state->idx,
379 (void *) $2, $4, 0)); 376 (void *) $2, $4, 0));
380 $$ = list; 377 $$ = list;
381} 378}
382| 379|
383PE_PREFIX_MEM PE_VALUE sep_dc 380PE_PREFIX_MEM PE_VALUE sep_dc
384{ 381{
385 struct parse_events_evlist *data = _data; 382 struct parse_events_state *parse_state = _parse_state;
386 struct list_head *list; 383 struct list_head *list;
387 384
388 ALLOC_LIST(list); 385 ALLOC_LIST(list);
389 ABORT_ON(parse_events_add_breakpoint(list, &data->idx, 386 ABORT_ON(parse_events_add_breakpoint(list, &parse_state->idx,
390 (void *) $2, NULL, 0)); 387 (void *) $2, NULL, 0));
391 $$ = list; 388 $$ = list;
392} 389}
@@ -394,15 +391,15 @@ PE_PREFIX_MEM PE_VALUE sep_dc
394event_legacy_tracepoint: 391event_legacy_tracepoint:
395tracepoint_name opt_event_config 392tracepoint_name opt_event_config
396{ 393{
397 struct parse_events_evlist *data = _data; 394 struct parse_events_state *parse_state = _parse_state;
398 struct parse_events_error *error = data->error; 395 struct parse_events_error *error = parse_state->error;
399 struct list_head *list; 396 struct list_head *list;
400 397
401 ALLOC_LIST(list); 398 ALLOC_LIST(list);
402 if (error) 399 if (error)
403 error->idx = @1.first_column; 400 error->idx = @1.first_column;
404 401
405 if (parse_events_add_tracepoint(list, &data->idx, $1.sys, $1.event, 402 if (parse_events_add_tracepoint(list, &parse_state->idx, $1.sys, $1.event,
406 error, $2)) 403 error, $2))
407 return -1; 404 return -1;
408 405
@@ -432,11 +429,10 @@ PE_NAME ':' PE_NAME
432event_legacy_numeric: 429event_legacy_numeric:
433PE_VALUE ':' PE_VALUE opt_event_config 430PE_VALUE ':' PE_VALUE opt_event_config
434{ 431{
435 struct parse_events_evlist *data = _data;
436 struct list_head *list; 432 struct list_head *list;
437 433
438 ALLOC_LIST(list); 434 ALLOC_LIST(list);
439 ABORT_ON(parse_events_add_numeric(data, list, (u32)$1, $3, $4)); 435 ABORT_ON(parse_events_add_numeric(_parse_state, list, (u32)$1, $3, $4));
440 parse_events_terms__delete($4); 436 parse_events_terms__delete($4);
441 $$ = list; 437 $$ = list;
442} 438}
@@ -444,11 +440,10 @@ PE_VALUE ':' PE_VALUE opt_event_config
444event_legacy_raw: 440event_legacy_raw:
445PE_RAW opt_event_config 441PE_RAW opt_event_config
446{ 442{
447 struct parse_events_evlist *data = _data;
448 struct list_head *list; 443 struct list_head *list;
449 444
450 ALLOC_LIST(list); 445 ALLOC_LIST(list);
451 ABORT_ON(parse_events_add_numeric(data, list, PERF_TYPE_RAW, $1, $2)); 446 ABORT_ON(parse_events_add_numeric(_parse_state, list, PERF_TYPE_RAW, $1, $2));
452 parse_events_terms__delete($2); 447 parse_events_terms__delete($2);
453 $$ = list; 448 $$ = list;
454} 449}
@@ -456,23 +451,22 @@ PE_RAW opt_event_config
456event_bpf_file: 451event_bpf_file:
457PE_BPF_OBJECT opt_event_config 452PE_BPF_OBJECT opt_event_config
458{ 453{
459 struct parse_events_evlist *data = _data; 454 struct parse_events_state *parse_state = _parse_state;
460 struct parse_events_error *error = data->error; 455 struct parse_events_error *error = parse_state->error;
461 struct list_head *list; 456 struct list_head *list;
462 457
463 ALLOC_LIST(list); 458 ALLOC_LIST(list);
464 ABORT_ON(parse_events_load_bpf(data, list, $1, false, $2)); 459 ABORT_ON(parse_events_load_bpf(parse_state, list, $1, false, $2));
465 parse_events_terms__delete($2); 460 parse_events_terms__delete($2);
466 $$ = list; 461 $$ = list;
467} 462}
468| 463|
469PE_BPF_SOURCE opt_event_config 464PE_BPF_SOURCE opt_event_config
470{ 465{
471 struct parse_events_evlist *data = _data;
472 struct list_head *list; 466 struct list_head *list;
473 467
474 ALLOC_LIST(list); 468 ALLOC_LIST(list);
475 ABORT_ON(parse_events_load_bpf(data, list, $1, true, $2)); 469 ABORT_ON(parse_events_load_bpf(_parse_state, list, $1, true, $2));
476 parse_events_terms__delete($2); 470 parse_events_terms__delete($2);
477 $$ = list; 471 $$ = list;
478} 472}
@@ -494,8 +488,8 @@ opt_event_config:
494 488
495start_terms: event_config 489start_terms: event_config
496{ 490{
497 struct parse_events_terms *data = _data; 491 struct parse_events_state *parse_state = _parse_state;
498 data->terms = $1; 492 parse_state->terms = $1;
499} 493}
500 494
501event_config: 495event_config:
@@ -685,9 +679,9 @@ sep_slash_dc: '/' | ':' |
685 679
686%% 680%%
687 681
688void parse_events_error(YYLTYPE *loc, void *data, 682void parse_events_error(YYLTYPE *loc, void *parse_state,
689 void *scanner __maybe_unused, 683 void *scanner __maybe_unused,
690 char const *msg __maybe_unused) 684 char const *msg __maybe_unused)
691{ 685{
692 parse_events_evlist_error(data, loc->last_column, "parser error"); 686 parse_events_evlist_error(parse_state, loc->last_column, "parser error");
693} 687}
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index a2670e9d652d..b7aaf9b2294d 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -184,13 +184,19 @@ static struct map *kernel_get_module_map(const char *module)
184 return NULL; 184 return NULL;
185} 185}
186 186
187struct map *get_target_map(const char *target, bool user) 187struct map *get_target_map(const char *target, struct nsinfo *nsi, bool user)
188{ 188{
189 /* Init maps of given executable or kernel */ 189 /* Init maps of given executable or kernel */
190 if (user) 190 if (user) {
191 return dso__new_map(target); 191 struct map *map;
192 else 192
193 map = dso__new_map(target);
194 if (map && map->dso)
195 map->dso->nsinfo = nsinfo__get(nsi);
196 return map;
197 } else {
193 return kernel_get_module_map(target); 198 return kernel_get_module_map(target);
199 }
194} 200}
195 201
196static int convert_exec_to_group(const char *exec, char **result) 202static int convert_exec_to_group(const char *exec, char **result)
@@ -366,7 +372,8 @@ found:
366static int find_alternative_probe_point(struct debuginfo *dinfo, 372static int find_alternative_probe_point(struct debuginfo *dinfo,
367 struct perf_probe_point *pp, 373 struct perf_probe_point *pp,
368 struct perf_probe_point *result, 374 struct perf_probe_point *result,
369 const char *target, bool uprobes) 375 const char *target, struct nsinfo *nsi,
376 bool uprobes)
370{ 377{
371 struct map *map = NULL; 378 struct map *map = NULL;
372 struct symbol *sym; 379 struct symbol *sym;
@@ -377,7 +384,7 @@ static int find_alternative_probe_point(struct debuginfo *dinfo,
377 if (!pp->function || pp->file) 384 if (!pp->function || pp->file)
378 return -ENOTSUP; 385 return -ENOTSUP;
379 386
380 map = get_target_map(target, uprobes); 387 map = get_target_map(target, nsi, uprobes);
381 if (!map) 388 if (!map)
382 return -EINVAL; 389 return -EINVAL;
383 390
@@ -421,8 +428,8 @@ static int get_alternative_probe_event(struct debuginfo *dinfo,
421 428
422 memcpy(tmp, &pev->point, sizeof(*tmp)); 429 memcpy(tmp, &pev->point, sizeof(*tmp));
423 memset(&pev->point, 0, sizeof(pev->point)); 430 memset(&pev->point, 0, sizeof(pev->point));
424 ret = find_alternative_probe_point(dinfo, tmp, &pev->point, 431 ret = find_alternative_probe_point(dinfo, tmp, &pev->point, pev->target,
425 pev->target, pev->uprobes); 432 pev->nsi, pev->uprobes);
426 if (ret < 0) 433 if (ret < 0)
427 memcpy(&pev->point, tmp, sizeof(*tmp)); 434 memcpy(&pev->point, tmp, sizeof(*tmp));
428 435
@@ -444,7 +451,7 @@ static int get_alternative_line_range(struct debuginfo *dinfo,
444 if (lr->end != INT_MAX) 451 if (lr->end != INT_MAX)
445 len = lr->end - lr->start; 452 len = lr->end - lr->start;
446 ret = find_alternative_probe_point(dinfo, &pp, &result, 453 ret = find_alternative_probe_point(dinfo, &pp, &result,
447 target, user); 454 target, NULL, user);
448 if (!ret) { 455 if (!ret) {
449 lr->function = result.function; 456 lr->function = result.function;
450 lr->file = result.file; 457 lr->file = result.file;
@@ -457,12 +464,14 @@ static int get_alternative_line_range(struct debuginfo *dinfo,
457} 464}
458 465
459/* Open new debuginfo of given module */ 466/* Open new debuginfo of given module */
460static struct debuginfo *open_debuginfo(const char *module, bool silent) 467static struct debuginfo *open_debuginfo(const char *module, struct nsinfo *nsi,
468 bool silent)
461{ 469{
462 const char *path = module; 470 const char *path = module;
463 char reason[STRERR_BUFSIZE]; 471 char reason[STRERR_BUFSIZE];
464 struct debuginfo *ret = NULL; 472 struct debuginfo *ret = NULL;
465 struct dso *dso = NULL; 473 struct dso *dso = NULL;
474 struct nscookie nsc;
466 int err; 475 int err;
467 476
468 if (!module || !strchr(module, '/')) { 477 if (!module || !strchr(module, '/')) {
@@ -480,6 +489,7 @@ static struct debuginfo *open_debuginfo(const char *module, bool silent)
480 } 489 }
481 path = dso->long_name; 490 path = dso->long_name;
482 } 491 }
492 nsinfo__mountns_enter(nsi, &nsc);
483 ret = debuginfo__new(path); 493 ret = debuginfo__new(path);
484 if (!ret && !silent) { 494 if (!ret && !silent) {
485 pr_warning("The %s file has no debug information.\n", path); 495 pr_warning("The %s file has no debug information.\n", path);
@@ -489,6 +499,7 @@ static struct debuginfo *open_debuginfo(const char *module, bool silent)
489 pr_warning("Rebuild with -g, "); 499 pr_warning("Rebuild with -g, ");
490 pr_warning("or install an appropriate debuginfo package.\n"); 500 pr_warning("or install an appropriate debuginfo package.\n");
491 } 501 }
502 nsinfo__mountns_exit(&nsc);
492 return ret; 503 return ret;
493} 504}
494 505
@@ -516,7 +527,7 @@ static struct debuginfo *debuginfo_cache__open(const char *module, bool silent)
516 goto out; 527 goto out;
517 } 528 }
518 529
519 debuginfo_cache = open_debuginfo(module, silent); 530 debuginfo_cache = open_debuginfo(module, NULL, silent);
520 if (!debuginfo_cache) 531 if (!debuginfo_cache)
521 zfree(&debuginfo_cache_path); 532 zfree(&debuginfo_cache_path);
522out: 533out:
@@ -531,14 +542,18 @@ static void debuginfo_cache__exit(void)
531} 542}
532 543
533 544
534static int get_text_start_address(const char *exec, unsigned long *address) 545static int get_text_start_address(const char *exec, unsigned long *address,
546 struct nsinfo *nsi)
535{ 547{
536 Elf *elf; 548 Elf *elf;
537 GElf_Ehdr ehdr; 549 GElf_Ehdr ehdr;
538 GElf_Shdr shdr; 550 GElf_Shdr shdr;
539 int fd, ret = -ENOENT; 551 int fd, ret = -ENOENT;
552 struct nscookie nsc;
540 553
554 nsinfo__mountns_enter(nsi, &nsc);
541 fd = open(exec, O_RDONLY); 555 fd = open(exec, O_RDONLY);
556 nsinfo__mountns_exit(&nsc);
542 if (fd < 0) 557 if (fd < 0)
543 return -errno; 558 return -errno;
544 559
@@ -582,7 +597,7 @@ static int find_perf_probe_point_from_dwarf(struct probe_trace_point *tp,
582 ret = -EINVAL; 597 ret = -EINVAL;
583 goto error; 598 goto error;
584 } 599 }
585 ret = get_text_start_address(tp->module, &stext); 600 ret = get_text_start_address(tp->module, &stext, NULL);
586 if (ret < 0) 601 if (ret < 0)
587 goto error; 602 goto error;
588 addr += stext; 603 addr += stext;
@@ -659,7 +674,7 @@ post_process_offline_probe_trace_events(struct probe_trace_event *tevs,
659 674
660 /* Prepare a map for offline binary */ 675 /* Prepare a map for offline binary */
661 map = dso__new_map(pathname); 676 map = dso__new_map(pathname);
662 if (!map || get_text_start_address(pathname, &stext) < 0) { 677 if (!map || get_text_start_address(pathname, &stext, NULL) < 0) {
663 pr_warning("Failed to get ELF symbols for %s\n", pathname); 678 pr_warning("Failed to get ELF symbols for %s\n", pathname);
664 return -EINVAL; 679 return -EINVAL;
665 } 680 }
@@ -676,7 +691,8 @@ post_process_offline_probe_trace_events(struct probe_trace_event *tevs,
676} 691}
677 692
678static int add_exec_to_probe_trace_events(struct probe_trace_event *tevs, 693static int add_exec_to_probe_trace_events(struct probe_trace_event *tevs,
679 int ntevs, const char *exec) 694 int ntevs, const char *exec,
695 struct nsinfo *nsi)
680{ 696{
681 int i, ret = 0; 697 int i, ret = 0;
682 unsigned long stext = 0; 698 unsigned long stext = 0;
@@ -684,7 +700,7 @@ static int add_exec_to_probe_trace_events(struct probe_trace_event *tevs,
684 if (!exec) 700 if (!exec)
685 return 0; 701 return 0;
686 702
687 ret = get_text_start_address(exec, &stext); 703 ret = get_text_start_address(exec, &stext, nsi);
688 if (ret < 0) 704 if (ret < 0)
689 return ret; 705 return ret;
690 706
@@ -715,7 +731,7 @@ post_process_module_probe_trace_events(struct probe_trace_event *tevs,
715 if (!module) 731 if (!module)
716 return 0; 732 return 0;
717 733
718 map = get_target_map(module, false); 734 map = get_target_map(module, NULL, false);
719 if (!map || debuginfo__get_text_offset(dinfo, &text_offs, true) < 0) { 735 if (!map || debuginfo__get_text_offset(dinfo, &text_offs, true) < 0) {
720 pr_warning("Failed to get ELF symbols for %s\n", module); 736 pr_warning("Failed to get ELF symbols for %s\n", module);
721 return -EINVAL; 737 return -EINVAL;
@@ -802,7 +818,8 @@ static int post_process_probe_trace_events(struct perf_probe_event *pev,
802 int ret; 818 int ret;
803 819
804 if (uprobe) 820 if (uprobe)
805 ret = add_exec_to_probe_trace_events(tevs, ntevs, module); 821 ret = add_exec_to_probe_trace_events(tevs, ntevs, module,
822 pev->nsi);
806 else if (module) 823 else if (module)
807 /* Currently ref_reloc_sym based probe is not for drivers */ 824 /* Currently ref_reloc_sym based probe is not for drivers */
808 ret = post_process_module_probe_trace_events(tevs, ntevs, 825 ret = post_process_module_probe_trace_events(tevs, ntevs,
@@ -825,7 +842,7 @@ static int try_to_find_probe_trace_events(struct perf_probe_event *pev,
825 struct debuginfo *dinfo; 842 struct debuginfo *dinfo;
826 int ntevs, ret = 0; 843 int ntevs, ret = 0;
827 844
828 dinfo = open_debuginfo(pev->target, !need_dwarf); 845 dinfo = open_debuginfo(pev->target, pev->nsi, !need_dwarf);
829 if (!dinfo) { 846 if (!dinfo) {
830 if (need_dwarf) 847 if (need_dwarf)
831 return -ENOENT; 848 return -ENOENT;
@@ -945,7 +962,7 @@ static int __show_line_range(struct line_range *lr, const char *module,
945 char sbuf[STRERR_BUFSIZE]; 962 char sbuf[STRERR_BUFSIZE];
946 963
947 /* Search a line range */ 964 /* Search a line range */
948 dinfo = open_debuginfo(module, false); 965 dinfo = open_debuginfo(module, NULL, false);
949 if (!dinfo) 966 if (!dinfo)
950 return -ENOENT; 967 return -ENOENT;
951 968
@@ -1021,14 +1038,18 @@ end:
1021 return ret; 1038 return ret;
1022} 1039}
1023 1040
1024int show_line_range(struct line_range *lr, const char *module, bool user) 1041int show_line_range(struct line_range *lr, const char *module,
1042 struct nsinfo *nsi, bool user)
1025{ 1043{
1026 int ret; 1044 int ret;
1045 struct nscookie nsc;
1027 1046
1028 ret = init_probe_symbol_maps(user); 1047 ret = init_probe_symbol_maps(user);
1029 if (ret < 0) 1048 if (ret < 0)
1030 return ret; 1049 return ret;
1050 nsinfo__mountns_enter(nsi, &nsc);
1031 ret = __show_line_range(lr, module, user); 1051 ret = __show_line_range(lr, module, user);
1052 nsinfo__mountns_exit(&nsc);
1032 exit_probe_symbol_maps(); 1053 exit_probe_symbol_maps();
1033 1054
1034 return ret; 1055 return ret;
@@ -1111,7 +1132,7 @@ int show_available_vars(struct perf_probe_event *pevs, int npevs,
1111 if (ret < 0) 1132 if (ret < 0)
1112 return ret; 1133 return ret;
1113 1134
1114 dinfo = open_debuginfo(pevs->target, false); 1135 dinfo = open_debuginfo(pevs->target, pevs->nsi, false);
1115 if (!dinfo) { 1136 if (!dinfo) {
1116 ret = -ENOENT; 1137 ret = -ENOENT;
1117 goto out; 1138 goto out;
@@ -1155,6 +1176,7 @@ static int try_to_find_probe_trace_events(struct perf_probe_event *pev,
1155 1176
1156int show_line_range(struct line_range *lr __maybe_unused, 1177int show_line_range(struct line_range *lr __maybe_unused,
1157 const char *module __maybe_unused, 1178 const char *module __maybe_unused,
1179 struct nsinfo *nsi __maybe_unused,
1158 bool user __maybe_unused) 1180 bool user __maybe_unused)
1159{ 1181{
1160 pr_warning("Debuginfo-analysis is not supported.\n"); 1182 pr_warning("Debuginfo-analysis is not supported.\n");
@@ -2373,7 +2395,7 @@ kprobe_blacklist__find_by_address(struct list_head *blacklist,
2373 struct kprobe_blacklist_node *node; 2395 struct kprobe_blacklist_node *node;
2374 2396
2375 list_for_each_entry(node, blacklist, list) { 2397 list_for_each_entry(node, blacklist, list) {
2376 if (node->start <= address && address <= node->end) 2398 if (node->start <= address && address < node->end)
2377 return node; 2399 return node;
2378 } 2400 }
2379 2401
@@ -2703,6 +2725,7 @@ static int __add_probe_trace_events(struct perf_probe_event *pev,
2703 struct probe_trace_event *tev = NULL; 2725 struct probe_trace_event *tev = NULL;
2704 struct probe_cache *cache = NULL; 2726 struct probe_cache *cache = NULL;
2705 struct strlist *namelist[2] = {NULL, NULL}; 2727 struct strlist *namelist[2] = {NULL, NULL};
2728 struct nscookie nsc;
2706 2729
2707 up = pev->uprobes ? 1 : 0; 2730 up = pev->uprobes ? 1 : 0;
2708 fd[up] = __open_probe_file_and_namelist(up, &namelist[up]); 2731 fd[up] = __open_probe_file_and_namelist(up, &namelist[up]);
@@ -2729,7 +2752,9 @@ static int __add_probe_trace_events(struct perf_probe_event *pev,
2729 if (ret < 0) 2752 if (ret < 0)
2730 break; 2753 break;
2731 2754
2755 nsinfo__mountns_enter(pev->nsi, &nsc);
2732 ret = probe_file__add_event(fd[up], tev); 2756 ret = probe_file__add_event(fd[up], tev);
2757 nsinfo__mountns_exit(&nsc);
2733 if (ret < 0) 2758 if (ret < 0)
2734 break; 2759 break;
2735 2760
@@ -2744,7 +2769,7 @@ static int __add_probe_trace_events(struct perf_probe_event *pev,
2744 if (ret == -EINVAL && pev->uprobes) 2769 if (ret == -EINVAL && pev->uprobes)
2745 warn_uprobe_event_compat(tev); 2770 warn_uprobe_event_compat(tev);
2746 if (ret == 0 && probe_conf.cache) { 2771 if (ret == 0 && probe_conf.cache) {
2747 cache = probe_cache__new(pev->target); 2772 cache = probe_cache__new(pev->target, pev->nsi);
2748 if (!cache || 2773 if (!cache ||
2749 probe_cache__add_entry(cache, pev, tevs, ntevs) < 0 || 2774 probe_cache__add_entry(cache, pev, tevs, ntevs) < 0 ||
2750 probe_cache__commit(cache) < 0) 2775 probe_cache__commit(cache) < 0)
@@ -2805,7 +2830,7 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
2805 int ret, i, j, skipped = 0; 2830 int ret, i, j, skipped = 0;
2806 char *mod_name; 2831 char *mod_name;
2807 2832
2808 map = get_target_map(pev->target, pev->uprobes); 2833 map = get_target_map(pev->target, pev->nsi, pev->uprobes);
2809 if (!map) { 2834 if (!map) {
2810 ret = -EINVAL; 2835 ret = -EINVAL;
2811 goto out; 2836 goto out;
@@ -3094,7 +3119,7 @@ static int find_cached_events(struct perf_probe_event *pev,
3094 int ntevs = 0; 3119 int ntevs = 0;
3095 int ret = 0; 3120 int ret = 0;
3096 3121
3097 cache = probe_cache__new(target); 3122 cache = probe_cache__new(target, pev->nsi);
3098 /* Return 0 ("not found") if the target has no probe cache. */ 3123 /* Return 0 ("not found") if the target has no probe cache. */
3099 if (!cache) 3124 if (!cache)
3100 return 0; 3125 return 0;
@@ -3184,7 +3209,7 @@ static int find_probe_trace_events_from_cache(struct perf_probe_event *pev,
3184 else 3209 else
3185 return find_cached_events(pev, tevs, pev->target); 3210 return find_cached_events(pev, tevs, pev->target);
3186 } 3211 }
3187 cache = probe_cache__new(pev->target); 3212 cache = probe_cache__new(pev->target, pev->nsi);
3188 if (!cache) 3213 if (!cache)
3189 return 0; 3214 return 0;
3190 3215
@@ -3345,13 +3370,16 @@ int apply_perf_probe_events(struct perf_probe_event *pevs, int npevs)
3345void cleanup_perf_probe_events(struct perf_probe_event *pevs, int npevs) 3370void cleanup_perf_probe_events(struct perf_probe_event *pevs, int npevs)
3346{ 3371{
3347 int i, j; 3372 int i, j;
3373 struct perf_probe_event *pev;
3348 3374
3349 /* Loop 3: cleanup and free trace events */ 3375 /* Loop 3: cleanup and free trace events */
3350 for (i = 0; i < npevs; i++) { 3376 for (i = 0; i < npevs; i++) {
3377 pev = &pevs[i];
3351 for (j = 0; j < pevs[i].ntevs; j++) 3378 for (j = 0; j < pevs[i].ntevs; j++)
3352 clear_probe_trace_event(&pevs[i].tevs[j]); 3379 clear_probe_trace_event(&pevs[i].tevs[j]);
3353 zfree(&pevs[i].tevs); 3380 zfree(&pevs[i].tevs);
3354 pevs[i].ntevs = 0; 3381 pevs[i].ntevs = 0;
3382 nsinfo__zput(pev->nsi);
3355 clear_perf_probe_event(&pevs[i]); 3383 clear_perf_probe_event(&pevs[i]);
3356 } 3384 }
3357} 3385}
@@ -3409,8 +3437,8 @@ out:
3409 return ret; 3437 return ret;
3410} 3438}
3411 3439
3412int show_available_funcs(const char *target, struct strfilter *_filter, 3440int show_available_funcs(const char *target, struct nsinfo *nsi,
3413 bool user) 3441 struct strfilter *_filter, bool user)
3414{ 3442{
3415 struct rb_node *nd; 3443 struct rb_node *nd;
3416 struct map *map; 3444 struct map *map;
@@ -3421,7 +3449,7 @@ int show_available_funcs(const char *target, struct strfilter *_filter,
3421 return ret; 3449 return ret;
3422 3450
3423 /* Get a symbol map */ 3451 /* Get a symbol map */
3424 map = get_target_map(target, user); 3452 map = get_target_map(target, nsi, user);
3425 if (!map) { 3453 if (!map) {
3426 pr_err("Failed to get a map for %s\n", (target) ? : "kernel"); 3454 pr_err("Failed to get a map for %s\n", (target) ? : "kernel");
3427 return -EINVAL; 3455 return -EINVAL;
diff --git a/tools/perf/util/probe-event.h b/tools/perf/util/probe-event.h
index 5812947418dd..078681d12168 100644
--- a/tools/perf/util/probe-event.h
+++ b/tools/perf/util/probe-event.h
@@ -4,6 +4,7 @@
4#include <linux/compiler.h> 4#include <linux/compiler.h>
5#include <stdbool.h> 5#include <stdbool.h>
6#include "intlist.h" 6#include "intlist.h"
7#include "namespaces.h"
7 8
8/* Probe related configurations */ 9/* Probe related configurations */
9struct probe_conf { 10struct probe_conf {
@@ -92,6 +93,7 @@ struct perf_probe_event {
92 struct perf_probe_arg *args; /* Arguments */ 93 struct perf_probe_arg *args; /* Arguments */
93 struct probe_trace_event *tevs; 94 struct probe_trace_event *tevs;
94 int ntevs; 95 int ntevs;
96 struct nsinfo *nsi; /* Target namespace */
95}; 97};
96 98
97/* Line range */ 99/* Line range */
@@ -163,10 +165,12 @@ int show_perf_probe_event(const char *group, const char *event,
163 struct perf_probe_event *pev, 165 struct perf_probe_event *pev,
164 const char *module, bool use_stdout); 166 const char *module, bool use_stdout);
165int show_perf_probe_events(struct strfilter *filter); 167int show_perf_probe_events(struct strfilter *filter);
166int show_line_range(struct line_range *lr, const char *module, bool user); 168int show_line_range(struct line_range *lr, const char *module,
169 struct nsinfo *nsi, bool user);
167int show_available_vars(struct perf_probe_event *pevs, int npevs, 170int show_available_vars(struct perf_probe_event *pevs, int npevs,
168 struct strfilter *filter); 171 struct strfilter *filter);
169int show_available_funcs(const char *module, struct strfilter *filter, bool user); 172int show_available_funcs(const char *module, struct nsinfo *nsi,
173 struct strfilter *filter, bool user);
170void arch__fix_tev_from_maps(struct perf_probe_event *pev, 174void arch__fix_tev_from_maps(struct perf_probe_event *pev,
171 struct probe_trace_event *tev, struct map *map, 175 struct probe_trace_event *tev, struct map *map,
172 struct symbol *sym); 176 struct symbol *sym);
@@ -180,7 +184,7 @@ int e_snprintf(char *str, size_t size, const char *format, ...) __printf(3, 4);
180int copy_to_probe_trace_arg(struct probe_trace_arg *tvar, 184int copy_to_probe_trace_arg(struct probe_trace_arg *tvar,
181 struct perf_probe_arg *pvar); 185 struct perf_probe_arg *pvar);
182 186
183struct map *get_target_map(const char *target, bool user); 187struct map *get_target_map(const char *target, struct nsinfo *nsi, bool user);
184 188
185void arch__post_process_probe_trace_events(struct perf_probe_event *pev, 189void arch__post_process_probe_trace_events(struct perf_probe_event *pev,
186 int ntevs); 190 int ntevs);
diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c
index d679389e627c..cdf8d83a484c 100644
--- a/tools/perf/util/probe-file.c
+++ b/tools/perf/util/probe-file.c
@@ -412,13 +412,15 @@ int probe_cache_entry__get_event(struct probe_cache_entry *entry,
412} 412}
413 413
414/* For the kernel probe caches, pass target = NULL or DSO__NAME_KALLSYMS */ 414/* For the kernel probe caches, pass target = NULL or DSO__NAME_KALLSYMS */
415static int probe_cache__open(struct probe_cache *pcache, const char *target) 415static int probe_cache__open(struct probe_cache *pcache, const char *target,
416 struct nsinfo *nsi)
416{ 417{
417 char cpath[PATH_MAX]; 418 char cpath[PATH_MAX];
418 char sbuildid[SBUILD_ID_SIZE]; 419 char sbuildid[SBUILD_ID_SIZE];
419 char *dir_name = NULL; 420 char *dir_name = NULL;
420 bool is_kallsyms = false; 421 bool is_kallsyms = false;
421 int ret, fd; 422 int ret, fd;
423 struct nscookie nsc;
422 424
423 if (target && build_id_cache__cached(target)) { 425 if (target && build_id_cache__cached(target)) {
424 /* This is a cached buildid */ 426 /* This is a cached buildid */
@@ -431,8 +433,11 @@ static int probe_cache__open(struct probe_cache *pcache, const char *target)
431 target = DSO__NAME_KALLSYMS; 433 target = DSO__NAME_KALLSYMS;
432 is_kallsyms = true; 434 is_kallsyms = true;
433 ret = sysfs__sprintf_build_id("/", sbuildid); 435 ret = sysfs__sprintf_build_id("/", sbuildid);
434 } else 436 } else {
437 nsinfo__mountns_enter(nsi, &nsc);
435 ret = filename__sprintf_build_id(target, sbuildid); 438 ret = filename__sprintf_build_id(target, sbuildid);
439 nsinfo__mountns_exit(&nsc);
440 }
436 441
437 if (ret < 0) { 442 if (ret < 0) {
438 pr_debug("Failed to get build-id from %s.\n", target); 443 pr_debug("Failed to get build-id from %s.\n", target);
@@ -441,7 +446,7 @@ static int probe_cache__open(struct probe_cache *pcache, const char *target)
441 446
442 /* If we have no buildid cache, make it */ 447 /* If we have no buildid cache, make it */
443 if (!build_id_cache__cached(sbuildid)) { 448 if (!build_id_cache__cached(sbuildid)) {
444 ret = build_id_cache__add_s(sbuildid, target, 449 ret = build_id_cache__add_s(sbuildid, target, nsi,
445 is_kallsyms, NULL); 450 is_kallsyms, NULL);
446 if (ret < 0) { 451 if (ret < 0) {
447 pr_debug("Failed to add build-id cache: %s\n", target); 452 pr_debug("Failed to add build-id cache: %s\n", target);
@@ -449,7 +454,7 @@ static int probe_cache__open(struct probe_cache *pcache, const char *target)
449 } 454 }
450 } 455 }
451 456
452 dir_name = build_id_cache__cachedir(sbuildid, target, is_kallsyms, 457 dir_name = build_id_cache__cachedir(sbuildid, target, nsi, is_kallsyms,
453 false); 458 false);
454found: 459found:
455 if (!dir_name) { 460 if (!dir_name) {
@@ -554,7 +559,7 @@ void probe_cache__delete(struct probe_cache *pcache)
554 free(pcache); 559 free(pcache);
555} 560}
556 561
557struct probe_cache *probe_cache__new(const char *target) 562struct probe_cache *probe_cache__new(const char *target, struct nsinfo *nsi)
558{ 563{
559 struct probe_cache *pcache = probe_cache__alloc(); 564 struct probe_cache *pcache = probe_cache__alloc();
560 int ret; 565 int ret;
@@ -562,7 +567,7 @@ struct probe_cache *probe_cache__new(const char *target)
562 if (!pcache) 567 if (!pcache)
563 return NULL; 568 return NULL;
564 569
565 ret = probe_cache__open(pcache, target); 570 ret = probe_cache__open(pcache, target, nsi);
566 if (ret < 0) { 571 if (ret < 0) {
567 pr_debug("Cache open error: %d\n", ret); 572 pr_debug("Cache open error: %d\n", ret);
568 goto out_err; 573 goto out_err;
@@ -974,7 +979,7 @@ int probe_cache__show_all_caches(struct strfilter *filter)
974 return -EINVAL; 979 return -EINVAL;
975 } 980 }
976 strlist__for_each_entry(nd, bidlist) { 981 strlist__for_each_entry(nd, bidlist) {
977 pcache = probe_cache__new(nd->s); 982 pcache = probe_cache__new(nd->s, NULL);
978 if (!pcache) 983 if (!pcache)
979 continue; 984 continue;
980 if (!list_empty(&pcache->entries)) { 985 if (!list_empty(&pcache->entries)) {
diff --git a/tools/perf/util/probe-file.h b/tools/perf/util/probe-file.h
index 5ecc9d3925db..2ca4163abafe 100644
--- a/tools/perf/util/probe-file.h
+++ b/tools/perf/util/probe-file.h
@@ -51,7 +51,7 @@ int probe_file__del_strlist(int fd, struct strlist *namelist);
51int probe_cache_entry__get_event(struct probe_cache_entry *entry, 51int probe_cache_entry__get_event(struct probe_cache_entry *entry,
52 struct probe_trace_event **tevs); 52 struct probe_trace_event **tevs);
53 53
54struct probe_cache *probe_cache__new(const char *target); 54struct probe_cache *probe_cache__new(const char *target, struct nsinfo *nsi);
55int probe_cache__add_entry(struct probe_cache *pcache, 55int probe_cache__add_entry(struct probe_cache *pcache,
56 struct perf_probe_event *pev, 56 struct perf_probe_event *pev,
57 struct probe_trace_event *tevs, int ntevs); 57 struct probe_trace_event *tevs, int ntevs);
@@ -69,7 +69,7 @@ int probe_cache__show_all_caches(struct strfilter *filter);
69bool probe_type_is_available(enum probe_type type); 69bool probe_type_is_available(enum probe_type type);
70bool kretprobe_offset_is_supported(void); 70bool kretprobe_offset_is_supported(void);
71#else /* ! HAVE_LIBELF_SUPPORT */ 71#else /* ! HAVE_LIBELF_SUPPORT */
72static inline struct probe_cache *probe_cache__new(const char *tgt __maybe_unused) 72static inline struct probe_cache *probe_cache__new(const char *tgt __maybe_unused, struct nsinfo *nsi __maybe_unused)
73{ 73{
74 return NULL; 74 return NULL;
75} 75}
diff --git a/tools/perf/util/python-ext-sources b/tools/perf/util/python-ext-sources
index 9f3b0d9754a8..e66dc495809a 100644
--- a/tools/perf/util/python-ext-sources
+++ b/tools/perf/util/python-ext-sources
@@ -10,6 +10,7 @@ util/ctype.c
10util/evlist.c 10util/evlist.c
11util/evsel.c 11util/evsel.c
12util/cpumap.c 12util/cpumap.c
13util/namespaces.c
13../lib/bitmap.c 14../lib/bitmap.c
14../lib/find_bit.c 15../lib/find_bit.c
15../lib/hweight.c 16../lib/hweight.c
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index 57b7a00e6f16..c7187f067d31 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -116,6 +116,34 @@ static PyObject *get_handler(const char *handler_name)
116 return handler; 116 return handler;
117} 117}
118 118
119static int get_argument_count(PyObject *handler)
120{
121 int arg_count = 0;
122
123 /*
124 * The attribute for the code object is func_code in Python 2,
125 * whereas it is __code__ in Python 3.0+.
126 */
127 PyObject *code_obj = PyObject_GetAttrString(handler,
128 "func_code");
129 if (PyErr_Occurred()) {
130 PyErr_Clear();
131 code_obj = PyObject_GetAttrString(handler,
132 "__code__");
133 }
134 PyErr_Clear();
135 if (code_obj) {
136 PyObject *arg_count_obj = PyObject_GetAttrString(code_obj,
137 "co_argcount");
138 if (arg_count_obj) {
139 arg_count = (int) PyInt_AsLong(arg_count_obj);
140 Py_DECREF(arg_count_obj);
141 }
142 Py_DECREF(code_obj);
143 }
144 return arg_count;
145}
146
119static void call_object(PyObject *handler, PyObject *args, const char *die_msg) 147static void call_object(PyObject *handler, PyObject *args, const char *die_msg)
120{ 148{
121 PyObject *retval; 149 PyObject *retval;
@@ -391,13 +419,115 @@ exit:
391 return pylist; 419 return pylist;
392} 420}
393 421
422static PyObject *get_sample_value_as_tuple(struct sample_read_value *value)
423{
424 PyObject *t;
425
426 t = PyTuple_New(2);
427 if (!t)
428 Py_FatalError("couldn't create Python tuple");
429 PyTuple_SetItem(t, 0, PyLong_FromUnsignedLongLong(value->id));
430 PyTuple_SetItem(t, 1, PyLong_FromUnsignedLongLong(value->value));
431 return t;
432}
433
434static void set_sample_read_in_dict(PyObject *dict_sample,
435 struct perf_sample *sample,
436 struct perf_evsel *evsel)
437{
438 u64 read_format = evsel->attr.read_format;
439 PyObject *values;
440 unsigned int i;
441
442 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
443 pydict_set_item_string_decref(dict_sample, "time_enabled",
444 PyLong_FromUnsignedLongLong(sample->read.time_enabled));
445 }
446
447 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
448 pydict_set_item_string_decref(dict_sample, "time_running",
449 PyLong_FromUnsignedLongLong(sample->read.time_running));
450 }
451
452 if (read_format & PERF_FORMAT_GROUP)
453 values = PyList_New(sample->read.group.nr);
454 else
455 values = PyList_New(1);
456
457 if (!values)
458 Py_FatalError("couldn't create Python list");
459
460 if (read_format & PERF_FORMAT_GROUP) {
461 for (i = 0; i < sample->read.group.nr; i++) {
462 PyObject *t = get_sample_value_as_tuple(&sample->read.group.values[i]);
463 PyList_SET_ITEM(values, i, t);
464 }
465 } else {
466 PyObject *t = get_sample_value_as_tuple(&sample->read.one);
467 PyList_SET_ITEM(values, 0, t);
468 }
469 pydict_set_item_string_decref(dict_sample, "values", values);
470}
471
472static PyObject *get_perf_sample_dict(struct perf_sample *sample,
473 struct perf_evsel *evsel,
474 struct addr_location *al,
475 PyObject *callchain)
476{
477 PyObject *dict, *dict_sample;
478
479 dict = PyDict_New();
480 if (!dict)
481 Py_FatalError("couldn't create Python dictionary");
482
483 dict_sample = PyDict_New();
484 if (!dict_sample)
485 Py_FatalError("couldn't create Python dictionary");
486
487 pydict_set_item_string_decref(dict, "ev_name", PyString_FromString(perf_evsel__name(evsel)));
488 pydict_set_item_string_decref(dict, "attr", PyString_FromStringAndSize(
489 (const char *)&evsel->attr, sizeof(evsel->attr)));
490
491 pydict_set_item_string_decref(dict_sample, "pid",
492 PyInt_FromLong(sample->pid));
493 pydict_set_item_string_decref(dict_sample, "tid",
494 PyInt_FromLong(sample->tid));
495 pydict_set_item_string_decref(dict_sample, "cpu",
496 PyInt_FromLong(sample->cpu));
497 pydict_set_item_string_decref(dict_sample, "ip",
498 PyLong_FromUnsignedLongLong(sample->ip));
499 pydict_set_item_string_decref(dict_sample, "time",
500 PyLong_FromUnsignedLongLong(sample->time));
501 pydict_set_item_string_decref(dict_sample, "period",
502 PyLong_FromUnsignedLongLong(sample->period));
503 set_sample_read_in_dict(dict_sample, sample, evsel);
504 pydict_set_item_string_decref(dict, "sample", dict_sample);
505
506 pydict_set_item_string_decref(dict, "raw_buf", PyString_FromStringAndSize(
507 (const char *)sample->raw_data, sample->raw_size));
508 pydict_set_item_string_decref(dict, "comm",
509 PyString_FromString(thread__comm_str(al->thread)));
510 if (al->map) {
511 pydict_set_item_string_decref(dict, "dso",
512 PyString_FromString(al->map->dso->name));
513 }
514 if (al->sym) {
515 pydict_set_item_string_decref(dict, "symbol",
516 PyString_FromString(al->sym->name));
517 }
518
519 pydict_set_item_string_decref(dict, "callchain", callchain);
520
521 return dict;
522}
523
394static void python_process_tracepoint(struct perf_sample *sample, 524static void python_process_tracepoint(struct perf_sample *sample,
395 struct perf_evsel *evsel, 525 struct perf_evsel *evsel,
396 struct addr_location *al) 526 struct addr_location *al)
397{ 527{
398 struct event_format *event = evsel->tp_format; 528 struct event_format *event = evsel->tp_format;
399 PyObject *handler, *context, *t, *obj = NULL, *callchain; 529 PyObject *handler, *context, *t, *obj = NULL, *callchain;
400 PyObject *dict = NULL; 530 PyObject *dict = NULL, *all_entries_dict = NULL;
401 static char handler_name[256]; 531 static char handler_name[256];
402 struct format_field *field; 532 struct format_field *field;
403 unsigned long s, ns; 533 unsigned long s, ns;
@@ -407,10 +537,7 @@ static void python_process_tracepoint(struct perf_sample *sample,
407 void *data = sample->raw_data; 537 void *data = sample->raw_data;
408 unsigned long long nsecs = sample->time; 538 unsigned long long nsecs = sample->time;
409 const char *comm = thread__comm_str(al->thread); 539 const char *comm = thread__comm_str(al->thread);
410 540 const char *default_handler_name = "trace_unhandled";
411 t = PyTuple_New(MAX_FIELDS);
412 if (!t)
413 Py_FatalError("couldn't create Python tuple");
414 541
415 if (!event) { 542 if (!event) {
416 snprintf(handler_name, sizeof(handler_name), 543 snprintf(handler_name, sizeof(handler_name),
@@ -427,10 +554,19 @@ static void python_process_tracepoint(struct perf_sample *sample,
427 554
428 handler = get_handler(handler_name); 555 handler = get_handler(handler_name);
429 if (!handler) { 556 if (!handler) {
557 handler = get_handler(default_handler_name);
558 if (!handler)
559 return;
430 dict = PyDict_New(); 560 dict = PyDict_New();
431 if (!dict) 561 if (!dict)
432 Py_FatalError("couldn't create Python dict"); 562 Py_FatalError("couldn't create Python dict");
433 } 563 }
564
565 t = PyTuple_New(MAX_FIELDS);
566 if (!t)
567 Py_FatalError("couldn't create Python tuple");
568
569
434 s = nsecs / NSEC_PER_SEC; 570 s = nsecs / NSEC_PER_SEC;
435 ns = nsecs - s * NSEC_PER_SEC; 571 ns = nsecs - s * NSEC_PER_SEC;
436 572
@@ -444,8 +580,10 @@ static void python_process_tracepoint(struct perf_sample *sample,
444 580
445 /* ip unwinding */ 581 /* ip unwinding */
446 callchain = python_process_callchain(sample, evsel, al); 582 callchain = python_process_callchain(sample, evsel, al);
583 /* Need an additional reference for the perf_sample dict */
584 Py_INCREF(callchain);
447 585
448 if (handler) { 586 if (!dict) {
449 PyTuple_SetItem(t, n++, PyInt_FromLong(cpu)); 587 PyTuple_SetItem(t, n++, PyInt_FromLong(cpu));
450 PyTuple_SetItem(t, n++, PyInt_FromLong(s)); 588 PyTuple_SetItem(t, n++, PyInt_FromLong(s));
451 PyTuple_SetItem(t, n++, PyInt_FromLong(ns)); 589 PyTuple_SetItem(t, n++, PyInt_FromLong(ns));
@@ -484,26 +622,35 @@ static void python_process_tracepoint(struct perf_sample *sample,
484 } else { /* FIELD_IS_NUMERIC */ 622 } else { /* FIELD_IS_NUMERIC */
485 obj = get_field_numeric_entry(event, field, data); 623 obj = get_field_numeric_entry(event, field, data);
486 } 624 }
487 if (handler) 625 if (!dict)
488 PyTuple_SetItem(t, n++, obj); 626 PyTuple_SetItem(t, n++, obj);
489 else 627 else
490 pydict_set_item_string_decref(dict, field->name, obj); 628 pydict_set_item_string_decref(dict, field->name, obj);
491 629
492 } 630 }
493 631
494 if (!handler) 632 if (dict)
495 PyTuple_SetItem(t, n++, dict); 633 PyTuple_SetItem(t, n++, dict);
496 634
635 if (get_argument_count(handler) == (int) n + 1) {
636 all_entries_dict = get_perf_sample_dict(sample, evsel, al,
637 callchain);
638 PyTuple_SetItem(t, n++, all_entries_dict);
639 } else {
640 Py_DECREF(callchain);
641 }
642
497 if (_PyTuple_Resize(&t, n) == -1) 643 if (_PyTuple_Resize(&t, n) == -1)
498 Py_FatalError("error resizing Python tuple"); 644 Py_FatalError("error resizing Python tuple");
499 645
500 if (handler) { 646 if (!dict) {
501 call_object(handler, t, handler_name); 647 call_object(handler, t, handler_name);
502 } else { 648 } else {
503 try_call_object("trace_unhandled", t); 649 call_object(handler, t, default_handler_name);
504 Py_DECREF(dict); 650 Py_DECREF(dict);
505 } 651 }
506 652
653 Py_XDECREF(all_entries_dict);
507 Py_DECREF(t); 654 Py_DECREF(t);
508} 655}
509 656
@@ -795,10 +942,16 @@ static void python_process_general_event(struct perf_sample *sample,
795 struct perf_evsel *evsel, 942 struct perf_evsel *evsel,
796 struct addr_location *al) 943 struct addr_location *al)
797{ 944{
798 PyObject *handler, *t, *dict, *callchain, *dict_sample; 945 PyObject *handler, *t, *dict, *callchain;
799 static char handler_name[64]; 946 static char handler_name[64];
800 unsigned n = 0; 947 unsigned n = 0;
801 948
949 snprintf(handler_name, sizeof(handler_name), "%s", "process_event");
950
951 handler = get_handler(handler_name);
952 if (!handler)
953 return;
954
802 /* 955 /*
803 * Use the MAX_FIELDS to make the function expandable, though 956 * Use the MAX_FIELDS to make the function expandable, though
804 * currently there is only one item for the tuple. 957 * currently there is only one item for the tuple.
@@ -807,61 +960,16 @@ static void python_process_general_event(struct perf_sample *sample,
807 if (!t) 960 if (!t)
808 Py_FatalError("couldn't create Python tuple"); 961 Py_FatalError("couldn't create Python tuple");
809 962
810 dict = PyDict_New();
811 if (!dict)
812 Py_FatalError("couldn't create Python dictionary");
813
814 dict_sample = PyDict_New();
815 if (!dict_sample)
816 Py_FatalError("couldn't create Python dictionary");
817
818 snprintf(handler_name, sizeof(handler_name), "%s", "process_event");
819
820 handler = get_handler(handler_name);
821 if (!handler)
822 goto exit;
823
824 pydict_set_item_string_decref(dict, "ev_name", PyString_FromString(perf_evsel__name(evsel)));
825 pydict_set_item_string_decref(dict, "attr", PyString_FromStringAndSize(
826 (const char *)&evsel->attr, sizeof(evsel->attr)));
827
828 pydict_set_item_string_decref(dict_sample, "pid",
829 PyInt_FromLong(sample->pid));
830 pydict_set_item_string_decref(dict_sample, "tid",
831 PyInt_FromLong(sample->tid));
832 pydict_set_item_string_decref(dict_sample, "cpu",
833 PyInt_FromLong(sample->cpu));
834 pydict_set_item_string_decref(dict_sample, "ip",
835 PyLong_FromUnsignedLongLong(sample->ip));
836 pydict_set_item_string_decref(dict_sample, "time",
837 PyLong_FromUnsignedLongLong(sample->time));
838 pydict_set_item_string_decref(dict_sample, "period",
839 PyLong_FromUnsignedLongLong(sample->period));
840 pydict_set_item_string_decref(dict, "sample", dict_sample);
841
842 pydict_set_item_string_decref(dict, "raw_buf", PyString_FromStringAndSize(
843 (const char *)sample->raw_data, sample->raw_size));
844 pydict_set_item_string_decref(dict, "comm",
845 PyString_FromString(thread__comm_str(al->thread)));
846 if (al->map) {
847 pydict_set_item_string_decref(dict, "dso",
848 PyString_FromString(al->map->dso->name));
849 }
850 if (al->sym) {
851 pydict_set_item_string_decref(dict, "symbol",
852 PyString_FromString(al->sym->name));
853 }
854
855 /* ip unwinding */ 963 /* ip unwinding */
856 callchain = python_process_callchain(sample, evsel, al); 964 callchain = python_process_callchain(sample, evsel, al);
857 pydict_set_item_string_decref(dict, "callchain", callchain); 965 dict = get_perf_sample_dict(sample, evsel, al, callchain);
858 966
859 PyTuple_SetItem(t, n++, dict); 967 PyTuple_SetItem(t, n++, dict);
860 if (_PyTuple_Resize(&t, n) == -1) 968 if (_PyTuple_Resize(&t, n) == -1)
861 Py_FatalError("error resizing Python tuple"); 969 Py_FatalError("error resizing Python tuple");
862 970
863 call_object(handler, t, handler_name); 971 call_object(handler, t, handler_name);
864exit: 972
865 Py_DECREF(dict); 973 Py_DECREF(dict);
866 Py_DECREF(t); 974 Py_DECREF(t);
867} 975}
@@ -1259,6 +1367,12 @@ static int python_generate_script(struct pevent *pevent, const char *outfile)
1259 1367
1260 fprintf(ofp, "%s", f->name); 1368 fprintf(ofp, "%s", f->name);
1261 } 1369 }
1370 if (not_first++)
1371 fprintf(ofp, ", ");
1372 if (++count % 5 == 0)
1373 fprintf(ofp, "\n\t\t");
1374 fprintf(ofp, "perf_sample_dict");
1375
1262 fprintf(ofp, "):\n"); 1376 fprintf(ofp, "):\n");
1263 1377
1264 fprintf(ofp, "\t\tprint_header(event_name, common_cpu, " 1378 fprintf(ofp, "\t\tprint_header(event_name, common_cpu, "
@@ -1328,6 +1442,9 @@ static int python_generate_script(struct pevent *pevent, const char *outfile)
1328 1442
1329 fprintf(ofp, ")\n\n"); 1443 fprintf(ofp, ")\n\n");
1330 1444
1445 fprintf(ofp, "\t\tprint 'Sample: {'+"
1446 "get_dict_as_string(perf_sample_dict['sample'], ', ')+'}'\n\n");
1447
1331 fprintf(ofp, "\t\tfor node in common_callchain:"); 1448 fprintf(ofp, "\t\tfor node in common_callchain:");
1332 fprintf(ofp, "\n\t\t\tif 'sym' in node:"); 1449 fprintf(ofp, "\n\t\t\tif 'sym' in node:");
1333 fprintf(ofp, "\n\t\t\t\tprint \"\\t[%%x] %%s\" %% (node['ip'], node['sym']['name'])"); 1450 fprintf(ofp, "\n\t\t\t\tprint \"\\t[%%x] %%s\" %% (node['ip'], node['sym']['name'])");
@@ -1338,15 +1455,20 @@ static int python_generate_script(struct pevent *pevent, const char *outfile)
1338 } 1455 }
1339 1456
1340 fprintf(ofp, "def trace_unhandled(event_name, context, " 1457 fprintf(ofp, "def trace_unhandled(event_name, context, "
1341 "event_fields_dict):\n"); 1458 "event_fields_dict, perf_sample_dict):\n");
1342 1459
1343 fprintf(ofp, "\t\tprint ' '.join(['%%s=%%s'%%(k,str(v))" 1460 fprintf(ofp, "\t\tprint get_dict_as_string(event_fields_dict)\n");
1344 "for k,v in sorted(event_fields_dict.items())])\n\n"); 1461 fprintf(ofp, "\t\tprint 'Sample: {'+"
1462 "get_dict_as_string(perf_sample_dict['sample'], ', ')+'}'\n\n");
1345 1463
1346 fprintf(ofp, "def print_header(" 1464 fprintf(ofp, "def print_header("
1347 "event_name, cpu, secs, nsecs, pid, comm):\n" 1465 "event_name, cpu, secs, nsecs, pid, comm):\n"
1348 "\tprint \"%%-20s %%5u %%05u.%%09u %%8u %%-20s \" %% \\\n\t" 1466 "\tprint \"%%-20s %%5u %%05u.%%09u %%8u %%-20s \" %% \\\n\t"
1349 "(event_name, cpu, secs, nsecs, pid, comm),\n"); 1467 "(event_name, cpu, secs, nsecs, pid, comm),\n\n");
1468
1469 fprintf(ofp, "def get_dict_as_string(a_dict, delimiter=' '):\n"
1470 "\treturn delimiter.join"
1471 "(['%%s=%%s'%%(k,str(v))for k,v in sorted(a_dict.items())])\n");
1350 1472
1351 fclose(ofp); 1473 fclose(ofp);
1352 1474
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index d19c40a81040..a7ebd9fe8e40 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -428,6 +428,8 @@ void perf_tool__fill_defaults(struct perf_tool *tool)
428 tool->stat_round = process_stat_round_stub; 428 tool->stat_round = process_stat_round_stub;
429 if (tool->time_conv == NULL) 429 if (tool->time_conv == NULL)
430 tool->time_conv = process_event_op2_stub; 430 tool->time_conv = process_event_op2_stub;
431 if (tool->feature == NULL)
432 tool->feature = process_event_op2_stub;
431} 433}
432 434
433static void swap_sample_id_all(union perf_event *event, void *data) 435static void swap_sample_id_all(union perf_event *event, void *data)
@@ -1118,6 +1120,9 @@ static void dump_sample(struct perf_evsel *evsel, union perf_event *event,
1118 if (sample_type & PERF_SAMPLE_DATA_SRC) 1120 if (sample_type & PERF_SAMPLE_DATA_SRC)
1119 printf(" . data_src: 0x%"PRIx64"\n", sample->data_src); 1121 printf(" . data_src: 0x%"PRIx64"\n", sample->data_src);
1120 1122
1123 if (sample_type & PERF_SAMPLE_PHYS_ADDR)
1124 printf(" .. phys_addr: 0x%"PRIx64"\n", sample->phys_addr);
1125
1121 if (sample_type & PERF_SAMPLE_TRANSACTION) 1126 if (sample_type & PERF_SAMPLE_TRANSACTION)
1122 printf("... transaction: %" PRIx64 "\n", sample->transaction); 1127 printf("... transaction: %" PRIx64 "\n", sample->transaction);
1123 1128
@@ -1125,6 +1130,30 @@ static void dump_sample(struct perf_evsel *evsel, union perf_event *event,
1125 sample_read__printf(sample, evsel->attr.read_format); 1130 sample_read__printf(sample, evsel->attr.read_format);
1126} 1131}
1127 1132
1133static void dump_read(struct perf_evsel *evsel, union perf_event *event)
1134{
1135 struct read_event *read_event = &event->read;
1136 u64 read_format;
1137
1138 if (!dump_trace)
1139 return;
1140
1141 printf(": %d %d %s %" PRIu64 "\n", event->read.pid, event->read.tid,
1142 evsel ? perf_evsel__name(evsel) : "FAIL",
1143 event->read.value);
1144
1145 read_format = evsel->attr.read_format;
1146
1147 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED)
1148 printf("... time enabled : %" PRIu64 "\n", read_event->time_enabled);
1149
1150 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING)
1151 printf("... time running : %" PRIu64 "\n", read_event->time_running);
1152
1153 if (read_format & PERF_FORMAT_ID)
1154 printf("... id : %" PRIu64 "\n", read_event->id);
1155}
1156
1128static struct machine *machines__find_for_cpumode(struct machines *machines, 1157static struct machine *machines__find_for_cpumode(struct machines *machines,
1129 union perf_event *event, 1158 union perf_event *event,
1130 struct perf_sample *sample) 1159 struct perf_sample *sample)
@@ -1269,6 +1298,7 @@ static int machines__deliver_event(struct machines *machines,
1269 evlist->stats.total_lost_samples += event->lost_samples.lost; 1298 evlist->stats.total_lost_samples += event->lost_samples.lost;
1270 return tool->lost_samples(tool, event, sample, machine); 1299 return tool->lost_samples(tool, event, sample, machine);
1271 case PERF_RECORD_READ: 1300 case PERF_RECORD_READ:
1301 dump_read(evsel, event);
1272 return tool->read(tool, event, sample, evsel, machine); 1302 return tool->read(tool, event, sample, evsel, machine);
1273 case PERF_RECORD_THROTTLE: 1303 case PERF_RECORD_THROTTLE:
1274 return tool->throttle(tool, event, sample, machine); 1304 return tool->throttle(tool, event, sample, machine);
@@ -1371,6 +1401,8 @@ static s64 perf_session__process_user_event(struct perf_session *session,
1371 case PERF_RECORD_TIME_CONV: 1401 case PERF_RECORD_TIME_CONV:
1372 session->time_conv = event->time_conv; 1402 session->time_conv = event->time_conv;
1373 return tool->time_conv(tool, event, session); 1403 return tool->time_conv(tool, event, session);
1404 case PERF_RECORD_HEADER_FEATURE:
1405 return tool->feature(tool, event, session);
1374 default: 1406 default:
1375 return -EINVAL; 1407 return -EINVAL;
1376 } 1408 }
diff --git a/tools/perf/util/setns.c b/tools/perf/util/setns.c
new file mode 100644
index 000000000000..ce8fc290fce8
--- /dev/null
+++ b/tools/perf/util/setns.c
@@ -0,0 +1,8 @@
1#include "util.h"
2#include <unistd.h>
3#include <sys/syscall.h>
4
5int setns(int fd, int nstype)
6{
7 return syscall(__NR_setns, fd, nstype);
8}
diff --git a/tools/perf/util/smt.c b/tools/perf/util/smt.c
new file mode 100644
index 000000000000..453f6f6f29f3
--- /dev/null
+++ b/tools/perf/util/smt.c
@@ -0,0 +1,44 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <unistd.h>
4#include <linux/bitops.h>
5#include "api/fs/fs.h"
6#include "smt.h"
7
8int smt_on(void)
9{
10 static bool cached;
11 static int cached_result;
12 int cpu;
13 int ncpu;
14
15 if (cached)
16 return cached_result;
17
18 ncpu = sysconf(_SC_NPROCESSORS_CONF);
19 for (cpu = 0; cpu < ncpu; cpu++) {
20 unsigned long long siblings;
21 char *str;
22 size_t strlen;
23 char fn[256];
24
25 snprintf(fn, sizeof fn,
26 "devices/system/cpu/cpu%d/topology/thread_siblings",
27 cpu);
28 if (sysfs__read_str(fn, &str, &strlen) < 0)
29 continue;
30 /* Entry is hex, but does not have 0x, so need custom parser */
31 siblings = strtoull(str, NULL, 16);
32 free(str);
33 if (hweight64(siblings) > 1) {
34 cached_result = 1;
35 cached = true;
36 break;
37 }
38 }
39 if (!cached) {
40 cached_result = 0;
41 cached = true;
42 }
43 return cached_result;
44}
diff --git a/tools/perf/util/smt.h b/tools/perf/util/smt.h
new file mode 100644
index 000000000000..b8414b7bcbc8
--- /dev/null
+++ b/tools/perf/util/smt.h
@@ -0,0 +1,6 @@
1#ifndef SMT_H
2#define SMT_H 1
3
4int smt_on(void);
5
6#endif
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 8b327c955a4f..eb3ab902a1c0 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1316,6 +1316,47 @@ struct sort_entry sort_mem_dcacheline = {
1316}; 1316};
1317 1317
1318static int64_t 1318static int64_t
1319sort__phys_daddr_cmp(struct hist_entry *left, struct hist_entry *right)
1320{
1321 uint64_t l = 0, r = 0;
1322
1323 if (left->mem_info)
1324 l = left->mem_info->daddr.phys_addr;
1325 if (right->mem_info)
1326 r = right->mem_info->daddr.phys_addr;
1327
1328 return (int64_t)(r - l);
1329}
1330
1331static int hist_entry__phys_daddr_snprintf(struct hist_entry *he, char *bf,
1332 size_t size, unsigned int width)
1333{
1334 uint64_t addr = 0;
1335 size_t ret = 0;
1336 size_t len = BITS_PER_LONG / 4;
1337
1338 addr = he->mem_info->daddr.phys_addr;
1339
1340 ret += repsep_snprintf(bf + ret, size - ret, "[%c] ", he->level);
1341
1342 ret += repsep_snprintf(bf + ret, size - ret, "%-#.*llx", len, addr);
1343
1344 ret += repsep_snprintf(bf + ret, size - ret, "%-*s", width - ret, "");
1345
1346 if (ret > width)
1347 bf[width] = '\0';
1348
1349 return width;
1350}
1351
1352struct sort_entry sort_mem_phys_daddr = {
1353 .se_header = "Data Physical Address",
1354 .se_cmp = sort__phys_daddr_cmp,
1355 .se_snprintf = hist_entry__phys_daddr_snprintf,
1356 .se_width_idx = HISTC_MEM_PHYS_DADDR,
1357};
1358
1359static int64_t
1319sort__abort_cmp(struct hist_entry *left, struct hist_entry *right) 1360sort__abort_cmp(struct hist_entry *left, struct hist_entry *right)
1320{ 1361{
1321 if (!left->branch_info || !right->branch_info) 1362 if (!left->branch_info || !right->branch_info)
@@ -1547,6 +1588,7 @@ static struct sort_dimension memory_sort_dimensions[] = {
1547 DIM(SORT_MEM_LVL, "mem", sort_mem_lvl), 1588 DIM(SORT_MEM_LVL, "mem", sort_mem_lvl),
1548 DIM(SORT_MEM_SNOOP, "snoop", sort_mem_snoop), 1589 DIM(SORT_MEM_SNOOP, "snoop", sort_mem_snoop),
1549 DIM(SORT_MEM_DCACHELINE, "dcacheline", sort_mem_dcacheline), 1590 DIM(SORT_MEM_DCACHELINE, "dcacheline", sort_mem_dcacheline),
1591 DIM(SORT_MEM_PHYS_DADDR, "phys_daddr", sort_mem_phys_daddr),
1550}; 1592};
1551 1593
1552#undef DIM 1594#undef DIM
@@ -2563,7 +2605,7 @@ static const char *get_default_sort_order(struct perf_evlist *evlist)
2563 2605
2564 BUG_ON(sort__mode >= ARRAY_SIZE(default_sort_orders)); 2606 BUG_ON(sort__mode >= ARRAY_SIZE(default_sort_orders));
2565 2607
2566 if (evlist == NULL) 2608 if (evlist == NULL || perf_evlist__empty(evlist))
2567 goto out_no_evlist; 2609 goto out_no_evlist;
2568 2610
2569 evlist__for_each_entry(evlist, evsel) { 2611 evlist__for_each_entry(evlist, evsel) {
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index b7c75597e18f..f36dc4980a6c 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -245,6 +245,7 @@ enum sort_type {
245 SORT_MEM_SNOOP, 245 SORT_MEM_SNOOP,
246 SORT_MEM_DCACHELINE, 246 SORT_MEM_DCACHELINE,
247 SORT_MEM_IADDR_SYMBOL, 247 SORT_MEM_IADDR_SYMBOL,
248 SORT_MEM_PHYS_DADDR,
248}; 249};
249 250
250/* 251/*
diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
index ebc88a74e67b..ed8e8d2de942 100644
--- a/tools/perf/util/srcline.c
+++ b/tools/perf/util/srcline.c
@@ -155,6 +155,9 @@ static void find_address_in_section(bfd *abfd, asection *section, void *data)
155 a2l->found = bfd_find_nearest_line(abfd, section, a2l->syms, pc - vma, 155 a2l->found = bfd_find_nearest_line(abfd, section, a2l->syms, pc - vma,
156 &a2l->filename, &a2l->funcname, 156 &a2l->filename, &a2l->funcname,
157 &a2l->line); 157 &a2l->line);
158
159 if (a2l->filename && !strlen(a2l->filename))
160 a2l->filename = NULL;
158} 161}
159 162
160static struct a2l_data *addr2line_init(const char *path) 163static struct a2l_data *addr2line_init(const char *path)
@@ -248,6 +251,9 @@ static int addr2line(const char *dso_name, u64 addr,
248 &a2l->funcname, &a2l->line) && 251 &a2l->funcname, &a2l->line) &&
249 cnt++ < MAX_INLINE_NEST) { 252 cnt++ < MAX_INLINE_NEST) {
250 253
254 if (a2l->filename && !strlen(a2l->filename))
255 a2l->filename = NULL;
256
251 if (node != NULL) { 257 if (node != NULL) {
252 if (inline_list__append_dso_a2l(dso, node)) 258 if (inline_list__append_dso_a2l(dso, node))
253 return 0; 259 return 0;
diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
index 719d6cb86952..a04cf56d3517 100644
--- a/tools/perf/util/stat-shadow.c
+++ b/tools/perf/util/stat-shadow.c
@@ -70,7 +70,11 @@ static int saved_value_cmp(struct rb_node *rb_node, const void *entry)
70 return a->ctx - b->ctx; 70 return a->ctx - b->ctx;
71 if (a->cpu != b->cpu) 71 if (a->cpu != b->cpu)
72 return a->cpu - b->cpu; 72 return a->cpu - b->cpu;
73 return a->evsel - b->evsel; 73 if (a->evsel == b->evsel)
74 return 0;
75 if ((char *)a->evsel < (char *)b->evsel)
76 return -1;
77 return +1;
74} 78}
75 79
76static struct rb_node *saved_value_new(struct rblist *rblist __maybe_unused, 80static struct rb_node *saved_value_new(struct rblist *rblist __maybe_unused,
diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
index 53b9a994a3dc..35e9848734d6 100644
--- a/tools/perf/util/stat.c
+++ b/tools/perf/util/stat.c
@@ -128,6 +128,10 @@ static int perf_evsel__alloc_stat_priv(struct perf_evsel *evsel)
128 128
129static void perf_evsel__free_stat_priv(struct perf_evsel *evsel) 129static void perf_evsel__free_stat_priv(struct perf_evsel *evsel)
130{ 130{
131 struct perf_stat_evsel *ps = evsel->priv;
132
133 if (ps)
134 free(ps->group_data);
131 zfree(&evsel->priv); 135 zfree(&evsel->priv);
132} 136}
133 137
diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h
index 7522bf10b03e..eacaf958e19d 100644
--- a/tools/perf/util/stat.h
+++ b/tools/perf/util/stat.h
@@ -28,8 +28,9 @@ enum perf_stat_evsel_id {
28}; 28};
29 29
30struct perf_stat_evsel { 30struct perf_stat_evsel {
31 struct stats res_stats[3]; 31 struct stats res_stats[3];
32 enum perf_stat_evsel_id id; 32 enum perf_stat_evsel_id id;
33 u64 *group_data;
33}; 34};
34 35
35enum aggr_mode { 36enum aggr_mode {
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 502505cf236a..9cf781f0d8a2 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -259,7 +259,7 @@ int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss, struct map *
259{ 259{
260 uint32_t nr_rel_entries, idx; 260 uint32_t nr_rel_entries, idx;
261 GElf_Sym sym; 261 GElf_Sym sym;
262 u64 plt_offset; 262 u64 plt_offset, plt_header_size, plt_entry_size;
263 GElf_Shdr shdr_plt; 263 GElf_Shdr shdr_plt;
264 struct symbol *f; 264 struct symbol *f;
265 GElf_Shdr shdr_rel_plt, shdr_dynsym; 265 GElf_Shdr shdr_rel_plt, shdr_dynsym;
@@ -326,6 +326,23 @@ int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss, struct map *
326 326
327 nr_rel_entries = shdr_rel_plt.sh_size / shdr_rel_plt.sh_entsize; 327 nr_rel_entries = shdr_rel_plt.sh_size / shdr_rel_plt.sh_entsize;
328 plt_offset = shdr_plt.sh_offset; 328 plt_offset = shdr_plt.sh_offset;
329 switch (ehdr.e_machine) {
330 case EM_ARM:
331 plt_header_size = 20;
332 plt_entry_size = 12;
333 break;
334
335 case EM_AARCH64:
336 plt_header_size = 32;
337 plt_entry_size = 16;
338 break;
339
340 default: /* FIXME: s390/alpha/mips/parisc/poperpc/sh/sparc/xtensa need to be checked */
341 plt_header_size = shdr_plt.sh_entsize;
342 plt_entry_size = shdr_plt.sh_entsize;
343 break;
344 }
345 plt_offset += plt_header_size;
329 346
330 if (shdr_rel_plt.sh_type == SHT_RELA) { 347 if (shdr_rel_plt.sh_type == SHT_RELA) {
331 GElf_Rela pos_mem, *pos; 348 GElf_Rela pos_mem, *pos;
@@ -335,7 +352,6 @@ int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss, struct map *
335 const char *elf_name = NULL; 352 const char *elf_name = NULL;
336 char *demangled = NULL; 353 char *demangled = NULL;
337 symidx = GELF_R_SYM(pos->r_info); 354 symidx = GELF_R_SYM(pos->r_info);
338 plt_offset += shdr_plt.sh_entsize;
339 gelf_getsym(syms, symidx, &sym); 355 gelf_getsym(syms, symidx, &sym);
340 356
341 elf_name = elf_sym__name(&sym, symstrs); 357 elf_name = elf_sym__name(&sym, symstrs);
@@ -346,11 +362,12 @@ int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss, struct map *
346 "%s@plt", elf_name); 362 "%s@plt", elf_name);
347 free(demangled); 363 free(demangled);
348 364
349 f = symbol__new(plt_offset, shdr_plt.sh_entsize, 365 f = symbol__new(plt_offset, plt_entry_size,
350 STB_GLOBAL, sympltname); 366 STB_GLOBAL, sympltname);
351 if (!f) 367 if (!f)
352 goto out_elf_end; 368 goto out_elf_end;
353 369
370 plt_offset += plt_entry_size;
354 symbols__insert(&dso->symbols[map->type], f); 371 symbols__insert(&dso->symbols[map->type], f);
355 ++nr; 372 ++nr;
356 } 373 }
@@ -361,7 +378,6 @@ int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss, struct map *
361 const char *elf_name = NULL; 378 const char *elf_name = NULL;
362 char *demangled = NULL; 379 char *demangled = NULL;
363 symidx = GELF_R_SYM(pos->r_info); 380 symidx = GELF_R_SYM(pos->r_info);
364 plt_offset += shdr_plt.sh_entsize;
365 gelf_getsym(syms, symidx, &sym); 381 gelf_getsym(syms, symidx, &sym);
366 382
367 elf_name = elf_sym__name(&sym, symstrs); 383 elf_name = elf_sym__name(&sym, symstrs);
@@ -372,11 +388,12 @@ int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss, struct map *
372 "%s@plt", elf_name); 388 "%s@plt", elf_name);
373 free(demangled); 389 free(demangled);
374 390
375 f = symbol__new(plt_offset, shdr_plt.sh_entsize, 391 f = symbol__new(plt_offset, plt_entry_size,
376 STB_GLOBAL, sympltname); 392 STB_GLOBAL, sympltname);
377 if (!f) 393 if (!f)
378 goto out_elf_end; 394 goto out_elf_end;
379 395
396 plt_offset += plt_entry_size;
380 symbols__insert(&dso->symbols[map->type], f); 397 symbols__insert(&dso->symbols[map->type], f);
381 ++nr; 398 ++nr;
382 } 399 }
@@ -391,7 +408,7 @@ out_elf_end:
391 return 0; 408 return 0;
392} 409}
393 410
394char *dso__demangle_sym(struct dso *dso, int kmodule, char *elf_name) 411char *dso__demangle_sym(struct dso *dso, int kmodule, const char *elf_name)
395{ 412{
396 return demangle_sym(dso, kmodule, elf_name); 413 return demangle_sym(dso, kmodule, elf_name);
397} 414}
@@ -1442,7 +1459,7 @@ static int kcore_copy__parse_kallsyms(struct kcore_copy_info *kci,
1442 1459
1443static int kcore_copy__process_modules(void *arg, 1460static int kcore_copy__process_modules(void *arg,
1444 const char *name __maybe_unused, 1461 const char *name __maybe_unused,
1445 u64 start) 1462 u64 start, u64 size __maybe_unused)
1446{ 1463{
1447 struct kcore_copy_info *kci = arg; 1464 struct kcore_copy_info *kci = arg;
1448 1465
diff --git a/tools/perf/util/symbol-minimal.c b/tools/perf/util/symbol-minimal.c
index 40bf5d4c0bfd..1a5aa35b0100 100644
--- a/tools/perf/util/symbol-minimal.c
+++ b/tools/perf/util/symbol-minimal.c
@@ -377,7 +377,7 @@ void symbol__elf_init(void)
377 377
378char *dso__demangle_sym(struct dso *dso __maybe_unused, 378char *dso__demangle_sym(struct dso *dso __maybe_unused,
379 int kmodule __maybe_unused, 379 int kmodule __maybe_unused,
380 char *elf_name __maybe_unused) 380 const char *elf_name __maybe_unused)
381{ 381{
382 return NULL; 382 return NULL;
383} 383}
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index e7a98dbd2aed..5909ee4c7ade 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -18,6 +18,7 @@
18#include "symbol.h" 18#include "symbol.h"
19#include "strlist.h" 19#include "strlist.h"
20#include "intlist.h" 20#include "intlist.h"
21#include "namespaces.h"
21#include "header.h" 22#include "header.h"
22#include "path.h" 23#include "path.h"
23#include "sane_ctype.h" 24#include "sane_ctype.h"
@@ -52,6 +53,7 @@ static enum dso_binary_type binary_type_symtab[] = {
52 DSO_BINARY_TYPE__JAVA_JIT, 53 DSO_BINARY_TYPE__JAVA_JIT,
53 DSO_BINARY_TYPE__DEBUGLINK, 54 DSO_BINARY_TYPE__DEBUGLINK,
54 DSO_BINARY_TYPE__BUILD_ID_CACHE, 55 DSO_BINARY_TYPE__BUILD_ID_CACHE,
56 DSO_BINARY_TYPE__BUILD_ID_CACHE_DEBUGINFO,
55 DSO_BINARY_TYPE__FEDORA_DEBUGINFO, 57 DSO_BINARY_TYPE__FEDORA_DEBUGINFO,
56 DSO_BINARY_TYPE__UBUNTU_DEBUGINFO, 58 DSO_BINARY_TYPE__UBUNTU_DEBUGINFO,
57 DSO_BINARY_TYPE__BUILDID_DEBUGINFO, 59 DSO_BINARY_TYPE__BUILDID_DEBUGINFO,
@@ -231,7 +233,8 @@ void __map_groups__fixup_end(struct map_groups *mg, enum map_type type)
231 goto out_unlock; 233 goto out_unlock;
232 234
233 for (next = map__next(curr); next; next = map__next(curr)) { 235 for (next = map__next(curr); next; next = map__next(curr)) {
234 curr->end = next->start; 236 if (!curr->end)
237 curr->end = next->start;
235 curr = next; 238 curr = next;
236 } 239 }
237 240
@@ -239,7 +242,8 @@ void __map_groups__fixup_end(struct map_groups *mg, enum map_type type)
239 * We still haven't the actual symbols, so guess the 242 * We still haven't the actual symbols, so guess the
240 * last map final address. 243 * last map final address.
241 */ 244 */
242 curr->end = ~0ULL; 245 if (!curr->end)
246 curr->end = ~0ULL;
243 247
244out_unlock: 248out_unlock:
245 pthread_rwlock_unlock(&maps->lock); 249 pthread_rwlock_unlock(&maps->lock);
@@ -550,7 +554,7 @@ void dso__sort_by_name(struct dso *dso, enum map_type type)
550 554
551int modules__parse(const char *filename, void *arg, 555int modules__parse(const char *filename, void *arg,
552 int (*process_module)(void *arg, const char *name, 556 int (*process_module)(void *arg, const char *name,
553 u64 start)) 557 u64 start, u64 size))
554{ 558{
555 char *line = NULL; 559 char *line = NULL;
556 size_t n; 560 size_t n;
@@ -563,8 +567,8 @@ int modules__parse(const char *filename, void *arg,
563 567
564 while (1) { 568 while (1) {
565 char name[PATH_MAX]; 569 char name[PATH_MAX];
566 u64 start; 570 u64 start, size;
567 char *sep; 571 char *sep, *endptr;
568 ssize_t line_len; 572 ssize_t line_len;
569 573
570 line_len = getline(&line, &n, file); 574 line_len = getline(&line, &n, file);
@@ -596,7 +600,11 @@ int modules__parse(const char *filename, void *arg,
596 600
597 scnprintf(name, sizeof(name), "[%s]", line); 601 scnprintf(name, sizeof(name), "[%s]", line);
598 602
599 err = process_module(arg, name, start); 603 size = strtoul(sep + 1, &endptr, 0);
604 if (*endptr != ' ' && *endptr != '\t')
605 continue;
606
607 err = process_module(arg, name, start, size);
600 if (err) 608 if (err)
601 break; 609 break;
602 } 610 }
@@ -943,7 +951,8 @@ static struct module_info *find_module(const char *name,
943 return NULL; 951 return NULL;
944} 952}
945 953
946static int __read_proc_modules(void *arg, const char *name, u64 start) 954static int __read_proc_modules(void *arg, const char *name, u64 start,
955 u64 size __maybe_unused)
947{ 956{
948 struct rb_root *modules = arg; 957 struct rb_root *modules = arg;
949 struct module_info *mi; 958 struct module_info *mi;
@@ -1325,14 +1334,15 @@ int dso__load_kallsyms(struct dso *dso, const char *filename,
1325 return __dso__load_kallsyms(dso, filename, map, false); 1334 return __dso__load_kallsyms(dso, filename, map, false);
1326} 1335}
1327 1336
1328static int dso__load_perf_map(struct dso *dso, struct map *map) 1337static int dso__load_perf_map(const char *map_path, struct dso *dso,
1338 struct map *map)
1329{ 1339{
1330 char *line = NULL; 1340 char *line = NULL;
1331 size_t n; 1341 size_t n;
1332 FILE *file; 1342 FILE *file;
1333 int nr_syms = 0; 1343 int nr_syms = 0;
1334 1344
1335 file = fopen(dso->long_name, "r"); 1345 file = fopen(map_path, "r");
1336 if (file == NULL) 1346 if (file == NULL)
1337 goto out_failure; 1347 goto out_failure;
1338 1348
@@ -1416,6 +1426,7 @@ static bool dso__is_compatible_symtab_type(struct dso *dso, bool kmod,
1416 return kmod && dso->symtab_type == type; 1426 return kmod && dso->symtab_type == type;
1417 1427
1418 case DSO_BINARY_TYPE__BUILD_ID_CACHE: 1428 case DSO_BINARY_TYPE__BUILD_ID_CACHE:
1429 case DSO_BINARY_TYPE__BUILD_ID_CACHE_DEBUGINFO:
1419 return true; 1430 return true;
1420 1431
1421 case DSO_BINARY_TYPE__NOT_FOUND: 1432 case DSO_BINARY_TYPE__NOT_FOUND:
@@ -1424,6 +1435,44 @@ static bool dso__is_compatible_symtab_type(struct dso *dso, bool kmod,
1424 } 1435 }
1425} 1436}
1426 1437
1438/* Checks for the existence of the perf-<pid>.map file in two different
1439 * locations. First, if the process is a separate mount namespace, check in
1440 * that namespace using the pid of the innermost pid namespace. If's not in a
1441 * namespace, or the file can't be found there, try in the mount namespace of
1442 * the tracing process using our view of its pid.
1443 */
1444static int dso__find_perf_map(char *filebuf, size_t bufsz,
1445 struct nsinfo **nsip)
1446{
1447 struct nscookie nsc;
1448 struct nsinfo *nsi;
1449 struct nsinfo *nnsi;
1450 int rc = -1;
1451
1452 nsi = *nsip;
1453
1454 if (nsi->need_setns) {
1455 snprintf(filebuf, bufsz, "/tmp/perf-%d.map", nsi->nstgid);
1456 nsinfo__mountns_enter(nsi, &nsc);
1457 rc = access(filebuf, R_OK);
1458 nsinfo__mountns_exit(&nsc);
1459 if (rc == 0)
1460 return rc;
1461 }
1462
1463 nnsi = nsinfo__copy(nsi);
1464 if (nnsi) {
1465 nsinfo__put(nsi);
1466
1467 nnsi->need_setns = false;
1468 snprintf(filebuf, bufsz, "/tmp/perf-%d.map", nnsi->tgid);
1469 *nsip = nnsi;
1470 rc = 0;
1471 }
1472
1473 return rc;
1474}
1475
1427int dso__load(struct dso *dso, struct map *map) 1476int dso__load(struct dso *dso, struct map *map)
1428{ 1477{
1429 char *name; 1478 char *name;
@@ -1435,8 +1484,21 @@ int dso__load(struct dso *dso, struct map *map)
1435 struct symsrc ss_[2]; 1484 struct symsrc ss_[2];
1436 struct symsrc *syms_ss = NULL, *runtime_ss = NULL; 1485 struct symsrc *syms_ss = NULL, *runtime_ss = NULL;
1437 bool kmod; 1486 bool kmod;
1487 bool perfmap;
1438 unsigned char build_id[BUILD_ID_SIZE]; 1488 unsigned char build_id[BUILD_ID_SIZE];
1489 struct nscookie nsc;
1490 char newmapname[PATH_MAX];
1491 const char *map_path = dso->long_name;
1492
1493 perfmap = strncmp(dso->name, "/tmp/perf-", 10) == 0;
1494 if (perfmap) {
1495 if (dso->nsinfo && (dso__find_perf_map(newmapname,
1496 sizeof(newmapname), &dso->nsinfo) == 0)) {
1497 map_path = newmapname;
1498 }
1499 }
1439 1500
1501 nsinfo__mountns_enter(dso->nsinfo, &nsc);
1440 pthread_mutex_lock(&dso->lock); 1502 pthread_mutex_lock(&dso->lock);
1441 1503
1442 /* check again under the dso->lock */ 1504 /* check again under the dso->lock */
@@ -1461,19 +1523,19 @@ int dso__load(struct dso *dso, struct map *map)
1461 1523
1462 dso->adjust_symbols = 0; 1524 dso->adjust_symbols = 0;
1463 1525
1464 if (strncmp(dso->name, "/tmp/perf-", 10) == 0) { 1526 if (perfmap) {
1465 struct stat st; 1527 struct stat st;
1466 1528
1467 if (lstat(dso->name, &st) < 0) 1529 if (lstat(map_path, &st) < 0)
1468 goto out; 1530 goto out;
1469 1531
1470 if (!symbol_conf.force && st.st_uid && (st.st_uid != geteuid())) { 1532 if (!symbol_conf.force && st.st_uid && (st.st_uid != geteuid())) {
1471 pr_warning("File %s not owned by current user or root, " 1533 pr_warning("File %s not owned by current user or root, "
1472 "ignoring it (use -f to override).\n", dso->name); 1534 "ignoring it (use -f to override).\n", map_path);
1473 goto out; 1535 goto out;
1474 } 1536 }
1475 1537
1476 ret = dso__load_perf_map(dso, map); 1538 ret = dso__load_perf_map(map_path, dso, map);
1477 dso->symtab_type = ret > 0 ? DSO_BINARY_TYPE__JAVA_JIT : 1539 dso->symtab_type = ret > 0 ? DSO_BINARY_TYPE__JAVA_JIT :
1478 DSO_BINARY_TYPE__NOT_FOUND; 1540 DSO_BINARY_TYPE__NOT_FOUND;
1479 goto out; 1541 goto out;
@@ -1511,9 +1573,15 @@ int dso__load(struct dso *dso, struct map *map)
1511 for (i = 0; i < DSO_BINARY_TYPE__SYMTAB_CNT; i++) { 1573 for (i = 0; i < DSO_BINARY_TYPE__SYMTAB_CNT; i++) {
1512 struct symsrc *ss = &ss_[ss_pos]; 1574 struct symsrc *ss = &ss_[ss_pos];
1513 bool next_slot = false; 1575 bool next_slot = false;
1576 bool is_reg;
1577 bool nsexit;
1578 int sirc;
1514 1579
1515 enum dso_binary_type symtab_type = binary_type_symtab[i]; 1580 enum dso_binary_type symtab_type = binary_type_symtab[i];
1516 1581
1582 nsexit = (symtab_type == DSO_BINARY_TYPE__BUILD_ID_CACHE ||
1583 symtab_type == DSO_BINARY_TYPE__BUILD_ID_CACHE_DEBUGINFO);
1584
1517 if (!dso__is_compatible_symtab_type(dso, kmod, symtab_type)) 1585 if (!dso__is_compatible_symtab_type(dso, kmod, symtab_type))
1518 continue; 1586 continue;
1519 1587
@@ -1521,12 +1589,20 @@ int dso__load(struct dso *dso, struct map *map)
1521 root_dir, name, PATH_MAX)) 1589 root_dir, name, PATH_MAX))
1522 continue; 1590 continue;
1523 1591
1524 if (!is_regular_file(name)) 1592 if (nsexit)
1525 continue; 1593 nsinfo__mountns_exit(&nsc);
1594
1595 is_reg = is_regular_file(name);
1596 sirc = symsrc__init(ss, dso, name, symtab_type);
1526 1597
1527 /* Name is now the name of the next image to try */ 1598 if (nsexit)
1528 if (symsrc__init(ss, dso, name, symtab_type) < 0) 1599 nsinfo__mountns_enter(dso->nsinfo, &nsc);
1600
1601 if (!is_reg || sirc < 0) {
1602 if (sirc >= 0)
1603 symsrc__destroy(ss);
1529 continue; 1604 continue;
1605 }
1530 1606
1531 if (!syms_ss && symsrc__has_symtab(ss)) { 1607 if (!syms_ss && symsrc__has_symtab(ss)) {
1532 syms_ss = ss; 1608 syms_ss = ss;
@@ -1584,6 +1660,7 @@ out_free:
1584out: 1660out:
1585 dso__set_loaded(dso, map->type); 1661 dso__set_loaded(dso, map->type);
1586 pthread_mutex_unlock(&dso->lock); 1662 pthread_mutex_unlock(&dso->lock);
1663 nsinfo__mountns_exit(&nsc);
1587 1664
1588 return ret; 1665 return ret;
1589} 1666}
@@ -1660,7 +1737,7 @@ int dso__load_vmlinux_path(struct dso *dso, struct map *map)
1660 } 1737 }
1661 1738
1662 if (!symbol_conf.ignore_vmlinux_buildid) 1739 if (!symbol_conf.ignore_vmlinux_buildid)
1663 filename = dso__build_id_filename(dso, NULL, 0); 1740 filename = dso__build_id_filename(dso, NULL, 0, false);
1664 if (filename != NULL) { 1741 if (filename != NULL) {
1665 err = dso__load_vmlinux(dso, map, filename, true); 1742 err = dso__load_vmlinux(dso, map, filename, true);
1666 if (err > 0) 1743 if (err > 0)
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 41ebba9a2eb2..aad99e7e179b 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -186,6 +186,7 @@ struct addr_map_symbol {
186 struct symbol *sym; 186 struct symbol *sym;
187 u64 addr; 187 u64 addr;
188 u64 al_addr; 188 u64 al_addr;
189 u64 phys_addr;
189}; 190};
190 191
191struct branch_info { 192struct branch_info {
@@ -273,7 +274,7 @@ int filename__read_build_id(const char *filename, void *bf, size_t size);
273int sysfs__read_build_id(const char *filename, void *bf, size_t size); 274int sysfs__read_build_id(const char *filename, void *bf, size_t size);
274int modules__parse(const char *filename, void *arg, 275int modules__parse(const char *filename, void *arg,
275 int (*process_module)(void *arg, const char *name, 276 int (*process_module)(void *arg, const char *name,
276 u64 start)); 277 u64 start, u64 size));
277int filename__read_debuglink(const char *filename, char *debuglink, 278int filename__read_debuglink(const char *filename, char *debuglink,
278 size_t size); 279 size_t size);
279 280
@@ -306,7 +307,7 @@ int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss,
306int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss, 307int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss,
307 struct map *map); 308 struct map *map);
308 309
309char *dso__demangle_sym(struct dso *dso, int kmodule, char *elf_name); 310char *dso__demangle_sym(struct dso *dso, int kmodule, const char *elf_name);
310 311
311void __symbols__insert(struct rb_root *symbols, struct symbol *sym, bool kernel); 312void __symbols__insert(struct rb_root *symbols, struct symbol *sym, bool kernel);
312void symbols__insert(struct rb_root *symbols, struct symbol *sym); 313void symbols__insert(struct rb_root *symbols, struct symbol *sym);
diff --git a/tools/perf/util/syscalltbl.c b/tools/perf/util/syscalltbl.c
index bbb4c1957578..6eea7cff3d4e 100644
--- a/tools/perf/util/syscalltbl.c
+++ b/tools/perf/util/syscalltbl.c
@@ -15,10 +15,11 @@
15 15
16#include "syscalltbl.h" 16#include "syscalltbl.h"
17#include <stdlib.h> 17#include <stdlib.h>
18#include <linux/compiler.h>
18 19
19#ifdef HAVE_SYSCALL_TABLE 20#ifdef HAVE_SYSCALL_TABLE
20#include <linux/compiler.h>
21#include <string.h> 21#include <string.h>
22#include "string2.h"
22#include "util.h" 23#include "util.h"
23 24
24#if defined(__x86_64__) 25#if defined(__x86_64__)
@@ -105,6 +106,27 @@ int syscalltbl__id(struct syscalltbl *tbl, const char *name)
105 return sc ? sc->id : -1; 106 return sc ? sc->id : -1;
106} 107}
107 108
109int syscalltbl__strglobmatch_next(struct syscalltbl *tbl, const char *syscall_glob, int *idx)
110{
111 int i;
112 struct syscall *syscalls = tbl->syscalls.entries;
113
114 for (i = *idx + 1; i < tbl->syscalls.nr_entries; ++i) {
115 if (strglobmatch(syscalls[i].name, syscall_glob)) {
116 *idx = i;
117 return syscalls[i].id;
118 }
119 }
120
121 return -1;
122}
123
124int syscalltbl__strglobmatch_first(struct syscalltbl *tbl, const char *syscall_glob, int *idx)
125{
126 *idx = -1;
127 return syscalltbl__strglobmatch_next(tbl, syscall_glob, idx);
128}
129
108#else /* HAVE_SYSCALL_TABLE */ 130#else /* HAVE_SYSCALL_TABLE */
109 131
110#include <libaudit.h> 132#include <libaudit.h>
@@ -131,4 +153,15 @@ int syscalltbl__id(struct syscalltbl *tbl, const char *name)
131{ 153{
132 return audit_name_to_syscall(name, tbl->audit_machine); 154 return audit_name_to_syscall(name, tbl->audit_machine);
133} 155}
156
157int syscalltbl__strglobmatch_next(struct syscalltbl *tbl __maybe_unused,
158 const char *syscall_glob __maybe_unused, int *idx __maybe_unused)
159{
160 return -1;
161}
162
163int syscalltbl__strglobmatch_first(struct syscalltbl *tbl, const char *syscall_glob, int *idx)
164{
165 return syscalltbl__strglobmatch_next(tbl, syscall_glob, idx);
166}
134#endif /* HAVE_SYSCALL_TABLE */ 167#endif /* HAVE_SYSCALL_TABLE */
diff --git a/tools/perf/util/syscalltbl.h b/tools/perf/util/syscalltbl.h
index e2951510484f..e9fb8786da7c 100644
--- a/tools/perf/util/syscalltbl.h
+++ b/tools/perf/util/syscalltbl.h
@@ -17,4 +17,7 @@ void syscalltbl__delete(struct syscalltbl *tbl);
17const char *syscalltbl__name(const struct syscalltbl *tbl, int id); 17const char *syscalltbl__name(const struct syscalltbl *tbl, int id);
18int syscalltbl__id(struct syscalltbl *tbl, const char *name); 18int syscalltbl__id(struct syscalltbl *tbl, const char *name);
19 19
20int syscalltbl__strglobmatch_first(struct syscalltbl *tbl, const char *syscall_glob, int *idx);
21int syscalltbl__strglobmatch_next(struct syscalltbl *tbl, const char *syscall_glob, int *idx);
22
20#endif /* __PERF_SYSCALLTBL_H */ 23#endif /* __PERF_SYSCALLTBL_H */
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index 378c418ca0c1..aee9a42102ba 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -59,6 +59,8 @@ struct thread *thread__new(pid_t pid, pid_t tid)
59 list_add(&comm->list, &thread->comm_list); 59 list_add(&comm->list, &thread->comm_list);
60 refcount_set(&thread->refcnt, 1); 60 refcount_set(&thread->refcnt, 1);
61 RB_CLEAR_NODE(&thread->rb_node); 61 RB_CLEAR_NODE(&thread->rb_node);
62 /* Thread holds first ref to nsdata. */
63 thread->nsinfo = nsinfo__new(pid);
62 } 64 }
63 65
64 return thread; 66 return thread;
@@ -91,6 +93,7 @@ void thread__delete(struct thread *thread)
91 comm__free(comm); 93 comm__free(comm);
92 } 94 }
93 unwind__finish_access(thread); 95 unwind__finish_access(thread);
96 nsinfo__zput(thread->nsinfo);
94 97
95 free(thread); 98 free(thread);
96} 99}
diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h
index 4eb849e9098f..cb1a5dd5c2b9 100644
--- a/tools/perf/util/thread.h
+++ b/tools/perf/util/thread.h
@@ -34,6 +34,7 @@ struct thread {
34 34
35 void *priv; 35 void *priv;
36 struct thread_stack *ts; 36 struct thread_stack *ts;
37 struct nsinfo *nsinfo;
37#ifdef HAVE_LIBUNWIND_SUPPORT 38#ifdef HAVE_LIBUNWIND_SUPPORT
38 void *addr_space; 39 void *addr_space;
39 struct unwind_libunwind_ops *unwind_libunwind_ops; 40 struct unwind_libunwind_ops *unwind_libunwind_ops;
diff --git a/tools/perf/util/tool.h b/tools/perf/util/tool.h
index 829471a1c6d7..d549e50db397 100644
--- a/tools/perf/util/tool.h
+++ b/tools/perf/util/tool.h
@@ -34,6 +34,12 @@ typedef int (*event_oe)(struct perf_tool *tool, union perf_event *event,
34typedef s64 (*event_op3)(struct perf_tool *tool, union perf_event *event, 34typedef s64 (*event_op3)(struct perf_tool *tool, union perf_event *event,
35 struct perf_session *session); 35 struct perf_session *session);
36 36
37enum show_feature_header {
38 SHOW_FEAT_NO_HEADER = 0,
39 SHOW_FEAT_HEADER,
40 SHOW_FEAT_HEADER_FULL_INFO,
41};
42
37struct perf_tool { 43struct perf_tool {
38 event_sample sample, 44 event_sample sample,
39 read; 45 read;
@@ -63,11 +69,13 @@ struct perf_tool {
63 cpu_map, 69 cpu_map,
64 stat_config, 70 stat_config,
65 stat, 71 stat,
66 stat_round; 72 stat_round,
73 feature;
67 event_op3 auxtrace; 74 event_op3 auxtrace;
68 bool ordered_events; 75 bool ordered_events;
69 bool ordering_requires_timestamps; 76 bool ordering_requires_timestamps;
70 bool namespace_events; 77 bool namespace_events;
78 enum show_feature_header show_feat_hdr;
71}; 79};
72 80
73#endif /* __PERF_TOOL_H */ 81#endif /* __PERF_TOOL_H */
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 988111e0bab5..4c360daa4e24 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -143,13 +143,17 @@ out:
143 return list; 143 return list;
144} 144}
145 145
146static int slow_copyfile(const char *from, const char *to) 146static int slow_copyfile(const char *from, const char *to, struct nsinfo *nsi)
147{ 147{
148 int err = -1; 148 int err = -1;
149 char *line = NULL; 149 char *line = NULL;
150 size_t n; 150 size_t n;
151 FILE *from_fp = fopen(from, "r"), *to_fp; 151 FILE *from_fp, *to_fp;
152 struct nscookie nsc;
152 153
154 nsinfo__mountns_enter(nsi, &nsc);
155 from_fp = fopen(from, "r");
156 nsinfo__mountns_exit(&nsc);
153 if (from_fp == NULL) 157 if (from_fp == NULL)
154 goto out; 158 goto out;
155 159
@@ -198,15 +202,21 @@ int copyfile_offset(int ifd, loff_t off_in, int ofd, loff_t off_out, u64 size)
198 return size ? -1 : 0; 202 return size ? -1 : 0;
199} 203}
200 204
201int copyfile_mode(const char *from, const char *to, mode_t mode) 205static int copyfile_mode_ns(const char *from, const char *to, mode_t mode,
206 struct nsinfo *nsi)
202{ 207{
203 int fromfd, tofd; 208 int fromfd, tofd;
204 struct stat st; 209 struct stat st;
205 int err = -1; 210 int err;
206 char *tmp = NULL, *ptr = NULL; 211 char *tmp = NULL, *ptr = NULL;
212 struct nscookie nsc;
207 213
208 if (stat(from, &st)) 214 nsinfo__mountns_enter(nsi, &nsc);
215 err = stat(from, &st);
216 nsinfo__mountns_exit(&nsc);
217 if (err)
209 goto out; 218 goto out;
219 err = -1;
210 220
211 /* extra 'x' at the end is to reserve space for '.' */ 221 /* extra 'x' at the end is to reserve space for '.' */
212 if (asprintf(&tmp, "%s.XXXXXXx", to) < 0) { 222 if (asprintf(&tmp, "%s.XXXXXXx", to) < 0) {
@@ -227,11 +237,13 @@ int copyfile_mode(const char *from, const char *to, mode_t mode)
227 goto out_close_to; 237 goto out_close_to;
228 238
229 if (st.st_size == 0) { /* /proc? do it slowly... */ 239 if (st.st_size == 0) { /* /proc? do it slowly... */
230 err = slow_copyfile(from, tmp); 240 err = slow_copyfile(from, tmp, nsi);
231 goto out_close_to; 241 goto out_close_to;
232 } 242 }
233 243
244 nsinfo__mountns_enter(nsi, &nsc);
234 fromfd = open(from, O_RDONLY); 245 fromfd = open(from, O_RDONLY);
246 nsinfo__mountns_exit(&nsc);
235 if (fromfd < 0) 247 if (fromfd < 0)
236 goto out_close_to; 248 goto out_close_to;
237 249
@@ -248,6 +260,16 @@ out:
248 return err; 260 return err;
249} 261}
250 262
263int copyfile_ns(const char *from, const char *to, struct nsinfo *nsi)
264{
265 return copyfile_mode_ns(from, to, 0755, nsi);
266}
267
268int copyfile_mode(const char *from, const char *to, mode_t mode)
269{
270 return copyfile_mode_ns(from, to, mode, NULL);
271}
272
251int copyfile(const char *from, const char *to) 273int copyfile(const char *from, const char *to)
252{ 274{
253 return copyfile_mode(from, to, 0755); 275 return copyfile_mode(from, to, 0755);
@@ -259,6 +281,7 @@ static ssize_t ion(bool is_read, int fd, void *buf, size_t n)
259 size_t left = n; 281 size_t left = n;
260 282
261 while (left) { 283 while (left) {
284 /* buf must be treated as const if !is_read. */
262 ssize_t ret = is_read ? read(fd, buf, left) : 285 ssize_t ret = is_read ? read(fd, buf, left) :
263 write(fd, buf, left); 286 write(fd, buf, left);
264 287
@@ -286,9 +309,10 @@ ssize_t readn(int fd, void *buf, size_t n)
286/* 309/*
287 * Write exactly 'n' bytes or return an error. 310 * Write exactly 'n' bytes or return an error.
288 */ 311 */
289ssize_t writen(int fd, void *buf, size_t n) 312ssize_t writen(int fd, const void *buf, size_t n)
290{ 313{
291 return ion(false, fd, buf, n); 314 /* ion does not modify buf. */
315 return ion(false, fd, (void *)buf, n);
292} 316}
293 317
294size_t hex_width(u64 v) 318size_t hex_width(u64 v)
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 2c9e58a45310..b136c271125f 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -12,6 +12,7 @@
12#include <stdarg.h> 12#include <stdarg.h>
13#include <linux/compiler.h> 13#include <linux/compiler.h>
14#include <linux/types.h> 14#include <linux/types.h>
15#include "namespaces.h"
15 16
16/* General helper functions */ 17/* General helper functions */
17void usage(const char *err) __noreturn; 18void usage(const char *err) __noreturn;
@@ -33,10 +34,11 @@ struct strlist *lsdir(const char *name, bool (*filter)(const char *, struct dire
33bool lsdir_no_dot_filter(const char *name, struct dirent *d); 34bool lsdir_no_dot_filter(const char *name, struct dirent *d);
34int copyfile(const char *from, const char *to); 35int copyfile(const char *from, const char *to);
35int copyfile_mode(const char *from, const char *to, mode_t mode); 36int copyfile_mode(const char *from, const char *to, mode_t mode);
37int copyfile_ns(const char *from, const char *to, struct nsinfo *nsi);
36int copyfile_offset(int fromfd, loff_t from_ofs, int tofd, loff_t to_ofs, u64 size); 38int copyfile_offset(int fromfd, loff_t from_ofs, int tofd, loff_t to_ofs, u64 size);
37 39
38ssize_t readn(int fd, void *buf, size_t n); 40ssize_t readn(int fd, void *buf, size_t n);
39ssize_t writen(int fd, void *buf, size_t n); 41ssize_t writen(int fd, const void *buf, size_t n);
40 42
41size_t hex_width(u64 v); 43size_t hex_width(u64 v);
42int hex2u64(const char *ptr, u64 *val); 44int hex2u64(const char *ptr, u64 *val);
@@ -58,4 +60,8 @@ const char *perf_tip(const char *dirpath);
58int sched_getcpu(void); 60int sched_getcpu(void);
59#endif 61#endif
60 62
63#ifndef HAVE_SETNS_SUPPORT
64int setns(int fd, int nstype);
65#endif
66
61#endif /* GIT_COMPAT_UTIL_H */ 67#endif /* GIT_COMPAT_UTIL_H */
diff --git a/tools/perf/util/values.c b/tools/perf/util/values.c
index 5de2e15e2eda..8a32bb0095e5 100644
--- a/tools/perf/util/values.c
+++ b/tools/perf/util/values.c
@@ -12,7 +12,7 @@ int perf_read_values_init(struct perf_read_values *values)
12 values->threads_max = 16; 12 values->threads_max = 16;
13 values->pid = malloc(values->threads_max * sizeof(*values->pid)); 13 values->pid = malloc(values->threads_max * sizeof(*values->pid));
14 values->tid = malloc(values->threads_max * sizeof(*values->tid)); 14 values->tid = malloc(values->threads_max * sizeof(*values->tid));
15 values->value = malloc(values->threads_max * sizeof(*values->value)); 15 values->value = zalloc(values->threads_max * sizeof(*values->value));
16 if (!values->pid || !values->tid || !values->value) { 16 if (!values->pid || !values->tid || !values->value) {
17 pr_debug("failed to allocate read_values threads arrays"); 17 pr_debug("failed to allocate read_values threads arrays");
18 goto out_free_pid; 18 goto out_free_pid;
@@ -98,15 +98,16 @@ static int perf_read_values__findnew_thread(struct perf_read_values *values,
98 return i; 98 return i;
99 } 99 }
100 100
101 i = values->threads + 1; 101 i = values->threads;
102 values->value[i] = malloc(values->counters_max * sizeof(**values->value)); 102
103 values->value[i] = zalloc(values->counters_max * sizeof(**values->value));
103 if (!values->value[i]) { 104 if (!values->value[i]) {
104 pr_debug("failed to allocate read_values counters array"); 105 pr_debug("failed to allocate read_values counters array");
105 return -ENOMEM; 106 return -ENOMEM;
106 } 107 }
107 values->pid[i] = pid; 108 values->pid[i] = pid;
108 values->tid[i] = tid; 109 values->tid[i] = tid;
109 values->threads = i; 110 values->threads = i + 1;
110 111
111 return i; 112 return i;
112} 113}
@@ -130,12 +131,16 @@ static int perf_read_values__enlarge_counters(struct perf_read_values *values)
130 131
131 for (i = 0; i < values->threads; i++) { 132 for (i = 0; i < values->threads; i++) {
132 u64 *value = realloc(values->value[i], counters_max * sizeof(**values->value)); 133 u64 *value = realloc(values->value[i], counters_max * sizeof(**values->value));
134 int j;
133 135
134 if (value) { 136 if (!value) {
135 pr_debug("failed to enlarge read_values ->values array"); 137 pr_debug("failed to enlarge read_values ->values array");
136 goto out_free_name; 138 goto out_free_name;
137 } 139 }
138 140
141 for (j = values->counters_max; j < counters_max; j++)
142 value[j] = 0;
143
139 values->value[i] = value; 144 values->value[i] = value;
140 } 145 }
141 146
@@ -187,7 +192,7 @@ int perf_read_values_add_value(struct perf_read_values *values,
187 if (cindex < 0) 192 if (cindex < 0)
188 return cindex; 193 return cindex;
189 194
190 values->value[tindex][cindex] = value; 195 values->value[tindex][cindex] += value;
191 return 0; 196 return 0;
192} 197}
193 198
diff --git a/tools/perf/util/xyarray.c b/tools/perf/util/xyarray.c
index 7251fdbabced..c8f415d9877b 100644
--- a/tools/perf/util/xyarray.c
+++ b/tools/perf/util/xyarray.c
@@ -12,6 +12,8 @@ struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size)
12 xy->entry_size = entry_size; 12 xy->entry_size = entry_size;
13 xy->row_size = row_size; 13 xy->row_size = row_size;
14 xy->entries = xlen * ylen; 14 xy->entries = xlen * ylen;
15 xy->max_x = xlen;
16 xy->max_y = ylen;
15 } 17 }
16 18
17 return xy; 19 return xy;
diff --git a/tools/perf/util/xyarray.h b/tools/perf/util/xyarray.h
index 7f30af371b7e..4ba726c90870 100644
--- a/tools/perf/util/xyarray.h
+++ b/tools/perf/util/xyarray.h
@@ -7,6 +7,8 @@ struct xyarray {
7 size_t row_size; 7 size_t row_size;
8 size_t entry_size; 8 size_t entry_size;
9 size_t entries; 9 size_t entries;
10 size_t max_x;
11 size_t max_y;
10 char contents[]; 12 char contents[];
11}; 13};
12 14
@@ -19,4 +21,14 @@ static inline void *xyarray__entry(struct xyarray *xy, int x, int y)
19 return &xy->contents[x * xy->row_size + y * xy->entry_size]; 21 return &xy->contents[x * xy->row_size + y * xy->entry_size];
20} 22}
21 23
24static inline int xyarray__max_y(struct xyarray *xy)
25{
26 return xy->max_x;
27}
28
29static inline int xyarray__max_x(struct xyarray *xy)
30{
31 return xy->max_y;
32}
33
22#endif /* _PERF_XYARRAY_H_ */ 34#endif /* _PERF_XYARRAY_H_ */