aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2018-03-19 15:37:48 -0400
committerIngo Molnar <mingo@kernel.org>2018-03-19 15:37:48 -0400
commitecd380b8dead1bad67e3af87e2ddfe826c3da79d (patch)
treeb35db1791ac7acaba54eb3aa9f751790b735428d
parent134933e55789ece9bca973d3502c7b8f7a9dae86 (diff)
parent1cd618838b9703eabe4a75badf433382b12f6bef (diff)
Merge tag 'perf-core-for-mingo-4.17-20180319' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo: - Fixes for problems experienced with new GCC 8 warnings, that treated as errors, broke the build, related to snprintf and casting issues. (Arnaldo Carvalho de Melo, Jiri Olsa, Josh Poinboeuf) - Fix build of new breakpoint 'perf test' entry with clang < 6, noticed on fedora 25, 26 and 27 (Arnaldo Carvalho de Melo) - Workaround problem with symbol resolution in 'perf annotate', using the symbol name already present in the objdump output (Arnaldo Carvalho de Melo) - Document 'perf top --ignore-vmlinux' (Arnaldo Carvalho de Melo) - Fix out of bounds access on array fd when cnt is 100 in one of the 'perf test' entries, detected using 'cpptest' (Colin Ian King) - Add support for the forced leader feature, i.e. 'perf report --group' for a group of events not really grouped when scheduled (without using {} to enclose the list of events in the command line) in pipe mode, e.g.: $ perf record -e cycles,instructions -o - kill | perf report --group -i - - Use right type to access array elements in 'perf probe' (Masami Hiramatsu) - Update POWER9 vendor events (those described in JSON format) (Sukadev Bhattiprolu) - Discard head in overwrite_rb_find_range() (Yisheng Xie) - Avoid setting 'quiet' to 'true' unnecessarily (Yisheng Xie) Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--tools/lib/str_error_r.c2
-rw-r--r--tools/perf/Documentation/perf-c2c.txt2
-rw-r--r--tools/perf/Documentation/perf-top.txt3
-rw-r--r--tools/perf/Makefile.config2
-rw-r--r--tools/perf/arch/arm64/include/arch-tests.h12
-rw-r--r--tools/perf/arch/arm64/tests/Build2
-rw-r--r--tools/perf/arch/arm64/tests/arch-tests.c16
-rw-r--r--tools/perf/arch/arm64/util/Build1
-rw-r--r--tools/perf/arch/arm64/util/unwind-libdw.c60
-rw-r--r--tools/perf/builtin-c2c.c223
-rw-r--r--tools/perf/builtin-record.c26
-rw-r--r--tools/perf/builtin-report.c57
-rw-r--r--tools/perf/builtin-script.c22
-rw-r--r--tools/perf/builtin-stat.c9
-rw-r--r--tools/perf/builtin-top.c6
-rw-r--r--tools/perf/pmu-events/Build2
-rw-r--r--tools/perf/pmu-events/README15
-rw-r--r--tools/perf/pmu-events/arch/arm64/arm/cortex-a53/branch.json (renamed from tools/perf/pmu-events/arch/arm64/cortex-a53/branch.json)14
-rw-r--r--tools/perf/pmu-events/arch/arm64/arm/cortex-a53/bus.json8
-rw-r--r--tools/perf/pmu-events/arch/arm64/arm/cortex-a53/cache.json27
-rw-r--r--tools/perf/pmu-events/arch/arm64/arm/cortex-a53/memory.json (renamed from tools/perf/pmu-events/arch/arm64/cortex-a53/memory.json)14
-rw-r--r--tools/perf/pmu-events/arch/arm64/arm/cortex-a53/other.json28
-rw-r--r--tools/perf/pmu-events/arch/arm64/arm/cortex-a53/pipeline.json (renamed from tools/perf/pmu-events/arch/arm64/cortex-a53/pipeline.json)20
-rw-r--r--tools/perf/pmu-events/arch/arm64/armv8-recommended.json452
-rw-r--r--tools/perf/pmu-events/arch/arm64/cavium/thunderx2-imp-def.json62
-rw-r--r--tools/perf/pmu-events/arch/arm64/cavium/thunderx2/core-imp-def.json32
-rw-r--r--tools/perf/pmu-events/arch/arm64/cortex-a53/bus.json22
-rw-r--r--tools/perf/pmu-events/arch/arm64/cortex-a53/cache.json27
-rw-r--r--tools/perf/pmu-events/arch/arm64/cortex-a53/other.json32
-rw-r--r--tools/perf/pmu-events/arch/arm64/hisilicon/hip08/core-imp-def.json122
-rw-r--r--tools/perf/pmu-events/arch/arm64/mapfile.csv6
-rw-r--r--tools/perf/pmu-events/arch/powerpc/power9/cache.json25
-rw-r--r--tools/perf/pmu-events/arch/powerpc/power9/frontend.json10
-rw-r--r--tools/perf/pmu-events/arch/powerpc/power9/marked.json5
-rw-r--r--tools/perf/pmu-events/arch/powerpc/power9/memory.json5
-rw-r--r--tools/perf/pmu-events/arch/powerpc/power9/other.json241
-rw-r--r--tools/perf/pmu-events/arch/powerpc/power9/pipeline.json50
-rw-r--r--tools/perf/pmu-events/arch/powerpc/power9/pmc.json5
-rw-r--r--tools/perf/pmu-events/arch/powerpc/power9/translation.json10
-rw-r--r--tools/perf/pmu-events/jevents.c291
-rw-r--r--tools/perf/tests/Build1
-rw-r--r--tools/perf/tests/attr.c4
-rw-r--r--tools/perf/tests/bp_account.c10
-rw-r--r--tools/perf/tests/builtin-test.c4
-rw-r--r--tools/perf/tests/mem.c2
-rw-r--r--tools/perf/tests/mem2node.c75
-rw-r--r--tools/perf/tests/pmu.c2
-rwxr-xr-xtools/perf/tests/shell/record+probe_libc_inet_pton.sh5
-rw-r--r--tools/perf/tests/tests.h1
-rw-r--r--tools/perf/ui/stdio/hist.c6
-rw-r--r--tools/perf/util/Build1
-rw-r--r--tools/perf/util/annotate.c20
-rw-r--r--tools/perf/util/cgroup.c2
-rw-r--r--tools/perf/util/debug.c1
-rw-r--r--tools/perf/util/env.c4
-rw-r--r--tools/perf/util/header.c11
-rw-r--r--tools/perf/util/llvm-utils.c14
-rw-r--r--tools/perf/util/machine.c28
-rw-r--r--tools/perf/util/mem2node.c134
-rw-r--r--tools/perf/util/mem2node.h19
-rw-r--r--tools/perf/util/mmap.c15
-rw-r--r--tools/perf/util/parse-events.c4
-rw-r--r--tools/perf/util/pmu.c2
-rw-r--r--tools/perf/util/probe-finder.c13
-rw-r--r--tools/perf/util/setup.py2
-rw-r--r--tools/perf/util/stat.c2
-rw-r--r--tools/perf/util/stat.h2
-rw-r--r--tools/perf/util/unwind-libdw.c2
68 files changed, 1834 insertions, 520 deletions
diff --git a/tools/lib/str_error_r.c b/tools/lib/str_error_r.c
index d6d65537b0d9..6aad8308a0ac 100644
--- a/tools/lib/str_error_r.c
+++ b/tools/lib/str_error_r.c
@@ -22,6 +22,6 @@ char *str_error_r(int errnum, char *buf, size_t buflen)
22{ 22{
23 int err = strerror_r(errnum, buf, buflen); 23 int err = strerror_r(errnum, buf, buflen);
24 if (err) 24 if (err)
25 snprintf(buf, buflen, "INTERNAL ERROR: strerror_r(%d, %p, %zd)=%d", errnum, buf, buflen, err); 25 snprintf(buf, buflen, "INTERNAL ERROR: strerror_r(%d, [buf], %zd)=%d", errnum, buflen, err);
26 return buf; 26 return buf;
27} 27}
diff --git a/tools/perf/Documentation/perf-c2c.txt b/tools/perf/Documentation/perf-c2c.txt
index 822414235170..095aebdc5bb7 100644
--- a/tools/perf/Documentation/perf-c2c.txt
+++ b/tools/perf/Documentation/perf-c2c.txt
@@ -116,7 +116,7 @@ and calls standard perf record command.
116Following perf record options are configured by default: 116Following perf record options are configured by default:
117(check perf record man page for details) 117(check perf record man page for details)
118 118
119 -W,-d,--sample-cpu 119 -W,-d,--phys-data,--sample-cpu
120 120
121Unless specified otherwise with '-e' option, following events are monitored by 121Unless specified otherwise with '-e' option, following events are monitored by
122default: 122default:
diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt
index a039407d63b8..114fda12aa49 100644
--- a/tools/perf/Documentation/perf-top.txt
+++ b/tools/perf/Documentation/perf-top.txt
@@ -67,6 +67,9 @@ Default is to monitor all CPUS.
67--vmlinux=<path>:: 67--vmlinux=<path>::
68 Path to vmlinux. Required for annotation functionality. 68 Path to vmlinux. Required for annotation functionality.
69 69
70--ignore-vmlinux::
71 Ignore vmlinux files.
72
70-m <pages>:: 73-m <pages>::
71--mmap-pages=<pages>:: 74--mmap-pages=<pages>::
72 Number of mmap data pages (must be a power of two) or size 75 Number of mmap data pages (must be a power of two) or size
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 89cb2a36b8ff..98ff73648b51 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -75,7 +75,7 @@ endif
75# Disable it on all other architectures in case libdw unwind 75# Disable it on all other architectures in case libdw unwind
76# support is detected in system. Add supported architectures 76# support is detected in system. Add supported architectures
77# to the check. 77# to the check.
78ifneq ($(SRCARCH),$(filter $(SRCARCH),x86 arm powerpc s390)) 78ifneq ($(SRCARCH),$(filter $(SRCARCH),x86 arm arm64 powerpc s390))
79 NO_LIBDW_DWARF_UNWIND := 1 79 NO_LIBDW_DWARF_UNWIND := 1
80endif 80endif
81 81
diff --git a/tools/perf/arch/arm64/include/arch-tests.h b/tools/perf/arch/arm64/include/arch-tests.h
new file mode 100644
index 000000000000..90ec4c8cb880
--- /dev/null
+++ b/tools/perf/arch/arm64/include/arch-tests.h
@@ -0,0 +1,12 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef ARCH_TESTS_H
3#define ARCH_TESTS_H
4
5#ifdef HAVE_DWARF_UNWIND_SUPPORT
6struct thread;
7struct perf_sample;
8#endif
9
10extern struct test arch_tests[];
11
12#endif
diff --git a/tools/perf/arch/arm64/tests/Build b/tools/perf/arch/arm64/tests/Build
index b30eff9bcc83..883c57ff0c08 100644
--- a/tools/perf/arch/arm64/tests/Build
+++ b/tools/perf/arch/arm64/tests/Build
@@ -1,2 +1,4 @@
1libperf-y += regs_load.o 1libperf-y += regs_load.o
2libperf-y += dwarf-unwind.o 2libperf-y += dwarf-unwind.o
3
4libperf-y += arch-tests.o
diff --git a/tools/perf/arch/arm64/tests/arch-tests.c b/tools/perf/arch/arm64/tests/arch-tests.c
new file mode 100644
index 000000000000..5b1543c98022
--- /dev/null
+++ b/tools/perf/arch/arm64/tests/arch-tests.c
@@ -0,0 +1,16 @@
1// SPDX-License-Identifier: GPL-2.0
2#include <string.h>
3#include "tests/tests.h"
4#include "arch-tests.h"
5
6struct test arch_tests[] = {
7#ifdef HAVE_DWARF_UNWIND_SUPPORT
8 {
9 .desc = "DWARF unwind",
10 .func = test__dwarf_unwind,
11 },
12#endif
13 {
14 .func = NULL,
15 },
16};
diff --git a/tools/perf/arch/arm64/util/Build b/tools/perf/arch/arm64/util/Build
index c0b8dfef98ba..68f8a8eb3ad0 100644
--- a/tools/perf/arch/arm64/util/Build
+++ b/tools/perf/arch/arm64/util/Build
@@ -2,6 +2,7 @@ libperf-y += header.o
2libperf-y += sym-handling.o 2libperf-y += sym-handling.o
3libperf-$(CONFIG_DWARF) += dwarf-regs.o 3libperf-$(CONFIG_DWARF) += dwarf-regs.o
4libperf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o 4libperf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o
5libperf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
5 6
6libperf-$(CONFIG_AUXTRACE) += ../../arm/util/pmu.o \ 7libperf-$(CONFIG_AUXTRACE) += ../../arm/util/pmu.o \
7 ../../arm/util/auxtrace.o \ 8 ../../arm/util/auxtrace.o \
diff --git a/tools/perf/arch/arm64/util/unwind-libdw.c b/tools/perf/arch/arm64/util/unwind-libdw.c
new file mode 100644
index 000000000000..7623d85e77f3
--- /dev/null
+++ b/tools/perf/arch/arm64/util/unwind-libdw.c
@@ -0,0 +1,60 @@
1// SPDX-License-Identifier: GPL-2.0
2#include <elfutils/libdwfl.h>
3#include "../../util/unwind-libdw.h"
4#include "../../util/perf_regs.h"
5#include "../../util/event.h"
6
7bool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg)
8{
9 struct unwind_info *ui = arg;
10 struct regs_dump *user_regs = &ui->sample->user_regs;
11 Dwarf_Word dwarf_regs[PERF_REG_ARM64_MAX], dwarf_pc;
12
13#define REG(r) ({ \
14 Dwarf_Word val = 0; \
15 perf_reg_value(&val, user_regs, PERF_REG_ARM64_##r); \
16 val; \
17})
18
19 dwarf_regs[0] = REG(X0);
20 dwarf_regs[1] = REG(X1);
21 dwarf_regs[2] = REG(X2);
22 dwarf_regs[3] = REG(X3);
23 dwarf_regs[4] = REG(X4);
24 dwarf_regs[5] = REG(X5);
25 dwarf_regs[6] = REG(X6);
26 dwarf_regs[7] = REG(X7);
27 dwarf_regs[8] = REG(X8);
28 dwarf_regs[9] = REG(X9);
29 dwarf_regs[10] = REG(X10);
30 dwarf_regs[11] = REG(X11);
31 dwarf_regs[12] = REG(X12);
32 dwarf_regs[13] = REG(X13);
33 dwarf_regs[14] = REG(X14);
34 dwarf_regs[15] = REG(X15);
35 dwarf_regs[16] = REG(X16);
36 dwarf_regs[17] = REG(X17);
37 dwarf_regs[18] = REG(X18);
38 dwarf_regs[19] = REG(X19);
39 dwarf_regs[20] = REG(X20);
40 dwarf_regs[21] = REG(X21);
41 dwarf_regs[22] = REG(X22);
42 dwarf_regs[23] = REG(X23);
43 dwarf_regs[24] = REG(X24);
44 dwarf_regs[25] = REG(X25);
45 dwarf_regs[26] = REG(X26);
46 dwarf_regs[27] = REG(X27);
47 dwarf_regs[28] = REG(X28);
48 dwarf_regs[29] = REG(X29);
49 dwarf_regs[30] = REG(LR);
50 dwarf_regs[31] = REG(SP);
51
52 if (!dwfl_thread_state_registers(thread, 0, PERF_REG_ARM64_MAX,
53 dwarf_regs))
54 return false;
55
56 dwarf_pc = REG(PC);
57 dwfl_thread_state_register_pc(thread, dwarf_pc);
58
59 return true;
60}
diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
index 98d243fa0c06..2126bfbcb385 100644
--- a/tools/perf/builtin-c2c.c
+++ b/tools/perf/builtin-c2c.c
@@ -32,6 +32,7 @@
32#include "evsel.h" 32#include "evsel.h"
33#include "ui/browsers/hists.h" 33#include "ui/browsers/hists.h"
34#include "thread.h" 34#include "thread.h"
35#include "mem2node.h"
35 36
36struct c2c_hists { 37struct c2c_hists {
37 struct hists hists; 38 struct hists hists;
@@ -49,6 +50,7 @@ struct c2c_hist_entry {
49 struct c2c_hists *hists; 50 struct c2c_hists *hists;
50 struct c2c_stats stats; 51 struct c2c_stats stats;
51 unsigned long *cpuset; 52 unsigned long *cpuset;
53 unsigned long *nodeset;
52 struct c2c_stats *node_stats; 54 struct c2c_stats *node_stats;
53 unsigned int cacheline_idx; 55 unsigned int cacheline_idx;
54 56
@@ -59,6 +61,11 @@ struct c2c_hist_entry {
59 * because of its callchain dynamic entry 61 * because of its callchain dynamic entry
60 */ 62 */
61 struct hist_entry he; 63 struct hist_entry he;
64
65 unsigned long paddr;
66 unsigned long paddr_cnt;
67 bool paddr_zero;
68 char *nodestr;
62}; 69};
63 70
64static char const *coalesce_default = "pid,iaddr"; 71static char const *coalesce_default = "pid,iaddr";
@@ -66,6 +73,7 @@ static char const *coalesce_default = "pid,iaddr";
66struct perf_c2c { 73struct perf_c2c {
67 struct perf_tool tool; 74 struct perf_tool tool;
68 struct c2c_hists hists; 75 struct c2c_hists hists;
76 struct mem2node mem2node;
69 77
70 unsigned long **nodes; 78 unsigned long **nodes;
71 int nodes_cnt; 79 int nodes_cnt;
@@ -123,6 +131,10 @@ static void *c2c_he_zalloc(size_t size)
123 if (!c2c_he->cpuset) 131 if (!c2c_he->cpuset)
124 return NULL; 132 return NULL;
125 133
134 c2c_he->nodeset = bitmap_alloc(c2c.nodes_cnt);
135 if (!c2c_he->nodeset)
136 return NULL;
137
126 c2c_he->node_stats = zalloc(c2c.nodes_cnt * sizeof(*c2c_he->node_stats)); 138 c2c_he->node_stats = zalloc(c2c.nodes_cnt * sizeof(*c2c_he->node_stats));
127 if (!c2c_he->node_stats) 139 if (!c2c_he->node_stats)
128 return NULL; 140 return NULL;
@@ -145,6 +157,8 @@ static void c2c_he_free(void *he)
145 } 157 }
146 158
147 free(c2c_he->cpuset); 159 free(c2c_he->cpuset);
160 free(c2c_he->nodeset);
161 free(c2c_he->nodestr);
148 free(c2c_he->node_stats); 162 free(c2c_he->node_stats);
149 free(c2c_he); 163 free(c2c_he);
150} 164}
@@ -194,6 +208,28 @@ static void c2c_he__set_cpu(struct c2c_hist_entry *c2c_he,
194 set_bit(sample->cpu, c2c_he->cpuset); 208 set_bit(sample->cpu, c2c_he->cpuset);
195} 209}
196 210
211static void c2c_he__set_node(struct c2c_hist_entry *c2c_he,
212 struct perf_sample *sample)
213{
214 int node;
215
216 if (!sample->phys_addr) {
217 c2c_he->paddr_zero = true;
218 return;
219 }
220
221 node = mem2node__node(&c2c.mem2node, sample->phys_addr);
222 if (WARN_ONCE(node < 0, "WARNING: failed to find node\n"))
223 return;
224
225 set_bit(node, c2c_he->nodeset);
226
227 if (c2c_he->paddr != sample->phys_addr) {
228 c2c_he->paddr_cnt++;
229 c2c_he->paddr = sample->phys_addr;
230 }
231}
232
197static void compute_stats(struct c2c_hist_entry *c2c_he, 233static void compute_stats(struct c2c_hist_entry *c2c_he,
198 struct c2c_stats *stats, 234 struct c2c_stats *stats,
199 u64 weight) 235 u64 weight)
@@ -257,6 +293,7 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
257 c2c_add_stats(&c2c_hists->stats, &stats); 293 c2c_add_stats(&c2c_hists->stats, &stats);
258 294
259 c2c_he__set_cpu(c2c_he, sample); 295 c2c_he__set_cpu(c2c_he, sample);
296 c2c_he__set_node(c2c_he, sample);
260 297
261 hists__inc_nr_samples(&c2c_hists->hists, he->filtered); 298 hists__inc_nr_samples(&c2c_hists->hists, he->filtered);
262 ret = hist_entry__append_callchain(he, sample); 299 ret = hist_entry__append_callchain(he, sample);
@@ -293,6 +330,7 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
293 compute_stats(c2c_he, &stats, sample->weight); 330 compute_stats(c2c_he, &stats, sample->weight);
294 331
295 c2c_he__set_cpu(c2c_he, sample); 332 c2c_he__set_cpu(c2c_he, sample);
333 c2c_he__set_node(c2c_he, sample);
296 334
297 hists__inc_nr_samples(&c2c_hists->hists, he->filtered); 335 hists__inc_nr_samples(&c2c_hists->hists, he->filtered);
298 ret = hist_entry__append_callchain(he, sample); 336 ret = hist_entry__append_callchain(he, sample);
@@ -455,6 +493,31 @@ static int dcacheline_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
455 return scnprintf(hpp->buf, hpp->size, "%*s", width, HEX_STR(buf, addr)); 493 return scnprintf(hpp->buf, hpp->size, "%*s", width, HEX_STR(buf, addr));
456} 494}
457 495
496static int
497dcacheline_node_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
498 struct hist_entry *he)
499{
500 struct c2c_hist_entry *c2c_he;
501 int width = c2c_width(fmt, hpp, he->hists);
502
503 c2c_he = container_of(he, struct c2c_hist_entry, he);
504 if (WARN_ON_ONCE(!c2c_he->nodestr))
505 return 0;
506
507 return scnprintf(hpp->buf, hpp->size, "%*s", width, c2c_he->nodestr);
508}
509
510static int
511dcacheline_node_count(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
512 struct hist_entry *he)
513{
514 struct c2c_hist_entry *c2c_he;
515 int width = c2c_width(fmt, hpp, he->hists);
516
517 c2c_he = container_of(he, struct c2c_hist_entry, he);
518 return scnprintf(hpp->buf, hpp->size, "%*lu", width, c2c_he->paddr_cnt);
519}
520
458static int offset_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, 521static int offset_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
459 struct hist_entry *he) 522 struct hist_entry *he)
460{ 523{
@@ -1200,23 +1263,47 @@ cl_idx_empty_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
1200 } 1263 }
1201 1264
1202static struct c2c_dimension dim_dcacheline = { 1265static struct c2c_dimension dim_dcacheline = {
1203 .header = HEADER_LOW("Cacheline"), 1266 .header = HEADER_SPAN("--- Cacheline ----", "Address", 2),
1204 .name = "dcacheline", 1267 .name = "dcacheline",
1205 .cmp = dcacheline_cmp, 1268 .cmp = dcacheline_cmp,
1206 .entry = dcacheline_entry, 1269 .entry = dcacheline_entry,
1207 .width = 18, 1270 .width = 18,
1208}; 1271};
1209 1272
1210static struct c2c_header header_offset_tui = HEADER_LOW("Off"); 1273static struct c2c_dimension dim_dcacheline_node = {
1274 .header = HEADER_LOW("Node"),
1275 .name = "dcacheline_node",
1276 .cmp = empty_cmp,
1277 .entry = dcacheline_node_entry,
1278 .width = 4,
1279};
1280
1281static struct c2c_dimension dim_dcacheline_count = {
1282 .header = HEADER_LOW("PA cnt"),
1283 .name = "dcacheline_count",
1284 .cmp = empty_cmp,
1285 .entry = dcacheline_node_count,
1286 .width = 6,
1287};
1288
1289static struct c2c_header header_offset_tui = HEADER_SPAN("-----", "Off", 2);
1211 1290
1212static struct c2c_dimension dim_offset = { 1291static struct c2c_dimension dim_offset = {
1213 .header = HEADER_BOTH("Data address", "Offset"), 1292 .header = HEADER_SPAN("--- Data address -", "Offset", 2),
1214 .name = "offset", 1293 .name = "offset",
1215 .cmp = offset_cmp, 1294 .cmp = offset_cmp,
1216 .entry = offset_entry, 1295 .entry = offset_entry,
1217 .width = 18, 1296 .width = 18,
1218}; 1297};
1219 1298
1299static struct c2c_dimension dim_offset_node = {
1300 .header = HEADER_LOW("Node"),
1301 .name = "offset_node",
1302 .cmp = empty_cmp,
1303 .entry = dcacheline_node_entry,
1304 .width = 4,
1305};
1306
1220static struct c2c_dimension dim_iaddr = { 1307static struct c2c_dimension dim_iaddr = {
1221 .header = HEADER_LOW("Code address"), 1308 .header = HEADER_LOW("Code address"),
1222 .name = "iaddr", 1309 .name = "iaddr",
@@ -1536,7 +1623,10 @@ static struct c2c_dimension dim_dcacheline_num_empty = {
1536 1623
1537static struct c2c_dimension *dimensions[] = { 1624static struct c2c_dimension *dimensions[] = {
1538 &dim_dcacheline, 1625 &dim_dcacheline,
1626 &dim_dcacheline_node,
1627 &dim_dcacheline_count,
1539 &dim_offset, 1628 &dim_offset,
1629 &dim_offset_node,
1540 &dim_iaddr, 1630 &dim_iaddr,
1541 &dim_tot_hitm, 1631 &dim_tot_hitm,
1542 &dim_lcl_hitm, 1632 &dim_lcl_hitm,
@@ -1839,20 +1929,56 @@ static inline int valid_hitm_or_store(struct hist_entry *he)
1839 return has_hitm || c2c_he->stats.store; 1929 return has_hitm || c2c_he->stats.store;
1840} 1930}
1841 1931
1842static void calc_width(struct hist_entry *he) 1932static void set_node_width(struct c2c_hist_entry *c2c_he, int len)
1933{
1934 struct c2c_dimension *dim;
1935
1936 dim = &c2c.hists == c2c_he->hists ?
1937 &dim_dcacheline_node : &dim_offset_node;
1938
1939 if (len > dim->width)
1940 dim->width = len;
1941}
1942
1943static int set_nodestr(struct c2c_hist_entry *c2c_he)
1944{
1945 char buf[30];
1946 int len;
1947
1948 if (c2c_he->nodestr)
1949 return 0;
1950
1951 if (bitmap_weight(c2c_he->nodeset, c2c.nodes_cnt)) {
1952 len = bitmap_scnprintf(c2c_he->nodeset, c2c.nodes_cnt,
1953 buf, sizeof(buf));
1954 } else {
1955 len = scnprintf(buf, sizeof(buf), "N/A");
1956 }
1957
1958 set_node_width(c2c_he, len);
1959 c2c_he->nodestr = strdup(buf);
1960 return c2c_he->nodestr ? 0 : -ENOMEM;
1961}
1962
1963static void calc_width(struct c2c_hist_entry *c2c_he)
1843{ 1964{
1844 struct c2c_hists *c2c_hists; 1965 struct c2c_hists *c2c_hists;
1845 1966
1846 c2c_hists = container_of(he->hists, struct c2c_hists, hists); 1967 c2c_hists = container_of(c2c_he->he.hists, struct c2c_hists, hists);
1847 hists__calc_col_len(&c2c_hists->hists, he); 1968 hists__calc_col_len(&c2c_hists->hists, &c2c_he->he);
1969 set_nodestr(c2c_he);
1848} 1970}
1849 1971
1850static int filter_cb(struct hist_entry *he) 1972static int filter_cb(struct hist_entry *he)
1851{ 1973{
1974 struct c2c_hist_entry *c2c_he;
1975
1976 c2c_he = container_of(he, struct c2c_hist_entry, he);
1977
1852 if (c2c.show_src && !he->srcline) 1978 if (c2c.show_src && !he->srcline)
1853 he->srcline = hist_entry__get_srcline(he); 1979 he->srcline = hist_entry__get_srcline(he);
1854 1980
1855 calc_width(he); 1981 calc_width(c2c_he);
1856 1982
1857 if (!valid_hitm_or_store(he)) 1983 if (!valid_hitm_or_store(he))
1858 he->filtered = HIST_FILTER__C2C; 1984 he->filtered = HIST_FILTER__C2C;
@@ -1869,12 +1995,11 @@ static int resort_cl_cb(struct hist_entry *he)
1869 c2c_he = container_of(he, struct c2c_hist_entry, he); 1995 c2c_he = container_of(he, struct c2c_hist_entry, he);
1870 c2c_hists = c2c_he->hists; 1996 c2c_hists = c2c_he->hists;
1871 1997
1872 calc_width(he);
1873
1874 if (display && c2c_hists) { 1998 if (display && c2c_hists) {
1875 static unsigned int idx; 1999 static unsigned int idx;
1876 2000
1877 c2c_he->cacheline_idx = idx++; 2001 c2c_he->cacheline_idx = idx++;
2002 calc_width(c2c_he);
1878 2003
1879 c2c_hists__reinit(c2c_hists, c2c.cl_output, c2c.cl_resort); 2004 c2c_hists__reinit(c2c_hists, c2c.cl_output, c2c.cl_resort);
1880 2005
@@ -2348,14 +2473,66 @@ static void perf_c2c_display(struct perf_session *session)
2348} 2473}
2349#endif /* HAVE_SLANG_SUPPORT */ 2474#endif /* HAVE_SLANG_SUPPORT */
2350 2475
2351static void ui_quirks(void) 2476static char *fill_line(const char *orig, int len)
2477{
2478 int i, j, olen = strlen(orig);
2479 char *buf;
2480
2481 buf = zalloc(len + 1);
2482 if (!buf)
2483 return NULL;
2484
2485 j = len / 2 - olen / 2;
2486
2487 for (i = 0; i < j - 1; i++)
2488 buf[i] = '-';
2489
2490 buf[i++] = ' ';
2491
2492 strcpy(buf + i, orig);
2493
2494 i += olen;
2495
2496 buf[i++] = ' ';
2497
2498 for (; i < len; i++)
2499 buf[i] = '-';
2500
2501 return buf;
2502}
2503
2504static int ui_quirks(void)
2352{ 2505{
2506 const char *nodestr = "Data address";
2507 char *buf;
2508
2353 if (!c2c.use_stdio) { 2509 if (!c2c.use_stdio) {
2354 dim_offset.width = 5; 2510 dim_offset.width = 5;
2355 dim_offset.header = header_offset_tui; 2511 dim_offset.header = header_offset_tui;
2512 nodestr = "CL";
2356 } 2513 }
2357 2514
2358 dim_percent_hitm.header = percent_hitm_header[c2c.display]; 2515 dim_percent_hitm.header = percent_hitm_header[c2c.display];
2516
2517 /* Fix the zero line for dcacheline column. */
2518 buf = fill_line("Cacheline", dim_dcacheline.width +
2519 dim_dcacheline_node.width +
2520 dim_dcacheline_count.width + 4);
2521 if (!buf)
2522 return -ENOMEM;
2523
2524 dim_dcacheline.header.line[0].text = buf;
2525
2526 /* Fix the zero line for offset column. */
2527 buf = fill_line(nodestr, dim_offset.width +
2528 dim_offset_node.width +
2529 dim_dcacheline_count.width + 4);
2530 if (!buf)
2531 return -ENOMEM;
2532
2533 dim_offset.header.line[0].text = buf;
2534
2535 return 0;
2359} 2536}
2360 2537
2361#define CALLCHAIN_DEFAULT_OPT "graph,0.5,caller,function,percent" 2538#define CALLCHAIN_DEFAULT_OPT "graph,0.5,caller,function,percent"
@@ -2471,7 +2648,7 @@ static int build_cl_output(char *cl_sort, bool no_source)
2471 "percent_lcl_hitm," 2648 "percent_lcl_hitm,"
2472 "percent_stores_l1hit," 2649 "percent_stores_l1hit,"
2473 "percent_stores_l1miss," 2650 "percent_stores_l1miss,"
2474 "offset,", 2651 "offset,offset_node,dcacheline_count,",
2475 add_pid ? "pid," : "", 2652 add_pid ? "pid," : "",
2476 add_tid ? "tid," : "", 2653 add_tid ? "tid," : "",
2477 add_iaddr ? "iaddr," : "", 2654 add_iaddr ? "iaddr," : "",
@@ -2600,17 +2777,21 @@ static int perf_c2c__report(int argc, const char **argv)
2600 goto out; 2777 goto out;
2601 } 2778 }
2602 2779
2603 err = setup_callchain(session->evlist); 2780 err = mem2node__init(&c2c.mem2node, &session->header.env);
2604 if (err) 2781 if (err)
2605 goto out_session; 2782 goto out_session;
2606 2783
2784 err = setup_callchain(session->evlist);
2785 if (err)
2786 goto out_mem2node;
2787
2607 if (symbol__init(&session->header.env) < 0) 2788 if (symbol__init(&session->header.env) < 0)
2608 goto out_session; 2789 goto out_mem2node;
2609 2790
2610 /* No pipe support at the moment. */ 2791 /* No pipe support at the moment. */
2611 if (perf_data__is_pipe(session->data)) { 2792 if (perf_data__is_pipe(session->data)) {
2612 pr_debug("No pipe support at the moment.\n"); 2793 pr_debug("No pipe support at the moment.\n");
2613 goto out_session; 2794 goto out_mem2node;
2614 } 2795 }
2615 2796
2616 if (c2c.use_stdio) 2797 if (c2c.use_stdio)
@@ -2623,12 +2804,14 @@ static int perf_c2c__report(int argc, const char **argv)
2623 err = perf_session__process_events(session); 2804 err = perf_session__process_events(session);
2624 if (err) { 2805 if (err) {
2625 pr_err("failed to process sample\n"); 2806 pr_err("failed to process sample\n");
2626 goto out_session; 2807 goto out_mem2node;
2627 } 2808 }
2628 2809
2629 c2c_hists__reinit(&c2c.hists, 2810 c2c_hists__reinit(&c2c.hists,
2630 "cl_idx," 2811 "cl_idx,"
2631 "dcacheline," 2812 "dcacheline,"
2813 "dcacheline_node,"
2814 "dcacheline_count,"
2632 "tot_recs," 2815 "tot_recs,"
2633 "percent_hitm," 2816 "percent_hitm,"
2634 "tot_hitm,lcl_hitm,rmt_hitm," 2817 "tot_hitm,lcl_hitm,rmt_hitm,"
@@ -2650,10 +2833,15 @@ static int perf_c2c__report(int argc, const char **argv)
2650 2833
2651 ui_progress__finish(); 2834 ui_progress__finish();
2652 2835
2653 ui_quirks(); 2836 if (ui_quirks()) {
2837 pr_err("failed to setup UI\n");
2838 goto out_mem2node;
2839 }
2654 2840
2655 perf_c2c_display(session); 2841 perf_c2c_display(session);
2656 2842
2843out_mem2node:
2844 mem2node__exit(&c2c.mem2node);
2657out_session: 2845out_session:
2658 perf_session__delete(session); 2846 perf_session__delete(session);
2659out: 2847out:
@@ -2704,7 +2892,7 @@ static int perf_c2c__record(int argc, const char **argv)
2704 argc = parse_options(argc, argv, options, record_mem_usage, 2892 argc = parse_options(argc, argv, options, record_mem_usage,
2705 PARSE_OPT_KEEP_UNKNOWN); 2893 PARSE_OPT_KEEP_UNKNOWN);
2706 2894
2707 rec_argc = argc + 10; /* max number of arguments */ 2895 rec_argc = argc + 11; /* max number of arguments */
2708 rec_argv = calloc(rec_argc + 1, sizeof(char *)); 2896 rec_argv = calloc(rec_argc + 1, sizeof(char *));
2709 if (!rec_argv) 2897 if (!rec_argv)
2710 return -1; 2898 return -1;
@@ -2720,6 +2908,7 @@ static int perf_c2c__record(int argc, const char **argv)
2720 rec_argv[i++] = "-W"; 2908 rec_argv[i++] = "-W";
2721 2909
2722 rec_argv[i++] = "-d"; 2910 rec_argv[i++] = "-d";
2911 rec_argv[i++] = "--phys-data";
2723 rec_argv[i++] = "--sample-cpu"; 2912 rec_argv[i++] = "--sample-cpu";
2724 2913
2725 for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) { 2914 for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) {
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index b81494587120..22ebeb92ac51 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -754,13 +754,10 @@ static int record__synthesize(struct record *rec, bool tail)
754 return 0; 754 return 0;
755 755
756 if (data->is_pipe) { 756 if (data->is_pipe) {
757 err = perf_event__synthesize_features( 757 /*
758 tool, session, rec->evlist, process_synthesized_event); 758 * We need to synthesize events first, because some
759 if (err < 0) { 759 * features works on top of them (on report side).
760 pr_err("Couldn't synthesize features.\n"); 760 */
761 return err;
762 }
763
764 err = perf_event__synthesize_attrs(tool, session, 761 err = perf_event__synthesize_attrs(tool, session,
765 process_synthesized_event); 762 process_synthesized_event);
766 if (err < 0) { 763 if (err < 0) {
@@ -768,6 +765,13 @@ static int record__synthesize(struct record *rec, bool tail)
768 goto out; 765 goto out;
769 } 766 }
770 767
768 err = perf_event__synthesize_features(tool, session, rec->evlist,
769 process_synthesized_event);
770 if (err < 0) {
771 pr_err("Couldn't synthesize features.\n");
772 return err;
773 }
774
771 if (have_tracepoints(&rec->evlist->entries)) { 775 if (have_tracepoints(&rec->evlist->entries)) {
772 /* 776 /*
773 * FIXME err <= 0 here actually means that 777 * FIXME err <= 0 here actually means that
@@ -1279,10 +1283,12 @@ static int perf_record_config(const char *var, const char *value, void *cb)
1279 return -1; 1283 return -1;
1280 return 0; 1284 return 0;
1281 } 1285 }
1282 if (!strcmp(var, "record.call-graph")) 1286 if (!strcmp(var, "record.call-graph")) {
1283 var = "call-graph.record-mode"; /* fall-through */ 1287 var = "call-graph.record-mode";
1288 return perf_default_config(var, value, cb);
1289 }
1284 1290
1285 return perf_default_config(var, value, cb); 1291 return 0;
1286} 1292}
1287 1293
1288struct clockid_map { 1294struct clockid_map {
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 971ccba85464..91da12975642 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -68,6 +68,7 @@ struct report {
68 bool header; 68 bool header;
69 bool header_only; 69 bool header_only;
70 bool nonany_branch_mode; 70 bool nonany_branch_mode;
71 bool group_set;
71 int max_stack; 72 int max_stack;
72 struct perf_read_values show_threads_values; 73 struct perf_read_values show_threads_values;
73 const char *pretty_printing_style; 74 const char *pretty_printing_style;
@@ -193,6 +194,45 @@ out:
193 return err; 194 return err;
194} 195}
195 196
197/*
198 * Events in data file are not collect in groups, but we still want
199 * the group display. Set the artificial group and set the leader's
200 * forced_leader flag to notify the display code.
201 */
202static void setup_forced_leader(struct report *report,
203 struct perf_evlist *evlist)
204{
205 if (report->group_set && !evlist->nr_groups) {
206 struct perf_evsel *leader = perf_evlist__first(evlist);
207
208 perf_evlist__set_leader(evlist);
209 leader->forced_leader = true;
210 }
211}
212
213static int process_feature_event(struct perf_tool *tool,
214 union perf_event *event,
215 struct perf_session *session __maybe_unused)
216{
217 struct report *rep = container_of(tool, struct report, tool);
218
219 if (event->feat.feat_id < HEADER_LAST_FEATURE)
220 return perf_event__process_feature(tool, event, session);
221
222 if (event->feat.feat_id != HEADER_LAST_FEATURE) {
223 pr_err("failed: wrong feature ID: %" PRIu64 "\n",
224 event->feat.feat_id);
225 return -1;
226 }
227
228 /*
229 * All features are received, we can force the
230 * group if needed.
231 */
232 setup_forced_leader(rep, session->evlist);
233 return 0;
234}
235
196static int process_sample_event(struct perf_tool *tool, 236static int process_sample_event(struct perf_tool *tool,
197 union perf_event *event, 237 union perf_event *event,
198 struct perf_sample *sample, 238 struct perf_sample *sample,
@@ -940,7 +980,6 @@ int cmd_report(int argc, const char **argv)
940 "perf report [<options>]", 980 "perf report [<options>]",
941 NULL 981 NULL
942 }; 982 };
943 bool group_set = false;
944 struct report report = { 983 struct report report = {
945 .tool = { 984 .tool = {
946 .sample = process_sample_event, 985 .sample = process_sample_event,
@@ -958,7 +997,7 @@ int cmd_report(int argc, const char **argv)
958 .id_index = perf_event__process_id_index, 997 .id_index = perf_event__process_id_index,
959 .auxtrace_info = perf_event__process_auxtrace_info, 998 .auxtrace_info = perf_event__process_auxtrace_info,
960 .auxtrace = perf_event__process_auxtrace, 999 .auxtrace = perf_event__process_auxtrace,
961 .feature = perf_event__process_feature, 1000 .feature = process_feature_event,
962 .ordered_events = true, 1001 .ordered_events = true,
963 .ordering_requires_timestamps = true, 1002 .ordering_requires_timestamps = true,
964 }, 1003 },
@@ -1060,7 +1099,7 @@ int cmd_report(int argc, const char **argv)
1060 "Specify disassembler style (e.g. -M intel for intel syntax)"), 1099 "Specify disassembler style (e.g. -M intel for intel syntax)"),
1061 OPT_BOOLEAN(0, "show-total-period", &symbol_conf.show_total_period, 1100 OPT_BOOLEAN(0, "show-total-period", &symbol_conf.show_total_period,
1062 "Show a column with the sum of periods"), 1101 "Show a column with the sum of periods"),
1063 OPT_BOOLEAN_SET(0, "group", &symbol_conf.event_group, &group_set, 1102 OPT_BOOLEAN_SET(0, "group", &symbol_conf.event_group, &report.group_set,
1064 "Show event group information together"), 1103 "Show event group information together"),
1065 OPT_CALLBACK_NOOPT('b', "branch-stack", &branch_mode, "", 1104 OPT_CALLBACK_NOOPT('b', "branch-stack", &branch_mode, "",
1066 "use branch records for per branch histogram filling", 1105 "use branch records for per branch histogram filling",
@@ -1177,17 +1216,7 @@ repeat:
1177 has_br_stack = perf_header__has_feat(&session->header, 1216 has_br_stack = perf_header__has_feat(&session->header,
1178 HEADER_BRANCH_STACK); 1217 HEADER_BRANCH_STACK);
1179 1218
1180 /* 1219 setup_forced_leader(&report, session->evlist);
1181 * Events in data file are not collect in groups, but we still want
1182 * the group display. Set the artificial group and set the leader's
1183 * forced_leader flag to notify the display code.
1184 */
1185 if (group_set && !session->evlist->nr_groups) {
1186 struct perf_evsel *leader = perf_evlist__first(session->evlist);
1187
1188 perf_evlist__set_leader(session->evlist);
1189 leader->forced_leader = true;
1190 }
1191 1220
1192 if (itrace_synth_opts.last_branch) 1221 if (itrace_synth_opts.last_branch)
1193 has_br_stack = true; 1222 has_br_stack = true;
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index cce926aeb0c0..313c42423393 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -2674,8 +2674,8 @@ static int list_available_scripts(const struct option *opt __maybe_unused,
2674 } 2674 }
2675 2675
2676 for_each_lang(scripts_path, scripts_dir, lang_dirent) { 2676 for_each_lang(scripts_path, scripts_dir, lang_dirent) {
2677 snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path, 2677 scnprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path,
2678 lang_dirent->d_name); 2678 lang_dirent->d_name);
2679 lang_dir = opendir(lang_path); 2679 lang_dir = opendir(lang_path);
2680 if (!lang_dir) 2680 if (!lang_dir)
2681 continue; 2681 continue;
@@ -2684,8 +2684,8 @@ static int list_available_scripts(const struct option *opt __maybe_unused,
2684 script_root = get_script_root(script_dirent, REPORT_SUFFIX); 2684 script_root = get_script_root(script_dirent, REPORT_SUFFIX);
2685 if (script_root) { 2685 if (script_root) {
2686 desc = script_desc__findnew(script_root); 2686 desc = script_desc__findnew(script_root);
2687 snprintf(script_path, MAXPATHLEN, "%s/%s", 2687 scnprintf(script_path, MAXPATHLEN, "%s/%s",
2688 lang_path, script_dirent->d_name); 2688 lang_path, script_dirent->d_name);
2689 read_script_info(desc, script_path); 2689 read_script_info(desc, script_path);
2690 free(script_root); 2690 free(script_root);
2691 } 2691 }
@@ -2721,7 +2721,7 @@ static int check_ev_match(char *dir_name, char *scriptname,
2721 int match, len; 2721 int match, len;
2722 FILE *fp; 2722 FILE *fp;
2723 2723
2724 sprintf(filename, "%s/bin/%s-record", dir_name, scriptname); 2724 scnprintf(filename, MAXPATHLEN, "%s/bin/%s-record", dir_name, scriptname);
2725 2725
2726 fp = fopen(filename, "r"); 2726 fp = fopen(filename, "r");
2727 if (!fp) 2727 if (!fp)
@@ -2799,8 +2799,8 @@ int find_scripts(char **scripts_array, char **scripts_path_array)
2799 } 2799 }
2800 2800
2801 for_each_lang(scripts_path, scripts_dir, lang_dirent) { 2801 for_each_lang(scripts_path, scripts_dir, lang_dirent) {
2802 snprintf(lang_path, MAXPATHLEN, "%s/%s", scripts_path, 2802 scnprintf(lang_path, MAXPATHLEN, "%s/%s", scripts_path,
2803 lang_dirent->d_name); 2803 lang_dirent->d_name);
2804#ifdef NO_LIBPERL 2804#ifdef NO_LIBPERL
2805 if (strstr(lang_path, "perl")) 2805 if (strstr(lang_path, "perl"))
2806 continue; 2806 continue;
@@ -2855,8 +2855,8 @@ static char *get_script_path(const char *script_root, const char *suffix)
2855 return NULL; 2855 return NULL;
2856 2856
2857 for_each_lang(scripts_path, scripts_dir, lang_dirent) { 2857 for_each_lang(scripts_path, scripts_dir, lang_dirent) {
2858 snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path, 2858 scnprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path,
2859 lang_dirent->d_name); 2859 lang_dirent->d_name);
2860 lang_dir = opendir(lang_path); 2860 lang_dir = opendir(lang_path);
2861 if (!lang_dir) 2861 if (!lang_dir)
2862 continue; 2862 continue;
@@ -2867,8 +2867,8 @@ static char *get_script_path(const char *script_root, const char *suffix)
2867 free(__script_root); 2867 free(__script_root);
2868 closedir(lang_dir); 2868 closedir(lang_dir);
2869 closedir(scripts_dir); 2869 closedir(scripts_dir);
2870 snprintf(script_path, MAXPATHLEN, "%s/%s", 2870 scnprintf(script_path, MAXPATHLEN, "%s/%s",
2871 lang_path, script_dirent->d_name); 2871 lang_path, script_dirent->d_name);
2872 return strdup(script_path); 2872 return strdup(script_path);
2873 } 2873 }
2874 free(__script_root); 2874 free(__script_root);
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 0fa9ea3a6d92..f5c454855908 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -2331,11 +2331,16 @@ static int add_default_attributes(void)
2331 return 0; 2331 return 0;
2332 2332
2333 if (transaction_run) { 2333 if (transaction_run) {
2334 struct parse_events_error errinfo;
2335
2334 if (pmu_have_event("cpu", "cycles-ct") && 2336 if (pmu_have_event("cpu", "cycles-ct") &&
2335 pmu_have_event("cpu", "el-start")) 2337 pmu_have_event("cpu", "el-start"))
2336 err = parse_events(evsel_list, transaction_attrs, NULL); 2338 err = parse_events(evsel_list, transaction_attrs,
2339 &errinfo);
2337 else 2340 else
2338 err = parse_events(evsel_list, transaction_limited_attrs, NULL); 2341 err = parse_events(evsel_list,
2342 transaction_limited_attrs,
2343 &errinfo);
2339 if (err) { 2344 if (err) {
2340 fprintf(stderr, "Cannot set up transaction events\n"); 2345 fprintf(stderr, "Cannot set up transaction events\n");
2341 return -1; 2346 return -1;
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 0a26b56afcc5..113c298ed38b 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1223,8 +1223,10 @@ parse_callchain_opt(const struct option *opt, const char *arg, int unset)
1223 1223
1224static int perf_top_config(const char *var, const char *value, void *cb __maybe_unused) 1224static int perf_top_config(const char *var, const char *value, void *cb __maybe_unused)
1225{ 1225{
1226 if (!strcmp(var, "top.call-graph")) 1226 if (!strcmp(var, "top.call-graph")) {
1227 var = "call-graph.record-mode"; /* fall-through */ 1227 var = "call-graph.record-mode";
1228 return perf_default_config(var, value, cb);
1229 }
1228 if (!strcmp(var, "top.children")) { 1230 if (!strcmp(var, "top.children")) {
1229 symbol_conf.cumulate_callchain = perf_config_bool(var, value); 1231 symbol_conf.cumulate_callchain = perf_config_bool(var, value);
1230 return 0; 1232 return 0;
diff --git a/tools/perf/pmu-events/Build b/tools/perf/pmu-events/Build
index 999a4e878162..17783913d330 100644
--- a/tools/perf/pmu-events/Build
+++ b/tools/perf/pmu-events/Build
@@ -1,10 +1,12 @@
1hostprogs := jevents 1hostprogs := jevents
2 2
3jevents-y += json.o jsmn.o jevents.o 3jevents-y += json.o jsmn.o jevents.o
4CHOSTFLAGS_jevents.o = -I$(srctree)/tools/include
4pmu-events-y += pmu-events.o 5pmu-events-y += pmu-events.o
5JDIR = pmu-events/arch/$(SRCARCH) 6JDIR = pmu-events/arch/$(SRCARCH)
6JSON = $(shell [ -d $(JDIR) ] && \ 7JSON = $(shell [ -d $(JDIR) ] && \
7 find $(JDIR) -name '*.json' -o -name 'mapfile.csv') 8 find $(JDIR) -name '*.json' -o -name 'mapfile.csv')
9
8# 10#
9# Locate/process JSON files in pmu-events/arch/ 11# Locate/process JSON files in pmu-events/arch/
10# directory and create tables in pmu-events.c. 12# directory and create tables in pmu-events.c.
diff --git a/tools/perf/pmu-events/README b/tools/perf/pmu-events/README
index c2ee3e4417fe..e62b09b6a844 100644
--- a/tools/perf/pmu-events/README
+++ b/tools/perf/pmu-events/README
@@ -11,12 +11,17 @@ tree tools/perf/pmu-events/arch/foo.
11 - Regular files with '.json' extension in the name are assumed to be 11 - Regular files with '.json' extension in the name are assumed to be
12 JSON files, each of which describes a set of PMU events. 12 JSON files, each of which describes a set of PMU events.
13 13
14 - Regular files with basename starting with 'mapfile.csv' are assumed 14 - The CSV file that maps a specific CPU to its set of PMU events is to
15 to be a CSV file that maps a specific CPU to its set of PMU events. 15 be named 'mapfile.csv' (see below for mapfile format).
16 (see below for mapfile format)
17 16
18 - Directories are traversed, but all other files are ignored. 17 - Directories are traversed, but all other files are ignored.
19 18
19 - To reduce JSON event duplication per architecture, platform JSONs may
20 use "ArchStdEvent" keyword to dereference an "Architecture standard
21 events", defined in architecture standard JSONs.
22 Architecture standard JSONs must be located in the architecture root
23 folder. Matching is based on the "EventName" field.
24
20The PMU events supported by a CPU model are expected to grouped into topics 25The PMU events supported by a CPU model are expected to grouped into topics
21such as Pipelining, Cache, Memory, Floating-point etc. All events for a topic 26such as Pipelining, Cache, Memory, Floating-point etc. All events for a topic
22should be placed in a separate JSON file - where the file name identifies 27should be placed in a separate JSON file - where the file name identifies
@@ -29,6 +34,10 @@ sub directory. Thus for the Silvermont X86 CPU:
29 Cache.json Memory.json Virtual-Memory.json 34 Cache.json Memory.json Virtual-Memory.json
30 Frontend.json Pipeline.json 35 Frontend.json Pipeline.json
31 36
37The JSONs folder for a CPU model/family may be placed in the root arch
38folder, or may be placed in a vendor sub-folder under the arch folder
39for instances where the arch and vendor are not the same.
40
32Using the JSON files and the mapfile, 'jevents' generates the C source file, 41Using the JSON files and the mapfile, 'jevents' generates the C source file,
33'pmu-events.c', which encodes the two sets of tables: 42'pmu-events.c', which encodes the two sets of tables:
34 43
diff --git a/tools/perf/pmu-events/arch/arm64/cortex-a53/branch.json b/tools/perf/pmu-events/arch/arm64/arm/cortex-a53/branch.json
index 3b6208763e50..0b0e6b26605b 100644
--- a/tools/perf/pmu-events/arch/arm64/cortex-a53/branch.json
+++ b/tools/perf/pmu-events/arch/arm64/arm/cortex-a53/branch.json
@@ -1,25 +1,23 @@
1[ 1[
2 {, 2 {
3 "EventCode": "0x7A", 3 "ArchStdEvent": "BR_INDIRECT_SPEC",
4 "EventName": "BR_INDIRECT_SPEC",
5 "BriefDescription": "Branch speculatively executed - Indirect branch"
6 }, 4 },
7 {, 5 {
8 "EventCode": "0xC9", 6 "EventCode": "0xC9",
9 "EventName": "BR_COND", 7 "EventName": "BR_COND",
10 "BriefDescription": "Conditional branch executed" 8 "BriefDescription": "Conditional branch executed"
11 }, 9 },
12 {, 10 {
13 "EventCode": "0xCA", 11 "EventCode": "0xCA",
14 "EventName": "BR_INDIRECT_MISPRED", 12 "EventName": "BR_INDIRECT_MISPRED",
15 "BriefDescription": "Indirect branch mispredicted" 13 "BriefDescription": "Indirect branch mispredicted"
16 }, 14 },
17 {, 15 {
18 "EventCode": "0xCB", 16 "EventCode": "0xCB",
19 "EventName": "BR_INDIRECT_MISPRED_ADDR", 17 "EventName": "BR_INDIRECT_MISPRED_ADDR",
20 "BriefDescription": "Indirect branch mispredicted because of address miscompare" 18 "BriefDescription": "Indirect branch mispredicted because of address miscompare"
21 }, 19 },
22 {, 20 {
23 "EventCode": "0xCC", 21 "EventCode": "0xCC",
24 "EventName": "BR_COND_MISPRED", 22 "EventName": "BR_COND_MISPRED",
25 "BriefDescription": "Conditional branch mispredicted" 23 "BriefDescription": "Conditional branch mispredicted"
diff --git a/tools/perf/pmu-events/arch/arm64/arm/cortex-a53/bus.json b/tools/perf/pmu-events/arch/arm64/arm/cortex-a53/bus.json
new file mode 100644
index 000000000000..ce33b2553277
--- /dev/null
+++ b/tools/perf/pmu-events/arch/arm64/arm/cortex-a53/bus.json
@@ -0,0 +1,8 @@
1[
2 {
3 "ArchStdEvent": "BUS_ACCESS_RD",
4 },
5 {
6 "ArchStdEvent": "BUS_ACCESS_WR",
7 }
8]
diff --git a/tools/perf/pmu-events/arch/arm64/arm/cortex-a53/cache.json b/tools/perf/pmu-events/arch/arm64/arm/cortex-a53/cache.json
new file mode 100644
index 000000000000..5dfbec43c9f9
--- /dev/null
+++ b/tools/perf/pmu-events/arch/arm64/arm/cortex-a53/cache.json
@@ -0,0 +1,27 @@
1[
2 {
3 "EventCode": "0xC2",
4 "EventName": "PREFETCH_LINEFILL",
5 "BriefDescription": "Linefill because of prefetch"
6 },
7 {
8 "EventCode": "0xC3",
9 "EventName": "PREFETCH_LINEFILL_DROP",
10 "BriefDescription": "Instruction Cache Throttle occurred"
11 },
12 {
13 "EventCode": "0xC4",
14 "EventName": "READ_ALLOC_ENTER",
15 "BriefDescription": "Entering read allocate mode"
16 },
17 {
18 "EventCode": "0xC5",
19 "EventName": "READ_ALLOC",
20 "BriefDescription": "Read allocate mode"
21 },
22 {
23 "EventCode": "0xC8",
24 "EventName": "EXT_SNOOP",
25 "BriefDescription": "SCU Snooped data from another CPU for this CPU"
26 }
27]
diff --git a/tools/perf/pmu-events/arch/arm64/cortex-a53/memory.json b/tools/perf/pmu-events/arch/arm64/arm/cortex-a53/memory.json
index 480d9f7460ab..25ae642ba381 100644
--- a/tools/perf/pmu-events/arch/arm64/cortex-a53/memory.json
+++ b/tools/perf/pmu-events/arch/arm64/arm/cortex-a53/memory.json
@@ -1,20 +1,10 @@
1[ 1[
2 {, 2 {
3 "EventCode": "0x60",
4 "EventName": "BUS_ACCESS_LD",
5 "BriefDescription": "Bus access - Read"
6 },
7 {,
8 "EventCode": "0x61",
9 "EventName": "BUS_ACCESS_ST",
10 "BriefDescription": "Bus access - Write"
11 },
12 {,
13 "EventCode": "0xC0", 3 "EventCode": "0xC0",
14 "EventName": "EXT_MEM_REQ", 4 "EventName": "EXT_MEM_REQ",
15 "BriefDescription": "External memory request" 5 "BriefDescription": "External memory request"
16 }, 6 },
17 {, 7 {
18 "EventCode": "0xC1", 8 "EventCode": "0xC1",
19 "EventName": "EXT_MEM_REQ_NC", 9 "EventName": "EXT_MEM_REQ_NC",
20 "BriefDescription": "Non-cacheable external memory request" 10 "BriefDescription": "Non-cacheable external memory request"
diff --git a/tools/perf/pmu-events/arch/arm64/arm/cortex-a53/other.json b/tools/perf/pmu-events/arch/arm64/arm/cortex-a53/other.json
new file mode 100644
index 000000000000..6cc6cbd7bf0b
--- /dev/null
+++ b/tools/perf/pmu-events/arch/arm64/arm/cortex-a53/other.json
@@ -0,0 +1,28 @@
1[
2 {
3 "ArchStdEvent": "EXC_IRQ",
4 },
5 {
6 "ArchStdEvent": "EXC_FIQ",
7 },
8 {
9 "EventCode": "0xC6",
10 "EventName": "PRE_DECODE_ERR",
11 "BriefDescription": "Pre-decode error"
12 },
13 {
14 "EventCode": "0xD0",
15 "EventName": "L1I_CACHE_ERR",
16 "BriefDescription": "L1 Instruction Cache (data or tag) memory error"
17 },
18 {
19 "EventCode": "0xD1",
20 "EventName": "L1D_CACHE_ERR",
21 "BriefDescription": "L1 Data Cache (data, tag or dirty) memory error, correctable or non-correctable"
22 },
23 {
24 "EventCode": "0xD2",
25 "EventName": "TLB_ERR",
26 "BriefDescription": "TLB memory error"
27 }
28]
diff --git a/tools/perf/pmu-events/arch/arm64/cortex-a53/pipeline.json b/tools/perf/pmu-events/arch/arm64/arm/cortex-a53/pipeline.json
index 3149fb90555a..f45a6b5d0025 100644
--- a/tools/perf/pmu-events/arch/arm64/cortex-a53/pipeline.json
+++ b/tools/perf/pmu-events/arch/arm64/arm/cortex-a53/pipeline.json
@@ -1,50 +1,50 @@
1[ 1[
2 {, 2 {
3 "EventCode": "0xC7", 3 "EventCode": "0xC7",
4 "EventName": "STALL_SB_FULL", 4 "EventName": "STALL_SB_FULL",
5 "BriefDescription": "Data Write operation that stalls the pipeline because the store buffer is full" 5 "BriefDescription": "Data Write operation that stalls the pipeline because the store buffer is full"
6 }, 6 },
7 {, 7 {
8 "EventCode": "0xE0", 8 "EventCode": "0xE0",
9 "EventName": "OTHER_IQ_DEP_STALL", 9 "EventName": "OTHER_IQ_DEP_STALL",
10 "BriefDescription": "Cycles that the DPU IQ is empty and that is not because of a recent micro-TLB miss, instruction cache miss or pre-decode error" 10 "BriefDescription": "Cycles that the DPU IQ is empty and that is not because of a recent micro-TLB miss, instruction cache miss or pre-decode error"
11 }, 11 },
12 {, 12 {
13 "EventCode": "0xE1", 13 "EventCode": "0xE1",
14 "EventName": "IC_DEP_STALL", 14 "EventName": "IC_DEP_STALL",
15 "BriefDescription": "Cycles the DPU IQ is empty and there is an instruction cache miss being processed" 15 "BriefDescription": "Cycles the DPU IQ is empty and there is an instruction cache miss being processed"
16 }, 16 },
17 {, 17 {
18 "EventCode": "0xE2", 18 "EventCode": "0xE2",
19 "EventName": "IUTLB_DEP_STALL", 19 "EventName": "IUTLB_DEP_STALL",
20 "BriefDescription": "Cycles the DPU IQ is empty and there is an instruction micro-TLB miss being processed" 20 "BriefDescription": "Cycles the DPU IQ is empty and there is an instruction micro-TLB miss being processed"
21 }, 21 },
22 {, 22 {
23 "EventCode": "0xE3", 23 "EventCode": "0xE3",
24 "EventName": "DECODE_DEP_STALL", 24 "EventName": "DECODE_DEP_STALL",
25 "BriefDescription": "Cycles the DPU IQ is empty and there is a pre-decode error being processed" 25 "BriefDescription": "Cycles the DPU IQ is empty and there is a pre-decode error being processed"
26 }, 26 },
27 {, 27 {
28 "EventCode": "0xE4", 28 "EventCode": "0xE4",
29 "EventName": "OTHER_INTERLOCK_STALL", 29 "EventName": "OTHER_INTERLOCK_STALL",
30 "BriefDescription": "Cycles there is an interlock other than Advanced SIMD/Floating-point instructions or load/store instruction" 30 "BriefDescription": "Cycles there is an interlock other than Advanced SIMD/Floating-point instructions or load/store instruction"
31 }, 31 },
32 {, 32 {
33 "EventCode": "0xE5", 33 "EventCode": "0xE5",
34 "EventName": "AGU_DEP_STALL", 34 "EventName": "AGU_DEP_STALL",
35 "BriefDescription": "Cycles there is an interlock for a load/store instruction waiting for data to calculate the address in the AGU" 35 "BriefDescription": "Cycles there is an interlock for a load/store instruction waiting for data to calculate the address in the AGU"
36 }, 36 },
37 {, 37 {
38 "EventCode": "0xE6", 38 "EventCode": "0xE6",
39 "EventName": "SIMD_DEP_STALL", 39 "EventName": "SIMD_DEP_STALL",
40 "BriefDescription": "Cycles there is an interlock for an Advanced SIMD/Floating-point operation." 40 "BriefDescription": "Cycles there is an interlock for an Advanced SIMD/Floating-point operation."
41 }, 41 },
42 {, 42 {
43 "EventCode": "0xE7", 43 "EventCode": "0xE7",
44 "EventName": "LD_DEP_STALL", 44 "EventName": "LD_DEP_STALL",
45 "BriefDescription": "Cycles there is a stall in the Wr stage because of a load miss" 45 "BriefDescription": "Cycles there is a stall in the Wr stage because of a load miss"
46 }, 46 },
47 {, 47 {
48 "EventCode": "0xE8", 48 "EventCode": "0xE8",
49 "EventName": "ST_DEP_STALL", 49 "EventName": "ST_DEP_STALL",
50 "BriefDescription": "Cycles there is a stall in the Wr stage because of a store" 50 "BriefDescription": "Cycles there is a stall in the Wr stage because of a store"
diff --git a/tools/perf/pmu-events/arch/arm64/armv8-recommended.json b/tools/perf/pmu-events/arch/arm64/armv8-recommended.json
new file mode 100644
index 000000000000..6328828c018c
--- /dev/null
+++ b/tools/perf/pmu-events/arch/arm64/armv8-recommended.json
@@ -0,0 +1,452 @@
1[
2 {
3 "PublicDescription": "Attributable Level 1 data cache access, read",
4 "EventCode": "0x40",
5 "EventName": "L1D_CACHE_RD",
6 "BriefDescription": "L1D cache access, read"
7 },
8 {
9 "PublicDescription": "Attributable Level 1 data cache access, write",
10 "EventCode": "0x41",
11 "EventName": "L1D_CACHE_WR",
12 "BriefDescription": "L1D cache access, write"
13 },
14 {
15 "PublicDescription": "Attributable Level 1 data cache refill, read",
16 "EventCode": "0x42",
17 "EventName": "L1D_CACHE_REFILL_RD",
18 "BriefDescription": "L1D cache refill, read"
19 },
20 {
21 "PublicDescription": "Attributable Level 1 data cache refill, write",
22 "EventCode": "0x43",
23 "EventName": "L1D_CACHE_REFILL_WR",
24 "BriefDescription": "L1D cache refill, write"
25 },
26 {
27 "PublicDescription": "Attributable Level 1 data cache refill, inner",
28 "EventCode": "0x44",
29 "EventName": "L1D_CACHE_REFILL_INNER",
30 "BriefDescription": "L1D cache refill, inner"
31 },
32 {
33 "PublicDescription": "Attributable Level 1 data cache refill, outer",
34 "EventCode": "0x45",
35 "EventName": "L1D_CACHE_REFILL_OUTER",
36 "BriefDescription": "L1D cache refill, outer"
37 },
38 {
39 "PublicDescription": "Attributable Level 1 data cache Write-Back, victim",
40 "EventCode": "0x46",
41 "EventName": "L1D_CACHE_WB_VICTIM",
42 "BriefDescription": "L1D cache Write-Back, victim"
43 },
44 {
45 "PublicDescription": "Level 1 data cache Write-Back, cleaning and coherency",
46 "EventCode": "0x47",
47 "EventName": "L1D_CACHE_WB_CLEAN",
48 "BriefDescription": "L1D cache Write-Back, cleaning and coherency"
49 },
50 {
51 "PublicDescription": "Attributable Level 1 data cache invalidate",
52 "EventCode": "0x48",
53 "EventName": "L1D_CACHE_INVAL",
54 "BriefDescription": "L1D cache invalidate"
55 },
56 {
57 "PublicDescription": "Attributable Level 1 data TLB refill, read",
58 "EventCode": "0x4C",
59 "EventName": "L1D_TLB_REFILL_RD",
60 "BriefDescription": "L1D tlb refill, read"
61 },
62 {
63 "PublicDescription": "Attributable Level 1 data TLB refill, write",
64 "EventCode": "0x4D",
65 "EventName": "L1D_TLB_REFILL_WR",
66 "BriefDescription": "L1D tlb refill, write"
67 },
68 {
69 "PublicDescription": "Attributable Level 1 data or unified TLB access, read",
70 "EventCode": "0x4E",
71 "EventName": "L1D_TLB_RD",
72 "BriefDescription": "L1D tlb access, read"
73 },
74 {
75 "PublicDescription": "Attributable Level 1 data or unified TLB access, write",
76 "EventCode": "0x4F",
77 "EventName": "L1D_TLB_WR",
78 "BriefDescription": "L1D tlb access, write"
79 },
80 {
81 "PublicDescription": "Attributable Level 2 data cache access, read",
82 "EventCode": "0x50",
83 "EventName": "L2D_CACHE_RD",
84 "BriefDescription": "L2D cache access, read"
85 },
86 {
87 "PublicDescription": "Attributable Level 2 data cache access, write",
88 "EventCode": "0x51",
89 "EventName": "L2D_CACHE_WR",
90 "BriefDescription": "L2D cache access, write"
91 },
92 {
93 "PublicDescription": "Attributable Level 2 data cache refill, read",
94 "EventCode": "0x52",
95 "EventName": "L2D_CACHE_REFILL_RD",
96 "BriefDescription": "L2D cache refill, read"
97 },
98 {
99 "PublicDescription": "Attributable Level 2 data cache refill, write",
100 "EventCode": "0x53",
101 "EventName": "L2D_CACHE_REFILL_WR",
102 "BriefDescription": "L2D cache refill, write"
103 },
104 {
105 "PublicDescription": "Attributable Level 2 data cache Write-Back, victim",
106 "EventCode": "0x56",
107 "EventName": "L2D_CACHE_WB_VICTIM",
108 "BriefDescription": "L2D cache Write-Back, victim"
109 },
110 {
111 "PublicDescription": "Level 2 data cache Write-Back, cleaning and coherency",
112 "EventCode": "0x57",
113 "EventName": "L2D_CACHE_WB_CLEAN",
114 "BriefDescription": "L2D cache Write-Back, cleaning and coherency"
115 },
116 {
117 "PublicDescription": "Attributable Level 2 data cache invalidate",
118 "EventCode": "0x58",
119 "EventName": "L2D_CACHE_INVAL",
120 "BriefDescription": "L2D cache invalidate"
121 },
122 {
123 "PublicDescription": "Attributable Level 2 data or unified TLB refill, read",
124 "EventCode": "0x5c",
125 "EventName": "L2D_TLB_REFILL_RD",
126 "BriefDescription": "L2D cache refill, read"
127 },
128 {
129 "PublicDescription": "Attributable Level 2 data or unified TLB refill, write",
130 "EventCode": "0x5d",
131 "EventName": "L2D_TLB_REFILL_WR",
132 "BriefDescription": "L2D cache refill, write"
133 },
134 {
135 "PublicDescription": "Attributable Level 2 data or unified TLB access, read",
136 "EventCode": "0x5e",
137 "EventName": "L2D_TLB_RD",
138 "BriefDescription": "L2D cache access, read"
139 },
140 {
141 "PublicDescription": "Attributable Level 2 data or unified TLB access, write",
142 "EventCode": "0x5f",
143 "EventName": "L2D_TLB_WR",
144 "BriefDescription": "L2D cache access, write"
145 },
146 {
147 "PublicDescription": "Bus access read",
148 "EventCode": "0x60",
149 "EventName": "BUS_ACCESS_RD",
150 "BriefDescription": "Bus access read"
151 },
152 {
153 "PublicDescription": "Bus access write",
154 "EventCode": "0x61",
155 "EventName": "BUS_ACCESS_WR",
156 "BriefDescription": "Bus access write"
157 }
158 {
159 "PublicDescription": "Bus access, Normal, Cacheable, Shareable",
160 "EventCode": "0x62",
161 "EventName": "BUS_ACCESS_SHARED",
162 "BriefDescription": "Bus access, Normal, Cacheable, Shareable"
163 }
164 {
165 "PublicDescription": "Bus access, not Normal, Cacheable, Shareable",
166 "EventCode": "0x63",
167 "EventName": "BUS_ACCESS_NOT_SHARED",
168 "BriefDescription": "Bus access, not Normal, Cacheable, Shareable"
169 }
170 {
171 "PublicDescription": "Bus access, Normal",
172 "EventCode": "0x64",
173 "EventName": "BUS_ACCESS_NORMAL",
174 "BriefDescription": "Bus access, Normal"
175 }
176 {
177 "PublicDescription": "Bus access, peripheral",
178 "EventCode": "0x65",
179 "EventName": "BUS_ACCESS_PERIPH",
180 "BriefDescription": "Bus access, peripheral"
181 }
182 {
183 "PublicDescription": "Data memory access, read",
184 "EventCode": "0x66",
185 "EventName": "MEM_ACCESS_RD",
186 "BriefDescription": "Data memory access, read"
187 }
188 {
189 "PublicDescription": "Data memory access, write",
190 "EventCode": "0x67",
191 "EventName": "MEM_ACCESS_WR",
192 "BriefDescription": "Data memory access, write"
193 }
194 {
195 "PublicDescription": "Unaligned access, read",
196 "EventCode": "0x68",
197 "EventName": "UNALIGNED_LD_SPEC",
198 "BriefDescription": "Unaligned access, read"
199 }
200 {
201 "PublicDescription": "Unaligned access, write",
202 "EventCode": "0x69",
203 "EventName": "UNALIGNED_ST_SPEC",
204 "BriefDescription": "Unaligned access, write"
205 }
206 {
207 "PublicDescription": "Unaligned access",
208 "EventCode": "0x6a",
209 "EventName": "UNALIGNED_LDST_SPEC",
210 "BriefDescription": "Unaligned access"
211 }
212 {
213 "PublicDescription": "Exclusive operation speculatively executed, LDREX or LDX",
214 "EventCode": "0x6c",
215 "EventName": "LDREX_SPEC",
216 "BriefDescription": "Exclusive operation speculatively executed, LDREX or LDX"
217 }
218 {
219 "PublicDescription": "Exclusive operation speculatively executed, STREX or STX pass",
220 "EventCode": "0x6d",
221 "EventName": "STREX_PASS_SPEC",
222 "BriefDescription": "Exclusive operation speculatively executed, STREX or STX pass"
223 }
224 {
225 "PublicDescription": "Exclusive operation speculatively executed, STREX or STX fail",
226 "EventCode": "0x6e",
227 "EventName": "STREX_FAIL_SPEC",
228 "BriefDescription": "Exclusive operation speculatively executed, STREX or STX fail"
229 }
230 {
231 "PublicDescription": "Exclusive operation speculatively executed, STREX or STX",
232 "EventCode": "0x6f",
233 "EventName": "STREX_SPEC",
234 "BriefDescription": "Exclusive operation speculatively executed, STREX or STX"
235 }
236 {
237 "PublicDescription": "Operation speculatively executed, load",
238 "EventCode": "0x70",
239 "EventName": "LD_SPEC",
240 "BriefDescription": "Operation speculatively executed, load"
241 }
242 {
243 "PublicDescription": "Operation speculatively executed, store"
244 "EventCode": "0x71",
245 "EventName": "ST_SPEC",
246 "BriefDescription": "Operation speculatively executed, store"
247 }
248 {
249 "PublicDescription": "Operation speculatively executed, load or store",
250 "EventCode": "0x72",
251 "EventName": "LDST_SPEC",
252 "BriefDescription": "Operation speculatively executed, load or store"
253 }
254 {
255 "PublicDescription": "Operation speculatively executed, integer data processing",
256 "EventCode": "0x73",
257 "EventName": "DP_SPEC",
258 "BriefDescription": "Operation speculatively executed, integer data processing"
259 }
260 {
261 "PublicDescription": "Operation speculatively executed, Advanced SIMD instruction",
262 "EventCode": "0x74",
263 "EventName": "ASE_SPEC",
264 "BriefDescription": "Operation speculatively executed, Advanced SIMD instruction",
265 }
266 {
267 "PublicDescription": "Operation speculatively executed, floating-point instruction",
268 "EventCode": "0x75",
269 "EventName": "VFP_SPEC",
270 "BriefDescription": "Operation speculatively executed, floating-point instruction"
271 }
272 {
273 "PublicDescription": "Operation speculatively executed, software change of the PC",
274 "EventCode": "0x76",
275 "EventName": "PC_WRITE_SPEC",
276 "BriefDescription": "Operation speculatively executed, software change of the PC"
277 }
278 {
279 "PublicDescription": "Operation speculatively executed, Cryptographic instruction",
280 "EventCode": "0x77",
281 "EventName": "CRYPTO_SPEC",
282 "BriefDescription": "Operation speculatively executed, Cryptographic instruction"
283 }
284 {
285 "PublicDescription": "Branch speculatively executed, immediate branch"
286 "EventCode": "0x78",
287 "EventName": "BR_IMMED_SPEC",
288 "BriefDescription": "Branch speculatively executed, immediate branch"
289 }
290 {
291 "PublicDescription": "Branch speculatively executed, procedure return"
292 "EventCode": "0x79",
293 "EventName": "BR_RETURN_SPEC",
294 "BriefDescription": "Branch speculatively executed, procedure return"
295 }
296 {
297 "PublicDescription": "Branch speculatively executed, indirect branch"
298 "EventCode": "0x7a",
299 "EventName": "BR_INDIRECT_SPEC",
300 "BriefDescription": "Branch speculatively executed, indirect branch"
301 }
302 {
303 "PublicDescription": "Barrier speculatively executed, ISB"
304 "EventCode": "0x7c",
305 "EventName": "ISB_SPEC",
306 "BriefDescription": "Barrier speculatively executed, ISB"
307 }
308 {
309 "PublicDescription": "Barrier speculatively executed, DSB"
310 "EventCode": "0x7d",
311 "EventName": "DSB_SPEC",
312 "BriefDescription": "Barrier speculatively executed, DSB"
313 }
314 {
315 "PublicDescription": "Barrier speculatively executed, DMB"
316 "EventCode": "0x7e",
317 "EventName": "DMB_SPEC",
318 "BriefDescription": "Barrier speculatively executed, DMB"
319 }
320 {
321 "PublicDescription": "Exception taken, Other synchronous"
322 "EventCode": "0x81",
323 "EventName": "EXC_UNDEF",
324 "BriefDescription": "Exception taken, Other synchronous"
325 }
326 {
327 "PublicDescription": "Exception taken, Supervisor Call"
328 "EventCode": "0x82",
329 "EventName": "EXC_SVC",
330 "BriefDescription": "Exception taken, Supervisor Call"
331 }
332 {
333 "PublicDescription": "Exception taken, Instruction Abort"
334 "EventCode": "0x83",
335 "EventName": "EXC_PABORT",
336 "BriefDescription": "Exception taken, Instruction Abort"
337 }
338 {
339 "PublicDescription": "Exception taken, Data Abort and SError"
340 "EventCode": "0x84",
341 "EventName": "EXC_DABORT",
342 "BriefDescription": "Exception taken, Data Abort and SError"
343 }
344 {
345 "PublicDescription": "Exception taken, IRQ"
346 "EventCode": "0x86",
347 "EventName": "EXC_IRQ",
348 "BriefDescription": "Exception taken, IRQ"
349 }
350 {
351 "PublicDescription": "Exception taken, FIQ"
352 "EventCode": "0x87",
353 "EventName": "EXC_FIQ",
354 "BriefDescription": "Exception taken, FIQ"
355 }
356 {
357 "PublicDescription": "Exception taken, Secure Monitor Call"
358 "EventCode": "0x88",
359 "EventName": "EXC_SMC",
360 "BriefDescription": "Exception taken, Secure Monitor Call"
361 }
362 {
363 "PublicDescription": "Exception taken, Hypervisor Call"
364 "EventCode": "0x8a",
365 "EventName": "EXC_HVC",
366 "BriefDescription": "Exception taken, Hypervisor Call"
367 }
368 {
369 "PublicDescription": "Exception taken, Instruction Abort not taken locally"
370 "EventCode": "0x8b",
371 "EventName": "EXC_TRAP_PABORT",
372 "BriefDescription": "Exception taken, Instruction Abort not taken locally"
373 }
374 {
375 "PublicDescription": "Exception taken, Data Abort or SError not taken locally"
376 "EventCode": "0x8c",
377 "EventName": "EXC_TRAP_DABORT",
378 "BriefDescription": "Exception taken, Data Abort or SError not taken locally"
379 }
380 {
381 "PublicDescription": "Exception taken, Other traps not taken locally"
382 "EventCode": "0x8d",
383 "EventName": "EXC_TRAP_OTHER",
384 "BriefDescription": "Exception taken, Other traps not taken locally"
385 }
386 {
387 "PublicDescription": "Exception taken, IRQ not taken locally"
388 "EventCode": "0x8e",
389 "EventName": "EXC_TRAP_IRQ",
390 "BriefDescription": "Exception taken, IRQ not taken locally"
391 }
392 {
393 "PublicDescription": "Exception taken, FIQ not taken locally"
394 "EventCode": "0x8f",
395 "EventName": "EXC_TRAP_FIQ",
396 "BriefDescription": "Exception taken, FIQ not taken locally"
397 }
398 {
399 "PublicDescription": "Release consistency operation speculatively executed, Load-Acquire"
400 "EventCode": "0x90",
401 "EventName": "RC_LD_SPEC",
402 "BriefDescription": "Release consistency operation speculatively executed, Load-Acquire"
403 }
404 {
405 "PublicDescription": "Release consistency operation speculatively executed, Store-Release"
406 "EventCode": "0x91",
407 "EventName": "RC_ST_SPEC",
408 "BriefDescription": "Release consistency operation speculatively executed, Store-Release"
409 }
410 {
411 "PublicDescription": "Attributable Level 3 data or unified cache access, read"
412 "EventCode": "0xa0",
413 "EventName": "L3D_CACHE_RD",
414 "BriefDescription": "Attributable Level 3 data or unified cache access, read"
415 }
416 {
417 "PublicDescription": "Attributable Level 3 data or unified cache access, write"
418 "EventCode": "0xa1",
419 "EventName": "L3D_CACHE_WR",
420 "BriefDescription": "Attributable Level 3 data or unified cache access, write"
421 }
422 {
423 "PublicDescription": "Attributable Level 3 data or unified cache refill, read"
424 "EventCode": "0xa2",
425 "EventName": "L3D_CACHE_REFILL_RD",
426 "BriefDescription": "Attributable Level 3 data or unified cache refill, read"
427 }
428 {
429 "PublicDescription": "Attributable Level 3 data or unified cache refill, write"
430 "EventCode": "0xa3",
431 "EventName": "L3D_CACHE_REFILL_WR",
432 "BriefDescription": "Attributable Level 3 data or unified cache refill, write"
433 }
434 {
435 "PublicDescription": "Attributable Level 3 data or unified cache Write-Back, victim"
436 "EventCode": "0xa6",
437 "EventName": "L3D_CACHE_WB_VICTIM",
438 "BriefDescription": "Attributable Level 3 data or unified cache Write-Back, victim"
439 }
440 {
441 "PublicDescription": "Attributable Level 3 data or unified cache Write-Back, cache clean"
442 "EventCode": "0xa7",
443 "EventName": "L3D_CACHE_WB_CLEAN",
444 "BriefDescription": "Attributable Level 3 data or unified cache Write-Back, cache clean"
445 }
446 {
447 "PublicDescription": "Attributable Level 3 data or unified cache access, invalidate"
448 "EventCode": "0xa8",
449 "EventName": "L3D_CACHE_INVAL",
450 "BriefDescription": "Attributable Level 3 data or unified cache access, invalidate"
451 }
452]
diff --git a/tools/perf/pmu-events/arch/arm64/cavium/thunderx2-imp-def.json b/tools/perf/pmu-events/arch/arm64/cavium/thunderx2-imp-def.json
deleted file mode 100644
index 2db45c40ebc7..000000000000
--- a/tools/perf/pmu-events/arch/arm64/cavium/thunderx2-imp-def.json
+++ /dev/null
@@ -1,62 +0,0 @@
1[
2 {
3 "PublicDescription": "Attributable Level 1 data cache access, read",
4 "EventCode": "0x40",
5 "EventName": "l1d_cache_rd",
6 "BriefDescription": "L1D cache read",
7 },
8 {
9 "PublicDescription": "Attributable Level 1 data cache access, write ",
10 "EventCode": "0x41",
11 "EventName": "l1d_cache_wr",
12 "BriefDescription": "L1D cache write",
13 },
14 {
15 "PublicDescription": "Attributable Level 1 data cache refill, read",
16 "EventCode": "0x42",
17 "EventName": "l1d_cache_refill_rd",
18 "BriefDescription": "L1D cache refill read",
19 },
20 {
21 "PublicDescription": "Attributable Level 1 data cache refill, write",
22 "EventCode": "0x43",
23 "EventName": "l1d_cache_refill_wr",
24 "BriefDescription": "L1D refill write",
25 },
26 {
27 "PublicDescription": "Attributable Level 1 data TLB refill, read",
28 "EventCode": "0x4C",
29 "EventName": "l1d_tlb_refill_rd",
30 "BriefDescription": "L1D tlb refill read",
31 },
32 {
33 "PublicDescription": "Attributable Level 1 data TLB refill, write",
34 "EventCode": "0x4D",
35 "EventName": "l1d_tlb_refill_wr",
36 "BriefDescription": "L1D tlb refill write",
37 },
38 {
39 "PublicDescription": "Attributable Level 1 data or unified TLB access, read",
40 "EventCode": "0x4E",
41 "EventName": "l1d_tlb_rd",
42 "BriefDescription": "L1D tlb read",
43 },
44 {
45 "PublicDescription": "Attributable Level 1 data or unified TLB access, write",
46 "EventCode": "0x4F",
47 "EventName": "l1d_tlb_wr",
48 "BriefDescription": "L1D tlb write",
49 },
50 {
51 "PublicDescription": "Bus access read",
52 "EventCode": "0x60",
53 "EventName": "bus_access_rd",
54 "BriefDescription": "Bus access read",
55 },
56 {
57 "PublicDescription": "Bus access write",
58 "EventCode": "0x61",
59 "EventName": "bus_access_wr",
60 "BriefDescription": "Bus access write",
61 }
62]
diff --git a/tools/perf/pmu-events/arch/arm64/cavium/thunderx2/core-imp-def.json b/tools/perf/pmu-events/arch/arm64/cavium/thunderx2/core-imp-def.json
new file mode 100644
index 000000000000..bc03c06c3918
--- /dev/null
+++ b/tools/perf/pmu-events/arch/arm64/cavium/thunderx2/core-imp-def.json
@@ -0,0 +1,32 @@
1[
2 {
3 "ArchStdEvent": "L1D_CACHE_RD",
4 },
5 {
6 "ArchStdEvent": "L1D_CACHE_WR",
7 },
8 {
9 "ArchStdEvent": "L1D_CACHE_REFILL_RD",
10 },
11 {
12 "ArchStdEvent": "L1D_CACHE_REFILL_WR",
13 },
14 {
15 "ArchStdEvent": "L1D_TLB_REFILL_RD",
16 },
17 {
18 "ArchStdEvent": "L1D_TLB_REFILL_WR",
19 },
20 {
21 "ArchStdEvent": "L1D_TLB_RD",
22 },
23 {
24 "ArchStdEvent": "L1D_TLB_WR",
25 },
26 {
27 "ArchStdEvent": "BUS_ACCESS_RD",
28 },
29 {
30 "ArchStdEvent": "BUS_ACCESS_WR",
31 }
32]
diff --git a/tools/perf/pmu-events/arch/arm64/cortex-a53/bus.json b/tools/perf/pmu-events/arch/arm64/cortex-a53/bus.json
deleted file mode 100644
index 480d9f7460ab..000000000000
--- a/tools/perf/pmu-events/arch/arm64/cortex-a53/bus.json
+++ /dev/null
@@ -1,22 +0,0 @@
1[
2 {,
3 "EventCode": "0x60",
4 "EventName": "BUS_ACCESS_LD",
5 "BriefDescription": "Bus access - Read"
6 },
7 {,
8 "EventCode": "0x61",
9 "EventName": "BUS_ACCESS_ST",
10 "BriefDescription": "Bus access - Write"
11 },
12 {,
13 "EventCode": "0xC0",
14 "EventName": "EXT_MEM_REQ",
15 "BriefDescription": "External memory request"
16 },
17 {,
18 "EventCode": "0xC1",
19 "EventName": "EXT_MEM_REQ_NC",
20 "BriefDescription": "Non-cacheable external memory request"
21 }
22]
diff --git a/tools/perf/pmu-events/arch/arm64/cortex-a53/cache.json b/tools/perf/pmu-events/arch/arm64/cortex-a53/cache.json
deleted file mode 100644
index 11baad6344b9..000000000000
--- a/tools/perf/pmu-events/arch/arm64/cortex-a53/cache.json
+++ /dev/null
@@ -1,27 +0,0 @@
1[
2 {,
3 "EventCode": "0xC2",
4 "EventName": "PREFETCH_LINEFILL",
5 "BriefDescription": "Linefill because of prefetch"
6 },
7 {,
8 "EventCode": "0xC3",
9 "EventName": "PREFETCH_LINEFILL_DROP",
10 "BriefDescription": "Instruction Cache Throttle occurred"
11 },
12 {,
13 "EventCode": "0xC4",
14 "EventName": "READ_ALLOC_ENTER",
15 "BriefDescription": "Entering read allocate mode"
16 },
17 {,
18 "EventCode": "0xC5",
19 "EventName": "READ_ALLOC",
20 "BriefDescription": "Read allocate mode"
21 },
22 {,
23 "EventCode": "0xC8",
24 "EventName": "EXT_SNOOP",
25 "BriefDescription": "SCU Snooped data from another CPU for this CPU"
26 }
27]
diff --git a/tools/perf/pmu-events/arch/arm64/cortex-a53/other.json b/tools/perf/pmu-events/arch/arm64/cortex-a53/other.json
deleted file mode 100644
index 73a22402d003..000000000000
--- a/tools/perf/pmu-events/arch/arm64/cortex-a53/other.json
+++ /dev/null
@@ -1,32 +0,0 @@
1[
2 {,
3 "EventCode": "0x86",
4 "EventName": "EXC_IRQ",
5 "BriefDescription": "Exception taken, IRQ"
6 },
7 {,
8 "EventCode": "0x87",
9 "EventName": "EXC_FIQ",
10 "BriefDescription": "Exception taken, FIQ"
11 },
12 {,
13 "EventCode": "0xC6",
14 "EventName": "PRE_DECODE_ERR",
15 "BriefDescription": "Pre-decode error"
16 },
17 {,
18 "EventCode": "0xD0",
19 "EventName": "L1I_CACHE_ERR",
20 "BriefDescription": "L1 Instruction Cache (data or tag) memory error"
21 },
22 {,
23 "EventCode": "0xD1",
24 "EventName": "L1D_CACHE_ERR",
25 "BriefDescription": "L1 Data Cache (data, tag or dirty) memory error, correctable or non-correctable"
26 },
27 {,
28 "EventCode": "0xD2",
29 "EventName": "TLB_ERR",
30 "BriefDescription": "TLB memory error"
31 }
32]
diff --git a/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/core-imp-def.json b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/core-imp-def.json
new file mode 100644
index 000000000000..9f0f15d15f75
--- /dev/null
+++ b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/core-imp-def.json
@@ -0,0 +1,122 @@
1[
2 {
3 "ArchStdEvent": "L1D_CACHE_RD",
4 },
5 {
6 "ArchStdEvent": "L1D_CACHE_WR",
7 },
8 {
9 "ArchStdEvent": "L1D_CACHE_REFILL_RD",
10 },
11 {
12 "ArchStdEvent": "L1D_CACHE_REFILL_WR",
13 },
14 {
15 "ArchStdEvent": "L1D_CACHE_WB_VICTIM",
16 },
17 {
18 "ArchStdEvent": "L1D_CACHE_WB_CLEAN",
19 },
20 {
21 "ArchStdEvent": "L1D_CACHE_INVAL",
22 },
23 {
24 "ArchStdEvent": "L1D_TLB_REFILL_RD",
25 },
26 {
27 "ArchStdEvent": "L1D_TLB_REFILL_WR",
28 },
29 {
30 "ArchStdEvent": "L1D_TLB_RD",
31 },
32 {
33 "ArchStdEvent": "L1D_TLB_WR",
34 },
35 {
36 "ArchStdEvent": "L2D_CACHE_RD",
37 },
38 {
39 "ArchStdEvent": "L2D_CACHE_WR",
40 },
41 {
42 "ArchStdEvent": "L2D_CACHE_REFILL_RD",
43 },
44 {
45 "ArchStdEvent": "L2D_CACHE_REFILL_WR",
46 },
47 {
48 "ArchStdEvent": "L2D_CACHE_WB_VICTIM",
49 },
50 {
51 "ArchStdEvent": "L2D_CACHE_WB_CLEAN",
52 },
53 {
54 "ArchStdEvent": "L2D_CACHE_INVAL",
55 },
56 {
57 "PublicDescription": "Level 1 instruction cache prefetch access count",
58 "EventCode": "0x102e",
59 "EventName": "L1I_CACHE_PRF",
60 "BriefDescription": "L1I cache prefetch access count",
61 },
62 {
63 "PublicDescription": "Level 1 instruction cache miss due to prefetch access count",
64 "EventCode": "0x102f",
65 "EventName": "L1I_CACHE_PRF_REFILL",
66 "BriefDescription": "L1I cache miss due to prefetch access count",
67 },
68 {
69 "PublicDescription": "Instruction queue is empty",
70 "EventCode": "0x1043",
71 "EventName": "IQ_IS_EMPTY",
72 "BriefDescription": "Instruction queue is empty",
73 },
74 {
75 "PublicDescription": "Instruction fetch stall cycles",
76 "EventCode": "0x1044",
77 "EventName": "IF_IS_STALL",
78 "BriefDescription": "Instruction fetch stall cycles",
79 },
80 {
81 "PublicDescription": "Instructions can receive, but not send",
82 "EventCode": "0x2014",
83 "EventName": "FETCH_BUBBLE",
84 "BriefDescription": "Instructions can receive, but not send",
85 },
86 {
87 "PublicDescription": "Prefetch request from LSU",
88 "EventCode": "0x6013",
89 "EventName": "PRF_REQ",
90 "BriefDescription": "Prefetch request from LSU",
91 },
92 {
93 "PublicDescription": "Hit on prefetched data",
94 "EventCode": "0x6014",
95 "EventName": "HIT_ON_PRF",
96 "BriefDescription": "Hit on prefetched data",
97 },
98 {
99 "PublicDescription": "Cycles of that the number of issuing micro operations are less than 4",
100 "EventCode": "0x7001",
101 "EventName": "EXE_STALL_CYCLE",
102 "BriefDescription": "Cycles of that the number of issue ups are less than 4",
103 },
104 {
105 "PublicDescription": "No any micro operation is issued and meanwhile any load operation is not resolved",
106 "EventCode": "0x7004",
107 "EventName": "MEM_STALL_ANYLOAD",
108 "BriefDescription": "No any micro operation is issued and meanwhile any load operation is not resolved",
109 },
110 {
111 "PublicDescription": "No any micro operation is issued and meanwhile there is any load operation missing L1 cache and pending data refill",
112 "EventCode": "0x7006",
113 "EventName": "MEM_STALL_L1MISS",
114 "BriefDescription": "No any micro operation is issued and meanwhile there is any load operation missing L1 cache and pending data refill",
115 },
116 {
117 "PublicDescription": "No any micro operation is issued and meanwhile there is any load operation missing both L1 and L2 cache and pending data refill from L3 cache",
118 "EventCode": "0x7007",
119 "EventName": "MEM_STALL_L2MISS",
120 "BriefDescription": "No any micro operation is issued and meanwhile there is any load operation missing both L1 and L2 cache and pending data refill from L3 cache",
121 },
122]
diff --git a/tools/perf/pmu-events/arch/arm64/mapfile.csv b/tools/perf/pmu-events/arch/arm64/mapfile.csv
index e61c9ca6cf9e..f03e26ecb658 100644
--- a/tools/perf/pmu-events/arch/arm64/mapfile.csv
+++ b/tools/perf/pmu-events/arch/arm64/mapfile.csv
@@ -12,5 +12,7 @@
12# 12#
13# 13#
14#Family-model,Version,Filename,EventType 14#Family-model,Version,Filename,EventType
150x00000000420f5160,v1,cavium,core 150x00000000410fd03[[:xdigit:]],v1,arm/cortex-a53,core
160x00000000410fd03[[:xdigit:]],v1,cortex-a53,core 160x00000000420f5160,v1,cavium/thunderx2,core
170x00000000430f0af0,v1,cavium/thunderx2,core
180x00000000480fd010,v1,hisilicon/hip08,core
diff --git a/tools/perf/pmu-events/arch/powerpc/power9/cache.json b/tools/perf/pmu-events/arch/powerpc/power9/cache.json
index 7945c5196c43..851072105054 100644
--- a/tools/perf/pmu-events/arch/powerpc/power9/cache.json
+++ b/tools/perf/pmu-events/arch/powerpc/power9/cache.json
@@ -20,11 +20,6 @@
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" 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 }, 21 },
22 {, 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", 23 "EventCode": "0x4D12A",
29 "EventName": "PM_MRK_DATA_FROM_RL4_CYC", 24 "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" 25 "BriefDescription": "Duration in cycles to reload from another chip's L4 on the same Node or Group ( Remote) due to a marked load"
@@ -80,21 +75,6 @@
80 "BriefDescription": "Threshold counter exceed a count of 4096" 75 "BriefDescription": "Threshold counter exceed a count of 4096"
81 }, 76 },
82 {, 77 {,
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", 78 "EventCode": "0x3F14A",
99 "EventName": "PM_MRK_DPTEG_FROM_RMEM", 79 "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" 80 "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"
@@ -123,10 +103,5 @@
123 "EventCode": "0x1002A", 103 "EventCode": "0x1002A",
124 "EventName": "PM_CMPLU_STALL_LARX", 104 "EventName": "PM_CMPLU_STALL_LARX",
125 "BriefDescription": "Finish stall because the NTF instruction was a larx waiting to be satisfied" 105 "BriefDescription": "Finish stall because the NTF instruction was a larx waiting to be satisfied"
126 },
127 {,
128 "EventCode": "0x1C058",
129 "EventName": "PM_DTLB_MISS_16G",
130 "BriefDescription": "Data TLB Miss page size 16G"
131 } 106 }
132] \ No newline at end of file 107] \ 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
index bd8361b5fd6a..f9fa84b16fb5 100644
--- a/tools/perf/pmu-events/arch/powerpc/power9/frontend.json
+++ b/tools/perf/pmu-events/arch/powerpc/power9/frontend.json
@@ -155,11 +155,6 @@
155 "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" 155 "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"
156 }, 156 },
157 {, 157 {,
158 "EventCode": "0x3C056",
159 "EventName": "PM_DTLB_MISS_64K",
160 "BriefDescription": "Data TLB Miss page size 64K"
161 },
162 {,
163 "EventCode": "0x30060", 158 "EventCode": "0x30060",
164 "EventName": "PM_TM_TRANS_RUN_INST", 159 "EventName": "PM_TM_TRANS_RUN_INST",
165 "BriefDescription": "Run instructions completed in transactional state (gated by the run latch)" 160 "BriefDescription": "Run instructions completed in transactional state (gated by the run latch)"
@@ -345,11 +340,6 @@
345 "BriefDescription": "Larx finished" 340 "BriefDescription": "Larx finished"
346 }, 341 },
347 {, 342 {,
348 "EventCode": "0x4C056",
349 "EventName": "PM_DTLB_MISS_16M",
350 "BriefDescription": "Data TLB Miss page size 16M"
351 },
352 {,
353 "EventCode": "0x1003A", 343 "EventCode": "0x1003A",
354 "EventName": "PM_CMPLU_STALL_LSU_FIN", 344 "EventName": "PM_CMPLU_STALL_LSU_FIN",
355 "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" 345 "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"
diff --git a/tools/perf/pmu-events/arch/powerpc/power9/marked.json b/tools/perf/pmu-events/arch/powerpc/power9/marked.json
index 22f9f32060a8..b1954c38bab1 100644
--- a/tools/perf/pmu-events/arch/powerpc/power9/marked.json
+++ b/tools/perf/pmu-events/arch/powerpc/power9/marked.json
@@ -530,11 +530,6 @@
530 "BriefDescription": "Counts all Icache reloads includes demand, prefetch, prefetch turned into demand and demand turned into prefetch" 530 "BriefDescription": "Counts all Icache reloads includes demand, prefetch, prefetch turned into demand and demand turned into prefetch"
531 }, 531 },
532 {, 532 {,
533 "EventCode": "0x4003C",
534 "EventName": "PM_DISP_HELD_SYNC_HOLD",
535 "BriefDescription": "Cycles in which dispatch is held because of a synchronizing instruction in the pipeline"
536 },
537 {,
538 "EventCode": "0x3003C", 533 "EventCode": "0x3003C",
539 "EventName": "PM_CMPLU_STALL_NESTED_TEND", 534 "EventName": "PM_CMPLU_STALL_NESTED_TEND",
540 "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" 535 "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"
diff --git a/tools/perf/pmu-events/arch/powerpc/power9/memory.json b/tools/perf/pmu-events/arch/powerpc/power9/memory.json
index 9960d1c0dd44..2e2ebc700c74 100644
--- a/tools/perf/pmu-events/arch/powerpc/power9/memory.json
+++ b/tools/perf/pmu-events/arch/powerpc/power9/memory.json
@@ -45,11 +45,6 @@
45 "BriefDescription": "count of Loads completed" 45 "BriefDescription": "count of Loads completed"
46 }, 46 },
47 {, 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", 48 "EventCode": "0x4C042",
54 "EventName": "PM_DATA_FROM_L3", 49 "EventName": "PM_DATA_FROM_L3",
55 "BriefDescription": "The processor's data cache was reloaded from local core's L3 due to a demand load" 50 "BriefDescription": "The processor's data cache was reloaded from local core's L3 due to a demand load"
diff --git a/tools/perf/pmu-events/arch/powerpc/power9/other.json b/tools/perf/pmu-events/arch/powerpc/power9/other.json
index 5ce312973f1e..48cf4f920b3f 100644
--- a/tools/perf/pmu-events/arch/powerpc/power9/other.json
+++ b/tools/perf/pmu-events/arch/powerpc/power9/other.json
@@ -70,6 +70,11 @@
70 "BriefDescription": "Cycles thread running at priority level 0 or 1" 70 "BriefDescription": "Cycles thread running at priority level 0 or 1"
71 }, 71 },
72 {, 72 {,
73 "EventCode": "0x4C054",
74 "EventName": "PM_DERAT_MISS_16G_1G",
75 "BriefDescription": "Data ERAT Miss (Data TLB Access) page size 16G (hpt mode) or 1G (radix mode)"
76 },
77 {,
73 "EventCode": "0x2084", 78 "EventCode": "0x2084",
74 "EventName": "PM_FLUSH_HB_RESTORE_CYC", 79 "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" 80 "BriefDescription": "Cycles in which no new instructions can be dispatched to the ICT after a flush. History buffer recovery"
@@ -107,12 +112,12 @@
107 {, 112 {,
108 "EventCode": "0x360B2", 113 "EventCode": "0x360B2",
109 "EventName": "PM_L3_GRP_GUESS_WRONG_LOW", 114 "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" 115 "BriefDescription": "Prefetch scope predictor selected GS or NNS, but was wrong because scope was LNS"
111 }, 116 },
112 {, 117 {,
113 "EventCode": "0x168A6", 118 "EventCode": "0x168A6",
114 "EventName": "PM_TM_CAM_OVERFLOW", 119 "EventName": "PM_TM_CAM_OVERFLOW",
115 "BriefDescription": "L3 TM cam overflow during L2 co of SC" 120 "BriefDescription": "L3 TM CAM is full when a L2 castout of TM_SC line occurs. Line is pushed to memory"
116 }, 121 },
117 {, 122 {,
118 "EventCode": "0xE8B0", 123 "EventCode": "0xE8B0",
@@ -150,11 +155,6 @@
150 "BriefDescription": "All ISU rejects" 155 "BriefDescription": "All ISU rejects"
151 }, 156 },
152 {, 157 {,
153 "EventCode": "0x460A6",
154 "EventName": "PM_RD_FORMING_SC",
155 "BriefDescription": "Read forming SC"
156 },
157 {,
158 "EventCode": "0x468A0", 158 "EventCode": "0x468A0",
159 "EventName": "PM_L3_PF_OFF_CHIP_MEM", 159 "EventName": "PM_L3_PF_OFF_CHIP_MEM",
160 "BriefDescription": "L3 PF from Off chip memory" 160 "BriefDescription": "L3 PF from Off chip memory"
@@ -187,7 +187,7 @@
187 {, 187 {,
188 "EventCode": "0x368A6", 188 "EventCode": "0x368A6",
189 "EventName": "PM_SNP_TM_HIT_T", 189 "EventName": "PM_SNP_TM_HIT_T",
190 "BriefDescription": "Snp TM sthit T/Tn/Te" 190 "BriefDescription": "TM snoop that is a store hits line in L3 in T, Tn or Te state (shared modified)"
191 }, 191 },
192 {, 192 {,
193 "EventCode": "0x3001A", 193 "EventCode": "0x3001A",
@@ -205,6 +205,11 @@
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" 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 }, 206 },
207 {, 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. The sum of this pair subtracted from the total number of allocs will give the total allocs in normal phase"
211 },
212 {,
208 "EventCode": "0xF894", 213 "EventCode": "0xF894",
209 "EventName": "PM_LSU3_L1_CAM_CANCEL", 214 "EventName": "PM_LSU3_L1_CAM_CANCEL",
210 "BriefDescription": "ls3 l1 tm cam cancel" 215 "BriefDescription": "ls3 l1 tm cam cancel"
@@ -227,7 +232,12 @@
227 {, 232 {,
228 "EventCode": "0x468A6", 233 "EventCode": "0x468A6",
229 "EventName": "PM_RD_CLEARING_SC", 234 "EventName": "PM_RD_CLEARING_SC",
230 "BriefDescription": "Read clearing SC" 235 "BriefDescription": "Core TM load hits line in L3 in TM_SC state and causes it to be invalidated"
236 },
237 {,
238 "EventCode": "0xD0B0",
239 "EventName": "PM_HWSYNC",
240 "BriefDescription": ""
231 }, 241 },
232 {, 242 {,
233 "EventCode": "0x168B0", 243 "EventCode": "0x168B0",
@@ -265,6 +275,11 @@
265 "BriefDescription": "Prefetch stream allocated by the hardware prefetch mechanism" 275 "BriefDescription": "Prefetch stream allocated by the hardware prefetch mechanism"
266 }, 276 },
267 {, 277 {,
278 "EventCode": "0xF0BC",
279 "EventName": "PM_LS2_UNALIGNED_ST",
280 "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"
281 },
282 {,
268 "EventCode": "0xD0AC", 283 "EventCode": "0xD0AC",
269 "EventName": "PM_SRQ_SYNC_CYC", 284 "EventName": "PM_SRQ_SYNC_CYC",
270 "BriefDescription": "A sync is in the S2Q (edge detect to count)" 285 "BriefDescription": "A sync is in the S2Q (edge detect to count)"
@@ -275,6 +290,11 @@
275 "BriefDescription": "Marked instruction was reloaded from a location beyond the local chiplet" 290 "BriefDescription": "Marked instruction was reloaded from a location beyond the local chiplet"
276 }, 291 },
277 {, 292 {,
293 "EventCode": "0x58A8",
294 "EventName": "PM_DECODE_HOLD_ICT_FULL",
295 "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"
296 },
297 {,
278 "EventCode": "0x26082", 298 "EventCode": "0x26082",
279 "EventName": "PM_L2_IC_INV", 299 "EventName": "PM_L2_IC_INV",
280 "BriefDescription": "I-cache Invalidates sent over the realod bus to the core" 300 "BriefDescription": "I-cache Invalidates sent over the realod bus to the core"
@@ -365,6 +385,16 @@
365 "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" 385 "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"
366 }, 386 },
367 {, 387 {,
388 "EventCode": "0xF888",
389 "EventName": "PM_LSU1_STORE_REJECT",
390 "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"
391 },
392 {,
393 "EventCode": "0xC098",
394 "EventName": "PM_LS2_UNALIGNED_LD",
395 "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"
396 },
397 {,
368 "EventCode": "0x20058", 398 "EventCode": "0x20058",
369 "EventName": "PM_DARQ1_10_12_ENTRIES", 399 "EventName": "PM_DARQ1_10_12_ENTRIES",
370 "BriefDescription": "Cycles in which 10 or more DARQ1 entries (out of 12) are in use" 400 "BriefDescription": "Cycles in which 10 or more DARQ1 entries (out of 12) are in use"
@@ -372,7 +402,7 @@
372 {, 402 {,
373 "EventCode": "0x360A6", 403 "EventCode": "0x360A6",
374 "EventName": "PM_SNP_TM_HIT_M", 404 "EventName": "PM_SNP_TM_HIT_M",
375 "BriefDescription": "Snp TM st hit M/Mu" 405 "BriefDescription": "TM snoop that is a store hits line in L3 in M or Mu state (exclusive modified)"
376 }, 406 },
377 {, 407 {,
378 "EventCode": "0x5898", 408 "EventCode": "0x5898",
@@ -395,9 +425,9 @@
395 "BriefDescription": "A data line was written to the L1 due to a hardware or software prefetch" 425 "BriefDescription": "A data line was written to the L1 due to a hardware or software prefetch"
396 }, 426 },
397 {, 427 {,
398 "EventCode": "0xF888", 428 "EventCode": "0x2608E",
399 "EventName": "PM_LSU1_STORE_REJECT", 429 "EventName": "PM_TM_LD_CONF",
400 "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" 430 "BriefDescription": "TM Load (fav or non-fav) ran into conflict (failed)"
401 }, 431 },
402 {, 432 {,
403 "EventCode": "0x1D144", 433 "EventCode": "0x1D144",
@@ -422,7 +452,7 @@
422 {, 452 {,
423 "EventCode": "0x26884", 453 "EventCode": "0x26884",
424 "EventName": "PM_DSIDE_MRU_TOUCH", 454 "EventName": "PM_DSIDE_MRU_TOUCH",
425 "BriefDescription": "D-side L2 MRU touch sent to L2" 455 "BriefDescription": "D-side L2 MRU touch commands sent to the L2"
426 }, 456 },
427 {, 457 {,
428 "EventCode": "0x30134", 458 "EventCode": "0x30134",
@@ -440,6 +470,16 @@
440 "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" 470 "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"
441 }, 471 },
442 {, 472 {,
473 "EventCode": "0xC094",
474 "EventName": "PM_LS0_UNALIGNED_LD",
475 "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"
476 },
477 {,
478 "EventCode": "0xF8BC",
479 "EventName": "PM_LS3_UNALIGNED_ST",
480 "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"
481 },
482 {,
443 "EventCode": "0x460AE", 483 "EventCode": "0x460AE",
444 "EventName": "PM_L3_P2_CO_RTY", 484 "EventName": "PM_L3_P2_CO_RTY",
445 "BriefDescription": "L3 CO received retry port 2 (memory only), every retry counted" 485 "BriefDescription": "L3 CO received retry port 2 (memory only), every retry counted"
@@ -492,7 +532,7 @@
492 {, 532 {,
493 "EventCode": "0xC880", 533 "EventCode": "0xC880",
494 "EventName": "PM_LS1_LD_VECTOR_FIN", 534 "EventName": "PM_LS1_LD_VECTOR_FIN",
495 "BriefDescription": "" 535 "BriefDescription": "LS1 finished load vector op"
496 }, 536 },
497 {, 537 {,
498 "EventCode": "0x2894", 538 "EventCode": "0x2894",
@@ -515,6 +555,11 @@
515 "BriefDescription": "Marked derat reload (miss) for any page size" 555 "BriefDescription": "Marked derat reload (miss) for any page size"
516 }, 556 },
517 {, 557 {,
558 "EventCode": "0x160A0",
559 "EventName": "PM_L3_PF_MISS_L3",
560 "BriefDescription": "L3 PF missed in L3"
561 },
562 {,
518 "EventCode": "0x1C04A", 563 "EventCode": "0x1C04A",
519 "EventName": "PM_DATA_FROM_RL2L3_SHR", 564 "EventName": "PM_DATA_FROM_RL2L3_SHR",
520 "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" 565 "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"
@@ -565,11 +610,21 @@
565 "BriefDescription": "L2 guess local (LNS) and guess was not correct (ie data not on chip)" 610 "BriefDescription": "L2 guess local (LNS) and guess was not correct (ie data not on chip)"
566 }, 611 },
567 {, 612 {,
613 "EventCode": "0xC888",
614 "EventName": "PM_LSU_DTLB_MISS_64K",
615 "BriefDescription": "Data TLB Miss page size 64K"
616 },
617 {,
568 "EventCode": "0xE0A4", 618 "EventCode": "0xE0A4",
569 "EventName": "PM_TMA_REQ_L2", 619 "EventName": "PM_TMA_REQ_L2",
570 "BriefDescription": "addrs only req to L2 only on the first one,Indication that Load footprint is not expanding" 620 "BriefDescription": "addrs only req to L2 only on the first one,Indication that Load footprint is not expanding"
571 }, 621 },
572 {, 622 {,
623 "EventCode": "0xC088",
624 "EventName": "PM_LSU_DTLB_MISS_4K",
625 "BriefDescription": "Data TLB Miss page size 4K"
626 },
627 {,
573 "EventCode": "0x3C042", 628 "EventCode": "0x3C042",
574 "EventName": "PM_DATA_FROM_L3_DISP_CONFLICT", 629 "EventName": "PM_DATA_FROM_L3_DISP_CONFLICT",
575 "BriefDescription": "The processor's data cache was reloaded from local core's L3 with dispatch conflict due to a demand load" 630 "BriefDescription": "The processor's data cache was reloaded from local core's L3 with dispatch conflict due to a demand load"
@@ -602,7 +657,7 @@
602 {, 657 {,
603 "EventCode": "0x26084", 658 "EventCode": "0x26084",
604 "EventName": "PM_L2_RCLD_DISP_FAIL_OTHER", 659 "EventName": "PM_L2_RCLD_DISP_FAIL_OTHER",
605 "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)" 660 "BriefDescription": "All D-side-Ld or I-side-instruction-fetch dispatch attempts for this thread that failed due to reasons other than an address collision conflicts with an L2 machines (e.g. Read-Claim/Snoop machine not available)"
606 }, 661 },
607 {, 662 {,
608 "EventCode": "0x101E4", 663 "EventCode": "0x101E4",
@@ -647,12 +702,12 @@
647 {, 702 {,
648 "EventCode": "0x46080", 703 "EventCode": "0x46080",
649 "EventName": "PM_L2_DISP_ALL_L2MISS", 704 "EventName": "PM_L2_DISP_ALL_L2MISS",
650 "BriefDescription": "All successful Ld/St dispatches for this thread that were an L2 miss (excludes i_l2mru_tch_reqs)" 705 "BriefDescription": "All successful D-side-Ld/St or I-side-instruction-fetch dispatches for this thread that were an L2 miss"
651 }, 706 },
652 {, 707 {,
653 "EventCode": "0x160A0", 708 "EventCode": "0xF8B8",
654 "EventName": "PM_L3_PF_MISS_L3", 709 "EventName": "PM_LS1_UNALIGNED_ST",
655 "BriefDescription": "L3 PF missed in L3" 710 "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"
656 }, 711 },
657 {, 712 {,
658 "EventCode": "0x408C", 713 "EventCode": "0x408C",
@@ -667,7 +722,7 @@
667 {, 722 {,
668 "EventCode": "0x160B2", 723 "EventCode": "0x160B2",
669 "EventName": "PM_L3_LOC_GUESS_CORRECT", 724 "EventName": "PM_L3_LOC_GUESS_CORRECT",
670 "BriefDescription": "initial scope=node/chip (LNS) and data from local node (local) (pred successful) - always PFs only" 725 "BriefDescription": "Prefetch scope predictor selected LNS and was correct"
671 }, 726 },
672 {, 727 {,
673 "EventCode": "0x48B4", 728 "EventCode": "0x48B4",
@@ -767,7 +822,7 @@
767 {, 822 {,
768 "EventCode": "0x36082", 823 "EventCode": "0x36082",
769 "EventName": "PM_L2_LD_DISP", 824 "EventName": "PM_L2_LD_DISP",
770 "BriefDescription": "All successful I-or-D side load dispatches for this thread (excludes i_l2mru_tch_reqs)" 825 "BriefDescription": "All successful D-side-Ld or I-side-instruction-fetch dispatches for this thread"
771 }, 826 },
772 {, 827 {,
773 "EventCode": "0xF8B0", 828 "EventCode": "0xF8B0",
@@ -787,7 +842,7 @@
787 {, 842 {,
788 "EventCode": "0x16884", 843 "EventCode": "0x16884",
789 "EventName": "PM_L2_RCLD_DISP_FAIL_ADDR", 844 "EventName": "PM_L2_RCLD_DISP_FAIL_ADDR",
790 "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)" 845 "BriefDescription": "All D-side-Ld or I-side-instruction-fetch dispatch attempts for this thread that failed due to an address collision conflicts with an L2 machines already working on this line (e.g. ld-hit-stq or Read-claim/Castout/Snoop machines)"
791 }, 846 },
792 {, 847 {,
793 "EventCode": "0x460A0", 848 "EventCode": "0x460A0",
@@ -830,6 +885,11 @@
830 "BriefDescription": "Instruction prefetch requests" 885 "BriefDescription": "Instruction prefetch requests"
831 }, 886 },
832 {, 887 {,
888 "EventCode": "0xC898",
889 "EventName": "PM_LS3_UNALIGNED_LD",
890 "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"
891 },
892 {,
833 "EventCode": "0x488C", 893 "EventCode": "0x488C",
834 "EventName": "PM_IC_PREF_WRITE", 894 "EventName": "PM_IC_PREF_WRITE",
835 "BriefDescription": "Instruction prefetch written into IL1" 895 "BriefDescription": "Instruction prefetch written into IL1"
@@ -837,7 +897,7 @@
837 {, 897 {,
838 "EventCode": "0xF89C", 898 "EventCode": "0xF89C",
839 "EventName": "PM_XLATE_MISS", 899 "EventName": "PM_XLATE_MISS",
840 "BriefDescription": "The LSU requested a line from L2 for translation. It may be satisfied from any source beyond L2. Includes speculative instructions" 900 "BriefDescription": "The LSU requested a line from L2 for translation. It may be satisfied from any source beyond L2. Includes speculative instructions. Includes instruction, prefetch and demand"
841 }, 901 },
842 {, 902 {,
843 "EventCode": "0x14158", 903 "EventCode": "0x14158",
@@ -850,9 +910,14 @@
850 "BriefDescription": "Duration in cycles to reload with Shared (S) data from another core's L3 on the same chip due to a marked load" 910 "BriefDescription": "Duration in cycles to reload with Shared (S) data from another core's L3 on the same chip due to a marked load"
851 }, 911 },
852 {, 912 {,
913 "EventCode": "0xC88C",
914 "EventName": "PM_LSU_DTLB_MISS_16G_1G",
915 "BriefDescription": "Data TLB Miss page size 16G (HPT) or 1G (Radix)"
916 },
917 {,
853 "EventCode": "0x268A6", 918 "EventCode": "0x268A6",
854 "EventName": "PM_TM_RST_SC", 919 "EventName": "PM_TM_RST_SC",
855 "BriefDescription": "TM-snp rst RM SC" 920 "BriefDescription": "TM snoop hits line in L3 that is TM_SC state and causes it to be invalidated"
856 }, 921 },
857 {, 922 {,
858 "EventCode": "0x468A4", 923 "EventCode": "0x468A4",
@@ -917,7 +982,7 @@
917 {, 982 {,
918 "EventCode": "0x46086", 983 "EventCode": "0x46086",
919 "EventName": "PM_L2_SN_M_RD_DONE", 984 "EventName": "PM_L2_SN_M_RD_DONE",
920 "BriefDescription": "SNP dispatched for a read and was M (true M)" 985 "BriefDescription": "Snoop dispatched for a read and was M (true M)"
921 }, 986 },
922 {, 987 {,
923 "EventCode": "0x40154", 988 "EventCode": "0x40154",
@@ -980,14 +1045,9 @@
980 "BriefDescription": "Link stack predicts right address" 1045 "BriefDescription": "Link stack predicts right address"
981 }, 1046 },
982 {, 1047 {,
983 "EventCode": "0x4C05A",
984 "EventName": "PM_DTLB_MISS_1G",
985 "BriefDescription": "Data TLB reload (after a miss) page size 1G. Implies radix translation was used"
986 },
987 {,
988 "EventCode": "0x36886", 1048 "EventCode": "0x36886",
989 "EventName": "PM_L2_SN_SX_I_DONE", 1049 "EventName": "PM_L2_SN_SX_I_DONE",
990 "BriefDescription": "SNP dispatched and went from Sx to Ix" 1050 "BriefDescription": "Snoop dispatched and went from Sx to Ix"
991 }, 1051 },
992 {, 1052 {,
993 "EventCode": "0x4E04A", 1053 "EventCode": "0x4E04A",
@@ -1000,11 +1060,6 @@
1000 "BriefDescription": "Duration in cycles to reload from another chip's L4 on a different Node or Group (Distant) due to a marked load" 1060 "BriefDescription": "Duration in cycles to reload from another chip's L4 on a different Node or Group (Distant) due to a marked load"
1001 }, 1061 },
1002 {, 1062 {,
1003 "EventCode": "0x2608E",
1004 "EventName": "PM_TM_LD_CONF",
1005 "BriefDescription": "TM Load (fav or non-fav) ran into conflict (failed)"
1006 },
1007 {,
1008 "EventCode": "0x4080", 1063 "EventCode": "0x4080",
1009 "EventName": "PM_INST_FROM_L1", 1064 "EventName": "PM_INST_FROM_L1",
1010 "BriefDescription": "Instruction fetches from L1. L1 instruction hit" 1065 "BriefDescription": "Instruction fetches from L1. L1 instruction hit"
@@ -1037,7 +1092,7 @@
1037 {, 1092 {,
1038 "EventCode": "0x260A6", 1093 "EventCode": "0x260A6",
1039 "EventName": "PM_NON_TM_RST_SC", 1094 "EventName": "PM_NON_TM_RST_SC",
1040 "BriefDescription": "Non-TM snp rst TM SC" 1095 "BriefDescription": "Non-TM snoop hits line in L3 that is TM_SC state and causes it to be invalidated"
1041 }, 1096 },
1042 {, 1097 {,
1043 "EventCode": "0x3608A", 1098 "EventCode": "0x3608A",
@@ -1065,11 +1120,6 @@
1065 "BriefDescription": "Branch mispredict flushes. Includes target and address misprecition" 1120 "BriefDescription": "Branch mispredict flushes. Includes target and address misprecition"
1066 }, 1121 },
1067 {, 1122 {,
1068 "EventCode": "0x508C",
1069 "EventName": "PM_SHL_CREATED",
1070 "BriefDescription": "Store-Hit-Load Table Entry Created"
1071 },
1072 {,
1073 "EventCode": "0x1504C", 1123 "EventCode": "0x1504C",
1074 "EventName": "PM_IPTEG_FROM_LL4", 1124 "EventName": "PM_IPTEG_FROM_LL4",
1075 "BriefDescription": "A Page Table Entry was loaded into the TLB from the local chip's L4 cache due to a instruction side request" 1125 "BriefDescription": "A Page Table Entry was loaded into the TLB from the local chip's L4 cache due to a instruction side request"
@@ -1107,7 +1157,7 @@
1107 {, 1157 {,
1108 "EventCode": "0x2608A", 1158 "EventCode": "0x2608A",
1109 "EventName": "PM_ISIDE_DISP_FAIL_ADDR", 1159 "EventName": "PM_ISIDE_DISP_FAIL_ADDR",
1110 "BriefDescription": "All I-side dispatch attempts for this thread that failed due to a addr collision with another machine (excludes i_l2mru_tch_reqs)" 1160 "BriefDescription": "All I-side-instruction-fetch dispatch attempts for this thread that failed due to an address collision conflict with an L2 machine already working on this line (e.g. ld-hit-stq or RC/CO/SN machines)"
1111 }, 1161 },
1112 {, 1162 {,
1113 "EventCode": "0x50B4", 1163 "EventCode": "0x50B4",
@@ -1180,9 +1230,9 @@
1180 "BriefDescription": "Number of stcx instructions finished. This includes instructions in the speculative path of a branch that may be flushed" 1230 "BriefDescription": "Number of stcx instructions finished. This includes instructions in the speculative path of a branch that may be flushed"
1181 }, 1231 },
1182 {, 1232 {,
1183 "EventCode": "0xE0B8", 1233 "EventCode": "0xD8AC",
1184 "EventName": "PM_LS2_TM_DISALLOW", 1234 "EventName": "PM_LWSYNC",
1185 "BriefDescription": "A TM-ineligible instruction tries to execute inside a transaction and the LSU disallows it" 1235 "BriefDescription": ""
1186 }, 1236 },
1187 {, 1237 {,
1188 "EventCode": "0x2094", 1238 "EventCode": "0x2094",
@@ -1210,6 +1260,11 @@
1210 "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)" 1260 "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)"
1211 }, 1261 },
1212 {, 1262 {,
1263 "EventCode": "0xC894",
1264 "EventName": "PM_LS1_UNALIGNED_LD",
1265 "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"
1266 },
1267 {,
1213 "EventCode": "0x360A2", 1268 "EventCode": "0x360A2",
1214 "EventName": "PM_L3_L2_CO_HIT", 1269 "EventName": "PM_L3_L2_CO_HIT",
1215 "BriefDescription": "L2 CO hits" 1270 "BriefDescription": "L2 CO hits"
@@ -1292,7 +1347,7 @@
1292 {, 1347 {,
1293 "EventCode": "0xC084", 1348 "EventCode": "0xC084",
1294 "EventName": "PM_LS2_LD_VECTOR_FIN", 1349 "EventName": "PM_LS2_LD_VECTOR_FIN",
1295 "BriefDescription": "" 1350 "BriefDescription": "LS2 finished load vector op"
1296 }, 1351 },
1297 {, 1352 {,
1298 "EventCode": "0x1608E", 1353 "EventCode": "0x1608E",
@@ -1345,6 +1400,11 @@
1345 "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" 1400 "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"
1346 }, 1401 },
1347 {, 1402 {,
1403 "EventCode": "0x36084",
1404 "EventName": "PM_L2_RCST_DISP",
1405 "BriefDescription": "All D-side store dispatch attempts for this thread"
1406 },
1407 {,
1348 "EventCode": "0x46084", 1408 "EventCode": "0x46084",
1349 "EventName": "PM_L2_RCST_DISP_FAIL_OTHER", 1409 "EventName": "PM_L2_RCST_DISP_FAIL_OTHER",
1350 "BriefDescription": "All D-side store dispatch attempts for this thread that failed due to reason other than address collision" 1410 "BriefDescription": "All D-side store dispatch attempts for this thread that failed due to reason other than address collision"
@@ -1355,11 +1415,6 @@
1355 "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." 1415 "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."
1356 }, 1416 },
1357 {, 1417 {,
1358 "EventCode": "0x36084",
1359 "EventName": "PM_L2_RCST_DISP",
1360 "BriefDescription": "All D-side store dispatch attempts for this thread"
1361 },
1362 {,
1363 "EventCode": "0x45054", 1418 "EventCode": "0x45054",
1364 "EventName": "PM_FMA_CMPL", 1419 "EventName": "PM_FMA_CMPL",
1365 "BriefDescription": "two flops operation completed (fmadd, fnmadd, fmsub, fnmsub) Scalar instructions only. " 1420 "BriefDescription": "two flops operation completed (fmadd, fnmadd, fmsub, fnmsub) Scalar instructions only. "
@@ -1372,7 +1427,7 @@
1372 {, 1427 {,
1373 "EventCode": "0x36080", 1428 "EventCode": "0x36080",
1374 "EventName": "PM_L2_INST", 1429 "EventName": "PM_L2_INST",
1375 "BriefDescription": "All successful I-side dispatches for this thread (excludes i_l2mru_tch reqs)" 1430 "BriefDescription": "All successful I-side-instruction-fetch (e.g. i-demand, i-prefetch) dispatches for this thread"
1376 }, 1431 },
1377 {, 1432 {,
1378 "EventCode": "0x3504C", 1433 "EventCode": "0x3504C",
@@ -1387,7 +1442,7 @@
1387 {, 1442 {,
1388 "EventCode": "0x1688A", 1443 "EventCode": "0x1688A",
1389 "EventName": "PM_ISIDE_DISP", 1444 "EventName": "PM_ISIDE_DISP",
1390 "BriefDescription": "All I-side dispatch attempts for this thread (excludes i_l2mru_tch_reqs)" 1445 "BriefDescription": "All I-side-instruction-fetch dispatch attempts for this thread"
1391 }, 1446 },
1392 {, 1447 {,
1393 "EventCode": "0x468AA", 1448 "EventCode": "0x468AA",
@@ -1420,6 +1475,11 @@
1420 "BriefDescription": "Load tm hit in L1" 1475 "BriefDescription": "Load tm hit in L1"
1421 }, 1476 },
1422 {, 1477 {,
1478 "EventCode": "0xE0B8",
1479 "EventName": "PM_LS2_TM_DISALLOW",
1480 "BriefDescription": "A TM-ineligible instruction tries to execute inside a transaction and the LSU disallows it"
1481 },
1482 {,
1423 "EventCode": "0x44044", 1483 "EventCode": "0x44044",
1424 "EventName": "PM_INST_FROM_L31_ECO_MOD", 1484 "EventName": "PM_INST_FROM_L31_ECO_MOD",
1425 "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)" 1485 "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)"
@@ -1467,7 +1527,7 @@
1467 {, 1527 {,
1468 "EventCode": "0x36086", 1528 "EventCode": "0x36086",
1469 "EventName": "PM_L2_RC_ST_DONE", 1529 "EventName": "PM_L2_RC_ST_DONE",
1470 "BriefDescription": "RC did store to line that was Tx or Sx" 1530 "BriefDescription": "Read-claim machine did store to line that was in Tx or Sx (Tagged or Shared state)"
1471 }, 1531 },
1472 {, 1532 {,
1473 "EventCode": "0xE8AC", 1533 "EventCode": "0xE8AC",
@@ -1500,6 +1560,11 @@
1500 "BriefDescription": "A Page Table Entry was loaded into the TLB from local core's L2 without conflict due to a instruction side request" 1560 "BriefDescription": "A Page Table Entry was loaded into the TLB from local core's L2 without conflict due to a instruction side request"
1501 }, 1561 },
1502 {, 1562 {,
1563 "EventCode": "0x460A6",
1564 "EventName": "PM_RD_FORMING_SC",
1565 "BriefDescription": "Doesn't occur"
1566 },
1567 {,
1503 "EventCode": "0x35042", 1568 "EventCode": "0x35042",
1504 "EventName": "PM_IPTEG_FROM_L3_DISP_CONFLICT", 1569 "EventName": "PM_IPTEG_FROM_L3_DISP_CONFLICT",
1505 "BriefDescription": "A Page Table Entry was loaded into the TLB from local core's L3 with dispatch conflict due to a instruction side request" 1570 "BriefDescription": "A Page Table Entry was loaded into the TLB from local core's L3 with dispatch conflict due to a instruction side request"
@@ -1527,7 +1592,7 @@
1527 {, 1592 {,
1528 "EventCode": "0x36882", 1593 "EventCode": "0x36882",
1529 "EventName": "PM_L2_LD_HIT", 1594 "EventName": "PM_L2_LD_HIT",
1530 "BriefDescription": "All successful I-or-D side load dispatches for this thread that were L2 hits (excludes i_l2mru_tch_reqs)" 1595 "BriefDescription": "All successful D-side-Ld or I-side-instruction-fetch dispatches for this thread that were L2 hits"
1531 }, 1596 },
1532 {, 1597 {,
1533 "EventCode": "0x168AC", 1598 "EventCode": "0x168AC",
@@ -1555,11 +1620,6 @@
1555 "BriefDescription": "ProbeNops dispatched" 1620 "BriefDescription": "ProbeNops dispatched"
1556 }, 1621 },
1557 {, 1622 {,
1558 "EventCode": "0x58A8",
1559 "EventName": "PM_DECODE_HOLD_ICT_FULL",
1560 "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"
1561 },
1562 {,
1563 "EventCode": "0x10052", 1623 "EventCode": "0x10052",
1564 "EventName": "PM_GRP_PUMP_MPRED_RTY", 1624 "EventName": "PM_GRP_PUMP_MPRED_RTY",
1565 "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)" 1625 "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)"
@@ -1572,7 +1632,7 @@
1572 {, 1632 {,
1573 "EventCode": "0x2688A", 1633 "EventCode": "0x2688A",
1574 "EventName": "PM_ISIDE_DISP_FAIL_OTHER", 1634 "EventName": "PM_ISIDE_DISP_FAIL_OTHER",
1575 "BriefDescription": "All I-side dispatch attempts for this thread that failed due to a reason other than addrs collision (excludes i_l2mru_tch_reqs)" 1635 "BriefDescription": "All I-side-instruction-fetch dispatch attempts for this thread that failed due to reasons other than an address collision conflict with an L2 machine (e.g. no available RC/CO machines)"
1576 }, 1636 },
1577 {, 1637 {,
1578 "EventCode": "0x2001A", 1638 "EventCode": "0x2001A",
@@ -1652,12 +1712,12 @@
1652 {, 1712 {,
1653 "EventCode": "0x46880", 1713 "EventCode": "0x46880",
1654 "EventName": "PM_ISIDE_MRU_TOUCH", 1714 "EventName": "PM_ISIDE_MRU_TOUCH",
1655 "BriefDescription": "I-side L2 MRU touch sent to L2 for this thread" 1715 "BriefDescription": "I-side L2 MRU touch sent to L2 for this thread I-side L2 MRU touch commands sent to the L2 for this thread"
1656 }, 1716 },
1657 {, 1717 {,
1658 "EventCode": "0x1C05C", 1718 "EventCode": "0x508C",
1659 "EventName": "PM_DTLB_MISS_2M", 1719 "EventName": "PM_SHL_CREATED",
1660 "BriefDescription": "Data TLB reload (after a miss) page size 2M. Implies radix translation was used" 1720 "BriefDescription": "Store-Hit-Load Table Entry Created"
1661 }, 1721 },
1662 {, 1722 {,
1663 "EventCode": "0x50B8", 1723 "EventCode": "0x50B8",
@@ -1672,7 +1732,7 @@
1672 {, 1732 {,
1673 "EventCode": "0x268B2", 1733 "EventCode": "0x268B2",
1674 "EventName": "PM_L3_LOC_GUESS_WRONG", 1734 "EventName": "PM_L3_LOC_GUESS_WRONG",
1675 "BriefDescription": "Initial scope=node (LNS) but data from out side local node (near or far or rem). Prediction too Low" 1735 "BriefDescription": "Prefetch scope predictor selected LNS, but was wrong"
1676 }, 1736 },
1677 {, 1737 {,
1678 "EventCode": "0x36088", 1738 "EventCode": "0x36088",
@@ -1685,6 +1745,11 @@
1685 "BriefDescription": "L3 PF received retry port 2, every retry counted" 1745 "BriefDescription": "L3 PF received retry port 2, every retry counted"
1686 }, 1746 },
1687 {, 1747 {,
1748 "EventCode": "0xD8B0",
1749 "EventName": "PM_PTESYNC",
1750 "BriefDescription": ""
1751 },
1752 {,
1688 "EventCode": "0x26086", 1753 "EventCode": "0x26086",
1689 "EventName": "PM_CO_TM_SC_FOOTPRINT", 1754 "EventName": "PM_CO_TM_SC_FOOTPRINT",
1690 "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" 1755 "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"
@@ -1740,6 +1805,11 @@
1740 "BriefDescription": "All successful D-Side Store dispatches that were an L2 miss for this thread" 1805 "BriefDescription": "All successful D-Side Store dispatches that were an L2 miss for this thread"
1741 }, 1806 },
1742 {, 1807 {,
1808 "EventCode": "0xF8B4",
1809 "EventName": "PM_DC_PREF_XCONS_ALLOC",
1810 "BriefDescription": "Prefetch stream allocated in the Ultra conservative phase by either the hardware prefetch mechanism or software prefetch"
1811 },
1812 {,
1743 "EventCode": "0x35048", 1813 "EventCode": "0x35048",
1744 "EventName": "PM_IPTEG_FROM_DL2L3_SHR", 1814 "EventName": "PM_IPTEG_FROM_DL2L3_SHR",
1745 "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" 1815 "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"
@@ -1782,7 +1852,7 @@
1782 {, 1852 {,
1783 "EventCode": "0x460B2", 1853 "EventCode": "0x460B2",
1784 "EventName": "PM_L3_SYS_GUESS_WRONG", 1854 "EventName": "PM_L3_SYS_GUESS_WRONG",
1785 "BriefDescription": "Initial scope=system (VGS or RNS) but data from local or near. Prediction too high" 1855 "BriefDescription": "Prefetch scope predictor selected VGS or RNS, but was wrong"
1786 }, 1856 },
1787 {, 1857 {,
1788 "EventCode": "0x58B8", 1858 "EventCode": "0x58B8",
@@ -1800,11 +1870,6 @@
1800 "BriefDescription": "Completion time tabortnoncd, tabortcd, treclaim" 1870 "BriefDescription": "Completion time tabortnoncd, tabortcd, treclaim"
1801 }, 1871 },
1802 {, 1872 {,
1803 "EventCode": "0x4C054",
1804 "EventName": "PM_DERAT_MISS_16G",
1805 "BriefDescription": "Data ERAT Miss (Data TLB Access) page size 16G"
1806 },
1807 {,
1808 "EventCode": "0x268A0", 1873 "EventCode": "0x268A0",
1809 "EventName": "PM_L3_CO_L31", 1874 "EventName": "PM_L3_CO_L31",
1810 "BriefDescription": "L3 CO to L3.1 OR of port 0 and 1 (lossy = may undercount if two cresps come in the same cyc)" 1875 "BriefDescription": "L3 CO to L3.1 OR of port 0 and 1 (lossy = may undercount if two cresps come in the same cyc)"
@@ -1862,7 +1927,7 @@
1862 {, 1927 {,
1863 "EventCode": "0x368B2", 1928 "EventCode": "0x368B2",
1864 "EventName": "PM_L3_GRP_GUESS_WRONG_HIGH", 1929 "EventName": "PM_L3_GRP_GUESS_WRONG_HIGH",
1865 "BriefDescription": "Initial scope=group (GS or NNS) but data from local node. Prediction too high" 1930 "BriefDescription": "Prefetch scope predictor selected GS or NNS, but was wrong because scope was VGS or RNS"
1866 }, 1931 },
1867 {, 1932 {,
1868 "EventCode": "0xE8BC", 1933 "EventCode": "0xE8BC",
@@ -1897,7 +1962,7 @@
1897 {, 1962 {,
1898 "EventCode": "0x260B2", 1963 "EventCode": "0x260B2",
1899 "EventName": "PM_L3_SYS_GUESS_CORRECT", 1964 "EventName": "PM_L3_SYS_GUESS_CORRECT",
1900 "BriefDescription": "Initial scope=system (VGS or RNS) and data from outside group (far or rem)(pred successful)" 1965 "BriefDescription": "Prefetch scope predictor selected VGS or RNS and was correct"
1901 }, 1966 },
1902 {, 1967 {,
1903 "EventCode": "0x1D146", 1968 "EventCode": "0x1D146",
@@ -1915,6 +1980,11 @@
1915 "BriefDescription": "RC requests that were on group (aka nodel) pump attempts" 1980 "BriefDescription": "RC requests that were on group (aka nodel) pump attempts"
1916 }, 1981 },
1917 {, 1982 {,
1983 "EventCode": "0xC08C",
1984 "EventName": "PM_LSU_DTLB_MISS_16M_2M",
1985 "BriefDescription": "Data TLB Miss page size 16M (HPT) or 2M (Radix)"
1986 },
1987 {,
1918 "EventCode": "0x16080", 1988 "EventCode": "0x16080",
1919 "EventName": "PM_L2_LD", 1989 "EventName": "PM_L2_LD",
1920 "BriefDescription": "All successful D-side Load dispatches for this thread (L2 miss + L2 hits)" 1990 "BriefDescription": "All successful D-side Load dispatches for this thread (L2 miss + L2 hits)"
@@ -1927,7 +1997,7 @@
1927 {, 1997 {,
1928 "EventCode": "0xC080", 1998 "EventCode": "0xC080",
1929 "EventName": "PM_LS0_LD_VECTOR_FIN", 1999 "EventName": "PM_LS0_LD_VECTOR_FIN",
1930 "BriefDescription": "" 2000 "BriefDescription": "LS0 finished load vector op"
1931 }, 2001 },
1932 {, 2002 {,
1933 "EventCode": "0x368B0", 2003 "EventCode": "0x368B0",
@@ -2000,6 +2070,11 @@
2000 "BriefDescription": "Conditional Branch Completed in which the HW correctly predicted the direction as taken. Counted at completion time" 2070 "BriefDescription": "Conditional Branch Completed in which the HW correctly predicted the direction as taken. Counted at completion time"
2001 }, 2071 },
2002 {, 2072 {,
2073 "EventCode": "0xF0B8",
2074 "EventName": "PM_LS0_UNALIGNED_ST",
2075 "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"
2076 },
2077 {,
2003 "EventCode": "0x20132", 2078 "EventCode": "0x20132",
2004 "EventName": "PM_MRK_DFU_FIN", 2079 "EventName": "PM_MRK_DFU_FIN",
2005 "BriefDescription": "Decimal Unit marked Instruction Finish" 2080 "BriefDescription": "Decimal Unit marked Instruction Finish"
@@ -2007,7 +2082,7 @@
2007 {, 2082 {,
2008 "EventCode": "0x160A6", 2083 "EventCode": "0x160A6",
2009 "EventName": "PM_TM_SC_CO", 2084 "EventName": "PM_TM_SC_CO",
2010 "BriefDescription": "L3 castout TM SC line" 2085 "BriefDescription": "L3 castout of line that was StoreCopy (original value of speculatively written line) in a Transaction"
2011 }, 2086 },
2012 {, 2087 {,
2013 "EventCode": "0xC8B0", 2088 "EventCode": "0xC8B0",
@@ -2017,7 +2092,7 @@
2017 {, 2092 {,
2018 "EventCode": "0x16084", 2093 "EventCode": "0x16084",
2019 "EventName": "PM_L2_RCLD_DISP", 2094 "EventName": "PM_L2_RCLD_DISP",
2020 "BriefDescription": "All I-or-D side load dispatch attempts for this thread (excludes i_l2mru_tch_reqs)" 2095 "BriefDescription": "All D-side-Ld or I-side-instruction-fetch dispatch attempts for this thread"
2021 }, 2096 },
2022 {, 2097 {,
2023 "EventCode": "0x3F150", 2098 "EventCode": "0x3F150",
@@ -2122,12 +2197,12 @@
2122 {, 2197 {,
2123 "EventCode": "0x46082", 2198 "EventCode": "0x46082",
2124 "EventName": "PM_L2_ST_DISP", 2199 "EventName": "PM_L2_ST_DISP",
2125 "BriefDescription": "All successful D-side store dispatches for this thread (L2 miss + L2 hits)" 2200 "BriefDescription": "All successful D-side store dispatches for this thread"
2126 }, 2201 },
2127 {, 2202 {,
2128 "EventCode": "0x36880", 2203 "EventCode": "0x36880",
2129 "EventName": "PM_L2_INST_MISS", 2204 "EventName": "PM_L2_INST_MISS",
2130 "BriefDescription": "All successful I-side dispatches that were an L2 miss for this thread (excludes i_l2mru_tch reqs)" 2205 "BriefDescription": "All successful I-side-instruction-fetch (e.g. i-demand, i-prefetch) dispatches for this thread that were an L2 miss"
2131 }, 2206 },
2132 {, 2207 {,
2133 "EventCode": "0xE084", 2208 "EventCode": "0xE084",
@@ -2217,7 +2292,7 @@
2217 {, 2292 {,
2218 "EventCode": "0xC884", 2293 "EventCode": "0xC884",
2219 "EventName": "PM_LS3_LD_VECTOR_FIN", 2294 "EventName": "PM_LS3_LD_VECTOR_FIN",
2220 "BriefDescription": "" 2295 "BriefDescription": "LS3 finished load vector op"
2221 }, 2296 },
2222 {, 2297 {,
2223 "EventCode": "0x360A8", 2298 "EventCode": "0x360A8",
@@ -2242,7 +2317,7 @@
2242 {, 2317 {,
2243 "EventCode": "0x168B2", 2318 "EventCode": "0x168B2",
2244 "EventName": "PM_L3_GRP_GUESS_CORRECT", 2319 "EventName": "PM_L3_GRP_GUESS_CORRECT",
2245 "BriefDescription": "Initial scope=group (GS or NNS) and data from same group (near) (pred successful)" 2320 "BriefDescription": "Prefetch scope predictor selected GS or NNS and was correct"
2246 }, 2321 },
2247 {, 2322 {,
2248 "EventCode": "0x48A4", 2323 "EventCode": "0x48A4",
diff --git a/tools/perf/pmu-events/arch/powerpc/power9/pipeline.json b/tools/perf/pmu-events/arch/powerpc/power9/pipeline.json
index 5af1abbe82c4..b4772f54a271 100644
--- a/tools/perf/pmu-events/arch/powerpc/power9/pipeline.json
+++ b/tools/perf/pmu-events/arch/powerpc/power9/pipeline.json
@@ -65,11 +65,6 @@
65 "BriefDescription": "Dispatch Held" 65 "BriefDescription": "Dispatch Held"
66 }, 66 },
67 {, 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", 68 "EventCode": "0x200F8",
74 "EventName": "PM_EXT_INT", 69 "EventName": "PM_EXT_INT",
75 "BriefDescription": "external interrupt" 70 "BriefDescription": "external interrupt"
@@ -120,6 +115,11 @@
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" 115 "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 }, 116 },
122 {, 117 {,
118 "EventCode": "0x4C15C",
119 "EventName": "PM_MRK_DERAT_MISS_16G_1G",
120 "BriefDescription": "Marked Data ERAT Miss (Data TLB Access) page size 16G (hpt mode) and 1G (radix mode)"
121 },
122 {,
123 "EventCode": "0x10024", 123 "EventCode": "0x10024",
124 "EventName": "PM_PMC5_OVERFLOW", 124 "EventName": "PM_PMC5_OVERFLOW",
125 "BriefDescription": "Overflow from counter 5" 125 "BriefDescription": "Overflow from counter 5"
@@ -155,11 +155,6 @@
155 "BriefDescription": "Ict empty for this thread due to Icache Miss" 155 "BriefDescription": "Ict empty for this thread due to Icache Miss"
156 }, 156 },
157 {, 157 {,
158 "EventCode": "0x3D152",
159 "EventName": "PM_MRK_DERAT_MISS_1G",
160 "BriefDescription": "Marked Data ERAT Miss (Data TLB Access) page size 1G. Implies radix translation"
161 },
162 {,
163 "EventCode": "0x4F14A", 158 "EventCode": "0x4F14A",
164 "EventName": "PM_MRK_DPTEG_FROM_OFF_CHIP_CACHE", 159 "EventName": "PM_MRK_DPTEG_FROM_OFF_CHIP_CACHE",
165 "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" 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"
@@ -185,11 +180,6 @@
185 "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" 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"
186 }, 181 },
187 {, 182 {,
188 "EventCode": "0x2C05A",
189 "EventName": "PM_DERAT_MISS_1G",
190 "BriefDescription": "Data ERAT Miss (Data TLB Access) page size 1G. Implies radix translation"
191 },
192 {,
193 "EventCode": "0x1F058", 183 "EventCode": "0x1F058",
194 "EventName": "PM_RADIX_PWC_L2_PTE_FROM_L2", 184 "EventName": "PM_RADIX_PWC_L2_PTE_FROM_L2",
195 "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" 185 "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"
@@ -240,11 +230,6 @@
240 "BriefDescription": "Data PTEG reload" 230 "BriefDescription": "Data PTEG reload"
241 }, 231 },
242 {, 232 {,
243 "EventCode": "0x2D152",
244 "EventName": "PM_MRK_DERAT_MISS_2M",
245 "BriefDescription": "Marked Data ERAT Miss (Data TLB Access) page size 2M. Implies radix translation"
246 },
247 {,
248 "EventCode": "0x2C046", 233 "EventCode": "0x2C046",
249 "EventName": "PM_DATA_FROM_RL2L3_MOD", 234 "EventName": "PM_DATA_FROM_RL2L3_MOD",
250 "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" 235 "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"
@@ -290,6 +275,11 @@
290 "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" 275 "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"
291 }, 276 },
292 {, 277 {,
278 "EventCode": "0x3C054",
279 "EventName": "PM_DERAT_MISS_16M_2M",
280 "BriefDescription": "Data ERAT Miss (Data TLB Access) page size 16M (HPT mode) or 2M (Radix mode)"
281 },
282 {,
293 "EventCode": "0x4C04C", 283 "EventCode": "0x4C04C",
294 "EventName": "PM_DATA_FROM_DMEM", 284 "EventName": "PM_DATA_FROM_DMEM",
295 "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" 285 "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"
@@ -360,11 +350,6 @@
360 "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)" 350 "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)"
361 }, 351 },
362 {, 352 {,
363 "EventCode": "0x1C05A",
364 "EventName": "PM_DERAT_MISS_2M",
365 "BriefDescription": "Data ERAT Miss (Data TLB Access) page size 2M. Implies radix translation"
366 },
367 {,
368 "EventCode": "0x30024", 353 "EventCode": "0x30024",
369 "EventName": "PM_PMC6_OVERFLOW", 354 "EventName": "PM_PMC6_OVERFLOW",
370 "BriefDescription": "Overflow from counter 6" 355 "BriefDescription": "Overflow from counter 6"
@@ -375,6 +360,11 @@
375 "BriefDescription": "Branch Instruction Finished" 360 "BriefDescription": "Branch Instruction Finished"
376 }, 361 },
377 {, 362 {,
363 "EventCode": "0x3D154",
364 "EventName": "PM_MRK_DERAT_MISS_16M_2M",
365 "BriefDescription": "Marked Data ERAT Miss (Data TLB Access) page size 16M (hpt mode) or 2M (radix mode)"
366 },
367 {,
378 "EventCode": "0x30020", 368 "EventCode": "0x30020",
379 "EventName": "PM_PMC2_REWIND", 369 "EventName": "PM_PMC2_REWIND",
380 "BriefDescription": "PMC2 Rewind Event (did not match condition)" 370 "BriefDescription": "PMC2 Rewind Event (did not match condition)"
@@ -410,11 +400,6 @@
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" 400 "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 }, 401 },
412 {, 402 {,
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", 403 "EventCode": "0x14052",
419 "EventName": "PM_INST_GRP_PUMP_MPRED_RTY", 404 "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" 405 "BriefDescription": "Final Pump Scope (Group) ended up larger than Initial Pump Scope (Chip) for an instruction fetch"
@@ -445,11 +430,6 @@
445 "BriefDescription": "Icache miss demand cycles" 430 "BriefDescription": "Icache miss demand cycles"
446 }, 431 },
447 {, 432 {,
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", 433 "EventCode": "0x2D14E",
454 "EventName": "PM_MRK_DATA_FROM_L21_SHR", 434 "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" 435 "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"
diff --git a/tools/perf/pmu-events/arch/powerpc/power9/pmc.json b/tools/perf/pmu-events/arch/powerpc/power9/pmc.json
index d0b89f930567..8b3b0f3be664 100644
--- a/tools/perf/pmu-events/arch/powerpc/power9/pmc.json
+++ b/tools/perf/pmu-events/arch/powerpc/power9/pmc.json
@@ -10,11 +10,6 @@
10 "BriefDescription": "Local memory above threshold for LSU medium" 10 "BriefDescription": "Local memory above threshold for LSU medium"
11 }, 11 },
12 {, 12 {,
13 "EventCode": "0x2C056",
14 "EventName": "PM_DTLB_MISS_4K",
15 "BriefDescription": "Data TLB Miss page size 4k"
16 },
17 {,
18 "EventCode": "0x40118", 13 "EventCode": "0x40118",
19 "EventName": "PM_MRK_DCACHE_RELOAD_INTV", 14 "EventName": "PM_MRK_DCACHE_RELOAD_INTV",
20 "BriefDescription": "Combined Intervention event" 15 "BriefDescription": "Combined Intervention event"
diff --git a/tools/perf/pmu-events/arch/powerpc/power9/translation.json b/tools/perf/pmu-events/arch/powerpc/power9/translation.json
index bc8e03d7a6b0..b27642676244 100644
--- a/tools/perf/pmu-events/arch/powerpc/power9/translation.json
+++ b/tools/perf/pmu-events/arch/powerpc/power9/translation.json
@@ -30,11 +30,6 @@
30 "BriefDescription": "Store finish count. Includes speculative activity" 30 "BriefDescription": "Store finish count. Includes speculative activity"
31 }, 31 },
32 {, 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", 33 "EventCode": "0x1504A",
39 "EventName": "PM_IPTEG_FROM_RL2L3_SHR", 34 "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" 35 "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"
@@ -125,6 +120,11 @@
125 "BriefDescription": "PMC1 Rewind Value saved" 120 "BriefDescription": "PMC1 Rewind Value saved"
126 }, 121 },
127 {, 122 {,
123 "EventCode": "0x44042",
124 "EventName": "PM_INST_FROM_L3",
125 "BriefDescription": "The processor's Instruction cache was reloaded from local core's L3 due to an instruction fetch (not prefetch)"
126 },
127 {,
128 "EventCode": "0x200FE", 128 "EventCode": "0x200FE",
129 "EventName": "PM_DATA_FROM_L2MISS", 129 "EventName": "PM_DATA_FROM_L2MISS",
130 "BriefDescription": "Demand LD - L2 Miss (not L2 hit)" 130 "BriefDescription": "Demand LD - L2 Miss (not L2 hit)"
diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
index b578aa26e375..db3a594ee1e4 100644
--- a/tools/perf/pmu-events/jevents.c
+++ b/tools/perf/pmu-events/jevents.c
@@ -39,11 +39,13 @@
39#include <unistd.h> 39#include <unistd.h>
40#include <stdarg.h> 40#include <stdarg.h>
41#include <libgen.h> 41#include <libgen.h>
42#include <limits.h>
42#include <dirent.h> 43#include <dirent.h>
43#include <sys/time.h> /* getrlimit */ 44#include <sys/time.h> /* getrlimit */
44#include <sys/resource.h> /* getrlimit */ 45#include <sys/resource.h> /* getrlimit */
45#include <ftw.h> 46#include <ftw.h>
46#include <sys/stat.h> 47#include <sys/stat.h>
48#include <linux/list.h>
47#include "jsmn.h" 49#include "jsmn.h"
48#include "json.h" 50#include "json.h"
49#include "jevents.h" 51#include "jevents.h"
@@ -249,31 +251,25 @@ static const char *field_to_perf(struct map *table, char *map, jsmntok_t *val)
249 jsmntok_t *loc = (t); \ 251 jsmntok_t *loc = (t); \
250 if (!(t)->start && (t) > tokens) \ 252 if (!(t)->start && (t) > tokens) \
251 loc = (t) - 1; \ 253 loc = (t) - 1; \
252 pr_err("%s:%d: " m ", got %s\n", fn, \ 254 pr_err("%s:%d: " m ", got %s\n", fn, \
253 json_line(map, loc), \ 255 json_line(map, loc), \
254 json_name(t)); \ 256 json_name(t)); \
257 err = -EIO; \
255 goto out_free; \ 258 goto out_free; \
256} } while (0) 259} } while (0)
257 260
258#define TOPIC_DEPTH 256 261static char *topic;
259static char *topic_array[TOPIC_DEPTH];
260static int topic_level;
261 262
262static char *get_topic(void) 263static char *get_topic(void)
263{ 264{
264 char *tp_old, *tp = NULL; 265 char *tp;
265 int i; 266 int i;
266 267
267 for (i = 0; i < topic_level + 1; i++) { 268 /* tp is free'd in process_one_file() */
268 int n; 269 i = asprintf(&tp, "%s", topic);
269 270 if (i < 0) {
270 tp_old = tp; 271 pr_info("%s: asprintf() error %s\n", prog);
271 n = asprintf(&tp, "%s%s", tp ?: "", topic_array[i]); 272 return NULL;
272 if (n < 0) {
273 pr_info("%s: asprintf() error %s\n", prog);
274 return NULL;
275 }
276 free(tp_old);
277 } 273 }
278 274
279 for (i = 0; i < (int) strlen(tp); i++) { 275 for (i = 0; i < (int) strlen(tp); i++) {
@@ -290,25 +286,15 @@ static char *get_topic(void)
290 return tp; 286 return tp;
291} 287}
292 288
293static int add_topic(int level, char *bname) 289static int add_topic(char *bname)
294{ 290{
295 char *topic; 291 free(topic);
296
297 level -= 2;
298
299 if (level >= TOPIC_DEPTH)
300 return -EINVAL;
301
302 topic = strdup(bname); 292 topic = strdup(bname);
303 if (!topic) { 293 if (!topic) {
304 pr_info("%s: strdup() error %s for file %s\n", prog, 294 pr_info("%s: strdup() error %s for file %s\n", prog,
305 strerror(errno), bname); 295 strerror(errno), bname);
306 return -ENOMEM; 296 return -ENOMEM;
307 } 297 }
308
309 free(topic_array[topic_level]);
310 topic_array[topic_level] = topic;
311 topic_level = level;
312 return 0; 298 return 0;
313} 299}
314 300
@@ -366,6 +352,81 @@ static int print_events_table_entry(void *data, char *name, char *event,
366 return 0; 352 return 0;
367} 353}
368 354
355struct event_struct {
356 struct list_head list;
357 char *name;
358 char *event;
359 char *desc;
360 char *long_desc;
361 char *pmu;
362 char *unit;
363 char *perpkg;
364 char *metric_expr;
365 char *metric_name;
366 char *metric_group;
367};
368
369#define ADD_EVENT_FIELD(field) do { if (field) { \
370 es->field = strdup(field); \
371 if (!es->field) \
372 goto out_free; \
373} } while (0)
374
375#define FREE_EVENT_FIELD(field) free(es->field)
376
377#define TRY_FIXUP_FIELD(field) do { if (es->field && !*field) {\
378 *field = strdup(es->field); \
379 if (!*field) \
380 return -ENOMEM; \
381} } while (0)
382
383#define FOR_ALL_EVENT_STRUCT_FIELDS(op) do { \
384 op(name); \
385 op(event); \
386 op(desc); \
387 op(long_desc); \
388 op(pmu); \
389 op(unit); \
390 op(perpkg); \
391 op(metric_expr); \
392 op(metric_name); \
393 op(metric_group); \
394} while (0)
395
396static LIST_HEAD(arch_std_events);
397
398static void free_arch_std_events(void)
399{
400 struct event_struct *es, *next;
401
402 list_for_each_entry_safe(es, next, &arch_std_events, list) {
403 FOR_ALL_EVENT_STRUCT_FIELDS(FREE_EVENT_FIELD);
404 list_del(&es->list);
405 free(es);
406 }
407}
408
409static int save_arch_std_events(void *data, char *name, char *event,
410 char *desc, char *long_desc, char *pmu,
411 char *unit, char *perpkg, char *metric_expr,
412 char *metric_name, char *metric_group)
413{
414 struct event_struct *es;
415 struct stat *sb = data;
416
417 es = malloc(sizeof(*es));
418 if (!es)
419 return -ENOMEM;
420 memset(es, 0, sizeof(*es));
421 FOR_ALL_EVENT_STRUCT_FIELDS(ADD_EVENT_FIELD);
422 list_add_tail(&es->list, &arch_std_events);
423 return 0;
424out_free:
425 FOR_ALL_EVENT_STRUCT_FIELDS(FREE_EVENT_FIELD);
426 free(es);
427 return -ENOMEM;
428}
429
369static void print_events_table_suffix(FILE *outfp) 430static void print_events_table_suffix(FILE *outfp)
370{ 431{
371 fprintf(outfp, "{\n"); 432 fprintf(outfp, "{\n");
@@ -407,6 +468,32 @@ static char *real_event(const char *name, char *event)
407 return event; 468 return event;
408} 469}
409 470
471static int
472try_fixup(const char *fn, char *arch_std, char **event, char **desc,
473 char **name, char **long_desc, char **pmu, char **filter,
474 char **perpkg, char **unit, char **metric_expr, char **metric_name,
475 char **metric_group, unsigned long long eventcode)
476{
477 /* try to find matching event from arch standard values */
478 struct event_struct *es;
479
480 list_for_each_entry(es, &arch_std_events, list) {
481 if (!strcmp(arch_std, es->name)) {
482 if (!eventcode && es->event) {
483 /* allow EventCode to be overridden */
484 free(*event);
485 *event = NULL;
486 }
487 FOR_ALL_EVENT_STRUCT_FIELDS(TRY_FIXUP_FIELD);
488 return 0;
489 }
490 }
491
492 pr_err("%s: could not find matching %s for %s\n",
493 prog, arch_std, fn);
494 return -1;
495}
496
410/* Call func with each event in the json file */ 497/* Call func with each event in the json file */
411int json_events(const char *fn, 498int json_events(const char *fn,
412 int (*func)(void *data, char *name, char *event, char *desc, 499 int (*func)(void *data, char *name, char *event, char *desc,
@@ -416,7 +503,7 @@ int json_events(const char *fn,
416 char *metric_name, char *metric_group), 503 char *metric_name, char *metric_group),
417 void *data) 504 void *data)
418{ 505{
419 int err = -EIO; 506 int err;
420 size_t size; 507 size_t size;
421 jsmntok_t *tokens, *tok; 508 jsmntok_t *tokens, *tok;
422 int i, j, len; 509 int i, j, len;
@@ -442,6 +529,7 @@ int json_events(const char *fn,
442 char *metric_expr = NULL; 529 char *metric_expr = NULL;
443 char *metric_name = NULL; 530 char *metric_name = NULL;
444 char *metric_group = NULL; 531 char *metric_group = NULL;
532 char *arch_std = NULL;
445 unsigned long long eventcode = 0; 533 unsigned long long eventcode = 0;
446 struct msrmap *msr = NULL; 534 struct msrmap *msr = NULL;
447 jsmntok_t *msrval = NULL; 535 jsmntok_t *msrval = NULL;
@@ -527,6 +615,10 @@ int json_events(const char *fn,
527 addfield(map, &metric_expr, "", "", val); 615 addfield(map, &metric_expr, "", "", val);
528 for (s = metric_expr; *s; s++) 616 for (s = metric_expr; *s; s++)
529 *s = tolower(*s); 617 *s = tolower(*s);
618 } else if (json_streq(map, field, "ArchStdEvent")) {
619 addfield(map, &arch_std, "", "", val);
620 for (s = arch_std; *s; s++)
621 *s = tolower(*s);
530 } 622 }
531 /* ignore unknown fields */ 623 /* ignore unknown fields */
532 } 624 }
@@ -551,8 +643,21 @@ int json_events(const char *fn,
551 if (name) 643 if (name)
552 fixname(name); 644 fixname(name);
553 645
646 if (arch_std) {
647 /*
648 * An arch standard event is referenced, so try to
649 * fixup any unassigned values.
650 */
651 err = try_fixup(fn, arch_std, &event, &desc, &name,
652 &long_desc, &pmu, &filter, &perpkg,
653 &unit, &metric_expr, &metric_name,
654 &metric_group, eventcode);
655 if (err)
656 goto free_strings;
657 }
554 err = func(data, name, real_event(name, event), desc, long_desc, 658 err = func(data, name, real_event(name, event), desc, long_desc,
555 pmu, unit, perpkg, metric_expr, metric_name, metric_group); 659 pmu, unit, perpkg, metric_expr, metric_name, metric_group);
660free_strings:
556 free(event); 661 free(event);
557 free(desc); 662 free(desc);
558 free(name); 663 free(name);
@@ -565,6 +670,8 @@ int json_events(const char *fn,
565 free(metric_expr); 670 free(metric_expr);
566 free(metric_name); 671 free(metric_name);
567 free(metric_group); 672 free(metric_group);
673 free(arch_std);
674
568 if (err) 675 if (err)
569 break; 676 break;
570 tok += j; 677 tok += j;
@@ -588,7 +695,7 @@ static char *file_name_to_table_name(char *fname)
588 * Derive rest of table name from basename of the JSON file, 695 * Derive rest of table name from basename of the JSON file,
589 * replacing hyphens and stripping out .json suffix. 696 * replacing hyphens and stripping out .json suffix.
590 */ 697 */
591 n = asprintf(&tblname, "pme_%s", basename(fname)); 698 n = asprintf(&tblname, "pme_%s", fname);
592 if (n < 0) { 699 if (n < 0) {
593 pr_info("%s: asprintf() error %s for file %s\n", prog, 700 pr_info("%s: asprintf() error %s for file %s\n", prog,
594 strerror(errno), fname); 701 strerror(errno), fname);
@@ -598,7 +705,7 @@ static char *file_name_to_table_name(char *fname)
598 for (i = 0; i < strlen(tblname); i++) { 705 for (i = 0; i < strlen(tblname); i++) {
599 c = tblname[i]; 706 c = tblname[i];
600 707
601 if (c == '-') 708 if (c == '-' || c == '/')
602 tblname[i] = '_'; 709 tblname[i] = '_';
603 else if (c == '.') { 710 else if (c == '.') {
604 tblname[i] = '\0'; 711 tblname[i] = '\0';
@@ -755,25 +862,106 @@ static int get_maxfds(void)
755static FILE *eventsfp; 862static FILE *eventsfp;
756static char *mapfile; 863static char *mapfile;
757 864
865static int is_leaf_dir(const char *fpath)
866{
867 DIR *d;
868 struct dirent *dir;
869 int res = 1;
870
871 d = opendir(fpath);
872 if (!d)
873 return 0;
874
875 while ((dir = readdir(d)) != NULL) {
876 if (!strcmp(dir->d_name, ".") || !strcmp(dir->d_name, ".."))
877 continue;
878
879 if (dir->d_type == DT_DIR) {
880 res = 0;
881 break;
882 } else if (dir->d_type == DT_UNKNOWN) {
883 char path[PATH_MAX];
884 struct stat st;
885
886 sprintf(path, "%s/%s", fpath, dir->d_name);
887 if (stat(path, &st))
888 break;
889
890 if (S_ISDIR(st.st_mode)) {
891 res = 0;
892 break;
893 }
894 }
895 }
896
897 closedir(d);
898
899 return res;
900}
901
902static int is_json_file(const char *name)
903{
904 const char *suffix;
905
906 if (strlen(name) < 5)
907 return 0;
908
909 suffix = name + strlen(name) - 5;
910
911 if (strncmp(suffix, ".json", 5) == 0)
912 return 1;
913 return 0;
914}
915
916static int preprocess_arch_std_files(const char *fpath, const struct stat *sb,
917 int typeflag, struct FTW *ftwbuf)
918{
919 int level = ftwbuf->level;
920 int is_file = typeflag == FTW_F;
921
922 if (level == 1 && is_file && is_json_file(fpath))
923 return json_events(fpath, save_arch_std_events, (void *)sb);
924
925 return 0;
926}
927
758static int process_one_file(const char *fpath, const struct stat *sb, 928static int process_one_file(const char *fpath, const struct stat *sb,
759 int typeflag, struct FTW *ftwbuf) 929 int typeflag, struct FTW *ftwbuf)
760{ 930{
761 char *tblname, *bname = (char *) fpath + ftwbuf->base; 931 char *tblname, *bname;
762 int is_dir = typeflag == FTW_D; 932 int is_dir = typeflag == FTW_D;
763 int is_file = typeflag == FTW_F; 933 int is_file = typeflag == FTW_F;
764 int level = ftwbuf->level; 934 int level = ftwbuf->level;
765 int err = 0; 935 int err = 0;
766 936
937 if (level == 2 && is_dir) {
938 /*
939 * For level 2 directory, bname will include parent name,
940 * like vendor/platform. So search back from platform dir
941 * to find this.
942 */
943 bname = (char *) fpath + ftwbuf->base - 2;
944 for (;;) {
945 if (*bname == '/')
946 break;
947 bname--;
948 }
949 bname++;
950 } else
951 bname = (char *) fpath + ftwbuf->base;
952
767 pr_debug("%s %d %7jd %-20s %s\n", 953 pr_debug("%s %d %7jd %-20s %s\n",
768 is_file ? "f" : is_dir ? "d" : "x", 954 is_file ? "f" : is_dir ? "d" : "x",
769 level, sb->st_size, bname, fpath); 955 level, sb->st_size, bname, fpath);
770 956
771 /* base dir */ 957 /* base dir or too deep */
772 if (level == 0) 958 if (level == 0 || level > 3)
773 return 0; 959 return 0;
774 960
961
775 /* model directory, reset topic */ 962 /* model directory, reset topic */
776 if (level == 1 && is_dir) { 963 if ((level == 1 && is_dir && is_leaf_dir(fpath)) ||
964 (level == 2 && is_dir)) {
777 if (close_table) 965 if (close_table)
778 print_events_table_suffix(eventsfp); 966 print_events_table_suffix(eventsfp);
779 967
@@ -798,16 +986,10 @@ static int process_one_file(const char *fpath, const struct stat *sb,
798 * after processing all JSON files (so we can write out the 986 * after processing all JSON files (so we can write out the
799 * mapping table after all PMU events tables). 987 * mapping table after all PMU events tables).
800 * 988 *
801 * TODO: Allow for multiple mapfiles? Punt for now.
802 */ 989 */
803 if (level == 1 && is_file) { 990 if (level == 1 && is_file) {
804 if (!strncmp(bname, "mapfile.csv", 11)) { 991 if (!strcmp(bname, "mapfile.csv")) {
805 if (mapfile) { 992 mapfile = strdup(fpath);
806 pr_info("%s: Many mapfiles? Using %s, ignoring %s\n",
807 prog, mapfile, fpath);
808 } else {
809 mapfile = strdup(fpath);
810 }
811 return 0; 993 return 0;
812 } 994 }
813 995
@@ -820,16 +1002,14 @@ static int process_one_file(const char *fpath, const struct stat *sb,
820 * ignore it. It could be a readme.txt for instance. 1002 * ignore it. It could be a readme.txt for instance.
821 */ 1003 */
822 if (is_file) { 1004 if (is_file) {
823 char *suffix = bname + strlen(bname) - 5; 1005 if (!is_json_file(bname)) {
824
825 if (strncmp(suffix, ".json", 5)) {
826 pr_info("%s: Ignoring file without .json suffix %s\n", prog, 1006 pr_info("%s: Ignoring file without .json suffix %s\n", prog,
827 fpath); 1007 fpath);
828 return 0; 1008 return 0;
829 } 1009 }
830 } 1010 }
831 1011
832 if (level > 1 && add_topic(level, bname)) 1012 if (level > 1 && add_topic(bname))
833 return -ENOMEM; 1013 return -ENOMEM;
834 1014
835 /* 1015 /*
@@ -928,12 +1108,26 @@ int main(int argc, char *argv[])
928 1108
929 maxfds = get_maxfds(); 1109 maxfds = get_maxfds();
930 mapfile = NULL; 1110 mapfile = NULL;
1111 rc = nftw(ldirname, preprocess_arch_std_files, maxfds, 0);
1112 if (rc && verbose) {
1113 pr_info("%s: Error preprocessing arch standard files %s\n",
1114 prog, ldirname);
1115 goto empty_map;
1116 } else if (rc < 0) {
1117 /* Make build fail */
1118 free_arch_std_events();
1119 return 1;
1120 } else if (rc) {
1121 goto empty_map;
1122 }
1123
931 rc = nftw(ldirname, process_one_file, maxfds, 0); 1124 rc = nftw(ldirname, process_one_file, maxfds, 0);
932 if (rc && verbose) { 1125 if (rc && verbose) {
933 pr_info("%s: Error walking file tree %s\n", prog, ldirname); 1126 pr_info("%s: Error walking file tree %s\n", prog, ldirname);
934 goto empty_map; 1127 goto empty_map;
935 } else if (rc < 0) { 1128 } else if (rc < 0) {
936 /* Make build fail */ 1129 /* Make build fail */
1130 free_arch_std_events();
937 return 1; 1131 return 1;
938 } else if (rc) { 1132 } else if (rc) {
939 goto empty_map; 1133 goto empty_map;
@@ -958,5 +1152,6 @@ int main(int argc, char *argv[])
958empty_map: 1152empty_map:
959 fclose(eventsfp); 1153 fclose(eventsfp);
960 create_empty_mapping(output_file); 1154 create_empty_mapping(output_file);
1155 free_arch_std_events();
961 return 0; 1156 return 0;
962} 1157}
diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build
index 62ca0174d5e1..6c108fa79ae3 100644
--- a/tools/perf/tests/Build
+++ b/tools/perf/tests/Build
@@ -48,6 +48,7 @@ perf-y += bitmap.o
48perf-y += perf-hooks.o 48perf-y += perf-hooks.o
49perf-y += clang.o 49perf-y += clang.o
50perf-y += unit_number__scnprintf.o 50perf-y += unit_number__scnprintf.o
51perf-y += mem2node.o
51 52
52$(OUTPUT)tests/llvm-src-base.c: tests/bpf-script-example.c tests/Build 53$(OUTPUT)tests/llvm-src-base.c: tests/bpf-script-example.c tests/Build
53 $(call rule_mkdir) 54 $(call rule_mkdir)
diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c
index 97f64ad7fa08..05dfe11c2f9e 100644
--- a/tools/perf/tests/attr.c
+++ b/tools/perf/tests/attr.c
@@ -170,8 +170,8 @@ static int run_dir(const char *d, const char *perf)
170 if (verbose > 0) 170 if (verbose > 0)
171 vcnt++; 171 vcnt++;
172 172
173 snprintf(cmd, 3*PATH_MAX, PYTHON " %s/attr.py -d %s/attr/ -p %s %.*s", 173 scnprintf(cmd, 3*PATH_MAX, PYTHON " %s/attr.py -d %s/attr/ -p %s %.*s",
174 d, d, perf, vcnt, v); 174 d, d, perf, vcnt, v);
175 175
176 return system(cmd) ? TEST_FAIL : TEST_OK; 176 return system(cmd) ? TEST_FAIL : TEST_OK;
177} 177}
diff --git a/tools/perf/tests/bp_account.c b/tools/perf/tests/bp_account.c
index 2f75fa0c4fef..a20cbc445426 100644
--- a/tools/perf/tests/bp_account.c
+++ b/tools/perf/tests/bp_account.c
@@ -103,20 +103,18 @@ static int bp_accounting(int wp_cnt, int share)
103static int detect_cnt(bool is_x) 103static int detect_cnt(bool is_x)
104{ 104{
105 struct perf_event_attr attr; 105 struct perf_event_attr attr;
106 void *addr = is_x ? test_function : (void *) &the_var; 106 void *addr = is_x ? (void *)test_function : (void *)&the_var;
107 int fd[100], cnt = 0, i; 107 int fd[100], cnt = 0, i;
108 108
109 while (1) { 109 while (1) {
110 fd[cnt] = __event(is_x, addr, &attr);
111
112 if (fd[cnt] < 0)
113 break;
114
115 if (cnt == 100) { 110 if (cnt == 100) {
116 pr_debug("way too many debug registers, fix the test\n"); 111 pr_debug("way too many debug registers, fix the test\n");
117 return 0; 112 return 0;
118 } 113 }
114 fd[cnt] = __event(is_x, addr, &attr);
119 115
116 if (fd[cnt] < 0)
117 break;
120 cnt++; 118 cnt++;
121 } 119 }
122 120
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 38bf109ce106..625f5a6772af 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -275,6 +275,10 @@ static struct test generic_tests[] = {
275 .func = test__unit_number__scnprint, 275 .func = test__unit_number__scnprint,
276 }, 276 },
277 { 277 {
278 .desc = "mem2node",
279 .func = test__mem2node,
280 },
281 {
278 .func = NULL, 282 .func = NULL,
279 }, 283 },
280}; 284};
diff --git a/tools/perf/tests/mem.c b/tools/perf/tests/mem.c
index 21952e1e6e6d..0f82ee9fd3f7 100644
--- a/tools/perf/tests/mem.c
+++ b/tools/perf/tests/mem.c
@@ -16,7 +16,7 @@ static int check(union perf_mem_data_src data_src,
16 16
17 n = perf_mem__snp_scnprintf(out, sizeof out, &mi); 17 n = perf_mem__snp_scnprintf(out, sizeof out, &mi);
18 n += perf_mem__lvl_scnprintf(out + n, sizeof out - n, &mi); 18 n += perf_mem__lvl_scnprintf(out + n, sizeof out - n, &mi);
19 snprintf(failure, sizeof failure, "unexpected %s", out); 19 scnprintf(failure, sizeof failure, "unexpected %s", out);
20 TEST_ASSERT_VAL(failure, !strcmp(string, out)); 20 TEST_ASSERT_VAL(failure, !strcmp(string, out));
21 return 0; 21 return 0;
22} 22}
diff --git a/tools/perf/tests/mem2node.c b/tools/perf/tests/mem2node.c
new file mode 100644
index 000000000000..0c3c87f86e03
--- /dev/null
+++ b/tools/perf/tests/mem2node.c
@@ -0,0 +1,75 @@
1#include <linux/compiler.h>
2#include <linux/bitmap.h>
3#include "cpumap.h"
4#include "mem2node.h"
5#include "tests.h"
6
7static struct node {
8 int node;
9 const char *map;
10} test_nodes[] = {
11 { .node = 0, .map = "0" },
12 { .node = 1, .map = "1-2" },
13 { .node = 3, .map = "5-7,9" },
14};
15
16#define T TEST_ASSERT_VAL
17
18static unsigned long *get_bitmap(const char *str, int nbits)
19{
20 struct cpu_map *map = cpu_map__new(str);
21 unsigned long *bm = NULL;
22 int i;
23
24 bm = bitmap_alloc(nbits);
25
26 if (map && bm) {
27 bitmap_zero(bm, nbits);
28
29 for (i = 0; i < map->nr; i++) {
30 set_bit(map->map[i], bm);
31 }
32 }
33
34 if (map)
35 cpu_map__put(map);
36 else
37 free(bm);
38
39 return bm && map ? bm : NULL;
40}
41
42int test__mem2node(struct test *t __maybe_unused, int subtest __maybe_unused)
43{
44 struct mem2node map;
45 struct memory_node nodes[3];
46 struct perf_env env = {
47 .memory_nodes = (struct memory_node *) &nodes[0],
48 .nr_memory_nodes = ARRAY_SIZE(nodes),
49 .memory_bsize = 0x100,
50 };
51 unsigned int i;
52
53 for (i = 0; i < ARRAY_SIZE(nodes); i++) {
54 nodes[i].node = test_nodes[i].node;
55 nodes[i].size = 10;
56
57 T("failed: alloc bitmap",
58 (nodes[i].set = get_bitmap(test_nodes[i].map, 10)));
59 }
60
61 T("failed: mem2node__init", !mem2node__init(&map, &env));
62 T("failed: mem2node__node", 0 == mem2node__node(&map, 0x50));
63 T("failed: mem2node__node", 1 == mem2node__node(&map, 0x100));
64 T("failed: mem2node__node", 1 == mem2node__node(&map, 0x250));
65 T("failed: mem2node__node", 3 == mem2node__node(&map, 0x500));
66 T("failed: mem2node__node", 3 == mem2node__node(&map, 0x650));
67 T("failed: mem2node__node", -1 == mem2node__node(&map, 0x450));
68 T("failed: mem2node__node", -1 == mem2node__node(&map, 0x1050));
69
70 for (i = 0; i < ARRAY_SIZE(nodes); i++)
71 free(nodes[i].set);
72
73 mem2node__exit(&map);
74 return 0;
75}
diff --git a/tools/perf/tests/pmu.c b/tools/perf/tests/pmu.c
index 9abca267afa9..7bedf8608fdd 100644
--- a/tools/perf/tests/pmu.c
+++ b/tools/perf/tests/pmu.c
@@ -98,7 +98,7 @@ static char *test_format_dir_get(void)
98 struct test_format *format = &test_formats[i]; 98 struct test_format *format = &test_formats[i];
99 FILE *file; 99 FILE *file;
100 100
101 snprintf(name, PATH_MAX, "%s/%s", dir, format->name); 101 scnprintf(name, PATH_MAX, "%s/%s", dir, format->name);
102 102
103 file = fopen(name, "w"); 103 file = fopen(name, "w");
104 if (!file) 104 if (!file)
diff --git a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
index 52c3ee701a89..1ecc1f0ff84a 100755
--- a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
+++ b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
@@ -47,7 +47,10 @@ trace_libc_inet_pton_backtrace() {
47 [ -z "${expected[$idx]}" ] && break 47 [ -z "${expected[$idx]}" ] && break
48 done 48 done
49 49
50 rm -f $file 50 # If any statements are executed from this point onwards,
51 # the exit code of the last among these will be reflected
52 # in err below. If the exit code is 0, the test will pass
53 # even if the perf script output does not match.
51} 54}
52 55
53# Check for IPv6 interface existence 56# Check for IPv6 interface existence
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index 9f51edac44ae..a9760e790563 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -103,6 +103,7 @@ int test__clang(struct test *test, int subtest);
103const char *test__clang_subtest_get_desc(int subtest); 103const char *test__clang_subtest_get_desc(int subtest);
104int test__clang_subtest_get_nr(void); 104int test__clang_subtest_get_nr(void);
105int test__unit_number__scnprint(struct test *test, int subtest); 105int test__unit_number__scnprint(struct test *test, int subtest);
106int test__mem2node(struct test *t, int subtest);
106 107
107bool test__bp_signal_is_supported(void); 108bool test__bp_signal_is_supported(void);
108 109
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index 25dd1e0ecc58..6832fcb2e6ff 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -840,15 +840,11 @@ size_t events_stats__fprintf(struct events_stats *stats, FILE *fp)
840 for (i = 0; i < PERF_RECORD_HEADER_MAX; ++i) { 840 for (i = 0; i < PERF_RECORD_HEADER_MAX; ++i) {
841 const char *name; 841 const char *name;
842 842
843 if (stats->nr_events[i] == 0)
844 continue;
845
846 name = perf_event__name(i); 843 name = perf_event__name(i);
847 if (!strcmp(name, "UNKNOWN")) 844 if (!strcmp(name, "UNKNOWN"))
848 continue; 845 continue;
849 846
850 ret += fprintf(fp, "%16s events: %10d\n", name, 847 ret += fprintf(fp, "%16s events: %10d\n", name, stats->nr_events[i]);
851 stats->nr_events[i]);
852 } 848 }
853 849
854 return ret; 850 return ret;
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index ea0a452550b0..8052373bcd6a 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -106,6 +106,7 @@ libperf-y += units.o
106libperf-y += time-utils.o 106libperf-y += time-utils.o
107libperf-y += expr-bison.o 107libperf-y += expr-bison.o
108libperf-y += branch.o 108libperf-y += branch.o
109libperf-y += mem2node.o
109 110
110libperf-$(CONFIG_LIBBPF) += bpf-loader.o 111libperf-$(CONFIG_LIBBPF) += bpf-loader.o
111libperf-$(CONFIG_BPF_PROLOGUE) += bpf-prologue.o 112libperf-$(CONFIG_BPF_PROLOGUE) += bpf-prologue.o
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index bc3302da702b..535357c6ce02 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -238,6 +238,9 @@ static int call__scnprintf(struct ins *ins, char *bf, size_t size,
238 if (ops->target.addr == 0) 238 if (ops->target.addr == 0)
239 return ins__raw_scnprintf(ins, bf, size, ops); 239 return ins__raw_scnprintf(ins, bf, size, ops);
240 240
241 if (ops->target.name)
242 return scnprintf(bf, size, "%-6s %s", ins->name, ops->target.name);
243
241 return scnprintf(bf, size, "%-6s *%" PRIx64, ins->name, ops->target.addr); 244 return scnprintf(bf, size, "%-6s *%" PRIx64, ins->name, ops->target.addr);
242} 245}
243 246
@@ -1427,7 +1430,7 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
1427{ 1430{
1428 struct map *map = args->map; 1431 struct map *map = args->map;
1429 struct dso *dso = map->dso; 1432 struct dso *dso = map->dso;
1430 char command[PATH_MAX * 2]; 1433 char *command;
1431 FILE *file; 1434 FILE *file;
1432 char symfs_filename[PATH_MAX]; 1435 char symfs_filename[PATH_MAX];
1433 struct kcore_extract kce; 1436 struct kcore_extract kce;
@@ -1468,7 +1471,7 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
1468 strcpy(symfs_filename, tmp); 1471 strcpy(symfs_filename, tmp);
1469 } 1472 }
1470 1473
1471 snprintf(command, sizeof(command), 1474 err = asprintf(&command,
1472 "%s %s%s --start-address=0x%016" PRIx64 1475 "%s %s%s --start-address=0x%016" PRIx64
1473 " --stop-address=0x%016" PRIx64 1476 " --stop-address=0x%016" PRIx64
1474 " -l -d %s %s -C \"%s\" 2>/dev/null|grep -v \"%s:\"|expand", 1477 " -l -d %s %s -C \"%s\" 2>/dev/null|grep -v \"%s:\"|expand",
@@ -1481,12 +1484,17 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
1481 symbol_conf.annotate_src ? "-S" : "", 1484 symbol_conf.annotate_src ? "-S" : "",
1482 symfs_filename, symfs_filename); 1485 symfs_filename, symfs_filename);
1483 1486
1487 if (err < 0) {
1488 pr_err("Failure allocating memory for the command to run\n");
1489 goto out_remove_tmp;
1490 }
1491
1484 pr_debug("Executing: %s\n", command); 1492 pr_debug("Executing: %s\n", command);
1485 1493
1486 err = -1; 1494 err = -1;
1487 if (pipe(stdout_fd) < 0) { 1495 if (pipe(stdout_fd) < 0) {
1488 pr_err("Failure creating the pipe to run %s\n", command); 1496 pr_err("Failure creating the pipe to run %s\n", command);
1489 goto out_remove_tmp; 1497 goto out_free_command;
1490 } 1498 }
1491 1499
1492 pid = fork(); 1500 pid = fork();
@@ -1513,7 +1521,7 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
1513 * If we were using debug info should retry with 1521 * If we were using debug info should retry with
1514 * original binary. 1522 * original binary.
1515 */ 1523 */
1516 goto out_remove_tmp; 1524 goto out_free_command;
1517 } 1525 }
1518 1526
1519 nline = 0; 1527 nline = 0;
@@ -1541,6 +1549,8 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
1541 1549
1542 fclose(file); 1550 fclose(file);
1543 err = 0; 1551 err = 0;
1552out_free_command:
1553 free(command);
1544out_remove_tmp: 1554out_remove_tmp:
1545 close(stdout_fd[0]); 1555 close(stdout_fd[0]);
1546 1556
@@ -1554,7 +1564,7 @@ out:
1554 1564
1555out_close_stdout: 1565out_close_stdout:
1556 close(stdout_fd[1]); 1566 close(stdout_fd[1]);
1557 goto out_remove_tmp; 1567 goto out_free_command;
1558} 1568}
1559 1569
1560static void calc_percent(struct sym_hist *hist, 1570static void calc_percent(struct sym_hist *hist,
diff --git a/tools/perf/util/cgroup.c b/tools/perf/util/cgroup.c
index 78408f5c4bad..decb91f9da82 100644
--- a/tools/perf/util/cgroup.c
+++ b/tools/perf/util/cgroup.c
@@ -81,7 +81,7 @@ static int open_cgroup(const char *name)
81 if (cgroupfs_find_mountpoint(mnt, PATH_MAX + 1)) 81 if (cgroupfs_find_mountpoint(mnt, PATH_MAX + 1))
82 return -1; 82 return -1;
83 83
84 snprintf(path, PATH_MAX, "%s/%s", mnt, name); 84 scnprintf(path, PATH_MAX, "%s/%s", mnt, name);
85 85
86 fd = open(path, O_RDONLY); 86 fd = open(path, O_RDONLY);
87 if (fd == -1) 87 if (fd == -1)
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c
index f3a71db83947..3d6459626c2a 100644
--- a/tools/perf/util/debug.c
+++ b/tools/perf/util/debug.c
@@ -232,7 +232,6 @@ int perf_quiet_option(void)
232 var++; 232 var++;
233 } 233 }
234 234
235 quiet = true;
236 return 0; 235 return 0;
237} 236}
238 237
diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c
index 6d311868d850..4c842762e3f2 100644
--- a/tools/perf/util/env.c
+++ b/tools/perf/util/env.c
@@ -32,6 +32,10 @@ void perf_env__exit(struct perf_env *env)
32 for (i = 0; i < env->caches_cnt; i++) 32 for (i = 0; i < env->caches_cnt; i++)
33 cpu_cache_level__free(&env->caches[i]); 33 cpu_cache_level__free(&env->caches[i]);
34 zfree(&env->caches); 34 zfree(&env->caches);
35
36 for (i = 0; i < env->nr_memory_nodes; i++)
37 free(env->memory_nodes[i].set);
38 zfree(&env->memory_nodes);
35} 39}
36 40
37int perf_env__set_cmdline(struct perf_env *env, int argc, const char *argv[]) 41int perf_env__set_cmdline(struct perf_env *env, int argc, const char *argv[])
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index e14b3f7c7212..121df1683c36 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -3415,8 +3415,17 @@ int perf_event__synthesize_features(struct perf_tool *tool,
3415 return ret; 3415 return ret;
3416 } 3416 }
3417 } 3417 }
3418
3419 /* Send HEADER_LAST_FEATURE mark. */
3420 fe = ff.buf;
3421 fe->feat_id = HEADER_LAST_FEATURE;
3422 fe->header.type = PERF_RECORD_HEADER_FEATURE;
3423 fe->header.size = sizeof(*fe);
3424
3425 ret = process(tool, ff.buf, NULL, NULL);
3426
3418 free(ff.buf); 3427 free(ff.buf);
3419 return 0; 3428 return ret;
3420} 3429}
3421 3430
3422int perf_event__process_feature(struct perf_tool *tool, 3431int perf_event__process_feature(struct perf_tool *tool,
diff --git a/tools/perf/util/llvm-utils.c b/tools/perf/util/llvm-utils.c
index 4952b429caa7..1cca0a2fa641 100644
--- a/tools/perf/util/llvm-utils.c
+++ b/tools/perf/util/llvm-utils.c
@@ -433,6 +433,7 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf,
433 char serr[STRERR_BUFSIZE]; 433 char serr[STRERR_BUFSIZE];
434 char *kbuild_dir = NULL, *kbuild_include_opts = NULL; 434 char *kbuild_dir = NULL, *kbuild_include_opts = NULL;
435 const char *template = llvm_param.clang_bpf_cmd_template; 435 const char *template = llvm_param.clang_bpf_cmd_template;
436 char *command_echo, *command_out;
436 437
437 if (path[0] != '-' && realpath(path, abspath) == NULL) { 438 if (path[0] != '-' && realpath(path, abspath) == NULL) {
438 err = errno; 439 err = errno;
@@ -487,6 +488,16 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf,
487 (path[0] == '-') ? path : abspath); 488 (path[0] == '-') ? path : abspath);
488 489
489 pr_debug("llvm compiling command template: %s\n", template); 490 pr_debug("llvm compiling command template: %s\n", template);
491
492 if (asprintf(&command_echo, "echo -n \"%s\"", template) < 0)
493 goto errout;
494
495 err = read_from_pipe(command_echo, (void **) &command_out, NULL);
496 if (err)
497 goto errout;
498
499 pr_debug("llvm compiling command : %s\n", command_out);
500
490 err = read_from_pipe(template, &obj_buf, &obj_buf_sz); 501 err = read_from_pipe(template, &obj_buf, &obj_buf_sz);
491 if (err) { 502 if (err) {
492 pr_err("ERROR:\tunable to compile %s\n", path); 503 pr_err("ERROR:\tunable to compile %s\n", path);
@@ -497,6 +508,8 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf,
497 goto errout; 508 goto errout;
498 } 509 }
499 510
511 free(command_echo);
512 free(command_out);
500 free(kbuild_dir); 513 free(kbuild_dir);
501 free(kbuild_include_opts); 514 free(kbuild_include_opts);
502 515
@@ -509,6 +522,7 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf,
509 *p_obj_buf_sz = obj_buf_sz; 522 *p_obj_buf_sz = obj_buf_sz;
510 return 0; 523 return 0;
511errout: 524errout:
525 free(command_echo);
512 free(kbuild_dir); 526 free(kbuild_dir);
513 free(kbuild_include_opts); 527 free(kbuild_include_opts);
514 free(obj_buf); 528 free(obj_buf);
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 43fbbee409ec..2eca8478e24f 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -50,21 +50,13 @@ static void machine__threads_init(struct machine *machine)
50 50
51static int machine__set_mmap_name(struct machine *machine) 51static int machine__set_mmap_name(struct machine *machine)
52{ 52{
53 if (machine__is_host(machine)) { 53 if (machine__is_host(machine))
54 if (symbol_conf.vmlinux_name) 54 machine->mmap_name = strdup("[kernel.kallsyms]");
55 machine->mmap_name = strdup(symbol_conf.vmlinux_name); 55 else if (machine__is_default_guest(machine))
56 else 56 machine->mmap_name = strdup("[guest.kernel.kallsyms]");
57 machine->mmap_name = strdup("[kernel.kallsyms]"); 57 else if (asprintf(&machine->mmap_name, "[guest.kernel.kallsyms.%d]",
58 } else if (machine__is_default_guest(machine)) { 58 machine->pid) < 0)
59 if (symbol_conf.default_guest_vmlinux_name) 59 machine->mmap_name = NULL;
60 machine->mmap_name = strdup(symbol_conf.default_guest_vmlinux_name);
61 else
62 machine->mmap_name = strdup("[guest.kernel.kallsyms]");
63 } else {
64 if (asprintf(&machine->mmap_name, "[guest.kernel.kallsyms.%d]",
65 machine->pid) < 0)
66 machine->mmap_name = NULL;
67 }
68 60
69 return machine->mmap_name ? 0 : -ENOMEM; 61 return machine->mmap_name ? 0 : -ENOMEM;
70} 62}
@@ -794,9 +786,15 @@ static struct dso *machine__get_kernel(struct machine *machine)
794 struct dso *kernel; 786 struct dso *kernel;
795 787
796 if (machine__is_host(machine)) { 788 if (machine__is_host(machine)) {
789 if (symbol_conf.vmlinux_name)
790 vmlinux_name = symbol_conf.vmlinux_name;
791
797 kernel = machine__findnew_kernel(machine, vmlinux_name, 792 kernel = machine__findnew_kernel(machine, vmlinux_name,
798 "[kernel]", DSO_TYPE_KERNEL); 793 "[kernel]", DSO_TYPE_KERNEL);
799 } else { 794 } else {
795 if (symbol_conf.default_guest_vmlinux_name)
796 vmlinux_name = symbol_conf.default_guest_vmlinux_name;
797
800 kernel = machine__findnew_kernel(machine, vmlinux_name, 798 kernel = machine__findnew_kernel(machine, vmlinux_name,
801 "[guest.kernel]", 799 "[guest.kernel]",
802 DSO_TYPE_GUEST_KERNEL); 800 DSO_TYPE_GUEST_KERNEL);
diff --git a/tools/perf/util/mem2node.c b/tools/perf/util/mem2node.c
new file mode 100644
index 000000000000..c6fd81c02586
--- /dev/null
+++ b/tools/perf/util/mem2node.c
@@ -0,0 +1,134 @@
1#include <errno.h>
2#include <inttypes.h>
3#include <linux/bitmap.h>
4#include "mem2node.h"
5#include "util.h"
6
7struct phys_entry {
8 struct rb_node rb_node;
9 u64 start;
10 u64 end;
11 u64 node;
12};
13
14static void phys_entry__insert(struct phys_entry *entry, struct rb_root *root)
15{
16 struct rb_node **p = &root->rb_node;
17 struct rb_node *parent = NULL;
18 struct phys_entry *e;
19
20 while (*p != NULL) {
21 parent = *p;
22 e = rb_entry(parent, struct phys_entry, rb_node);
23
24 if (entry->start < e->start)
25 p = &(*p)->rb_left;
26 else
27 p = &(*p)->rb_right;
28 }
29
30 rb_link_node(&entry->rb_node, parent, p);
31 rb_insert_color(&entry->rb_node, root);
32}
33
34static void
35phys_entry__init(struct phys_entry *entry, u64 start, u64 bsize, u64 node)
36{
37 entry->start = start;
38 entry->end = start + bsize;
39 entry->node = node;
40 RB_CLEAR_NODE(&entry->rb_node);
41}
42
43int mem2node__init(struct mem2node *map, struct perf_env *env)
44{
45 struct memory_node *n, *nodes = &env->memory_nodes[0];
46 struct phys_entry *entries, *tmp_entries;
47 u64 bsize = env->memory_bsize;
48 int i, j = 0, max = 0;
49
50 memset(map, 0x0, sizeof(*map));
51 map->root = RB_ROOT;
52
53 for (i = 0; i < env->nr_memory_nodes; i++) {
54 n = &nodes[i];
55 max += bitmap_weight(n->set, n->size);
56 }
57
58 entries = zalloc(sizeof(*entries) * max);
59 if (!entries)
60 return -ENOMEM;
61
62 for (i = 0; i < env->nr_memory_nodes; i++) {
63 u64 bit;
64
65 n = &nodes[i];
66
67 for (bit = 0; bit < n->size; bit++) {
68 u64 start;
69
70 if (!test_bit(bit, n->set))
71 continue;
72
73 start = bit * bsize;
74
75 /*
76 * Merge nearby areas, we walk in order
77 * through the bitmap, so no need to sort.
78 */
79 if (j > 0) {
80 struct phys_entry *prev = &entries[j - 1];
81
82 if ((prev->end == start) &&
83 (prev->node == n->node)) {
84 prev->end += bsize;
85 continue;
86 }
87 }
88
89 phys_entry__init(&entries[j++], start, bsize, n->node);
90 }
91 }
92
93 /* Cut unused entries, due to merging. */
94 tmp_entries = realloc(entries, sizeof(*entries) * j);
95 if (tmp_entries)
96 entries = tmp_entries;
97
98 for (i = 0; i < j; i++) {
99 pr_debug("mem2node %03" PRIu64 " [0x%016" PRIx64 "-0x%016" PRIx64 "]\n",
100 entries[i].node, entries[i].start, entries[i].end);
101
102 phys_entry__insert(&entries[i], &map->root);
103 }
104
105 map->entries = entries;
106 return 0;
107}
108
109void mem2node__exit(struct mem2node *map)
110{
111 zfree(&map->entries);
112}
113
114int mem2node__node(struct mem2node *map, u64 addr)
115{
116 struct rb_node **p, *parent = NULL;
117 struct phys_entry *entry;
118
119 p = &map->root.rb_node;
120 while (*p != NULL) {
121 parent = *p;
122 entry = rb_entry(parent, struct phys_entry, rb_node);
123 if (addr < entry->start)
124 p = &(*p)->rb_left;
125 else if (addr >= entry->end)
126 p = &(*p)->rb_right;
127 else
128 goto out;
129 }
130
131 entry = NULL;
132out:
133 return entry ? (int) entry->node : -1;
134}
diff --git a/tools/perf/util/mem2node.h b/tools/perf/util/mem2node.h
new file mode 100644
index 000000000000..59c4752a2181
--- /dev/null
+++ b/tools/perf/util/mem2node.h
@@ -0,0 +1,19 @@
1#ifndef __MEM2NODE_H
2#define __MEM2NODE_H
3
4#include <linux/rbtree.h>
5#include "env.h"
6
7struct phys_entry;
8
9struct mem2node {
10 struct rb_root root;
11 struct phys_entry *entries;
12 int cnt;
13};
14
15int mem2node__init(struct mem2node *map, struct perf_env *env);
16void mem2node__exit(struct mem2node *map);
17int mem2node__node(struct mem2node *map, u64 addr);
18
19#endif /* __MEM2NODE_H */
diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c
index 074c4fd3b67e..38ca3ffb9d61 100644
--- a/tools/perf/util/mmap.c
+++ b/tools/perf/util/mmap.c
@@ -199,19 +199,18 @@ int perf_mmap__mmap(struct perf_mmap *map, struct mmap_params *mp, int fd)
199 return 0; 199 return 0;
200} 200}
201 201
202static int overwrite_rb_find_range(void *buf, int mask, u64 head, u64 *start, u64 *end) 202static int overwrite_rb_find_range(void *buf, int mask, u64 *start, u64 *end)
203{ 203{
204 struct perf_event_header *pheader; 204 struct perf_event_header *pheader;
205 u64 evt_head = head; 205 u64 evt_head = *start;
206 int size = mask + 1; 206 int size = mask + 1;
207 207
208 pr_debug2("overwrite_rb_find_range: buf=%p, head=%"PRIx64"\n", buf, head); 208 pr_debug2("%s: buf=%p, start=%"PRIx64"\n", __func__, buf, *start);
209 pheader = (struct perf_event_header *)(buf + (head & mask)); 209 pheader = (struct perf_event_header *)(buf + (*start & mask));
210 *start = head;
211 while (true) { 210 while (true) {
212 if (evt_head - head >= (unsigned int)size) { 211 if (evt_head - *start >= (unsigned int)size) {
213 pr_debug("Finished reading overwrite ring buffer: rewind\n"); 212 pr_debug("Finished reading overwrite ring buffer: rewind\n");
214 if (evt_head - head > (unsigned int)size) 213 if (evt_head - *start > (unsigned int)size)
215 evt_head -= pheader->size; 214 evt_head -= pheader->size;
216 *end = evt_head; 215 *end = evt_head;
217 return 0; 216 return 0;
@@ -262,7 +261,7 @@ int perf_mmap__read_init(struct perf_mmap *md)
262 * Backward ring buffer is full. We still have a chance to read 261 * Backward ring buffer is full. We still have a chance to read
263 * most of data from it. 262 * most of data from it.
264 */ 263 */
265 if (overwrite_rb_find_range(data, md->mask, head, &md->start, &md->end)) 264 if (overwrite_rb_find_range(data, md->mask, &md->start, &md->end))
266 return -EINVAL; 265 return -EINVAL;
267 } 266 }
268 267
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 4e80ca320399..2fb0272146d8 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -206,8 +206,8 @@ struct tracepoint_path *tracepoint_id_to_path(u64 config)
206 206
207 for_each_event(sys_dirent, evt_dir, evt_dirent) { 207 for_each_event(sys_dirent, evt_dir, evt_dirent) {
208 208
209 snprintf(evt_path, MAXPATHLEN, "%s/%s/id", dir_path, 209 scnprintf(evt_path, MAXPATHLEN, "%s/%s/id", dir_path,
210 evt_dirent->d_name); 210 evt_dirent->d_name);
211 fd = open(evt_path, O_RDONLY); 211 fd = open(evt_path, O_RDONLY);
212 if (fd < 0) 212 if (fd < 0)
213 continue; 213 continue;
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 1111d5bf15ca..064bdcb7bd78 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -351,7 +351,7 @@ static int pmu_aliases_parse(char *dir, struct list_head *head)
351 if (pmu_alias_info_file(name)) 351 if (pmu_alias_info_file(name))
352 continue; 352 continue;
353 353
354 snprintf(path, PATH_MAX, "%s/%s", dir, name); 354 scnprintf(path, PATH_MAX, "%s/%s", dir, name);
355 355
356 file = fopen(path, "r"); 356 file = fopen(path, "r");
357 if (!file) { 357 if (!file) {
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index a5731de0e5eb..c37fbef1711d 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -423,20 +423,20 @@ static int convert_variable_fields(Dwarf_Die *vr_die, const char *varname,
423 pr_warning("Failed to get the type of %s.\n", varname); 423 pr_warning("Failed to get the type of %s.\n", varname);
424 return -ENOENT; 424 return -ENOENT;
425 } 425 }
426 pr_debug2("Var real type: (%x)\n", (unsigned)dwarf_dieoffset(&type)); 426 pr_debug2("Var real type: %s (%x)\n", dwarf_diename(&type),
427 (unsigned)dwarf_dieoffset(&type));
427 tag = dwarf_tag(&type); 428 tag = dwarf_tag(&type);
428 429
429 if (field->name[0] == '[' && 430 if (field->name[0] == '[' &&
430 (tag == DW_TAG_array_type || tag == DW_TAG_pointer_type)) { 431 (tag == DW_TAG_array_type || tag == DW_TAG_pointer_type)) {
431 if (field->next) 432 /* Save original type for next field or type */
432 /* Save original type for next field */ 433 memcpy(die_mem, &type, sizeof(*die_mem));
433 memcpy(die_mem, &type, sizeof(*die_mem));
434 /* Get the type of this array */ 434 /* Get the type of this array */
435 if (die_get_real_type(&type, &type) == NULL) { 435 if (die_get_real_type(&type, &type) == NULL) {
436 pr_warning("Failed to get the type of %s.\n", varname); 436 pr_warning("Failed to get the type of %s.\n", varname);
437 return -ENOENT; 437 return -ENOENT;
438 } 438 }
439 pr_debug2("Array real type: (%x)\n", 439 pr_debug2("Array real type: %s (%x)\n", dwarf_diename(&type),
440 (unsigned)dwarf_dieoffset(&type)); 440 (unsigned)dwarf_dieoffset(&type));
441 if (tag == DW_TAG_pointer_type) { 441 if (tag == DW_TAG_pointer_type) {
442 ref = zalloc(sizeof(struct probe_trace_arg_ref)); 442 ref = zalloc(sizeof(struct probe_trace_arg_ref));
@@ -448,9 +448,6 @@ static int convert_variable_fields(Dwarf_Die *vr_die, const char *varname,
448 *ref_ptr = ref; 448 *ref_ptr = ref;
449 } 449 }
450 ref->offset += dwarf_bytesize(&type) * field->index; 450 ref->offset += dwarf_bytesize(&type) * field->index;
451 if (!field->next)
452 /* Save vr_die for converting types */
453 memcpy(die_mem, vr_die, sizeof(*die_mem));
454 goto next; 451 goto next;
455 } else if (tag == DW_TAG_pointer_type) { 452 } else if (tag == DW_TAG_pointer_type) {
456 /* Check the pointer and dereference */ 453 /* Check the pointer and dereference */
diff --git a/tools/perf/util/setup.py b/tools/perf/util/setup.py
index 6891635b50c3..001be4f9d3b9 100644
--- a/tools/perf/util/setup.py
+++ b/tools/perf/util/setup.py
@@ -28,6 +28,8 @@ class install_lib(_install_lib):
28cflags = getenv('CFLAGS', '').split() 28cflags = getenv('CFLAGS', '').split()
29# switch off several checks (need to be at the end of cflags list) 29# switch off several checks (need to be at the end of cflags list)
30cflags += ['-fno-strict-aliasing', '-Wno-write-strings', '-Wno-unused-parameter' ] 30cflags += ['-fno-strict-aliasing', '-Wno-write-strings', '-Wno-unused-parameter' ]
31if cc != "clang":
32 cflags += ['-Wno-cast-function-type' ]
31 33
32src_perf = getenv('srctree') + '/tools/perf' 34src_perf = getenv('srctree') + '/tools/perf'
33build_lib = getenv('PYTHON_EXTBUILD_LIB') 35build_lib = getenv('PYTHON_EXTBUILD_LIB')
diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
index 32235657c1ac..a0061e0b0fad 100644
--- a/tools/perf/util/stat.c
+++ b/tools/perf/util/stat.c
@@ -92,7 +92,7 @@ static const char *id_str[PERF_STAT_EVSEL_ID__MAX] = {
92}; 92};
93#undef ID 93#undef ID
94 94
95void perf_stat_evsel_id_init(struct perf_evsel *evsel) 95static void perf_stat_evsel_id_init(struct perf_evsel *evsel)
96{ 96{
97 struct perf_stat_evsel *ps = evsel->stats; 97 struct perf_stat_evsel *ps = evsel->stats;
98 int i; 98 int i;
diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h
index 2f44e386a0e8..8f56ba4fd258 100644
--- a/tools/perf/util/stat.h
+++ b/tools/perf/util/stat.h
@@ -128,8 +128,6 @@ bool __perf_evsel_stat__is(struct perf_evsel *evsel,
128#define perf_stat_evsel__is(evsel, id) \ 128#define perf_stat_evsel__is(evsel, id) \
129 __perf_evsel_stat__is(evsel, PERF_STAT_EVSEL_ID__ ## id) 129 __perf_evsel_stat__is(evsel, PERF_STAT_EVSEL_ID__ ## id)
130 130
131void perf_stat_evsel_id_init(struct perf_evsel *evsel);
132
133extern struct runtime_stat rt_stat; 131extern struct runtime_stat rt_stat;
134extern struct stats walltime_nsecs_stats; 132extern struct stats walltime_nsecs_stats;
135 133
diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c
index 1e9c974faf67..8e969f28cc59 100644
--- a/tools/perf/util/unwind-libdw.c
+++ b/tools/perf/util/unwind-libdw.c
@@ -50,7 +50,7 @@ static int __report_module(struct addr_location *al, u64 ip,
50 50
51 if (!mod) 51 if (!mod)
52 mod = dwfl_report_elf(ui->dwfl, dso->short_name, 52 mod = dwfl_report_elf(ui->dwfl, dso->short_name,
53 dso->long_name, -1, al->map->start, 53 (dso->symsrc_filename ? dso->symsrc_filename : dso->long_name), -1, al->map->start,
54 false); 54 false);
55 55
56 return mod && dwfl_addrmodule(ui->dwfl, ip) == mod ? 0 : -1; 56 return mod && dwfl_addrmodule(ui->dwfl, ip) == mod ? 0 : -1;