aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2017-03-24 14:37:40 -0400
committerIngo Molnar <mingo@kernel.org>2017-03-24 14:37:40 -0400
commite3a6a62400520452fe39740dca90a1d0b94b8f92 (patch)
tree0339ad6ca5de37105e47d4fa0d3b082e091ccbb0
parent267dd0a07eefbb37264fcfad984fffc8856898ad (diff)
parentbf874fcf9f2fed58510dc83abcee388cee2b427e (diff)
Merge tag 'perf-core-for-mingo-4.12-20170324' 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: User visible changes: - Allow suppressing 'uncore_' when specifying PMU events (Andi Kleen) - Collapse identically named PMU events in 'perf stat', allow not merging it via --no-merge (Andi Kleen) Fixes: - Use more precise 'grep -v' to suppress unwanted 'objdump -dS' disassembly output to not ditch line:number lines needed by 'perf annotate --print-lines' logic (Taeung Song) Infrastructure changes: - SDT (Statically Defined Tracing)/uprobes_events arguments improvements (Alexis Berlemont, Ravi Bangoria) - Improvements for the handling of JSON described vendor events, including having an expression parser to calculate metrics from multiple vendor events (Andi Kleen) - Update Intel JSON vendor event files (Andi Kleen) - Restore error reporting in 'perf probe -d' when none of the events requested to be deleted exist. (Kefeng Wang) - Bump MAX_CMDLEN in 'perf probe' to match what the kernel accepts (Ravi Bangoria) Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--tools/perf/Documentation/perf-list.txt4
-rw-r--r--tools/perf/Documentation/perf-stat.txt3
-rw-r--r--tools/perf/arch/x86/util/perf_regs.c103
-rw-r--r--tools/perf/builtin-list.c14
-rw-r--r--tools/perf/builtin-probe.c6
-rw-r--r--tools/perf/builtin-stat.c146
-rw-r--r--tools/perf/pmu-events/arch/x86/broadwellde/uncore-cache.json28
-rw-r--r--tools/perf/pmu-events/arch/x86/broadwellde/uncore-memory.json26
-rw-r--r--tools/perf/pmu-events/arch/x86/broadwellde/uncore-power.json26
-rw-r--r--tools/perf/pmu-events/arch/x86/broadwellx/uncore-cache.json28
-rw-r--r--tools/perf/pmu-events/arch/x86/broadwellx/uncore-interconnect.json6
-rw-r--r--tools/perf/pmu-events/arch/x86/broadwellx/uncore-memory.json21
-rw-r--r--tools/perf/pmu-events/arch/x86/broadwellx/uncore-power.json26
-rw-r--r--tools/perf/pmu-events/arch/x86/haswellx/uncore-cache.json28
-rw-r--r--tools/perf/pmu-events/arch/x86/haswellx/uncore-interconnect.json6
-rw-r--r--tools/perf/pmu-events/arch/x86/haswellx/uncore-memory.json21
-rw-r--r--tools/perf/pmu-events/arch/x86/haswellx/uncore-power.json26
-rw-r--r--tools/perf/pmu-events/arch/x86/ivytown/uncore-cache.json22
-rw-r--r--tools/perf/pmu-events/arch/x86/ivytown/uncore-interconnect.json12
-rw-r--r--tools/perf/pmu-events/arch/x86/ivytown/uncore-memory.json19
-rw-r--r--tools/perf/pmu-events/arch/x86/ivytown/uncore-power.json53
-rw-r--r--tools/perf/pmu-events/arch/x86/jaketown/uncore-cache.json13
-rw-r--r--tools/perf/pmu-events/arch/x86/jaketown/uncore-interconnect.json12
-rw-r--r--tools/perf/pmu-events/arch/x86/jaketown/uncore-memory.json21
-rw-r--r--tools/perf/pmu-events/arch/x86/jaketown/uncore-power.json53
-rw-r--r--tools/perf/pmu-events/jevents.c26
-rw-r--r--tools/perf/pmu-events/jevents.h3
-rw-r--r--tools/perf/pmu-events/pmu-events.h2
-rw-r--r--tools/perf/tests/Build1
-rw-r--r--tools/perf/tests/builtin-test.c4
-rw-r--r--tools/perf/tests/expr.c56
-rw-r--r--tools/perf/tests/tests.h1
-rw-r--r--tools/perf/util/Build6
-rw-r--r--tools/perf/util/annotate.c8
-rw-r--r--tools/perf/util/evsel.c4
-rw-r--r--tools/perf/util/evsel.h5
-rw-r--r--tools/perf/util/expr.h25
-rw-r--r--tools/perf/util/expr.y173
-rw-r--r--tools/perf/util/parse-events.c78
-rw-r--r--tools/perf/util/parse-events.h10
-rw-r--r--tools/perf/util/parse-events.y73
-rw-r--r--tools/perf/util/perf_regs.c6
-rw-r--r--tools/perf/util/perf_regs.h6
-rw-r--r--tools/perf/util/pmu.c32
-rw-r--r--tools/perf/util/pmu.h6
-rw-r--r--tools/perf/util/probe-event.c1
-rw-r--r--tools/perf/util/probe-file.c173
-rw-r--r--tools/perf/util/stat-shadow.c197
-rw-r--r--tools/perf/util/stat.h2
-rw-r--r--tools/perf/util/symbol-elf.c25
-rw-r--r--tools/perf/util/symbol.h1
51 files changed, 1370 insertions, 277 deletions
diff --git a/tools/perf/Documentation/perf-list.txt b/tools/perf/Documentation/perf-list.txt
index 41857cce5e86..143d98df2df9 100644
--- a/tools/perf/Documentation/perf-list.txt
+++ b/tools/perf/Documentation/perf-list.txt
@@ -24,6 +24,10 @@ Don't print descriptions.
24--long-desc:: 24--long-desc::
25Print longer event descriptions. 25Print longer event descriptions.
26 26
27--details::
28Print how named events are resolved internally into perf events, and also
29any extra expressions computed by perf stat.
30
27 31
28[[EVENT_MODIFIERS]] 32[[EVENT_MODIFIERS]]
29EVENT MODIFIERS 33EVENT MODIFIERS
diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt
index 978548138624..bd0e4417f2be 100644
--- a/tools/perf/Documentation/perf-stat.txt
+++ b/tools/perf/Documentation/perf-stat.txt
@@ -236,6 +236,9 @@ To interpret the results it is usually needed to know on which
236CPUs the workload runs on. If needed the CPUs can be forced using 236CPUs the workload runs on. If needed the CPUs can be forced using
237taskset. 237taskset.
238 238
239--no-merge::
240Do not merge results from same PMUs.
241
239EXAMPLES 242EXAMPLES
240-------- 243--------
241 244
diff --git a/tools/perf/arch/x86/util/perf_regs.c b/tools/perf/arch/x86/util/perf_regs.c
index c5db14f36cc7..d8a8dcf761f7 100644
--- a/tools/perf/arch/x86/util/perf_regs.c
+++ b/tools/perf/arch/x86/util/perf_regs.c
@@ -1,4 +1,7 @@
1#include <string.h>
2
1#include "../../perf.h" 3#include "../../perf.h"
4#include "../../util/util.h"
2#include "../../util/perf_regs.h" 5#include "../../util/perf_regs.h"
3 6
4const struct sample_reg sample_reg_masks[] = { 7const struct sample_reg sample_reg_masks[] = {
@@ -26,3 +29,103 @@ const struct sample_reg sample_reg_masks[] = {
26#endif 29#endif
27 SMPL_REG_END 30 SMPL_REG_END
28}; 31};
32
33struct sdt_name_reg {
34 const char *sdt_name;
35 const char *uprobe_name;
36};
37#define SDT_NAME_REG(n, m) {.sdt_name = "%" #n, .uprobe_name = "%" #m}
38#define SDT_NAME_REG_END {.sdt_name = NULL, .uprobe_name = NULL}
39
40static const struct sdt_name_reg sdt_reg_renamings[] = {
41 SDT_NAME_REG(eax, ax),
42 SDT_NAME_REG(rax, ax),
43 SDT_NAME_REG(ebx, bx),
44 SDT_NAME_REG(rbx, bx),
45 SDT_NAME_REG(ecx, cx),
46 SDT_NAME_REG(rcx, cx),
47 SDT_NAME_REG(edx, dx),
48 SDT_NAME_REG(rdx, dx),
49 SDT_NAME_REG(esi, si),
50 SDT_NAME_REG(rsi, si),
51 SDT_NAME_REG(sil, si),
52 SDT_NAME_REG(edi, di),
53 SDT_NAME_REG(rdi, di),
54 SDT_NAME_REG(dil, di),
55 SDT_NAME_REG(ebp, bp),
56 SDT_NAME_REG(rbp, bp),
57 SDT_NAME_REG(bpl, bp),
58 SDT_NAME_REG(rsp, sp),
59 SDT_NAME_REG(esp, sp),
60 SDT_NAME_REG(spl, sp),
61
62 /* rNN registers */
63 SDT_NAME_REG(r8b, r8),
64 SDT_NAME_REG(r8w, r8),
65 SDT_NAME_REG(r8d, r8),
66 SDT_NAME_REG(r9b, r9),
67 SDT_NAME_REG(r9w, r9),
68 SDT_NAME_REG(r9d, r9),
69 SDT_NAME_REG(r10b, r10),
70 SDT_NAME_REG(r10w, r10),
71 SDT_NAME_REG(r10d, r10),
72 SDT_NAME_REG(r11b, r11),
73 SDT_NAME_REG(r11w, r11),
74 SDT_NAME_REG(r11d, r11),
75 SDT_NAME_REG(r12b, r12),
76 SDT_NAME_REG(r12w, r12),
77 SDT_NAME_REG(r12d, r12),
78 SDT_NAME_REG(r13b, r13),
79 SDT_NAME_REG(r13w, r13),
80 SDT_NAME_REG(r13d, r13),
81 SDT_NAME_REG(r14b, r14),
82 SDT_NAME_REG(r14w, r14),
83 SDT_NAME_REG(r14d, r14),
84 SDT_NAME_REG(r15b, r15),
85 SDT_NAME_REG(r15w, r15),
86 SDT_NAME_REG(r15d, r15),
87 SDT_NAME_REG_END,
88};
89
90int sdt_rename_register(char **pdesc, char *old_name)
91{
92 const struct sdt_name_reg *rnames = sdt_reg_renamings;
93 char *new_desc, *old_desc = *pdesc;
94 size_t prefix_len, sdt_len, uprobe_len, old_desc_len, offset;
95 int ret = -1;
96
97 while (ret != 0 && rnames->sdt_name != NULL) {
98 sdt_len = strlen(rnames->sdt_name);
99 ret = strncmp(old_name, rnames->sdt_name, sdt_len);
100 rnames += !!ret;
101 }
102
103 if (rnames->sdt_name == NULL)
104 return 0;
105
106 sdt_len = strlen(rnames->sdt_name);
107 uprobe_len = strlen(rnames->uprobe_name);
108 old_desc_len = strlen(old_desc) + 1;
109
110 new_desc = zalloc(old_desc_len + uprobe_len - sdt_len);
111 if (new_desc == NULL)
112 return -1;
113
114 /* Copy the chars before the register name (at least '%') */
115 prefix_len = old_name - old_desc;
116 memcpy(new_desc, old_desc, prefix_len);
117
118 /* Copy the new register name */
119 memcpy(new_desc + prefix_len, rnames->uprobe_name, uprobe_len);
120
121 /* Copy the chars after the register name (if need be) */
122 offset = prefix_len + sdt_len;
123 if (offset < old_desc_len)
124 memcpy(new_desc + prefix_len + uprobe_len,
125 old_desc + offset, old_desc_len - offset);
126
127 free(old_desc);
128 *pdesc = new_desc;
129
130 return 0;
131}
diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
index 3b9d98b5feef..be9195e95c78 100644
--- a/tools/perf/builtin-list.c
+++ b/tools/perf/builtin-list.c
@@ -18,6 +18,7 @@
18#include <subcmd/parse-options.h> 18#include <subcmd/parse-options.h>
19 19
20static bool desc_flag = true; 20static bool desc_flag = true;
21static bool details_flag;
21 22
22int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused) 23int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
23{ 24{
@@ -30,6 +31,8 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
30 "Print extra event descriptions. --no-desc to not print."), 31 "Print extra event descriptions. --no-desc to not print."),
31 OPT_BOOLEAN('v', "long-desc", &long_desc_flag, 32 OPT_BOOLEAN('v', "long-desc", &long_desc_flag,
32 "Print longer event descriptions."), 33 "Print longer event descriptions."),
34 OPT_BOOLEAN(0, "details", &details_flag,
35 "Print information on the perf event names and expressions used internally by events."),
33 OPT_INCR(0, "debug", &verbose, 36 OPT_INCR(0, "debug", &verbose,
34 "Enable debugging output"), 37 "Enable debugging output"),
35 OPT_END() 38 OPT_END()
@@ -50,7 +53,8 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
50 printf("\nList of pre-defined events (to be used in -e):\n\n"); 53 printf("\nList of pre-defined events (to be used in -e):\n\n");
51 54
52 if (argc == 0) { 55 if (argc == 0) {
53 print_events(NULL, raw_dump, !desc_flag, long_desc_flag); 56 print_events(NULL, raw_dump, !desc_flag, long_desc_flag,
57 details_flag);
54 return 0; 58 return 0;
55 } 59 }
56 60
@@ -72,7 +76,7 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
72 print_hwcache_events(NULL, raw_dump); 76 print_hwcache_events(NULL, raw_dump);
73 else if (strcmp(argv[i], "pmu") == 0) 77 else if (strcmp(argv[i], "pmu") == 0)
74 print_pmu_events(NULL, raw_dump, !desc_flag, 78 print_pmu_events(NULL, raw_dump, !desc_flag,
75 long_desc_flag); 79 long_desc_flag, details_flag);
76 else if (strcmp(argv[i], "sdt") == 0) 80 else if (strcmp(argv[i], "sdt") == 0)
77 print_sdt_events(NULL, NULL, raw_dump); 81 print_sdt_events(NULL, NULL, raw_dump);
78 else if ((sep = strchr(argv[i], ':')) != NULL) { 82 else if ((sep = strchr(argv[i], ':')) != NULL) {
@@ -80,7 +84,8 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
80 84
81 if (sep == NULL) { 85 if (sep == NULL) {
82 print_events(argv[i], raw_dump, !desc_flag, 86 print_events(argv[i], raw_dump, !desc_flag,
83 long_desc_flag); 87 long_desc_flag,
88 details_flag);
84 continue; 89 continue;
85 } 90 }
86 sep_idx = sep - argv[i]; 91 sep_idx = sep - argv[i];
@@ -103,7 +108,8 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
103 event_symbols_sw, PERF_COUNT_SW_MAX, raw_dump); 108 event_symbols_sw, PERF_COUNT_SW_MAX, raw_dump);
104 print_hwcache_events(s, raw_dump); 109 print_hwcache_events(s, raw_dump);
105 print_pmu_events(s, raw_dump, !desc_flag, 110 print_pmu_events(s, raw_dump, !desc_flag,
106 long_desc_flag); 111 long_desc_flag,
112 details_flag);
107 print_tracepoint_events(NULL, s, raw_dump); 113 print_tracepoint_events(NULL, s, raw_dump);
108 print_sdt_events(NULL, s, raw_dump); 114 print_sdt_events(NULL, s, raw_dump);
109 free(s); 115 free(s);
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index 1fcebc31a508..51cdc230f6ca 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -442,9 +442,9 @@ static int perf_del_probe_events(struct strfilter *filter)
442 } 442 }
443 443
444 if (ret == -ENOENT && ret2 == -ENOENT) 444 if (ret == -ENOENT && ret2 == -ENOENT)
445 pr_debug("\"%s\" does not hit any event.\n", str); 445 pr_warning("\"%s\" does not hit any event.\n", str);
446 /* Note that this is silently ignored */ 446 else
447 ret = 0; 447 ret = 0;
448 448
449error: 449error:
450 if (kfd >= 0) 450 if (kfd >= 0)
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index f53f449d864d..01b589e3c3a6 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -140,6 +140,7 @@ static unsigned int unit_width = 4; /* strlen("unit") */
140static bool forever = false; 140static bool forever = false;
141static bool metric_only = false; 141static bool metric_only = false;
142static bool force_metric_only = false; 142static bool force_metric_only = false;
143static bool no_merge = false;
143static struct timespec ref_time; 144static struct timespec ref_time;
144static struct cpu_map *aggr_map; 145static struct cpu_map *aggr_map;
145static aggr_get_id_t aggr_get_id; 146static aggr_get_id_t aggr_get_id;
@@ -1144,6 +1145,7 @@ static void printout(int id, int nr, struct perf_evsel *counter, double uval,
1144 out.print_metric = pm; 1145 out.print_metric = pm;
1145 out.new_line = nl; 1146 out.new_line = nl;
1146 out.ctx = &os; 1147 out.ctx = &os;
1148 out.force_header = false;
1147 1149
1148 if (csv_output && !metric_only) { 1150 if (csv_output && !metric_only) {
1149 print_noise(counter, noise); 1151 print_noise(counter, noise);
@@ -1182,11 +1184,81 @@ static void aggr_update_shadow(void)
1182 } 1184 }
1183} 1185}
1184 1186
1187static void collect_all_aliases(struct perf_evsel *counter,
1188 void (*cb)(struct perf_evsel *counter, void *data,
1189 bool first),
1190 void *data)
1191{
1192 struct perf_evsel *alias;
1193
1194 alias = list_prepare_entry(counter, &(evsel_list->entries), node);
1195 list_for_each_entry_continue (alias, &evsel_list->entries, node) {
1196 if (strcmp(perf_evsel__name(alias), perf_evsel__name(counter)) ||
1197 alias->scale != counter->scale ||
1198 alias->cgrp != counter->cgrp ||
1199 strcmp(alias->unit, counter->unit) ||
1200 nsec_counter(alias) != nsec_counter(counter))
1201 break;
1202 alias->merged_stat = true;
1203 cb(alias, data, false);
1204 }
1205}
1206
1207static bool collect_data(struct perf_evsel *counter,
1208 void (*cb)(struct perf_evsel *counter, void *data,
1209 bool first),
1210 void *data)
1211{
1212 if (counter->merged_stat)
1213 return false;
1214 cb(counter, data, true);
1215 if (!no_merge)
1216 collect_all_aliases(counter, cb, data);
1217 return true;
1218}
1219
1220struct aggr_data {
1221 u64 ena, run, val;
1222 int id;
1223 int nr;
1224 int cpu;
1225};
1226
1227static void aggr_cb(struct perf_evsel *counter, void *data, bool first)
1228{
1229 struct aggr_data *ad = data;
1230 int cpu, s2;
1231
1232 for (cpu = 0; cpu < perf_evsel__nr_cpus(counter); cpu++) {
1233 struct perf_counts_values *counts;
1234
1235 s2 = aggr_get_id(perf_evsel__cpus(counter), cpu);
1236 if (s2 != ad->id)
1237 continue;
1238 if (first)
1239 ad->nr++;
1240 counts = perf_counts(counter->counts, cpu, 0);
1241 /*
1242 * When any result is bad, make them all to give
1243 * consistent output in interval mode.
1244 */
1245 if (counts->ena == 0 || counts->run == 0 ||
1246 counter->counts->scaled == -1) {
1247 ad->ena = 0;
1248 ad->run = 0;
1249 break;
1250 }
1251 ad->val += counts->val;
1252 ad->ena += counts->ena;
1253 ad->run += counts->run;
1254 }
1255}
1256
1185static void print_aggr(char *prefix) 1257static void print_aggr(char *prefix)
1186{ 1258{
1187 FILE *output = stat_config.output; 1259 FILE *output = stat_config.output;
1188 struct perf_evsel *counter; 1260 struct perf_evsel *counter;
1189 int cpu, s, s2, id, nr; 1261 int s, id, nr;
1190 double uval; 1262 double uval;
1191 u64 ena, run, val; 1263 u64 ena, run, val;
1192 bool first; 1264 bool first;
@@ -1201,23 +1273,21 @@ static void print_aggr(char *prefix)
1201 * Without each counter has its own line. 1273 * Without each counter has its own line.
1202 */ 1274 */
1203 for (s = 0; s < aggr_map->nr; s++) { 1275 for (s = 0; s < aggr_map->nr; s++) {
1276 struct aggr_data ad;
1204 if (prefix && metric_only) 1277 if (prefix && metric_only)
1205 fprintf(output, "%s", prefix); 1278 fprintf(output, "%s", prefix);
1206 1279
1207 id = aggr_map->map[s]; 1280 ad.id = id = aggr_map->map[s];
1208 first = true; 1281 first = true;
1209 evlist__for_each_entry(evsel_list, counter) { 1282 evlist__for_each_entry(evsel_list, counter) {
1210 val = ena = run = 0; 1283 ad.val = ad.ena = ad.run = 0;
1211 nr = 0; 1284 ad.nr = 0;
1212 for (cpu = 0; cpu < perf_evsel__nr_cpus(counter); cpu++) { 1285 if (!collect_data(counter, aggr_cb, &ad))
1213 s2 = aggr_get_id(perf_evsel__cpus(counter), cpu); 1286 continue;
1214 if (s2 != id) 1287 nr = ad.nr;
1215 continue; 1288 ena = ad.ena;
1216 val += perf_counts(counter->counts, cpu, 0)->val; 1289 run = ad.run;
1217 ena += perf_counts(counter->counts, cpu, 0)->ena; 1290 val = ad.val;
1218 run += perf_counts(counter->counts, cpu, 0)->run;
1219 nr++;
1220 }
1221 if (first && metric_only) { 1291 if (first && metric_only) {
1222 first = false; 1292 first = false;
1223 aggr_printout(counter, id, nr); 1293 aggr_printout(counter, id, nr);
@@ -1261,6 +1331,21 @@ static void print_aggr_thread(struct perf_evsel *counter, char *prefix)
1261 } 1331 }
1262} 1332}
1263 1333
1334struct caggr_data {
1335 double avg, avg_enabled, avg_running;
1336};
1337
1338static void counter_aggr_cb(struct perf_evsel *counter, void *data,
1339 bool first __maybe_unused)
1340{
1341 struct caggr_data *cd = data;
1342 struct perf_stat_evsel *ps = counter->priv;
1343
1344 cd->avg += avg_stats(&ps->res_stats[0]);
1345 cd->avg_enabled += avg_stats(&ps->res_stats[1]);
1346 cd->avg_running += avg_stats(&ps->res_stats[2]);
1347}
1348
1264/* 1349/*
1265 * Print out the results of a single counter: 1350 * Print out the results of a single counter:
1266 * aggregated counts in system-wide mode 1351 * aggregated counts in system-wide mode
@@ -1268,23 +1353,31 @@ static void print_aggr_thread(struct perf_evsel *counter, char *prefix)
1268static void print_counter_aggr(struct perf_evsel *counter, char *prefix) 1353static void print_counter_aggr(struct perf_evsel *counter, char *prefix)
1269{ 1354{
1270 FILE *output = stat_config.output; 1355 FILE *output = stat_config.output;
1271 struct perf_stat_evsel *ps = counter->priv;
1272 double avg = avg_stats(&ps->res_stats[0]);
1273 double uval; 1356 double uval;
1274 double avg_enabled, avg_running; 1357 struct caggr_data cd = { .avg = 0.0 };
1275 1358
1276 avg_enabled = avg_stats(&ps->res_stats[1]); 1359 if (!collect_data(counter, counter_aggr_cb, &cd))
1277 avg_running = avg_stats(&ps->res_stats[2]); 1360 return;
1278 1361
1279 if (prefix && !metric_only) 1362 if (prefix && !metric_only)
1280 fprintf(output, "%s", prefix); 1363 fprintf(output, "%s", prefix);
1281 1364
1282 uval = avg * counter->scale; 1365 uval = cd.avg * counter->scale;
1283 printout(-1, 0, counter, uval, prefix, avg_running, avg_enabled, avg); 1366 printout(-1, 0, counter, uval, prefix, cd.avg_running, cd.avg_enabled, cd.avg);
1284 if (!metric_only) 1367 if (!metric_only)
1285 fprintf(output, "\n"); 1368 fprintf(output, "\n");
1286} 1369}
1287 1370
1371static void counter_cb(struct perf_evsel *counter, void *data,
1372 bool first __maybe_unused)
1373{
1374 struct aggr_data *ad = data;
1375
1376 ad->val += perf_counts(counter->counts, ad->cpu, 0)->val;
1377 ad->ena += perf_counts(counter->counts, ad->cpu, 0)->ena;
1378 ad->run += perf_counts(counter->counts, ad->cpu, 0)->run;
1379}
1380
1288/* 1381/*
1289 * Print out the results of a single counter: 1382 * Print out the results of a single counter:
1290 * does not use aggregated count in system-wide 1383 * does not use aggregated count in system-wide
@@ -1297,9 +1390,13 @@ static void print_counter(struct perf_evsel *counter, char *prefix)
1297 int cpu; 1390 int cpu;
1298 1391
1299 for (cpu = 0; cpu < perf_evsel__nr_cpus(counter); cpu++) { 1392 for (cpu = 0; cpu < perf_evsel__nr_cpus(counter); cpu++) {
1300 val = perf_counts(counter->counts, cpu, 0)->val; 1393 struct aggr_data ad = { .cpu = cpu };
1301 ena = perf_counts(counter->counts, cpu, 0)->ena; 1394
1302 run = perf_counts(counter->counts, cpu, 0)->run; 1395 if (!collect_data(counter, counter_cb, &ad))
1396 return;
1397 val = ad.val;
1398 ena = ad.ena;
1399 run = ad.run;
1303 1400
1304 if (prefix) 1401 if (prefix)
1305 fprintf(output, "%s", prefix); 1402 fprintf(output, "%s", prefix);
@@ -1384,6 +1481,7 @@ static void print_metric_headers(const char *prefix, bool no_indent)
1384 out.ctx = &os; 1481 out.ctx = &os;
1385 out.print_metric = print_metric_header; 1482 out.print_metric = print_metric_header;
1386 out.new_line = new_line_metric; 1483 out.new_line = new_line_metric;
1484 out.force_header = true;
1387 os.evsel = counter; 1485 os.evsel = counter;
1388 perf_stat__print_shadow_stats(counter, 0, 1486 perf_stat__print_shadow_stats(counter, 0,
1389 0, 1487 0,
@@ -1644,6 +1742,7 @@ static const struct option stat_options[] = {
1644 "list of cpus to monitor in system-wide"), 1742 "list of cpus to monitor in system-wide"),
1645 OPT_SET_UINT('A', "no-aggr", &stat_config.aggr_mode, 1743 OPT_SET_UINT('A', "no-aggr", &stat_config.aggr_mode,
1646 "disable CPU count aggregation", AGGR_NONE), 1744 "disable CPU count aggregation", AGGR_NONE),
1745 OPT_BOOLEAN(0, "no-merge", &no_merge, "Do not merge identical named events"),
1647 OPT_STRING('x', "field-separator", &csv_sep, "separator", 1746 OPT_STRING('x', "field-separator", &csv_sep, "separator",
1648 "print counts with custom separator"), 1747 "print counts with custom separator"),
1649 OPT_CALLBACK('G', "cgroup", &evsel_list, "name", 1748 OPT_CALLBACK('G', "cgroup", &evsel_list, "name",
@@ -2401,6 +2500,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
2401 argc = parse_options_subcommand(argc, argv, stat_options, stat_subcommands, 2500 argc = parse_options_subcommand(argc, argv, stat_options, stat_subcommands,
2402 (const char **) stat_usage, 2501 (const char **) stat_usage,
2403 PARSE_OPT_STOP_AT_NON_OPTION); 2502 PARSE_OPT_STOP_AT_NON_OPTION);
2503 perf_stat__collect_metric_expr(evsel_list);
2404 perf_stat__init_shadow_stats(); 2504 perf_stat__init_shadow_stats();
2405 2505
2406 if (csv_sep) { 2506 if (csv_sep) {
diff --git a/tools/perf/pmu-events/arch/x86/broadwellde/uncore-cache.json b/tools/perf/pmu-events/arch/x86/broadwellde/uncore-cache.json
index 076459c51d4e..58ed6d33d1f4 100644
--- a/tools/perf/pmu-events/arch/x86/broadwellde/uncore-cache.json
+++ b/tools/perf/pmu-events/arch/x86/broadwellde/uncore-cache.json
@@ -1,13 +1,13 @@
1[ 1[
2 { 2 {
3 "BriefDescription": "Uncore cache clock ticks. Derived from unc_c_clockticks", 3 "BriefDescription": "Uncore cache clock ticks",
4 "Counter": "0,1,2,3", 4 "Counter": "0,1,2,3",
5 "EventName": "UNC_C_CLOCKTICKS", 5 "EventName": "UNC_C_CLOCKTICKS",
6 "PerPkg": "1", 6 "PerPkg": "1",
7 "Unit": "CBO" 7 "Unit": "CBO"
8 }, 8 },
9 { 9 {
10 "BriefDescription": "All LLC Misses (code+ data rd + data wr - including demand and prefetch). Derived from unc_c_llc_lookup.any", 10 "BriefDescription": "All LLC Misses (code+ data rd + data wr - including demand and prefetch)",
11 "Counter": "0,1,2,3", 11 "Counter": "0,1,2,3",
12 "EventCode": "0x34", 12 "EventCode": "0x34",
13 "EventName": "UNC_C_LLC_LOOKUP.ANY", 13 "EventName": "UNC_C_LLC_LOOKUP.ANY",
@@ -18,7 +18,7 @@
18 "Unit": "CBO" 18 "Unit": "CBO"
19 }, 19 },
20 { 20 {
21 "BriefDescription": "M line evictions from LLC (writebacks to memory). Derived from unc_c_llc_victims.m_state", 21 "BriefDescription": "M line evictions from LLC (writebacks to memory)",
22 "Counter": "0,1,2,3", 22 "Counter": "0,1,2,3",
23 "EventCode": "0x37", 23 "EventCode": "0x37",
24 "EventName": "UNC_C_LLC_VICTIMS.M_STATE", 24 "EventName": "UNC_C_LLC_VICTIMS.M_STATE",
@@ -212,7 +212,7 @@
212 "Unit": "CBO" 212 "Unit": "CBO"
213 }, 213 },
214 { 214 {
215 "BriefDescription": "read requests to home agent. Derived from unc_h_requests.reads", 215 "BriefDescription": "read requests to home agent",
216 "Counter": "0,1,2,3", 216 "Counter": "0,1,2,3",
217 "EventCode": "0x1", 217 "EventCode": "0x1",
218 "EventName": "UNC_H_REQUESTS.READS", 218 "EventName": "UNC_H_REQUESTS.READS",
@@ -221,7 +221,7 @@
221 "Unit": "HA" 221 "Unit": "HA"
222 }, 222 },
223 { 223 {
224 "BriefDescription": "read requests to local home agent. Derived from unc_h_requests.reads_local", 224 "BriefDescription": "read requests to local home agent",
225 "Counter": "0,1,2,3", 225 "Counter": "0,1,2,3",
226 "EventCode": "0x1", 226 "EventCode": "0x1",
227 "EventName": "UNC_H_REQUESTS.READS_LOCAL", 227 "EventName": "UNC_H_REQUESTS.READS_LOCAL",
@@ -230,7 +230,7 @@
230 "Unit": "HA" 230 "Unit": "HA"
231 }, 231 },
232 { 232 {
233 "BriefDescription": "read requests to remote home agent. Derived from unc_h_requests.reads_remote", 233 "BriefDescription": "read requests to remote home agent",
234 "Counter": "0,1,2,3", 234 "Counter": "0,1,2,3",
235 "EventCode": "0x1", 235 "EventCode": "0x1",
236 "EventName": "UNC_H_REQUESTS.READS_REMOTE", 236 "EventName": "UNC_H_REQUESTS.READS_REMOTE",
@@ -239,7 +239,7 @@
239 "Unit": "HA" 239 "Unit": "HA"
240 }, 240 },
241 { 241 {
242 "BriefDescription": "write requests to home agent. Derived from unc_h_requests.writes", 242 "BriefDescription": "write requests to home agent",
243 "Counter": "0,1,2,3", 243 "Counter": "0,1,2,3",
244 "EventCode": "0x1", 244 "EventCode": "0x1",
245 "EventName": "UNC_H_REQUESTS.WRITES", 245 "EventName": "UNC_H_REQUESTS.WRITES",
@@ -248,7 +248,7 @@
248 "Unit": "HA" 248 "Unit": "HA"
249 }, 249 },
250 { 250 {
251 "BriefDescription": "write requests to local home agent. Derived from unc_h_requests.writes_local", 251 "BriefDescription": "write requests to local home agent",
252 "Counter": "0,1,2,3", 252 "Counter": "0,1,2,3",
253 "EventCode": "0x1", 253 "EventCode": "0x1",
254 "EventName": "UNC_H_REQUESTS.WRITES_LOCAL", 254 "EventName": "UNC_H_REQUESTS.WRITES_LOCAL",
@@ -257,7 +257,7 @@
257 "Unit": "HA" 257 "Unit": "HA"
258 }, 258 },
259 { 259 {
260 "BriefDescription": "write requests to remote home agent. Derived from unc_h_requests.writes_remote", 260 "BriefDescription": "write requests to remote home agent",
261 "Counter": "0,1,2,3", 261 "Counter": "0,1,2,3",
262 "EventCode": "0x1", 262 "EventCode": "0x1",
263 "EventName": "UNC_H_REQUESTS.WRITES_REMOTE", 263 "EventName": "UNC_H_REQUESTS.WRITES_REMOTE",
@@ -266,7 +266,7 @@
266 "Unit": "HA" 266 "Unit": "HA"
267 }, 267 },
268 { 268 {
269 "BriefDescription": "Conflict requests (requests for same address from multiple agents simultaneously). Derived from unc_h_snoop_resp.rspcnflct", 269 "BriefDescription": "Conflict requests (requests for same address from multiple agents simultaneously)",
270 "Counter": "0,1,2,3", 270 "Counter": "0,1,2,3",
271 "EventCode": "0x21", 271 "EventCode": "0x21",
272 "EventName": "UNC_H_SNOOP_RESP.RSPCNFLCT", 272 "EventName": "UNC_H_SNOOP_RESP.RSPCNFLCT",
@@ -275,7 +275,7 @@
275 "Unit": "HA" 275 "Unit": "HA"
276 }, 276 },
277 { 277 {
278 "BriefDescription": "M line forwarded from remote cache along with writeback to memory. Derived from unc_h_snoop_resp.rsp_fwd_wb", 278 "BriefDescription": "M line forwarded from remote cache along with writeback to memory",
279 "Counter": "0,1,2,3", 279 "Counter": "0,1,2,3",
280 "EventCode": "0x21", 280 "EventCode": "0x21",
281 "EventName": "UNC_H_SNOOP_RESP.RSP_FWD_WB", 281 "EventName": "UNC_H_SNOOP_RESP.RSP_FWD_WB",
@@ -285,7 +285,7 @@
285 "Unit": "HA" 285 "Unit": "HA"
286 }, 286 },
287 { 287 {
288 "BriefDescription": "M line forwarded from remote cache with no writeback to memory. Derived from unc_h_snoop_resp.rspifwd", 288 "BriefDescription": "M line forwarded from remote cache with no writeback to memory",
289 "Counter": "0,1,2,3", 289 "Counter": "0,1,2,3",
290 "EventCode": "0x21", 290 "EventCode": "0x21",
291 "EventName": "UNC_H_SNOOP_RESP.RSPIFWD", 291 "EventName": "UNC_H_SNOOP_RESP.RSPIFWD",
@@ -295,7 +295,7 @@
295 "Unit": "HA" 295 "Unit": "HA"
296 }, 296 },
297 { 297 {
298 "BriefDescription": "Shared line response from remote cache. Derived from unc_h_snoop_resp.rsps", 298 "BriefDescription": "Shared line response from remote cache",
299 "Counter": "0,1,2,3", 299 "Counter": "0,1,2,3",
300 "EventCode": "0x21", 300 "EventCode": "0x21",
301 "EventName": "UNC_H_SNOOP_RESP.RSPS", 301 "EventName": "UNC_H_SNOOP_RESP.RSPS",
@@ -305,7 +305,7 @@
305 "Unit": "HA" 305 "Unit": "HA"
306 }, 306 },
307 { 307 {
308 "BriefDescription": "Shared line forwarded from remote cache. Derived from unc_h_snoop_resp.rspsfwd", 308 "BriefDescription": "Shared line forwarded from remote cache",
309 "Counter": "0,1,2,3", 309 "Counter": "0,1,2,3",
310 "EventCode": "0x21", 310 "EventCode": "0x21",
311 "EventName": "UNC_H_SNOOP_RESP.RSPSFWD", 311 "EventName": "UNC_H_SNOOP_RESP.RSPSFWD",
diff --git a/tools/perf/pmu-events/arch/x86/broadwellde/uncore-memory.json b/tools/perf/pmu-events/arch/x86/broadwellde/uncore-memory.json
index d17dc235f734..fa09e12018ce 100644
--- a/tools/perf/pmu-events/arch/x86/broadwellde/uncore-memory.json
+++ b/tools/perf/pmu-events/arch/x86/broadwellde/uncore-memory.json
@@ -3,7 +3,7 @@
3 "BriefDescription": "read requests to memory controller. Derived from unc_m_cas_count.rd", 3 "BriefDescription": "read requests to memory controller. Derived from unc_m_cas_count.rd",
4 "Counter": "0,1,2,3", 4 "Counter": "0,1,2,3",
5 "EventCode": "0x4", 5 "EventCode": "0x4",
6 "EventName": "UNC_M_CAS_COUNT.RD", 6 "EventName": "LLC_MISSES.MEM_READ",
7 "PerPkg": "1", 7 "PerPkg": "1",
8 "ScaleUnit": "64Bytes", 8 "ScaleUnit": "64Bytes",
9 "UMask": "0x3", 9 "UMask": "0x3",
@@ -13,48 +13,44 @@
13 "BriefDescription": "write requests to memory controller. Derived from unc_m_cas_count.wr", 13 "BriefDescription": "write requests to memory controller. Derived from unc_m_cas_count.wr",
14 "Counter": "0,1,2,3", 14 "Counter": "0,1,2,3",
15 "EventCode": "0x4", 15 "EventCode": "0x4",
16 "EventName": "UNC_M_CAS_COUNT.WR", 16 "EventName": "LLC_MISSES.MEM_WRITE",
17 "PerPkg": "1", 17 "PerPkg": "1",
18 "ScaleUnit": "64Bytes", 18 "ScaleUnit": "64Bytes",
19 "UMask": "0xC", 19 "UMask": "0xC",
20 "Unit": "iMC" 20 "Unit": "iMC"
21 }, 21 },
22 { 22 {
23 "BriefDescription": "Memory controller clock ticks. Derived from unc_m_clockticks", 23 "BriefDescription": "Cycles where DRAM ranks are in power down (CKE) mode",
24 "Counter": "0,1,2,3",
25 "EventName": "UNC_M_CLOCKTICKS",
26 "PerPkg": "1",
27 "Unit": "iMC"
28 },
29 {
30 "BriefDescription": "Cycles where DRAM ranks are in power down (CKE) mode. Derived from unc_m_power_channel_ppd",
31 "Counter": "0,1,2,3", 24 "Counter": "0,1,2,3",
32 "EventCode": "0x85", 25 "EventCode": "0x85",
33 "EventName": "UNC_M_POWER_CHANNEL_PPD", 26 "EventName": "UNC_M_POWER_CHANNEL_PPD",
34 "MetricExpr": "(UNC_M_POWER_CHANNEL_PPD / UNC_M_CLOCKTICKS) * 100.", 27 "MetricExpr": "(UNC_M_POWER_CHANNEL_PPD / UNC_M_CLOCKTICKS) * 100.",
28 "MetricName": "power_channel_ppd %",
35 "PerPkg": "1", 29 "PerPkg": "1",
36 "Unit": "iMC" 30 "Unit": "iMC"
37 }, 31 },
38 { 32 {
39 "BriefDescription": "Cycles all ranks are in critical thermal throttle. Derived from unc_m_power_critical_throttle_cycles", 33 "BriefDescription": "Cycles all ranks are in critical thermal throttle",
40 "Counter": "0,1,2,3", 34 "Counter": "0,1,2,3",
41 "EventCode": "0x86", 35 "EventCode": "0x86",
42 "EventName": "UNC_M_POWER_CRITICAL_THROTTLE_CYCLES", 36 "EventName": "UNC_M_POWER_CRITICAL_THROTTLE_CYCLES",
43 "MetricExpr": "(UNC_M_POWER_CRITICAL_THROTTLE_CYCLES / UNC_M_CLOCKTICKS) * 100.", 37 "MetricExpr": "(UNC_M_POWER_CRITICAL_THROTTLE_CYCLES / UNC_M_CLOCKTICKS) * 100.",
38 "MetricName": "power_critical_throttle_cycles %",
44 "PerPkg": "1", 39 "PerPkg": "1",
45 "Unit": "iMC" 40 "Unit": "iMC"
46 }, 41 },
47 { 42 {
48 "BriefDescription": "Cycles Memory is in self refresh power mode. Derived from unc_m_power_self_refresh", 43 "BriefDescription": "Cycles Memory is in self refresh power mode",
49 "Counter": "0,1,2,3", 44 "Counter": "0,1,2,3",
50 "EventCode": "0x43", 45 "EventCode": "0x43",
51 "EventName": "UNC_M_POWER_SELF_REFRESH", 46 "EventName": "UNC_M_POWER_SELF_REFRESH",
52 "MetricExpr": "(UNC_M_POWER_SELF_REFRESH / UNC_M_CLOCKTICKS) * 100.", 47 "MetricExpr": "(UNC_M_POWER_SELF_REFRESH / UNC_M_CLOCKTICKS) * 100.",
48 "MetricName": "power_self_refresh %",
53 "PerPkg": "1", 49 "PerPkg": "1",
54 "Unit": "iMC" 50 "Unit": "iMC"
55 }, 51 },
56 { 52 {
57 "BriefDescription": "Pre-charges due to page misses. Derived from unc_m_pre_count.page_miss", 53 "BriefDescription": "Pre-charges due to page misses",
58 "Counter": "0,1,2,3", 54 "Counter": "0,1,2,3",
59 "EventCode": "0x2", 55 "EventCode": "0x2",
60 "EventName": "UNC_M_PRE_COUNT.PAGE_MISS", 56 "EventName": "UNC_M_PRE_COUNT.PAGE_MISS",
@@ -63,7 +59,7 @@
63 "Unit": "iMC" 59 "Unit": "iMC"
64 }, 60 },
65 { 61 {
66 "BriefDescription": "Pre-charge for reads. Derived from unc_m_pre_count.rd", 62 "BriefDescription": "Pre-charge for reads",
67 "Counter": "0,1,2,3", 63 "Counter": "0,1,2,3",
68 "EventCode": "0x2", 64 "EventCode": "0x2",
69 "EventName": "UNC_M_PRE_COUNT.RD", 65 "EventName": "UNC_M_PRE_COUNT.RD",
@@ -72,7 +68,7 @@
72 "Unit": "iMC" 68 "Unit": "iMC"
73 }, 69 },
74 { 70 {
75 "BriefDescription": "Pre-charge for writes. Derived from unc_m_pre_count.wr", 71 "BriefDescription": "Pre-charge for writes",
76 "Counter": "0,1,2,3", 72 "Counter": "0,1,2,3",
77 "EventCode": "0x2", 73 "EventCode": "0x2",
78 "EventName": "UNC_M_PRE_COUNT.WR", 74 "EventName": "UNC_M_PRE_COUNT.WR",
diff --git a/tools/perf/pmu-events/arch/x86/broadwellde/uncore-power.json b/tools/perf/pmu-events/arch/x86/broadwellde/uncore-power.json
index b44d43088bbb..dd1b95655d1d 100644
--- a/tools/perf/pmu-events/arch/x86/broadwellde/uncore-power.json
+++ b/tools/perf/pmu-events/arch/x86/broadwellde/uncore-power.json
@@ -1,83 +1,91 @@
1[ 1[
2 { 2 {
3 "BriefDescription": "PCU clock ticks. Use to get percentages of PCU cycles events. Derived from unc_p_clockticks", 3 "BriefDescription": "PCU clock ticks. Use to get percentages of PCU cycles events",
4 "Counter": "0,1,2,3", 4 "Counter": "0,1,2,3",
5 "EventName": "UNC_P_CLOCKTICKS", 5 "EventName": "UNC_P_CLOCKTICKS",
6 "PerPkg": "1", 6 "PerPkg": "1",
7 "Unit": "PCU" 7 "Unit": "PCU"
8 }, 8 },
9 { 9 {
10 "BriefDescription": "C0 and C1. Derived from unc_p_power_state_occupancy.cores_c0", 10 "BriefDescription": "This is an occupancy event that tracks the number of cores that are in C0. It can be used by itself to get the average number of cores in C0, with threshholding to generate histograms, or with other PCU events and occupancy triggering to capture other details",
11 "Counter": "0,1,2,3", 11 "Counter": "0,1,2,3",
12 "EventCode": "0x80", 12 "EventCode": "0x80",
13 "EventName": "UNC_P_POWER_STATE_OCCUPANCY.CORES_C0", 13 "EventName": "UNC_P_POWER_STATE_OCCUPANCY.CORES_C0",
14 "Filter": "occ_sel=1", 14 "Filter": "occ_sel=1",
15 "MetricExpr": "(UNC_P_POWER_STATE_OCCUPANCY.CORES_C0 / UNC_P_CLOCKTICKS) * 100.", 15 "MetricExpr": "(UNC_P_POWER_STATE_OCCUPANCY.CORES_C0 / UNC_P_CLOCKTICKS) * 100.",
16 "MetricName": "power_state_occupancy.cores_c0 %",
16 "PerPkg": "1", 17 "PerPkg": "1",
17 "Unit": "PCU" 18 "Unit": "PCU"
18 }, 19 },
19 { 20 {
20 "BriefDescription": "C3. Derived from unc_p_power_state_occupancy.cores_c3", 21 "BriefDescription": "This is an occupancy event that tracks the number of cores that are in C3. It can be used by itself to get the average number of cores in C0, with threshholding to generate histograms, or with other PCU events and occupancy triggering to capture other details",
21 "Counter": "0,1,2,3", 22 "Counter": "0,1,2,3",
22 "EventCode": "0x80", 23 "EventCode": "0x80",
23 "EventName": "UNC_P_POWER_STATE_OCCUPANCY.CORES_C3", 24 "EventName": "UNC_P_POWER_STATE_OCCUPANCY.CORES_C3",
24 "Filter": "occ_sel=2", 25 "Filter": "occ_sel=2",
25 "MetricExpr": "(UNC_P_POWER_STATE_OCCUPANCY.CORES_C3 / UNC_P_CLOCKTICKS) * 100.", 26 "MetricExpr": "(UNC_P_POWER_STATE_OCCUPANCY.CORES_C3 / UNC_P_CLOCKTICKS) * 100.",
27 "MetricName": "power_state_occupancy.cores_c3 %",
26 "PerPkg": "1", 28 "PerPkg": "1",
27 "Unit": "PCU" 29 "Unit": "PCU"
28 }, 30 },
29 { 31 {
30 "BriefDescription": "C6 and C7. Derived from unc_p_power_state_occupancy.cores_c6", 32 "BriefDescription": "This is an occupancy event that tracks the number of cores that are in C6. It can be used by itself to get the average number of cores in C0, with threshholding to generate histograms, or with other PCU events ",
31 "Counter": "0,1,2,3", 33 "Counter": "0,1,2,3",
32 "EventCode": "0x80", 34 "EventCode": "0x80",
33 "EventName": "UNC_P_POWER_STATE_OCCUPANCY.CORES_C6", 35 "EventName": "UNC_P_POWER_STATE_OCCUPANCY.CORES_C6",
34 "Filter": "occ_sel=3", 36 "Filter": "occ_sel=3",
35 "MetricExpr": "(UNC_P_POWER_STATE_OCCUPANCY.CORES_C6 / UNC_P_CLOCKTICKS) * 100.", 37 "MetricExpr": "(UNC_P_POWER_STATE_OCCUPANCY.CORES_C6 / UNC_P_CLOCKTICKS) * 100.",
38 "MetricName": "power_state_occupancy.cores_c6 %",
36 "PerPkg": "1", 39 "PerPkg": "1",
37 "Unit": "PCU" 40 "Unit": "PCU"
38 }, 41 },
39 { 42 {
40 "BriefDescription": "External Prochot. Derived from unc_p_prochot_external_cycles", 43 "BriefDescription": "Counts the number of cycles that we are in external PROCHOT mode. This mode is triggered when a sensor off the die determines that something off-die (like DRAM) is too hot and must throttle to avoid damaging the chip",
41 "Counter": "0,1,2,3", 44 "Counter": "0,1,2,3",
42 "EventCode": "0xA", 45 "EventCode": "0xA",
43 "EventName": "UNC_P_PROCHOT_EXTERNAL_CYCLES", 46 "EventName": "UNC_P_PROCHOT_EXTERNAL_CYCLES",
44 "MetricExpr": "(UNC_P_PROCHOT_EXTERNAL_CYCLES / UNC_P_CLOCKTICKS) * 100.", 47 "MetricExpr": "(UNC_P_PROCHOT_EXTERNAL_CYCLES / UNC_P_CLOCKTICKS) * 100.",
48 "MetricName": "prochot_external_cycles %",
45 "PerPkg": "1", 49 "PerPkg": "1",
46 "Unit": "PCU" 50 "Unit": "PCU"
47 }, 51 },
48 { 52 {
49 "BriefDescription": "Thermal Strongest Upper Limit Cycles. Derived from unc_p_freq_max_limit_thermal_cycles", 53 "BriefDescription": "Counts the number of cycles when temperature is the upper limit on frequency",
50 "Counter": "0,1,2,3", 54 "Counter": "0,1,2,3",
51 "EventCode": "0x4", 55 "EventCode": "0x4",
52 "EventName": "UNC_P_FREQ_MAX_LIMIT_THERMAL_CYCLES", 56 "EventName": "UNC_P_FREQ_MAX_LIMIT_THERMAL_CYCLES",
53 "MetricExpr": "(UNC_P_FREQ_MAX_LIMIT_THERMAL_CYCLES / UNC_P_CLOCKTICKS) * 100.", 57 "MetricExpr": "(UNC_P_FREQ_MAX_LIMIT_THERMAL_CYCLES / UNC_P_CLOCKTICKS) * 100.",
58 "MetricName": "freq_max_limit_thermal_cycles %",
54 "PerPkg": "1", 59 "PerPkg": "1",
55 "Unit": "PCU" 60 "Unit": "PCU"
56 }, 61 },
57 { 62 {
58 "BriefDescription": "OS Strongest Upper Limit Cycles. Derived from unc_p_freq_max_os_cycles", 63 "BriefDescription": "Counts the number of cycles when the OS is the upper limit on frequency",
59 "Counter": "0,1,2,3", 64 "Counter": "0,1,2,3",
60 "EventCode": "0x6", 65 "EventCode": "0x6",
61 "EventName": "UNC_P_FREQ_MAX_OS_CYCLES", 66 "EventName": "UNC_P_FREQ_MAX_OS_CYCLES",
62 "MetricExpr": "(UNC_P_FREQ_MAX_OS_CYCLES / UNC_P_CLOCKTICKS) * 100.", 67 "MetricExpr": "(UNC_P_FREQ_MAX_OS_CYCLES / UNC_P_CLOCKTICKS) * 100.",
68 "MetricName": "freq_max_os_cycles %",
63 "PerPkg": "1", 69 "PerPkg": "1",
64 "Unit": "PCU" 70 "Unit": "PCU"
65 }, 71 },
66 { 72 {
67 "BriefDescription": "Power Strongest Upper Limit Cycles. Derived from unc_p_freq_max_power_cycles", 73 "BriefDescription": "Counts the number of cycles when power is the upper limit on frequency",
68 "Counter": "0,1,2,3", 74 "Counter": "0,1,2,3",
69 "EventCode": "0x5", 75 "EventCode": "0x5",
70 "EventName": "UNC_P_FREQ_MAX_POWER_CYCLES", 76 "EventName": "UNC_P_FREQ_MAX_POWER_CYCLES",
71 "MetricExpr": "(UNC_P_FREQ_MAX_POWER_CYCLES / UNC_P_CLOCKTICKS) * 100.", 77 "MetricExpr": "(UNC_P_FREQ_MAX_POWER_CYCLES / UNC_P_CLOCKTICKS) * 100.",
78 "MetricName": "freq_max_power_cycles %",
72 "PerPkg": "1", 79 "PerPkg": "1",
73 "Unit": "PCU" 80 "Unit": "PCU"
74 }, 81 },
75 { 82 {
76 "BriefDescription": "Cycles spent changing Frequency. Derived from unc_p_freq_trans_cycles", 83 "BriefDescription": "Counts the number of cycles when current is the upper limit on frequency",
77 "Counter": "0,1,2,3", 84 "Counter": "0,1,2,3",
78 "EventCode": "0x74", 85 "EventCode": "0x74",
79 "EventName": "UNC_P_FREQ_TRANS_CYCLES", 86 "EventName": "UNC_P_FREQ_TRANS_CYCLES",
80 "MetricExpr": "(UNC_P_FREQ_TRANS_CYCLES / UNC_P_CLOCKTICKS) * 100.", 87 "MetricExpr": "(UNC_P_FREQ_TRANS_CYCLES / UNC_P_CLOCKTICKS) * 100.",
88 "MetricName": "freq_trans_cycles %",
81 "PerPkg": "1", 89 "PerPkg": "1",
82 "Unit": "PCU" 90 "Unit": "PCU"
83 } 91 }
diff --git a/tools/perf/pmu-events/arch/x86/broadwellx/uncore-cache.json b/tools/perf/pmu-events/arch/x86/broadwellx/uncore-cache.json
index 076459c51d4e..58ed6d33d1f4 100644
--- a/tools/perf/pmu-events/arch/x86/broadwellx/uncore-cache.json
+++ b/tools/perf/pmu-events/arch/x86/broadwellx/uncore-cache.json
@@ -1,13 +1,13 @@
1[ 1[
2 { 2 {
3 "BriefDescription": "Uncore cache clock ticks. Derived from unc_c_clockticks", 3 "BriefDescription": "Uncore cache clock ticks",
4 "Counter": "0,1,2,3", 4 "Counter": "0,1,2,3",
5 "EventName": "UNC_C_CLOCKTICKS", 5 "EventName": "UNC_C_CLOCKTICKS",
6 "PerPkg": "1", 6 "PerPkg": "1",
7 "Unit": "CBO" 7 "Unit": "CBO"
8 }, 8 },
9 { 9 {
10 "BriefDescription": "All LLC Misses (code+ data rd + data wr - including demand and prefetch). Derived from unc_c_llc_lookup.any", 10 "BriefDescription": "All LLC Misses (code+ data rd + data wr - including demand and prefetch)",
11 "Counter": "0,1,2,3", 11 "Counter": "0,1,2,3",
12 "EventCode": "0x34", 12 "EventCode": "0x34",
13 "EventName": "UNC_C_LLC_LOOKUP.ANY", 13 "EventName": "UNC_C_LLC_LOOKUP.ANY",
@@ -18,7 +18,7 @@
18 "Unit": "CBO" 18 "Unit": "CBO"
19 }, 19 },
20 { 20 {
21 "BriefDescription": "M line evictions from LLC (writebacks to memory). Derived from unc_c_llc_victims.m_state", 21 "BriefDescription": "M line evictions from LLC (writebacks to memory)",
22 "Counter": "0,1,2,3", 22 "Counter": "0,1,2,3",
23 "EventCode": "0x37", 23 "EventCode": "0x37",
24 "EventName": "UNC_C_LLC_VICTIMS.M_STATE", 24 "EventName": "UNC_C_LLC_VICTIMS.M_STATE",
@@ -212,7 +212,7 @@
212 "Unit": "CBO" 212 "Unit": "CBO"
213 }, 213 },
214 { 214 {
215 "BriefDescription": "read requests to home agent. Derived from unc_h_requests.reads", 215 "BriefDescription": "read requests to home agent",
216 "Counter": "0,1,2,3", 216 "Counter": "0,1,2,3",
217 "EventCode": "0x1", 217 "EventCode": "0x1",
218 "EventName": "UNC_H_REQUESTS.READS", 218 "EventName": "UNC_H_REQUESTS.READS",
@@ -221,7 +221,7 @@
221 "Unit": "HA" 221 "Unit": "HA"
222 }, 222 },
223 { 223 {
224 "BriefDescription": "read requests to local home agent. Derived from unc_h_requests.reads_local", 224 "BriefDescription": "read requests to local home agent",
225 "Counter": "0,1,2,3", 225 "Counter": "0,1,2,3",
226 "EventCode": "0x1", 226 "EventCode": "0x1",
227 "EventName": "UNC_H_REQUESTS.READS_LOCAL", 227 "EventName": "UNC_H_REQUESTS.READS_LOCAL",
@@ -230,7 +230,7 @@
230 "Unit": "HA" 230 "Unit": "HA"
231 }, 231 },
232 { 232 {
233 "BriefDescription": "read requests to remote home agent. Derived from unc_h_requests.reads_remote", 233 "BriefDescription": "read requests to remote home agent",
234 "Counter": "0,1,2,3", 234 "Counter": "0,1,2,3",
235 "EventCode": "0x1", 235 "EventCode": "0x1",
236 "EventName": "UNC_H_REQUESTS.READS_REMOTE", 236 "EventName": "UNC_H_REQUESTS.READS_REMOTE",
@@ -239,7 +239,7 @@
239 "Unit": "HA" 239 "Unit": "HA"
240 }, 240 },
241 { 241 {
242 "BriefDescription": "write requests to home agent. Derived from unc_h_requests.writes", 242 "BriefDescription": "write requests to home agent",
243 "Counter": "0,1,2,3", 243 "Counter": "0,1,2,3",
244 "EventCode": "0x1", 244 "EventCode": "0x1",
245 "EventName": "UNC_H_REQUESTS.WRITES", 245 "EventName": "UNC_H_REQUESTS.WRITES",
@@ -248,7 +248,7 @@
248 "Unit": "HA" 248 "Unit": "HA"
249 }, 249 },
250 { 250 {
251 "BriefDescription": "write requests to local home agent. Derived from unc_h_requests.writes_local", 251 "BriefDescription": "write requests to local home agent",
252 "Counter": "0,1,2,3", 252 "Counter": "0,1,2,3",
253 "EventCode": "0x1", 253 "EventCode": "0x1",
254 "EventName": "UNC_H_REQUESTS.WRITES_LOCAL", 254 "EventName": "UNC_H_REQUESTS.WRITES_LOCAL",
@@ -257,7 +257,7 @@
257 "Unit": "HA" 257 "Unit": "HA"
258 }, 258 },
259 { 259 {
260 "BriefDescription": "write requests to remote home agent. Derived from unc_h_requests.writes_remote", 260 "BriefDescription": "write requests to remote home agent",
261 "Counter": "0,1,2,3", 261 "Counter": "0,1,2,3",
262 "EventCode": "0x1", 262 "EventCode": "0x1",
263 "EventName": "UNC_H_REQUESTS.WRITES_REMOTE", 263 "EventName": "UNC_H_REQUESTS.WRITES_REMOTE",
@@ -266,7 +266,7 @@
266 "Unit": "HA" 266 "Unit": "HA"
267 }, 267 },
268 { 268 {
269 "BriefDescription": "Conflict requests (requests for same address from multiple agents simultaneously). Derived from unc_h_snoop_resp.rspcnflct", 269 "BriefDescription": "Conflict requests (requests for same address from multiple agents simultaneously)",
270 "Counter": "0,1,2,3", 270 "Counter": "0,1,2,3",
271 "EventCode": "0x21", 271 "EventCode": "0x21",
272 "EventName": "UNC_H_SNOOP_RESP.RSPCNFLCT", 272 "EventName": "UNC_H_SNOOP_RESP.RSPCNFLCT",
@@ -275,7 +275,7 @@
275 "Unit": "HA" 275 "Unit": "HA"
276 }, 276 },
277 { 277 {
278 "BriefDescription": "M line forwarded from remote cache along with writeback to memory. Derived from unc_h_snoop_resp.rsp_fwd_wb", 278 "BriefDescription": "M line forwarded from remote cache along with writeback to memory",
279 "Counter": "0,1,2,3", 279 "Counter": "0,1,2,3",
280 "EventCode": "0x21", 280 "EventCode": "0x21",
281 "EventName": "UNC_H_SNOOP_RESP.RSP_FWD_WB", 281 "EventName": "UNC_H_SNOOP_RESP.RSP_FWD_WB",
@@ -285,7 +285,7 @@
285 "Unit": "HA" 285 "Unit": "HA"
286 }, 286 },
287 { 287 {
288 "BriefDescription": "M line forwarded from remote cache with no writeback to memory. Derived from unc_h_snoop_resp.rspifwd", 288 "BriefDescription": "M line forwarded from remote cache with no writeback to memory",
289 "Counter": "0,1,2,3", 289 "Counter": "0,1,2,3",
290 "EventCode": "0x21", 290 "EventCode": "0x21",
291 "EventName": "UNC_H_SNOOP_RESP.RSPIFWD", 291 "EventName": "UNC_H_SNOOP_RESP.RSPIFWD",
@@ -295,7 +295,7 @@
295 "Unit": "HA" 295 "Unit": "HA"
296 }, 296 },
297 { 297 {
298 "BriefDescription": "Shared line response from remote cache. Derived from unc_h_snoop_resp.rsps", 298 "BriefDescription": "Shared line response from remote cache",
299 "Counter": "0,1,2,3", 299 "Counter": "0,1,2,3",
300 "EventCode": "0x21", 300 "EventCode": "0x21",
301 "EventName": "UNC_H_SNOOP_RESP.RSPS", 301 "EventName": "UNC_H_SNOOP_RESP.RSPS",
@@ -305,7 +305,7 @@
305 "Unit": "HA" 305 "Unit": "HA"
306 }, 306 },
307 { 307 {
308 "BriefDescription": "Shared line forwarded from remote cache. Derived from unc_h_snoop_resp.rspsfwd", 308 "BriefDescription": "Shared line forwarded from remote cache",
309 "Counter": "0,1,2,3", 309 "Counter": "0,1,2,3",
310 "EventCode": "0x21", 310 "EventCode": "0x21",
311 "EventName": "UNC_H_SNOOP_RESP.RSPSFWD", 311 "EventName": "UNC_H_SNOOP_RESP.RSPSFWD",
diff --git a/tools/perf/pmu-events/arch/x86/broadwellx/uncore-interconnect.json b/tools/perf/pmu-events/arch/x86/broadwellx/uncore-interconnect.json
index 39387f7909b2..824961318c1e 100644
--- a/tools/perf/pmu-events/arch/x86/broadwellx/uncore-interconnect.json
+++ b/tools/perf/pmu-events/arch/x86/broadwellx/uncore-interconnect.json
@@ -1,6 +1,6 @@
1[ 1[
2 { 2 {
3 "BriefDescription": "QPI clock ticks. Derived from unc_q_clockticks", 3 "BriefDescription": "QPI clock ticks",
4 "Counter": "0,1,2,3", 4 "Counter": "0,1,2,3",
5 "EventCode": "0x14", 5 "EventCode": "0x14",
6 "EventName": "UNC_Q_CLOCKTICKS", 6 "EventName": "UNC_Q_CLOCKTICKS",
@@ -10,7 +10,7 @@
10 { 10 {
11 "BriefDescription": "Number of data flits transmitted . Derived from unc_q_txl_flits_g0.data", 11 "BriefDescription": "Number of data flits transmitted . Derived from unc_q_txl_flits_g0.data",
12 "Counter": "0,1,2,3", 12 "Counter": "0,1,2,3",
13 "EventName": "UNC_Q_TxL_FLITS_G0.DATA", 13 "EventName": "QPI_DATA_BANDWIDTH_TX",
14 "PerPkg": "1", 14 "PerPkg": "1",
15 "ScaleUnit": "8Bytes", 15 "ScaleUnit": "8Bytes",
16 "UMask": "0x2", 16 "UMask": "0x2",
@@ -19,7 +19,7 @@
19 { 19 {
20 "BriefDescription": "Number of non data (control) flits transmitted . Derived from unc_q_txl_flits_g0.non_data", 20 "BriefDescription": "Number of non data (control) flits transmitted . Derived from unc_q_txl_flits_g0.non_data",
21 "Counter": "0,1,2,3", 21 "Counter": "0,1,2,3",
22 "EventName": "UNC_Q_TxL_FLITS_G0.NON_DATA", 22 "EventName": "QPI_CTL_BANDWIDTH_TX",
23 "PerPkg": "1", 23 "PerPkg": "1",
24 "ScaleUnit": "8Bytes", 24 "ScaleUnit": "8Bytes",
25 "UMask": "0x4", 25 "UMask": "0x4",
diff --git a/tools/perf/pmu-events/arch/x86/broadwellx/uncore-memory.json b/tools/perf/pmu-events/arch/x86/broadwellx/uncore-memory.json
index d17dc235f734..66eed399724c 100644
--- a/tools/perf/pmu-events/arch/x86/broadwellx/uncore-memory.json
+++ b/tools/perf/pmu-events/arch/x86/broadwellx/uncore-memory.json
@@ -3,7 +3,7 @@
3 "BriefDescription": "read requests to memory controller. Derived from unc_m_cas_count.rd", 3 "BriefDescription": "read requests to memory controller. Derived from unc_m_cas_count.rd",
4 "Counter": "0,1,2,3", 4 "Counter": "0,1,2,3",
5 "EventCode": "0x4", 5 "EventCode": "0x4",
6 "EventName": "UNC_M_CAS_COUNT.RD", 6 "EventName": "LLC_MISSES.MEM_READ",
7 "PerPkg": "1", 7 "PerPkg": "1",
8 "ScaleUnit": "64Bytes", 8 "ScaleUnit": "64Bytes",
9 "UMask": "0x3", 9 "UMask": "0x3",
@@ -13,48 +13,51 @@
13 "BriefDescription": "write requests to memory controller. Derived from unc_m_cas_count.wr", 13 "BriefDescription": "write requests to memory controller. Derived from unc_m_cas_count.wr",
14 "Counter": "0,1,2,3", 14 "Counter": "0,1,2,3",
15 "EventCode": "0x4", 15 "EventCode": "0x4",
16 "EventName": "UNC_M_CAS_COUNT.WR", 16 "EventName": "LLC_MISSES.MEM_WRITE",
17 "PerPkg": "1", 17 "PerPkg": "1",
18 "ScaleUnit": "64Bytes", 18 "ScaleUnit": "64Bytes",
19 "UMask": "0xC", 19 "UMask": "0xC",
20 "Unit": "iMC" 20 "Unit": "iMC"
21 }, 21 },
22 { 22 {
23 "BriefDescription": "Memory controller clock ticks. Derived from unc_m_clockticks", 23 "BriefDescription": "Memory controller clock ticks",
24 "Counter": "0,1,2,3", 24 "Counter": "0,1,2,3",
25 "EventName": "UNC_M_CLOCKTICKS", 25 "EventName": "UNC_M_CLOCKTICKS",
26 "PerPkg": "1", 26 "PerPkg": "1",
27 "Unit": "iMC" 27 "Unit": "iMC"
28 }, 28 },
29 { 29 {
30 "BriefDescription": "Cycles where DRAM ranks are in power down (CKE) mode. Derived from unc_m_power_channel_ppd", 30 "BriefDescription": "Cycles where DRAM ranks are in power down (CKE) mode",
31 "Counter": "0,1,2,3", 31 "Counter": "0,1,2,3",
32 "EventCode": "0x85", 32 "EventCode": "0x85",
33 "EventName": "UNC_M_POWER_CHANNEL_PPD", 33 "EventName": "UNC_M_POWER_CHANNEL_PPD",
34 "MetricExpr": "(UNC_M_POWER_CHANNEL_PPD / UNC_M_CLOCKTICKS) * 100.", 34 "MetricExpr": "(UNC_M_POWER_CHANNEL_PPD / UNC_M_CLOCKTICKS) * 100.",
35 "MetricName": "power_channel_ppd %",
35 "PerPkg": "1", 36 "PerPkg": "1",
36 "Unit": "iMC" 37 "Unit": "iMC"
37 }, 38 },
38 { 39 {
39 "BriefDescription": "Cycles all ranks are in critical thermal throttle. Derived from unc_m_power_critical_throttle_cycles", 40 "BriefDescription": "Cycles all ranks are in critical thermal throttle",
40 "Counter": "0,1,2,3", 41 "Counter": "0,1,2,3",
41 "EventCode": "0x86", 42 "EventCode": "0x86",
42 "EventName": "UNC_M_POWER_CRITICAL_THROTTLE_CYCLES", 43 "EventName": "UNC_M_POWER_CRITICAL_THROTTLE_CYCLES",
43 "MetricExpr": "(UNC_M_POWER_CRITICAL_THROTTLE_CYCLES / UNC_M_CLOCKTICKS) * 100.", 44 "MetricExpr": "(UNC_M_POWER_CRITICAL_THROTTLE_CYCLES / UNC_M_CLOCKTICKS) * 100.",
45 "MetricName": "power_critical_throttle_cycles %",
44 "PerPkg": "1", 46 "PerPkg": "1",
45 "Unit": "iMC" 47 "Unit": "iMC"
46 }, 48 },
47 { 49 {
48 "BriefDescription": "Cycles Memory is in self refresh power mode. Derived from unc_m_power_self_refresh", 50 "BriefDescription": "Cycles Memory is in self refresh power mode",
49 "Counter": "0,1,2,3", 51 "Counter": "0,1,2,3",
50 "EventCode": "0x43", 52 "EventCode": "0x43",
51 "EventName": "UNC_M_POWER_SELF_REFRESH", 53 "EventName": "UNC_M_POWER_SELF_REFRESH",
52 "MetricExpr": "(UNC_M_POWER_SELF_REFRESH / UNC_M_CLOCKTICKS) * 100.", 54 "MetricExpr": "(UNC_M_POWER_SELF_REFRESH / UNC_M_CLOCKTICKS) * 100.",
55 "MetricName": "power_self_refresh %",
53 "PerPkg": "1", 56 "PerPkg": "1",
54 "Unit": "iMC" 57 "Unit": "iMC"
55 }, 58 },
56 { 59 {
57 "BriefDescription": "Pre-charges due to page misses. Derived from unc_m_pre_count.page_miss", 60 "BriefDescription": "Pre-charges due to page misses",
58 "Counter": "0,1,2,3", 61 "Counter": "0,1,2,3",
59 "EventCode": "0x2", 62 "EventCode": "0x2",
60 "EventName": "UNC_M_PRE_COUNT.PAGE_MISS", 63 "EventName": "UNC_M_PRE_COUNT.PAGE_MISS",
@@ -63,7 +66,7 @@
63 "Unit": "iMC" 66 "Unit": "iMC"
64 }, 67 },
65 { 68 {
66 "BriefDescription": "Pre-charge for reads. Derived from unc_m_pre_count.rd", 69 "BriefDescription": "Pre-charge for reads",
67 "Counter": "0,1,2,3", 70 "Counter": "0,1,2,3",
68 "EventCode": "0x2", 71 "EventCode": "0x2",
69 "EventName": "UNC_M_PRE_COUNT.RD", 72 "EventName": "UNC_M_PRE_COUNT.RD",
@@ -72,7 +75,7 @@
72 "Unit": "iMC" 75 "Unit": "iMC"
73 }, 76 },
74 { 77 {
75 "BriefDescription": "Pre-charge for writes. Derived from unc_m_pre_count.wr", 78 "BriefDescription": "Pre-charge for writes",
76 "Counter": "0,1,2,3", 79 "Counter": "0,1,2,3",
77 "EventCode": "0x2", 80 "EventCode": "0x2",
78 "EventName": "UNC_M_PRE_COUNT.WR", 81 "EventName": "UNC_M_PRE_COUNT.WR",
diff --git a/tools/perf/pmu-events/arch/x86/broadwellx/uncore-power.json b/tools/perf/pmu-events/arch/x86/broadwellx/uncore-power.json
index b44d43088bbb..dd1b95655d1d 100644
--- a/tools/perf/pmu-events/arch/x86/broadwellx/uncore-power.json
+++ b/tools/perf/pmu-events/arch/x86/broadwellx/uncore-power.json
@@ -1,83 +1,91 @@
1[ 1[
2 { 2 {
3 "BriefDescription": "PCU clock ticks. Use to get percentages of PCU cycles events. Derived from unc_p_clockticks", 3 "BriefDescription": "PCU clock ticks. Use to get percentages of PCU cycles events",
4 "Counter": "0,1,2,3", 4 "Counter": "0,1,2,3",
5 "EventName": "UNC_P_CLOCKTICKS", 5 "EventName": "UNC_P_CLOCKTICKS",
6 "PerPkg": "1", 6 "PerPkg": "1",
7 "Unit": "PCU" 7 "Unit": "PCU"
8 }, 8 },
9 { 9 {
10 "BriefDescription": "C0 and C1. Derived from unc_p_power_state_occupancy.cores_c0", 10 "BriefDescription": "This is an occupancy event that tracks the number of cores that are in C0. It can be used by itself to get the average number of cores in C0, with threshholding to generate histograms, or with other PCU events and occupancy triggering to capture other details",
11 "Counter": "0,1,2,3", 11 "Counter": "0,1,2,3",
12 "EventCode": "0x80", 12 "EventCode": "0x80",
13 "EventName": "UNC_P_POWER_STATE_OCCUPANCY.CORES_C0", 13 "EventName": "UNC_P_POWER_STATE_OCCUPANCY.CORES_C0",
14 "Filter": "occ_sel=1", 14 "Filter": "occ_sel=1",
15 "MetricExpr": "(UNC_P_POWER_STATE_OCCUPANCY.CORES_C0 / UNC_P_CLOCKTICKS) * 100.", 15 "MetricExpr": "(UNC_P_POWER_STATE_OCCUPANCY.CORES_C0 / UNC_P_CLOCKTICKS) * 100.",
16 "MetricName": "power_state_occupancy.cores_c0 %",
16 "PerPkg": "1", 17 "PerPkg": "1",
17 "Unit": "PCU" 18 "Unit": "PCU"
18 }, 19 },
19 { 20 {
20 "BriefDescription": "C3. Derived from unc_p_power_state_occupancy.cores_c3", 21 "BriefDescription": "This is an occupancy event that tracks the number of cores that are in C3. It can be used by itself to get the average number of cores in C0, with threshholding to generate histograms, or with other PCU events and occupancy triggering to capture other details",
21 "Counter": "0,1,2,3", 22 "Counter": "0,1,2,3",
22 "EventCode": "0x80", 23 "EventCode": "0x80",
23 "EventName": "UNC_P_POWER_STATE_OCCUPANCY.CORES_C3", 24 "EventName": "UNC_P_POWER_STATE_OCCUPANCY.CORES_C3",
24 "Filter": "occ_sel=2", 25 "Filter": "occ_sel=2",
25 "MetricExpr": "(UNC_P_POWER_STATE_OCCUPANCY.CORES_C3 / UNC_P_CLOCKTICKS) * 100.", 26 "MetricExpr": "(UNC_P_POWER_STATE_OCCUPANCY.CORES_C3 / UNC_P_CLOCKTICKS) * 100.",
27 "MetricName": "power_state_occupancy.cores_c3 %",
26 "PerPkg": "1", 28 "PerPkg": "1",
27 "Unit": "PCU" 29 "Unit": "PCU"
28 }, 30 },
29 { 31 {
30 "BriefDescription": "C6 and C7. Derived from unc_p_power_state_occupancy.cores_c6", 32 "BriefDescription": "This is an occupancy event that tracks the number of cores that are in C6. It can be used by itself to get the average number of cores in C0, with threshholding to generate histograms, or with other PCU events ",
31 "Counter": "0,1,2,3", 33 "Counter": "0,1,2,3",
32 "EventCode": "0x80", 34 "EventCode": "0x80",
33 "EventName": "UNC_P_POWER_STATE_OCCUPANCY.CORES_C6", 35 "EventName": "UNC_P_POWER_STATE_OCCUPANCY.CORES_C6",
34 "Filter": "occ_sel=3", 36 "Filter": "occ_sel=3",
35 "MetricExpr": "(UNC_P_POWER_STATE_OCCUPANCY.CORES_C6 / UNC_P_CLOCKTICKS) * 100.", 37 "MetricExpr": "(UNC_P_POWER_STATE_OCCUPANCY.CORES_C6 / UNC_P_CLOCKTICKS) * 100.",
38 "MetricName": "power_state_occupancy.cores_c6 %",
36 "PerPkg": "1", 39 "PerPkg": "1",
37 "Unit": "PCU" 40 "Unit": "PCU"
38 }, 41 },
39 { 42 {
40 "BriefDescription": "External Prochot. Derived from unc_p_prochot_external_cycles", 43 "BriefDescription": "Counts the number of cycles that we are in external PROCHOT mode. This mode is triggered when a sensor off the die determines that something off-die (like DRAM) is too hot and must throttle to avoid damaging the chip",
41 "Counter": "0,1,2,3", 44 "Counter": "0,1,2,3",
42 "EventCode": "0xA", 45 "EventCode": "0xA",
43 "EventName": "UNC_P_PROCHOT_EXTERNAL_CYCLES", 46 "EventName": "UNC_P_PROCHOT_EXTERNAL_CYCLES",
44 "MetricExpr": "(UNC_P_PROCHOT_EXTERNAL_CYCLES / UNC_P_CLOCKTICKS) * 100.", 47 "MetricExpr": "(UNC_P_PROCHOT_EXTERNAL_CYCLES / UNC_P_CLOCKTICKS) * 100.",
48 "MetricName": "prochot_external_cycles %",
45 "PerPkg": "1", 49 "PerPkg": "1",
46 "Unit": "PCU" 50 "Unit": "PCU"
47 }, 51 },
48 { 52 {
49 "BriefDescription": "Thermal Strongest Upper Limit Cycles. Derived from unc_p_freq_max_limit_thermal_cycles", 53 "BriefDescription": "Counts the number of cycles when temperature is the upper limit on frequency",
50 "Counter": "0,1,2,3", 54 "Counter": "0,1,2,3",
51 "EventCode": "0x4", 55 "EventCode": "0x4",
52 "EventName": "UNC_P_FREQ_MAX_LIMIT_THERMAL_CYCLES", 56 "EventName": "UNC_P_FREQ_MAX_LIMIT_THERMAL_CYCLES",
53 "MetricExpr": "(UNC_P_FREQ_MAX_LIMIT_THERMAL_CYCLES / UNC_P_CLOCKTICKS) * 100.", 57 "MetricExpr": "(UNC_P_FREQ_MAX_LIMIT_THERMAL_CYCLES / UNC_P_CLOCKTICKS) * 100.",
58 "MetricName": "freq_max_limit_thermal_cycles %",
54 "PerPkg": "1", 59 "PerPkg": "1",
55 "Unit": "PCU" 60 "Unit": "PCU"
56 }, 61 },
57 { 62 {
58 "BriefDescription": "OS Strongest Upper Limit Cycles. Derived from unc_p_freq_max_os_cycles", 63 "BriefDescription": "Counts the number of cycles when the OS is the upper limit on frequency",
59 "Counter": "0,1,2,3", 64 "Counter": "0,1,2,3",
60 "EventCode": "0x6", 65 "EventCode": "0x6",
61 "EventName": "UNC_P_FREQ_MAX_OS_CYCLES", 66 "EventName": "UNC_P_FREQ_MAX_OS_CYCLES",
62 "MetricExpr": "(UNC_P_FREQ_MAX_OS_CYCLES / UNC_P_CLOCKTICKS) * 100.", 67 "MetricExpr": "(UNC_P_FREQ_MAX_OS_CYCLES / UNC_P_CLOCKTICKS) * 100.",
68 "MetricName": "freq_max_os_cycles %",
63 "PerPkg": "1", 69 "PerPkg": "1",
64 "Unit": "PCU" 70 "Unit": "PCU"
65 }, 71 },
66 { 72 {
67 "BriefDescription": "Power Strongest Upper Limit Cycles. Derived from unc_p_freq_max_power_cycles", 73 "BriefDescription": "Counts the number of cycles when power is the upper limit on frequency",
68 "Counter": "0,1,2,3", 74 "Counter": "0,1,2,3",
69 "EventCode": "0x5", 75 "EventCode": "0x5",
70 "EventName": "UNC_P_FREQ_MAX_POWER_CYCLES", 76 "EventName": "UNC_P_FREQ_MAX_POWER_CYCLES",
71 "MetricExpr": "(UNC_P_FREQ_MAX_POWER_CYCLES / UNC_P_CLOCKTICKS) * 100.", 77 "MetricExpr": "(UNC_P_FREQ_MAX_POWER_CYCLES / UNC_P_CLOCKTICKS) * 100.",
78 "MetricName": "freq_max_power_cycles %",
72 "PerPkg": "1", 79 "PerPkg": "1",
73 "Unit": "PCU" 80 "Unit": "PCU"
74 }, 81 },
75 { 82 {
76 "BriefDescription": "Cycles spent changing Frequency. Derived from unc_p_freq_trans_cycles", 83 "BriefDescription": "Counts the number of cycles when current is the upper limit on frequency",
77 "Counter": "0,1,2,3", 84 "Counter": "0,1,2,3",
78 "EventCode": "0x74", 85 "EventCode": "0x74",
79 "EventName": "UNC_P_FREQ_TRANS_CYCLES", 86 "EventName": "UNC_P_FREQ_TRANS_CYCLES",
80 "MetricExpr": "(UNC_P_FREQ_TRANS_CYCLES / UNC_P_CLOCKTICKS) * 100.", 87 "MetricExpr": "(UNC_P_FREQ_TRANS_CYCLES / UNC_P_CLOCKTICKS) * 100.",
88 "MetricName": "freq_trans_cycles %",
81 "PerPkg": "1", 89 "PerPkg": "1",
82 "Unit": "PCU" 90 "Unit": "PCU"
83 } 91 }
diff --git a/tools/perf/pmu-events/arch/x86/haswellx/uncore-cache.json b/tools/perf/pmu-events/arch/x86/haswellx/uncore-cache.json
index 076459c51d4e..58ed6d33d1f4 100644
--- a/tools/perf/pmu-events/arch/x86/haswellx/uncore-cache.json
+++ b/tools/perf/pmu-events/arch/x86/haswellx/uncore-cache.json
@@ -1,13 +1,13 @@
1[ 1[
2 { 2 {
3 "BriefDescription": "Uncore cache clock ticks. Derived from unc_c_clockticks", 3 "BriefDescription": "Uncore cache clock ticks",
4 "Counter": "0,1,2,3", 4 "Counter": "0,1,2,3",
5 "EventName": "UNC_C_CLOCKTICKS", 5 "EventName": "UNC_C_CLOCKTICKS",
6 "PerPkg": "1", 6 "PerPkg": "1",
7 "Unit": "CBO" 7 "Unit": "CBO"
8 }, 8 },
9 { 9 {
10 "BriefDescription": "All LLC Misses (code+ data rd + data wr - including demand and prefetch). Derived from unc_c_llc_lookup.any", 10 "BriefDescription": "All LLC Misses (code+ data rd + data wr - including demand and prefetch)",
11 "Counter": "0,1,2,3", 11 "Counter": "0,1,2,3",
12 "EventCode": "0x34", 12 "EventCode": "0x34",
13 "EventName": "UNC_C_LLC_LOOKUP.ANY", 13 "EventName": "UNC_C_LLC_LOOKUP.ANY",
@@ -18,7 +18,7 @@
18 "Unit": "CBO" 18 "Unit": "CBO"
19 }, 19 },
20 { 20 {
21 "BriefDescription": "M line evictions from LLC (writebacks to memory). Derived from unc_c_llc_victims.m_state", 21 "BriefDescription": "M line evictions from LLC (writebacks to memory)",
22 "Counter": "0,1,2,3", 22 "Counter": "0,1,2,3",
23 "EventCode": "0x37", 23 "EventCode": "0x37",
24 "EventName": "UNC_C_LLC_VICTIMS.M_STATE", 24 "EventName": "UNC_C_LLC_VICTIMS.M_STATE",
@@ -212,7 +212,7 @@
212 "Unit": "CBO" 212 "Unit": "CBO"
213 }, 213 },
214 { 214 {
215 "BriefDescription": "read requests to home agent. Derived from unc_h_requests.reads", 215 "BriefDescription": "read requests to home agent",
216 "Counter": "0,1,2,3", 216 "Counter": "0,1,2,3",
217 "EventCode": "0x1", 217 "EventCode": "0x1",
218 "EventName": "UNC_H_REQUESTS.READS", 218 "EventName": "UNC_H_REQUESTS.READS",
@@ -221,7 +221,7 @@
221 "Unit": "HA" 221 "Unit": "HA"
222 }, 222 },
223 { 223 {
224 "BriefDescription": "read requests to local home agent. Derived from unc_h_requests.reads_local", 224 "BriefDescription": "read requests to local home agent",
225 "Counter": "0,1,2,3", 225 "Counter": "0,1,2,3",
226 "EventCode": "0x1", 226 "EventCode": "0x1",
227 "EventName": "UNC_H_REQUESTS.READS_LOCAL", 227 "EventName": "UNC_H_REQUESTS.READS_LOCAL",
@@ -230,7 +230,7 @@
230 "Unit": "HA" 230 "Unit": "HA"
231 }, 231 },
232 { 232 {
233 "BriefDescription": "read requests to remote home agent. Derived from unc_h_requests.reads_remote", 233 "BriefDescription": "read requests to remote home agent",
234 "Counter": "0,1,2,3", 234 "Counter": "0,1,2,3",
235 "EventCode": "0x1", 235 "EventCode": "0x1",
236 "EventName": "UNC_H_REQUESTS.READS_REMOTE", 236 "EventName": "UNC_H_REQUESTS.READS_REMOTE",
@@ -239,7 +239,7 @@
239 "Unit": "HA" 239 "Unit": "HA"
240 }, 240 },
241 { 241 {
242 "BriefDescription": "write requests to home agent. Derived from unc_h_requests.writes", 242 "BriefDescription": "write requests to home agent",
243 "Counter": "0,1,2,3", 243 "Counter": "0,1,2,3",
244 "EventCode": "0x1", 244 "EventCode": "0x1",
245 "EventName": "UNC_H_REQUESTS.WRITES", 245 "EventName": "UNC_H_REQUESTS.WRITES",
@@ -248,7 +248,7 @@
248 "Unit": "HA" 248 "Unit": "HA"
249 }, 249 },
250 { 250 {
251 "BriefDescription": "write requests to local home agent. Derived from unc_h_requests.writes_local", 251 "BriefDescription": "write requests to local home agent",
252 "Counter": "0,1,2,3", 252 "Counter": "0,1,2,3",
253 "EventCode": "0x1", 253 "EventCode": "0x1",
254 "EventName": "UNC_H_REQUESTS.WRITES_LOCAL", 254 "EventName": "UNC_H_REQUESTS.WRITES_LOCAL",
@@ -257,7 +257,7 @@
257 "Unit": "HA" 257 "Unit": "HA"
258 }, 258 },
259 { 259 {
260 "BriefDescription": "write requests to remote home agent. Derived from unc_h_requests.writes_remote", 260 "BriefDescription": "write requests to remote home agent",
261 "Counter": "0,1,2,3", 261 "Counter": "0,1,2,3",
262 "EventCode": "0x1", 262 "EventCode": "0x1",
263 "EventName": "UNC_H_REQUESTS.WRITES_REMOTE", 263 "EventName": "UNC_H_REQUESTS.WRITES_REMOTE",
@@ -266,7 +266,7 @@
266 "Unit": "HA" 266 "Unit": "HA"
267 }, 267 },
268 { 268 {
269 "BriefDescription": "Conflict requests (requests for same address from multiple agents simultaneously). Derived from unc_h_snoop_resp.rspcnflct", 269 "BriefDescription": "Conflict requests (requests for same address from multiple agents simultaneously)",
270 "Counter": "0,1,2,3", 270 "Counter": "0,1,2,3",
271 "EventCode": "0x21", 271 "EventCode": "0x21",
272 "EventName": "UNC_H_SNOOP_RESP.RSPCNFLCT", 272 "EventName": "UNC_H_SNOOP_RESP.RSPCNFLCT",
@@ -275,7 +275,7 @@
275 "Unit": "HA" 275 "Unit": "HA"
276 }, 276 },
277 { 277 {
278 "BriefDescription": "M line forwarded from remote cache along with writeback to memory. Derived from unc_h_snoop_resp.rsp_fwd_wb", 278 "BriefDescription": "M line forwarded from remote cache along with writeback to memory",
279 "Counter": "0,1,2,3", 279 "Counter": "0,1,2,3",
280 "EventCode": "0x21", 280 "EventCode": "0x21",
281 "EventName": "UNC_H_SNOOP_RESP.RSP_FWD_WB", 281 "EventName": "UNC_H_SNOOP_RESP.RSP_FWD_WB",
@@ -285,7 +285,7 @@
285 "Unit": "HA" 285 "Unit": "HA"
286 }, 286 },
287 { 287 {
288 "BriefDescription": "M line forwarded from remote cache with no writeback to memory. Derived from unc_h_snoop_resp.rspifwd", 288 "BriefDescription": "M line forwarded from remote cache with no writeback to memory",
289 "Counter": "0,1,2,3", 289 "Counter": "0,1,2,3",
290 "EventCode": "0x21", 290 "EventCode": "0x21",
291 "EventName": "UNC_H_SNOOP_RESP.RSPIFWD", 291 "EventName": "UNC_H_SNOOP_RESP.RSPIFWD",
@@ -295,7 +295,7 @@
295 "Unit": "HA" 295 "Unit": "HA"
296 }, 296 },
297 { 297 {
298 "BriefDescription": "Shared line response from remote cache. Derived from unc_h_snoop_resp.rsps", 298 "BriefDescription": "Shared line response from remote cache",
299 "Counter": "0,1,2,3", 299 "Counter": "0,1,2,3",
300 "EventCode": "0x21", 300 "EventCode": "0x21",
301 "EventName": "UNC_H_SNOOP_RESP.RSPS", 301 "EventName": "UNC_H_SNOOP_RESP.RSPS",
@@ -305,7 +305,7 @@
305 "Unit": "HA" 305 "Unit": "HA"
306 }, 306 },
307 { 307 {
308 "BriefDescription": "Shared line forwarded from remote cache. Derived from unc_h_snoop_resp.rspsfwd", 308 "BriefDescription": "Shared line forwarded from remote cache",
309 "Counter": "0,1,2,3", 309 "Counter": "0,1,2,3",
310 "EventCode": "0x21", 310 "EventCode": "0x21",
311 "EventName": "UNC_H_SNOOP_RESP.RSPSFWD", 311 "EventName": "UNC_H_SNOOP_RESP.RSPSFWD",
diff --git a/tools/perf/pmu-events/arch/x86/haswellx/uncore-interconnect.json b/tools/perf/pmu-events/arch/x86/haswellx/uncore-interconnect.json
index 39387f7909b2..824961318c1e 100644
--- a/tools/perf/pmu-events/arch/x86/haswellx/uncore-interconnect.json
+++ b/tools/perf/pmu-events/arch/x86/haswellx/uncore-interconnect.json
@@ -1,6 +1,6 @@
1[ 1[
2 { 2 {
3 "BriefDescription": "QPI clock ticks. Derived from unc_q_clockticks", 3 "BriefDescription": "QPI clock ticks",
4 "Counter": "0,1,2,3", 4 "Counter": "0,1,2,3",
5 "EventCode": "0x14", 5 "EventCode": "0x14",
6 "EventName": "UNC_Q_CLOCKTICKS", 6 "EventName": "UNC_Q_CLOCKTICKS",
@@ -10,7 +10,7 @@
10 { 10 {
11 "BriefDescription": "Number of data flits transmitted . Derived from unc_q_txl_flits_g0.data", 11 "BriefDescription": "Number of data flits transmitted . Derived from unc_q_txl_flits_g0.data",
12 "Counter": "0,1,2,3", 12 "Counter": "0,1,2,3",
13 "EventName": "UNC_Q_TxL_FLITS_G0.DATA", 13 "EventName": "QPI_DATA_BANDWIDTH_TX",
14 "PerPkg": "1", 14 "PerPkg": "1",
15 "ScaleUnit": "8Bytes", 15 "ScaleUnit": "8Bytes",
16 "UMask": "0x2", 16 "UMask": "0x2",
@@ -19,7 +19,7 @@
19 { 19 {
20 "BriefDescription": "Number of non data (control) flits transmitted . Derived from unc_q_txl_flits_g0.non_data", 20 "BriefDescription": "Number of non data (control) flits transmitted . Derived from unc_q_txl_flits_g0.non_data",
21 "Counter": "0,1,2,3", 21 "Counter": "0,1,2,3",
22 "EventName": "UNC_Q_TxL_FLITS_G0.NON_DATA", 22 "EventName": "QPI_CTL_BANDWIDTH_TX",
23 "PerPkg": "1", 23 "PerPkg": "1",
24 "ScaleUnit": "8Bytes", 24 "ScaleUnit": "8Bytes",
25 "UMask": "0x4", 25 "UMask": "0x4",
diff --git a/tools/perf/pmu-events/arch/x86/haswellx/uncore-memory.json b/tools/perf/pmu-events/arch/x86/haswellx/uncore-memory.json
index d17dc235f734..66eed399724c 100644
--- a/tools/perf/pmu-events/arch/x86/haswellx/uncore-memory.json
+++ b/tools/perf/pmu-events/arch/x86/haswellx/uncore-memory.json
@@ -3,7 +3,7 @@
3 "BriefDescription": "read requests to memory controller. Derived from unc_m_cas_count.rd", 3 "BriefDescription": "read requests to memory controller. Derived from unc_m_cas_count.rd",
4 "Counter": "0,1,2,3", 4 "Counter": "0,1,2,3",
5 "EventCode": "0x4", 5 "EventCode": "0x4",
6 "EventName": "UNC_M_CAS_COUNT.RD", 6 "EventName": "LLC_MISSES.MEM_READ",
7 "PerPkg": "1", 7 "PerPkg": "1",
8 "ScaleUnit": "64Bytes", 8 "ScaleUnit": "64Bytes",
9 "UMask": "0x3", 9 "UMask": "0x3",
@@ -13,48 +13,51 @@
13 "BriefDescription": "write requests to memory controller. Derived from unc_m_cas_count.wr", 13 "BriefDescription": "write requests to memory controller. Derived from unc_m_cas_count.wr",
14 "Counter": "0,1,2,3", 14 "Counter": "0,1,2,3",
15 "EventCode": "0x4", 15 "EventCode": "0x4",
16 "EventName": "UNC_M_CAS_COUNT.WR", 16 "EventName": "LLC_MISSES.MEM_WRITE",
17 "PerPkg": "1", 17 "PerPkg": "1",
18 "ScaleUnit": "64Bytes", 18 "ScaleUnit": "64Bytes",
19 "UMask": "0xC", 19 "UMask": "0xC",
20 "Unit": "iMC" 20 "Unit": "iMC"
21 }, 21 },
22 { 22 {
23 "BriefDescription": "Memory controller clock ticks. Derived from unc_m_clockticks", 23 "BriefDescription": "Memory controller clock ticks",
24 "Counter": "0,1,2,3", 24 "Counter": "0,1,2,3",
25 "EventName": "UNC_M_CLOCKTICKS", 25 "EventName": "UNC_M_CLOCKTICKS",
26 "PerPkg": "1", 26 "PerPkg": "1",
27 "Unit": "iMC" 27 "Unit": "iMC"
28 }, 28 },
29 { 29 {
30 "BriefDescription": "Cycles where DRAM ranks are in power down (CKE) mode. Derived from unc_m_power_channel_ppd", 30 "BriefDescription": "Cycles where DRAM ranks are in power down (CKE) mode",
31 "Counter": "0,1,2,3", 31 "Counter": "0,1,2,3",
32 "EventCode": "0x85", 32 "EventCode": "0x85",
33 "EventName": "UNC_M_POWER_CHANNEL_PPD", 33 "EventName": "UNC_M_POWER_CHANNEL_PPD",
34 "MetricExpr": "(UNC_M_POWER_CHANNEL_PPD / UNC_M_CLOCKTICKS) * 100.", 34 "MetricExpr": "(UNC_M_POWER_CHANNEL_PPD / UNC_M_CLOCKTICKS) * 100.",
35 "MetricName": "power_channel_ppd %",
35 "PerPkg": "1", 36 "PerPkg": "1",
36 "Unit": "iMC" 37 "Unit": "iMC"
37 }, 38 },
38 { 39 {
39 "BriefDescription": "Cycles all ranks are in critical thermal throttle. Derived from unc_m_power_critical_throttle_cycles", 40 "BriefDescription": "Cycles all ranks are in critical thermal throttle",
40 "Counter": "0,1,2,3", 41 "Counter": "0,1,2,3",
41 "EventCode": "0x86", 42 "EventCode": "0x86",
42 "EventName": "UNC_M_POWER_CRITICAL_THROTTLE_CYCLES", 43 "EventName": "UNC_M_POWER_CRITICAL_THROTTLE_CYCLES",
43 "MetricExpr": "(UNC_M_POWER_CRITICAL_THROTTLE_CYCLES / UNC_M_CLOCKTICKS) * 100.", 44 "MetricExpr": "(UNC_M_POWER_CRITICAL_THROTTLE_CYCLES / UNC_M_CLOCKTICKS) * 100.",
45 "MetricName": "power_critical_throttle_cycles %",
44 "PerPkg": "1", 46 "PerPkg": "1",
45 "Unit": "iMC" 47 "Unit": "iMC"
46 }, 48 },
47 { 49 {
48 "BriefDescription": "Cycles Memory is in self refresh power mode. Derived from unc_m_power_self_refresh", 50 "BriefDescription": "Cycles Memory is in self refresh power mode",
49 "Counter": "0,1,2,3", 51 "Counter": "0,1,2,3",
50 "EventCode": "0x43", 52 "EventCode": "0x43",
51 "EventName": "UNC_M_POWER_SELF_REFRESH", 53 "EventName": "UNC_M_POWER_SELF_REFRESH",
52 "MetricExpr": "(UNC_M_POWER_SELF_REFRESH / UNC_M_CLOCKTICKS) * 100.", 54 "MetricExpr": "(UNC_M_POWER_SELF_REFRESH / UNC_M_CLOCKTICKS) * 100.",
55 "MetricName": "power_self_refresh %",
53 "PerPkg": "1", 56 "PerPkg": "1",
54 "Unit": "iMC" 57 "Unit": "iMC"
55 }, 58 },
56 { 59 {
57 "BriefDescription": "Pre-charges due to page misses. Derived from unc_m_pre_count.page_miss", 60 "BriefDescription": "Pre-charges due to page misses",
58 "Counter": "0,1,2,3", 61 "Counter": "0,1,2,3",
59 "EventCode": "0x2", 62 "EventCode": "0x2",
60 "EventName": "UNC_M_PRE_COUNT.PAGE_MISS", 63 "EventName": "UNC_M_PRE_COUNT.PAGE_MISS",
@@ -63,7 +66,7 @@
63 "Unit": "iMC" 66 "Unit": "iMC"
64 }, 67 },
65 { 68 {
66 "BriefDescription": "Pre-charge for reads. Derived from unc_m_pre_count.rd", 69 "BriefDescription": "Pre-charge for reads",
67 "Counter": "0,1,2,3", 70 "Counter": "0,1,2,3",
68 "EventCode": "0x2", 71 "EventCode": "0x2",
69 "EventName": "UNC_M_PRE_COUNT.RD", 72 "EventName": "UNC_M_PRE_COUNT.RD",
@@ -72,7 +75,7 @@
72 "Unit": "iMC" 75 "Unit": "iMC"
73 }, 76 },
74 { 77 {
75 "BriefDescription": "Pre-charge for writes. Derived from unc_m_pre_count.wr", 78 "BriefDescription": "Pre-charge for writes",
76 "Counter": "0,1,2,3", 79 "Counter": "0,1,2,3",
77 "EventCode": "0x2", 80 "EventCode": "0x2",
78 "EventName": "UNC_M_PRE_COUNT.WR", 81 "EventName": "UNC_M_PRE_COUNT.WR",
diff --git a/tools/perf/pmu-events/arch/x86/haswellx/uncore-power.json b/tools/perf/pmu-events/arch/x86/haswellx/uncore-power.json
index b44d43088bbb..dd1b95655d1d 100644
--- a/tools/perf/pmu-events/arch/x86/haswellx/uncore-power.json
+++ b/tools/perf/pmu-events/arch/x86/haswellx/uncore-power.json
@@ -1,83 +1,91 @@
1[ 1[
2 { 2 {
3 "BriefDescription": "PCU clock ticks. Use to get percentages of PCU cycles events. Derived from unc_p_clockticks", 3 "BriefDescription": "PCU clock ticks. Use to get percentages of PCU cycles events",
4 "Counter": "0,1,2,3", 4 "Counter": "0,1,2,3",
5 "EventName": "UNC_P_CLOCKTICKS", 5 "EventName": "UNC_P_CLOCKTICKS",
6 "PerPkg": "1", 6 "PerPkg": "1",
7 "Unit": "PCU" 7 "Unit": "PCU"
8 }, 8 },
9 { 9 {
10 "BriefDescription": "C0 and C1. Derived from unc_p_power_state_occupancy.cores_c0", 10 "BriefDescription": "This is an occupancy event that tracks the number of cores that are in C0. It can be used by itself to get the average number of cores in C0, with threshholding to generate histograms, or with other PCU events and occupancy triggering to capture other details",
11 "Counter": "0,1,2,3", 11 "Counter": "0,1,2,3",
12 "EventCode": "0x80", 12 "EventCode": "0x80",
13 "EventName": "UNC_P_POWER_STATE_OCCUPANCY.CORES_C0", 13 "EventName": "UNC_P_POWER_STATE_OCCUPANCY.CORES_C0",
14 "Filter": "occ_sel=1", 14 "Filter": "occ_sel=1",
15 "MetricExpr": "(UNC_P_POWER_STATE_OCCUPANCY.CORES_C0 / UNC_P_CLOCKTICKS) * 100.", 15 "MetricExpr": "(UNC_P_POWER_STATE_OCCUPANCY.CORES_C0 / UNC_P_CLOCKTICKS) * 100.",
16 "MetricName": "power_state_occupancy.cores_c0 %",
16 "PerPkg": "1", 17 "PerPkg": "1",
17 "Unit": "PCU" 18 "Unit": "PCU"
18 }, 19 },
19 { 20 {
20 "BriefDescription": "C3. Derived from unc_p_power_state_occupancy.cores_c3", 21 "BriefDescription": "This is an occupancy event that tracks the number of cores that are in C3. It can be used by itself to get the average number of cores in C0, with threshholding to generate histograms, or with other PCU events and occupancy triggering to capture other details",
21 "Counter": "0,1,2,3", 22 "Counter": "0,1,2,3",
22 "EventCode": "0x80", 23 "EventCode": "0x80",
23 "EventName": "UNC_P_POWER_STATE_OCCUPANCY.CORES_C3", 24 "EventName": "UNC_P_POWER_STATE_OCCUPANCY.CORES_C3",
24 "Filter": "occ_sel=2", 25 "Filter": "occ_sel=2",
25 "MetricExpr": "(UNC_P_POWER_STATE_OCCUPANCY.CORES_C3 / UNC_P_CLOCKTICKS) * 100.", 26 "MetricExpr": "(UNC_P_POWER_STATE_OCCUPANCY.CORES_C3 / UNC_P_CLOCKTICKS) * 100.",
27 "MetricName": "power_state_occupancy.cores_c3 %",
26 "PerPkg": "1", 28 "PerPkg": "1",
27 "Unit": "PCU" 29 "Unit": "PCU"
28 }, 30 },
29 { 31 {
30 "BriefDescription": "C6 and C7. Derived from unc_p_power_state_occupancy.cores_c6", 32 "BriefDescription": "This is an occupancy event that tracks the number of cores that are in C6. It can be used by itself to get the average number of cores in C0, with threshholding to generate histograms, or with other PCU events ",
31 "Counter": "0,1,2,3", 33 "Counter": "0,1,2,3",
32 "EventCode": "0x80", 34 "EventCode": "0x80",
33 "EventName": "UNC_P_POWER_STATE_OCCUPANCY.CORES_C6", 35 "EventName": "UNC_P_POWER_STATE_OCCUPANCY.CORES_C6",
34 "Filter": "occ_sel=3", 36 "Filter": "occ_sel=3",
35 "MetricExpr": "(UNC_P_POWER_STATE_OCCUPANCY.CORES_C6 / UNC_P_CLOCKTICKS) * 100.", 37 "MetricExpr": "(UNC_P_POWER_STATE_OCCUPANCY.CORES_C6 / UNC_P_CLOCKTICKS) * 100.",
38 "MetricName": "power_state_occupancy.cores_c6 %",
36 "PerPkg": "1", 39 "PerPkg": "1",
37 "Unit": "PCU" 40 "Unit": "PCU"
38 }, 41 },
39 { 42 {
40 "BriefDescription": "External Prochot. Derived from unc_p_prochot_external_cycles", 43 "BriefDescription": "Counts the number of cycles that we are in external PROCHOT mode. This mode is triggered when a sensor off the die determines that something off-die (like DRAM) is too hot and must throttle to avoid damaging the chip",
41 "Counter": "0,1,2,3", 44 "Counter": "0,1,2,3",
42 "EventCode": "0xA", 45 "EventCode": "0xA",
43 "EventName": "UNC_P_PROCHOT_EXTERNAL_CYCLES", 46 "EventName": "UNC_P_PROCHOT_EXTERNAL_CYCLES",
44 "MetricExpr": "(UNC_P_PROCHOT_EXTERNAL_CYCLES / UNC_P_CLOCKTICKS) * 100.", 47 "MetricExpr": "(UNC_P_PROCHOT_EXTERNAL_CYCLES / UNC_P_CLOCKTICKS) * 100.",
48 "MetricName": "prochot_external_cycles %",
45 "PerPkg": "1", 49 "PerPkg": "1",
46 "Unit": "PCU" 50 "Unit": "PCU"
47 }, 51 },
48 { 52 {
49 "BriefDescription": "Thermal Strongest Upper Limit Cycles. Derived from unc_p_freq_max_limit_thermal_cycles", 53 "BriefDescription": "Counts the number of cycles when temperature is the upper limit on frequency",
50 "Counter": "0,1,2,3", 54 "Counter": "0,1,2,3",
51 "EventCode": "0x4", 55 "EventCode": "0x4",
52 "EventName": "UNC_P_FREQ_MAX_LIMIT_THERMAL_CYCLES", 56 "EventName": "UNC_P_FREQ_MAX_LIMIT_THERMAL_CYCLES",
53 "MetricExpr": "(UNC_P_FREQ_MAX_LIMIT_THERMAL_CYCLES / UNC_P_CLOCKTICKS) * 100.", 57 "MetricExpr": "(UNC_P_FREQ_MAX_LIMIT_THERMAL_CYCLES / UNC_P_CLOCKTICKS) * 100.",
58 "MetricName": "freq_max_limit_thermal_cycles %",
54 "PerPkg": "1", 59 "PerPkg": "1",
55 "Unit": "PCU" 60 "Unit": "PCU"
56 }, 61 },
57 { 62 {
58 "BriefDescription": "OS Strongest Upper Limit Cycles. Derived from unc_p_freq_max_os_cycles", 63 "BriefDescription": "Counts the number of cycles when the OS is the upper limit on frequency",
59 "Counter": "0,1,2,3", 64 "Counter": "0,1,2,3",
60 "EventCode": "0x6", 65 "EventCode": "0x6",
61 "EventName": "UNC_P_FREQ_MAX_OS_CYCLES", 66 "EventName": "UNC_P_FREQ_MAX_OS_CYCLES",
62 "MetricExpr": "(UNC_P_FREQ_MAX_OS_CYCLES / UNC_P_CLOCKTICKS) * 100.", 67 "MetricExpr": "(UNC_P_FREQ_MAX_OS_CYCLES / UNC_P_CLOCKTICKS) * 100.",
68 "MetricName": "freq_max_os_cycles %",
63 "PerPkg": "1", 69 "PerPkg": "1",
64 "Unit": "PCU" 70 "Unit": "PCU"
65 }, 71 },
66 { 72 {
67 "BriefDescription": "Power Strongest Upper Limit Cycles. Derived from unc_p_freq_max_power_cycles", 73 "BriefDescription": "Counts the number of cycles when power is the upper limit on frequency",
68 "Counter": "0,1,2,3", 74 "Counter": "0,1,2,3",
69 "EventCode": "0x5", 75 "EventCode": "0x5",
70 "EventName": "UNC_P_FREQ_MAX_POWER_CYCLES", 76 "EventName": "UNC_P_FREQ_MAX_POWER_CYCLES",
71 "MetricExpr": "(UNC_P_FREQ_MAX_POWER_CYCLES / UNC_P_CLOCKTICKS) * 100.", 77 "MetricExpr": "(UNC_P_FREQ_MAX_POWER_CYCLES / UNC_P_CLOCKTICKS) * 100.",
78 "MetricName": "freq_max_power_cycles %",
72 "PerPkg": "1", 79 "PerPkg": "1",
73 "Unit": "PCU" 80 "Unit": "PCU"
74 }, 81 },
75 { 82 {
76 "BriefDescription": "Cycles spent changing Frequency. Derived from unc_p_freq_trans_cycles", 83 "BriefDescription": "Counts the number of cycles when current is the upper limit on frequency",
77 "Counter": "0,1,2,3", 84 "Counter": "0,1,2,3",
78 "EventCode": "0x74", 85 "EventCode": "0x74",
79 "EventName": "UNC_P_FREQ_TRANS_CYCLES", 86 "EventName": "UNC_P_FREQ_TRANS_CYCLES",
80 "MetricExpr": "(UNC_P_FREQ_TRANS_CYCLES / UNC_P_CLOCKTICKS) * 100.", 87 "MetricExpr": "(UNC_P_FREQ_TRANS_CYCLES / UNC_P_CLOCKTICKS) * 100.",
88 "MetricName": "freq_trans_cycles %",
81 "PerPkg": "1", 89 "PerPkg": "1",
82 "Unit": "PCU" 90 "Unit": "PCU"
83 } 91 }
diff --git a/tools/perf/pmu-events/arch/x86/ivytown/uncore-cache.json b/tools/perf/pmu-events/arch/x86/ivytown/uncore-cache.json
index 2efdc6772e0b..267410594833 100644
--- a/tools/perf/pmu-events/arch/x86/ivytown/uncore-cache.json
+++ b/tools/perf/pmu-events/arch/x86/ivytown/uncore-cache.json
@@ -1,13 +1,13 @@
1[ 1[
2 { 2 {
3 "BriefDescription": "Uncore cache clock ticks. Derived from unc_c_clockticks", 3 "BriefDescription": "Uncore cache clock ticks",
4 "Counter": "0,1,2,3", 4 "Counter": "0,1,2,3",
5 "EventName": "UNC_C_CLOCKTICKS", 5 "EventName": "UNC_C_CLOCKTICKS",
6 "PerPkg": "1", 6 "PerPkg": "1",
7 "Unit": "CBO" 7 "Unit": "CBO"
8 }, 8 },
9 { 9 {
10 "BriefDescription": "All LLC Misses (code+ data rd + data wr - including demand and prefetch). Derived from unc_c_llc_lookup.any", 10 "BriefDescription": "All LLC Misses (code+ data rd + data wr - including demand and prefetch)",
11 "Counter": "0,1", 11 "Counter": "0,1",
12 "EventCode": "0x34", 12 "EventCode": "0x34",
13 "EventName": "UNC_C_LLC_LOOKUP.ANY", 13 "EventName": "UNC_C_LLC_LOOKUP.ANY",
@@ -18,7 +18,7 @@
18 "Unit": "CBO" 18 "Unit": "CBO"
19 }, 19 },
20 { 20 {
21 "BriefDescription": "M line evictions from LLC (writebacks to memory). Derived from unc_c_llc_victims.m_state", 21 "BriefDescription": "M line evictions from LLC (writebacks to memory)",
22 "Counter": "0,1", 22 "Counter": "0,1",
23 "EventCode": "0x37", 23 "EventCode": "0x37",
24 "EventName": "UNC_C_LLC_VICTIMS.M_STATE", 24 "EventName": "UNC_C_LLC_VICTIMS.M_STATE",
@@ -237,7 +237,7 @@
237 "Unit": "CBO" 237 "Unit": "CBO"
238 }, 238 },
239 { 239 {
240 "BriefDescription": "Occupancy for all LLC misses that are addressed to local memory. Derived from unc_c_tor_occupancy.miss_local", 240 "BriefDescription": "Occupancy for all LLC misses that are addressed to local memory",
241 "EventCode": "0x36", 241 "EventCode": "0x36",
242 "EventName": "UNC_C_TOR_OCCUPANCY.MISS_LOCAL", 242 "EventName": "UNC_C_TOR_OCCUPANCY.MISS_LOCAL",
243 "PerPkg": "1", 243 "PerPkg": "1",
@@ -254,7 +254,7 @@
254 "Unit": "CBO" 254 "Unit": "CBO"
255 }, 255 },
256 { 256 {
257 "BriefDescription": "Occupancy for all LLC misses that are addressed to remote memory. Derived from unc_c_tor_occupancy.miss_remote", 257 "BriefDescription": "Occupancy for all LLC misses that are addressed to remote memory",
258 "EventCode": "0x36", 258 "EventCode": "0x36",
259 "EventName": "UNC_C_TOR_OCCUPANCY.MISS_REMOTE", 259 "EventName": "UNC_C_TOR_OCCUPANCY.MISS_REMOTE",
260 "PerPkg": "1", 260 "PerPkg": "1",
@@ -262,7 +262,7 @@
262 "Unit": "CBO" 262 "Unit": "CBO"
263 }, 263 },
264 { 264 {
265 "BriefDescription": "Read requests to home agent. Derived from unc_h_requests.reads", 265 "BriefDescription": "Read requests to home agent",
266 "Counter": "0,1,2,3", 266 "Counter": "0,1,2,3",
267 "EventCode": "0x1", 267 "EventCode": "0x1",
268 "EventName": "UNC_H_REQUESTS.READS", 268 "EventName": "UNC_H_REQUESTS.READS",
@@ -271,7 +271,7 @@
271 "Unit": "HA" 271 "Unit": "HA"
272 }, 272 },
273 { 273 {
274 "BriefDescription": "Write requests to home agent. Derived from unc_h_requests.writes", 274 "BriefDescription": "Write requests to home agent",
275 "Counter": "0,1,2,3", 275 "Counter": "0,1,2,3",
276 "EventCode": "0x1", 276 "EventCode": "0x1",
277 "EventName": "UNC_H_REQUESTS.WRITES", 277 "EventName": "UNC_H_REQUESTS.WRITES",
@@ -280,7 +280,7 @@
280 "Unit": "HA" 280 "Unit": "HA"
281 }, 281 },
282 { 282 {
283 "BriefDescription": "M line forwarded from remote cache along with writeback to memory. Derived from unc_h_snoop_resp.rsp_fwd_wb", 283 "BriefDescription": "M line forwarded from remote cache along with writeback to memory",
284 "Counter": "0,1,2,3", 284 "Counter": "0,1,2,3",
285 "EventCode": "0x21", 285 "EventCode": "0x21",
286 "EventName": "UNC_H_SNOOP_RESP.RSP_FWD_WB", 286 "EventName": "UNC_H_SNOOP_RESP.RSP_FWD_WB",
@@ -290,7 +290,7 @@
290 "Unit": "HA" 290 "Unit": "HA"
291 }, 291 },
292 { 292 {
293 "BriefDescription": "M line forwarded from remote cache with no writeback to memory. Derived from unc_h_snoop_resp.rspifwd", 293 "BriefDescription": "M line forwarded from remote cache with no writeback to memory",
294 "Counter": "0,1,2,3", 294 "Counter": "0,1,2,3",
295 "EventCode": "0x21", 295 "EventCode": "0x21",
296 "EventName": "UNC_H_SNOOP_RESP.RSPIFWD", 296 "EventName": "UNC_H_SNOOP_RESP.RSPIFWD",
@@ -300,7 +300,7 @@
300 "Unit": "HA" 300 "Unit": "HA"
301 }, 301 },
302 { 302 {
303 "BriefDescription": "Shared line response from remote cache. Derived from unc_h_snoop_resp.rsps", 303 "BriefDescription": "Shared line response from remote cache",
304 "Counter": "0,1,2,3", 304 "Counter": "0,1,2,3",
305 "EventCode": "0x21", 305 "EventCode": "0x21",
306 "EventName": "UNC_H_SNOOP_RESP.RSPS", 306 "EventName": "UNC_H_SNOOP_RESP.RSPS",
@@ -310,7 +310,7 @@
310 "Unit": "HA" 310 "Unit": "HA"
311 }, 311 },
312 { 312 {
313 "BriefDescription": "Shared line forwarded from remote cache. Derived from unc_h_snoop_resp.rspsfwd", 313 "BriefDescription": "Shared line forwarded from remote cache",
314 "Counter": "0,1,2,3", 314 "Counter": "0,1,2,3",
315 "EventCode": "0x21", 315 "EventCode": "0x21",
316 "EventName": "UNC_H_SNOOP_RESP.RSPSFWD", 316 "EventName": "UNC_H_SNOOP_RESP.RSPSFWD",
diff --git a/tools/perf/pmu-events/arch/x86/ivytown/uncore-interconnect.json b/tools/perf/pmu-events/arch/x86/ivytown/uncore-interconnect.json
index d7e2fda1d695..b798a860bc81 100644
--- a/tools/perf/pmu-events/arch/x86/ivytown/uncore-interconnect.json
+++ b/tools/perf/pmu-events/arch/x86/ivytown/uncore-interconnect.json
@@ -1,6 +1,6 @@
1[ 1[
2 { 2 {
3 "BriefDescription": "QPI clock ticks. Use to get percentages for QPI cycles events. Derived from unc_q_clockticks", 3 "BriefDescription": "QPI clock ticks. Use to get percentages for QPI cycles events",
4 "Counter": "0,1,2,3", 4 "Counter": "0,1,2,3",
5 "EventCode": "0x14", 5 "EventCode": "0x14",
6 "EventName": "UNC_Q_CLOCKTICKS", 6 "EventName": "UNC_Q_CLOCKTICKS",
@@ -8,25 +8,27 @@
8 "Unit": "QPI LL" 8 "Unit": "QPI LL"
9 }, 9 },
10 { 10 {
11 "BriefDescription": "Cycles where receiving QPI link is in half-width mode. Derived from unc_q_rxl0p_power_cycles", 11 "BriefDescription": "Cycles where receiving QPI link is in half-width mode",
12 "Counter": "0,1,2,3", 12 "Counter": "0,1,2,3",
13 "EventCode": "0x10", 13 "EventCode": "0x10",
14 "EventName": "UNC_Q_RxL0P_POWER_CYCLES", 14 "EventName": "UNC_Q_RxL0P_POWER_CYCLES",
15 "MetricExpr": "(UNC_Q_RxL0P_POWER_CYCLES / UNC_Q_CLOCKTICKS) * 100.", 15 "MetricExpr": "(UNC_Q_RxL0P_POWER_CYCLES / UNC_Q_CLOCKTICKS) * 100.",
16 "MetricName": "rxl0p_power_cycles %",
16 "PerPkg": "1", 17 "PerPkg": "1",
17 "Unit": "QPI LL" 18 "Unit": "QPI LL"
18 }, 19 },
19 { 20 {
20 "BriefDescription": "Cycles where transmitting QPI link is in half-width mode. Derived from unc_q_txl0p_power_cycles", 21 "BriefDescription": "Cycles where transmitting QPI link is in half-width mode",
21 "Counter": "0,1,2,3", 22 "Counter": "0,1,2,3",
22 "EventCode": "0xd", 23 "EventCode": "0xd",
23 "EventName": "UNC_Q_TxL0P_POWER_CYCLES", 24 "EventName": "UNC_Q_TxL0P_POWER_CYCLES",
24 "MetricExpr": "(UNC_Q_TxL0P_POWER_CYCLES / UNC_Q_CLOCKTICKS) * 100.", 25 "MetricExpr": "(UNC_Q_TxL0P_POWER_CYCLES / UNC_Q_CLOCKTICKS) * 100.",
26 "MetricName": "txl0p_power_cycles %",
25 "PerPkg": "1", 27 "PerPkg": "1",
26 "Unit": "QPI LL" 28 "Unit": "QPI LL"
27 }, 29 },
28 { 30 {
29 "BriefDescription": "Number of data flits transmitted . Derived from unc_q_txl_flits_g0.data", 31 "BriefDescription": "Number of data flits transmitted ",
30 "Counter": "0,1,2,3", 32 "Counter": "0,1,2,3",
31 "EventName": "UNC_Q_TxL_FLITS_G0.DATA", 33 "EventName": "UNC_Q_TxL_FLITS_G0.DATA",
32 "PerPkg": "1", 34 "PerPkg": "1",
@@ -35,7 +37,7 @@
35 "Unit": "QPI LL" 37 "Unit": "QPI LL"
36 }, 38 },
37 { 39 {
38 "BriefDescription": "Number of non data (control) flits transmitted . Derived from unc_q_txl_flits_g0.non_data", 40 "BriefDescription": "Number of non data (control) flits transmitted ",
39 "Counter": "0,1,2,3", 41 "Counter": "0,1,2,3",
40 "EventName": "UNC_Q_TxL_FLITS_G0.NON_DATA", 42 "EventName": "UNC_Q_TxL_FLITS_G0.NON_DATA",
41 "PerPkg": "1", 43 "PerPkg": "1",
diff --git a/tools/perf/pmu-events/arch/x86/ivytown/uncore-memory.json b/tools/perf/pmu-events/arch/x86/ivytown/uncore-memory.json
index ac4ad4d6357b..df4b43294fa0 100644
--- a/tools/perf/pmu-events/arch/x86/ivytown/uncore-memory.json
+++ b/tools/perf/pmu-events/arch/x86/ivytown/uncore-memory.json
@@ -1,6 +1,6 @@
1[ 1[
2 { 2 {
3 "BriefDescription": "Memory page activates for reads and writes. Derived from unc_m_act_count.rd", 3 "BriefDescription": "Memory page activates for reads and writes",
4 "Counter": "0,1,2,3", 4 "Counter": "0,1,2,3",
5 "EventCode": "0x1", 5 "EventCode": "0x1",
6 "EventName": "UNC_M_ACT_COUNT.RD", 6 "EventName": "UNC_M_ACT_COUNT.RD",
@@ -13,7 +13,7 @@
13 "BriefDescription": "Read requests to memory controller. Derived from unc_m_cas_count.rd", 13 "BriefDescription": "Read requests to memory controller. Derived from unc_m_cas_count.rd",
14 "Counter": "0,1,2,3", 14 "Counter": "0,1,2,3",
15 "EventCode": "0x4", 15 "EventCode": "0x4",
16 "EventName": "UNC_M_CAS_COUNT.RD", 16 "EventName": "LLC_MISSES.MEM_READ",
17 "PerPkg": "1", 17 "PerPkg": "1",
18 "ScaleUnit": "64Bytes", 18 "ScaleUnit": "64Bytes",
19 "UMask": "0x3", 19 "UMask": "0x3",
@@ -23,48 +23,51 @@
23 "BriefDescription": "Write requests to memory controller. Derived from unc_m_cas_count.wr", 23 "BriefDescription": "Write requests to memory controller. Derived from unc_m_cas_count.wr",
24 "Counter": "0,1,2,3", 24 "Counter": "0,1,2,3",
25 "EventCode": "0x4", 25 "EventCode": "0x4",
26 "EventName": "UNC_M_CAS_COUNT.WR", 26 "EventName": "LLC_MISSES.MEM_WRITE",
27 "PerPkg": "1", 27 "PerPkg": "1",
28 "ScaleUnit": "64Bytes", 28 "ScaleUnit": "64Bytes",
29 "UMask": "0xC", 29 "UMask": "0xC",
30 "Unit": "iMC" 30 "Unit": "iMC"
31 }, 31 },
32 { 32 {
33 "BriefDescription": "Memory controller clock ticks. Use to generate percentages for memory controller CYCLES events. Derived from unc_m_clockticks", 33 "BriefDescription": "Memory controller clock ticks. Use to generate percentages for memory controller CYCLES events",
34 "Counter": "0,1,2,3", 34 "Counter": "0,1,2,3",
35 "EventName": "UNC_M_CLOCKTICKS", 35 "EventName": "UNC_M_CLOCKTICKS",
36 "PerPkg": "1", 36 "PerPkg": "1",
37 "Unit": "iMC" 37 "Unit": "iMC"
38 }, 38 },
39 { 39 {
40 "BriefDescription": "Cycles where DRAM ranks are in power down (CKE) mode. Derived from unc_m_power_channel_ppd", 40 "BriefDescription": "Cycles where DRAM ranks are in power down (CKE) mode",
41 "Counter": "0,1,2,3", 41 "Counter": "0,1,2,3",
42 "EventCode": "0x85", 42 "EventCode": "0x85",
43 "EventName": "UNC_M_POWER_CHANNEL_PPD", 43 "EventName": "UNC_M_POWER_CHANNEL_PPD",
44 "MetricExpr": "(UNC_M_POWER_CHANNEL_PPD / UNC_M_CLOCKTICKS) * 100.", 44 "MetricExpr": "(UNC_M_POWER_CHANNEL_PPD / UNC_M_CLOCKTICKS) * 100.",
45 "MetricName": "power_channel_ppd %",
45 "PerPkg": "1", 46 "PerPkg": "1",
46 "Unit": "iMC" 47 "Unit": "iMC"
47 }, 48 },
48 { 49 {
49 "BriefDescription": "Cycles all ranks are in critical thermal throttle. Derived from unc_m_power_critical_throttle_cycles", 50 "BriefDescription": "Cycles all ranks are in critical thermal throttle",
50 "Counter": "0,1,2,3", 51 "Counter": "0,1,2,3",
51 "EventCode": "0x86", 52 "EventCode": "0x86",
52 "EventName": "UNC_M_POWER_CRITICAL_THROTTLE_CYCLES", 53 "EventName": "UNC_M_POWER_CRITICAL_THROTTLE_CYCLES",
53 "MetricExpr": "(UNC_M_POWER_CRITICAL_THROTTLE_CYCLES / UNC_M_CLOCKTICKS) * 100.", 54 "MetricExpr": "(UNC_M_POWER_CRITICAL_THROTTLE_CYCLES / UNC_M_CLOCKTICKS) * 100.",
55 "MetricName": "power_critical_throttle_cycles %",
54 "PerPkg": "1", 56 "PerPkg": "1",
55 "Unit": "iMC" 57 "Unit": "iMC"
56 }, 58 },
57 { 59 {
58 "BriefDescription": "Cycles Memory is in self refresh power mode. Derived from unc_m_power_self_refresh", 60 "BriefDescription": "Cycles Memory is in self refresh power mode",
59 "Counter": "0,1,2,3", 61 "Counter": "0,1,2,3",
60 "EventCode": "0x43", 62 "EventCode": "0x43",
61 "EventName": "UNC_M_POWER_SELF_REFRESH", 63 "EventName": "UNC_M_POWER_SELF_REFRESH",
62 "MetricExpr": "(UNC_M_POWER_SELF_REFRESH / UNC_M_CLOCKTICKS) * 100.", 64 "MetricExpr": "(UNC_M_POWER_SELF_REFRESH / UNC_M_CLOCKTICKS) * 100.",
65 "MetricName": "power_self_refresh %",
63 "PerPkg": "1", 66 "PerPkg": "1",
64 "Unit": "iMC" 67 "Unit": "iMC"
65 }, 68 },
66 { 69 {
67 "BriefDescription": "Memory page conflicts. Derived from unc_m_pre_count.page_miss", 70 "BriefDescription": "Memory page conflicts",
68 "Counter": "0,1,2,3", 71 "Counter": "0,1,2,3",
69 "EventCode": "0x2", 72 "EventCode": "0x2",
70 "EventName": "UNC_M_PRE_COUNT.PAGE_MISS", 73 "EventName": "UNC_M_PRE_COUNT.PAGE_MISS",
diff --git a/tools/perf/pmu-events/arch/x86/ivytown/uncore-power.json b/tools/perf/pmu-events/arch/x86/ivytown/uncore-power.json
index dc2586db0dfc..d40498f2cb1e 100644
--- a/tools/perf/pmu-events/arch/x86/ivytown/uncore-power.json
+++ b/tools/perf/pmu-events/arch/x86/ivytown/uncore-power.json
@@ -1,44 +1,48 @@
1[ 1[
2 { 2 {
3 "BriefDescription": "PCU clock ticks. Use to get percentages of PCU cycles events. Derived from unc_p_clockticks", 3 "BriefDescription": "PCU clock ticks. Use to get percentages of PCU cycles events",
4 "Counter": "0,1,2,3", 4 "Counter": "0,1,2,3",
5 "EventName": "UNC_P_CLOCKTICKS", 5 "EventName": "UNC_P_CLOCKTICKS",
6 "PerPkg": "1", 6 "PerPkg": "1",
7 "Unit": "PCU" 7 "Unit": "PCU"
8 }, 8 },
9 { 9 {
10 "BriefDescription": "Counts the number of cycles that the uncore was running at a frequency greater than or equal to the frequency that is configured in the filter. (filter_band0=XXX, with XXX in 100Mhz units). One can also use inversion (filter_inv=1) to track cycles when we were less than the configured frequency. Derived from unc_p_freq_band0_cycles", 10 "BriefDescription": "Counts the number of cycles that the uncore was running at a frequency greater than or equal to the frequency that is configured in the filter. (filter_band0=XXX, with XXX in 100Mhz units). One can also use inversion (filter_inv=1) to track cycles when we were less than the configured frequency",
11 "Counter": "0,1,2,3", 11 "Counter": "0,1,2,3",
12 "EventCode": "0xb", 12 "EventCode": "0xb",
13 "EventName": "UNC_P_FREQ_BAND0_CYCLES", 13 "EventName": "UNC_P_FREQ_BAND0_CYCLES",
14 "MetricExpr": "(UNC_P_FREQ_BAND0_CYCLES / UNC_P_CLOCKTICKS) * 100.", 14 "MetricExpr": "(UNC_P_FREQ_BAND0_CYCLES / UNC_P_CLOCKTICKS) * 100.",
15 "MetricName": "freq_band0_cycles %",
15 "PerPkg": "1", 16 "PerPkg": "1",
16 "Unit": "PCU" 17 "Unit": "PCU"
17 }, 18 },
18 { 19 {
19 "BriefDescription": "Counts the number of cycles that the uncore was running at a frequency greater than or equal to the frequency that is configured in the filter. (filter_band1=XXX, with XXX in 100Mhz units). One can also use inversion (filter_inv=1) to track cycles when we were less than the configured frequency. Derived from unc_p_freq_band1_cycles", 20 "BriefDescription": "Counts the number of cycles that the uncore was running at a frequency greater than or equal to the frequency that is configured in the filter. (filter_band1=XXX, with XXX in 100Mhz units). One can also use inversion (filter_inv=1) to track cycles when we were less than the configured frequency",
20 "Counter": "0,1,2,3", 21 "Counter": "0,1,2,3",
21 "EventCode": "0xc", 22 "EventCode": "0xc",
22 "EventName": "UNC_P_FREQ_BAND1_CYCLES", 23 "EventName": "UNC_P_FREQ_BAND1_CYCLES",
23 "MetricExpr": "(UNC_P_FREQ_BAND1_CYCLES / UNC_P_CLOCKTICKS) * 100.", 24 "MetricExpr": "(UNC_P_FREQ_BAND1_CYCLES / UNC_P_CLOCKTICKS) * 100.",
25 "MetricName": "freq_band1_cycles %",
24 "PerPkg": "1", 26 "PerPkg": "1",
25 "Unit": "PCU" 27 "Unit": "PCU"
26 }, 28 },
27 { 29 {
28 "BriefDescription": "Counts the number of cycles that the uncore was running at a frequency greater than or equal to the frequency that is configured in the filter. (filter_band2=XXX, with XXX in 100Mhz units). One can also use inversion (filter_inv=1) to track cycles when we were less than the configured frequency. Derived from unc_p_freq_band2_cycles", 30 "BriefDescription": "Counts the number of cycles that the uncore was running at a frequency greater than or equal to the frequency that is configured in the filter. (filter_band2=XXX, with XXX in 100Mhz units). One can also use inversion (filter_inv=1) to track cycles when we were less than the configured frequency",
29 "Counter": "0,1,2,3", 31 "Counter": "0,1,2,3",
30 "EventCode": "0xd", 32 "EventCode": "0xd",
31 "EventName": "UNC_P_FREQ_BAND2_CYCLES", 33 "EventName": "UNC_P_FREQ_BAND2_CYCLES",
32 "MetricExpr": "(UNC_P_FREQ_BAND2_CYCLES / UNC_P_CLOCKTICKS) * 100.", 34 "MetricExpr": "(UNC_P_FREQ_BAND2_CYCLES / UNC_P_CLOCKTICKS) * 100.",
35 "MetricName": "freq_band2_cycles %",
33 "PerPkg": "1", 36 "PerPkg": "1",
34 "Unit": "PCU" 37 "Unit": "PCU"
35 }, 38 },
36 { 39 {
37 "BriefDescription": "Counts the number of cycles that the uncore was running at a frequency greater than or equal to the frequency that is configured in the filter. (filter_band3=XXX, with XXX in 100Mhz units). One can also use inversion (filter_inv=1) to track cycles when we were less than the configured frequency. Derived from unc_p_freq_band3_cycles", 40 "BriefDescription": "Counts the number of cycles that the uncore was running at a frequency greater than or equal to the frequency that is configured in the filter. (filter_band3=XXX, with XXX in 100Mhz units). One can also use inversion (filter_inv=1) to track cycles when we were less than the configured frequency",
38 "Counter": "0,1,2,3", 41 "Counter": "0,1,2,3",
39 "EventCode": "0xe", 42 "EventCode": "0xe",
40 "EventName": "UNC_P_FREQ_BAND3_CYCLES", 43 "EventName": "UNC_P_FREQ_BAND3_CYCLES",
41 "MetricExpr": "(UNC_P_FREQ_BAND3_CYCLES / UNC_P_CLOCKTICKS) * 100.", 44 "MetricExpr": "(UNC_P_FREQ_BAND3_CYCLES / UNC_P_CLOCKTICKS) * 100.",
45 "MetricName": "freq_band3_cycles %",
42 "PerPkg": "1", 46 "PerPkg": "1",
43 "Unit": "PCU" 47 "Unit": "PCU"
44 }, 48 },
@@ -49,6 +53,7 @@
49 "EventName": "UNC_P_FREQ_BAND0_TRANSITIONS", 53 "EventName": "UNC_P_FREQ_BAND0_TRANSITIONS",
50 "Filter": "edge=1", 54 "Filter": "edge=1",
51 "MetricExpr": "(UNC_P_FREQ_BAND0_CYCLES / UNC_P_CLOCKTICKS) * 100.", 55 "MetricExpr": "(UNC_P_FREQ_BAND0_CYCLES / UNC_P_CLOCKTICKS) * 100.",
56 "MetricName": "freq_band0_cycles %",
52 "PerPkg": "1", 57 "PerPkg": "1",
53 "Unit": "PCU" 58 "Unit": "PCU"
54 }, 59 },
@@ -59,6 +64,7 @@
59 "EventName": "UNC_P_FREQ_BAND1_TRANSITIONS", 64 "EventName": "UNC_P_FREQ_BAND1_TRANSITIONS",
60 "Filter": "edge=1", 65 "Filter": "edge=1",
61 "MetricExpr": "(UNC_P_FREQ_BAND1_CYCLES / UNC_P_CLOCKTICKS) * 100.", 66 "MetricExpr": "(UNC_P_FREQ_BAND1_CYCLES / UNC_P_CLOCKTICKS) * 100.",
67 "MetricName": "freq_band1_cycles %",
62 "PerPkg": "1", 68 "PerPkg": "1",
63 "Unit": "PCU" 69 "Unit": "PCU"
64 }, 70 },
@@ -69,6 +75,7 @@
69 "EventName": "UNC_P_FREQ_BAND2_TRANSITIONS", 75 "EventName": "UNC_P_FREQ_BAND2_TRANSITIONS",
70 "Filter": "edge=1", 76 "Filter": "edge=1",
71 "MetricExpr": "(UNC_P_FREQ_BAND2_CYCLES / UNC_P_CLOCKTICKS) * 100.", 77 "MetricExpr": "(UNC_P_FREQ_BAND2_CYCLES / UNC_P_CLOCKTICKS) * 100.",
78 "MetricName": "freq_band2_cycles %",
72 "PerPkg": "1", 79 "PerPkg": "1",
73 "Unit": "PCU" 80 "Unit": "PCU"
74 }, 81 },
@@ -79,90 +86,100 @@
79 "EventName": "UNC_P_FREQ_BAND3_TRANSITIONS", 86 "EventName": "UNC_P_FREQ_BAND3_TRANSITIONS",
80 "Filter": "edge=1", 87 "Filter": "edge=1",
81 "MetricExpr": "(UNC_P_FREQ_BAND3_CYCLES / UNC_P_CLOCKTICKS) * 100.", 88 "MetricExpr": "(UNC_P_FREQ_BAND3_CYCLES / UNC_P_CLOCKTICKS) * 100.",
89 "MetricName": "freq_band3_cycles %",
82 "PerPkg": "1", 90 "PerPkg": "1",
83 "Unit": "PCU" 91 "Unit": "PCU"
84 }, 92 },
85 { 93 {
86 "BriefDescription": "This is an occupancy event that tracks the number of cores that are in the chosen C-State. It can be used by itself to get the average number of cores in that C-state with threshholding to generate histograms, or with other PCU events and occupancy triggering to capture other details. Derived from unc_p_power_state_occupancy.cores_c0", 94 "BriefDescription": "This is an occupancy event that tracks the number of cores that are in C0. It can be used by itself to get the average number of cores in C0, with threshholding to generate histograms, or with other PCU events and occupancy triggering to capture other details",
87 "Counter": "0,1,2,3", 95 "Counter": "0,1,2,3",
88 "EventCode": "0x80", 96 "EventCode": "0x80",
89 "EventName": "UNC_P_POWER_STATE_OCCUPANCY.CORES_C0", 97 "EventName": "UNC_P_POWER_STATE_OCCUPANCY.CORES_C0",
90 "Filter": "occ_sel=1", 98 "Filter": "occ_sel=1",
91 "MetricExpr": "(UNC_P_POWER_STATE_OCCUPANCY.CORES_C0 / UNC_P_CLOCKTICKS) * 100.", 99 "MetricExpr": "(UNC_P_POWER_STATE_OCCUPANCY.CORES_C0 / UNC_P_CLOCKTICKS) * 100.",
100 "MetricName": "power_state_occupancy.cores_c0 %",
92 "PerPkg": "1", 101 "PerPkg": "1",
93 "Unit": "PCU" 102 "Unit": "PCU"
94 }, 103 },
95 { 104 {
96 "BriefDescription": "This is an occupancy event that tracks the number of cores that are in the chosen C-State. It can be used by itself to get the average number of cores in that C-state with threshholding to generate histograms, or with other PCU events and occupancy triggering to capture other details. Derived from unc_p_power_state_occupancy.cores_c3", 105 "BriefDescription": "This is an occupancy event that tracks the number of cores that are in C3. It can be used by itself to get the average number of cores in C0, with threshholding to generate histograms, or with other PCU events and occupancy triggering to capture other details",
97 "Counter": "0,1,2,3", 106 "Counter": "0,1,2,3",
98 "EventCode": "0x80", 107 "EventCode": "0x80",
99 "EventName": "UNC_P_POWER_STATE_OCCUPANCY.CORES_C3", 108 "EventName": "UNC_P_POWER_STATE_OCCUPANCY.CORES_C3",
100 "Filter": "occ_sel=2", 109 "Filter": "occ_sel=2",
101 "MetricExpr": "(UNC_P_POWER_STATE_OCCUPANCY.CORES_C3 / UNC_P_CLOCKTICKS) * 100.", 110 "MetricExpr": "(UNC_P_POWER_STATE_OCCUPANCY.CORES_C3 / UNC_P_CLOCKTICKS) * 100.",
111 "MetricName": "power_state_occupancy.cores_c3 %",
102 "PerPkg": "1", 112 "PerPkg": "1",
103 "Unit": "PCU" 113 "Unit": "PCU"
104 }, 114 },
105 { 115 {
106 "BriefDescription": "This is an occupancy event that tracks the number of cores that are in the chosen C-State. It can be used by itself to get the average number of cores in that C-state with threshholding to generate histograms, or with other PCU events and occupancy triggering to capture other details. Derived from unc_p_power_state_occupancy.cores_c6", 116 "BriefDescription": "This is an occupancy event that tracks the number of cores that are in C6. It can be used by itself to get the average number of cores in C0, with threshholding to generate histograms, or with other PCU events ",
107 "Counter": "0,1,2,3", 117 "Counter": "0,1,2,3",
108 "EventCode": "0x80", 118 "EventCode": "0x80",
109 "EventName": "UNC_P_POWER_STATE_OCCUPANCY.CORES_C6", 119 "EventName": "UNC_P_POWER_STATE_OCCUPANCY.CORES_C6",
110 "Filter": "occ_sel=3", 120 "Filter": "occ_sel=3",
111 "MetricExpr": "(UNC_P_POWER_STATE_OCCUPANCY.CORES_C6 / UNC_P_CLOCKTICKS) * 100.", 121 "MetricExpr": "(UNC_P_POWER_STATE_OCCUPANCY.CORES_C6 / UNC_P_CLOCKTICKS) * 100.",
122 "MetricName": "power_state_occupancy.cores_c6 %",
112 "PerPkg": "1", 123 "PerPkg": "1",
113 "Unit": "PCU" 124 "Unit": "PCU"
114 }, 125 },
115 { 126 {
116 "BriefDescription": "Counts the number of cycles that we are in external PROCHOT mode. This mode is triggered when a sensor off the die determines that something off-die (like DRAM) is too hot and must throttle to avoid damaging the chip. Derived from unc_p_prochot_external_cycles", 127 "BriefDescription": "Counts the number of cycles that we are in external PROCHOT mode. This mode is triggered when a sensor off the die determines that something off-die (like DRAM) is too hot and must throttle to avoid damaging the chip",
117 "Counter": "0,1,2,3", 128 "Counter": "0,1,2,3",
118 "EventCode": "0xa", 129 "EventCode": "0xa",
119 "EventName": "UNC_P_PROCHOT_EXTERNAL_CYCLES", 130 "EventName": "UNC_P_PROCHOT_EXTERNAL_CYCLES",
120 "MetricExpr": "(UNC_P_PROCHOT_EXTERNAL_CYCLES / UNC_P_CLOCKTICKS) * 100.", 131 "MetricExpr": "(UNC_P_PROCHOT_EXTERNAL_CYCLES / UNC_P_CLOCKTICKS) * 100.",
132 "MetricName": "prochot_external_cycles %",
121 "PerPkg": "1", 133 "PerPkg": "1",
122 "Unit": "PCU" 134 "Unit": "PCU"
123 }, 135 },
124 { 136 {
125 "BriefDescription": "Counts the number of cycles when thermal conditions are the upper limit on frequency. This is related to the THERMAL_THROTTLE CYCLES_ABOVE_TEMP event, which always counts cycles when we are above the thermal temperature. This event (STRONGEST_UPPER_LIMIT) is sampled at the output of the algorithm that determines the actual frequency, while THERMAL_THROTTLE looks at the input. Derived from unc_p_freq_max_limit_thermal_cycles", 137 "BriefDescription": "Counts the number of cycles when temperature is the upper limit on frequency",
126 "Counter": "0,1,2,3", 138 "Counter": "0,1,2,3",
127 "EventCode": "0x4", 139 "EventCode": "0x4",
128 "EventName": "UNC_P_FREQ_MAX_LIMIT_THERMAL_CYCLES", 140 "EventName": "UNC_P_FREQ_MAX_LIMIT_THERMAL_CYCLES",
129 "MetricExpr": "(UNC_P_FREQ_MAX_LIMIT_THERMAL_CYCLES / UNC_P_CLOCKTICKS) * 100.", 141 "MetricExpr": "(UNC_P_FREQ_MAX_LIMIT_THERMAL_CYCLES / UNC_P_CLOCKTICKS) * 100.",
142 "MetricName": "freq_max_limit_thermal_cycles %",
130 "PerPkg": "1", 143 "PerPkg": "1",
131 "Unit": "PCU" 144 "Unit": "PCU"
132 }, 145 },
133 { 146 {
134 "BriefDescription": "Counts the number of cycles when the OS is the upper limit on frequency. Derived from unc_p_freq_max_os_cycles", 147 "BriefDescription": "Counts the number of cycles when the OS is the upper limit on frequency",
135 "Counter": "0,1,2,3", 148 "Counter": "0,1,2,3",
136 "EventCode": "0x6", 149 "EventCode": "0x6",
137 "EventName": "UNC_P_FREQ_MAX_OS_CYCLES", 150 "EventName": "UNC_P_FREQ_MAX_OS_CYCLES",
138 "MetricExpr": "(UNC_P_FREQ_MAX_OS_CYCLES / UNC_P_CLOCKTICKS) * 100.", 151 "MetricExpr": "(UNC_P_FREQ_MAX_OS_CYCLES / UNC_P_CLOCKTICKS) * 100.",
152 "MetricName": "freq_max_os_cycles %",
139 "PerPkg": "1", 153 "PerPkg": "1",
140 "Unit": "PCU" 154 "Unit": "PCU"
141 }, 155 },
142 { 156 {
143 "BriefDescription": "Counts the number of cycles when power is the upper limit on frequency. Derived from unc_p_freq_max_power_cycles", 157 "BriefDescription": "Counts the number of cycles when power is the upper limit on frequency",
144 "Counter": "0,1,2,3", 158 "Counter": "0,1,2,3",
145 "EventCode": "0x5", 159 "EventCode": "0x5",
146 "EventName": "UNC_P_FREQ_MAX_POWER_CYCLES", 160 "EventName": "UNC_P_FREQ_MAX_POWER_CYCLES",
147 "MetricExpr": "(UNC_P_FREQ_MAX_POWER_CYCLES / UNC_P_CLOCKTICKS) * 100.", 161 "MetricExpr": "(UNC_P_FREQ_MAX_POWER_CYCLES / UNC_P_CLOCKTICKS) * 100.",
162 "MetricName": "freq_max_power_cycles %",
148 "PerPkg": "1", 163 "PerPkg": "1",
149 "Unit": "PCU" 164 "Unit": "PCU"
150 }, 165 },
151 { 166 {
152 "BriefDescription": "Counts the number of cycles when current is the upper limit on frequency. Derived from unc_p_freq_max_current_cycles", 167 "BriefDescription": "Counts the number of cycles when current is the upper limit on frequency",
153 "Counter": "0,1,2,3", 168 "Counter": "0,1,2,3",
154 "EventCode": "0x7", 169 "EventCode": "0x7",
155 "EventName": "UNC_P_FREQ_MAX_CURRENT_CYCLES", 170 "EventName": "UNC_P_FREQ_MAX_CURRENT_CYCLES",
156 "MetricExpr": "(UNC_P_FREQ_MAX_CURRENT_CYCLES / UNC_P_CLOCKTICKS) * 100.", 171 "MetricExpr": "(UNC_P_FREQ_MAX_CURRENT_CYCLES / UNC_P_CLOCKTICKS) * 100.",
172 "MetricName": "freq_max_current_cycles %",
157 "PerPkg": "1", 173 "PerPkg": "1",
158 "Unit": "PCU" 174 "Unit": "PCU"
159 }, 175 },
160 { 176 {
161 "BriefDescription": "Counts the number of cycles when the system is changing frequency. This can not be filtered by thread ID. One can also use it with the occupancy counter that monitors number of threads in C0 to estimate the performance impact that frequency transitions had on the system. Derived from unc_p_freq_trans_cycles", 177 "BriefDescription": "Cycles spent changing Frequency",
162 "Counter": "0,1,2,3", 178 "Counter": "0,1,2,3",
163 "EventCode": "0x60", 179 "EventCode": "0x60",
164 "EventName": "UNC_P_FREQ_TRANS_CYCLES", 180 "EventName": "UNC_P_FREQ_TRANS_CYCLES",
165 "MetricExpr": "(UNC_P_FREQ_TRANS_CYCLES / UNC_P_CLOCKTICKS) * 100.", 181 "MetricExpr": "(UNC_P_FREQ_TRANS_CYCLES / UNC_P_CLOCKTICKS) * 100.",
182 "MetricName": "freq_trans_cycles %",
166 "PerPkg": "1", 183 "PerPkg": "1",
167 "Unit": "PCU" 184 "Unit": "PCU"
168 }, 185 },
@@ -173,6 +190,7 @@
173 "EventName": "UNC_P_FREQ_GE_1200MHZ_CYCLES", 190 "EventName": "UNC_P_FREQ_GE_1200MHZ_CYCLES",
174 "Filter": "filter_band0=1200", 191 "Filter": "filter_band0=1200",
175 "MetricExpr": "(UNC_P_FREQ_GE_1200MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", 192 "MetricExpr": "(UNC_P_FREQ_GE_1200MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.",
193 "MetricName": "freq_ge_1200mhz_cycles %",
176 "PerPkg": "1", 194 "PerPkg": "1",
177 "Unit": "PCU" 195 "Unit": "PCU"
178 }, 196 },
@@ -183,6 +201,7 @@
183 "EventName": "UNC_P_FREQ_GE_2000MHZ_CYCLES", 201 "EventName": "UNC_P_FREQ_GE_2000MHZ_CYCLES",
184 "Filter": "filter_band1=2000", 202 "Filter": "filter_band1=2000",
185 "MetricExpr": "(UNC_P_FREQ_GE_2000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", 203 "MetricExpr": "(UNC_P_FREQ_GE_2000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.",
204 "MetricName": "freq_ge_2000mhz_cycles %",
186 "PerPkg": "1", 205 "PerPkg": "1",
187 "Unit": "PCU" 206 "Unit": "PCU"
188 }, 207 },
@@ -193,6 +212,7 @@
193 "EventName": "UNC_P_FREQ_GE_3000MHZ_CYCLES", 212 "EventName": "UNC_P_FREQ_GE_3000MHZ_CYCLES",
194 "Filter": "filter_band2=3000", 213 "Filter": "filter_band2=3000",
195 "MetricExpr": "(UNC_P_FREQ_GE_3000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", 214 "MetricExpr": "(UNC_P_FREQ_GE_3000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.",
215 "MetricName": "freq_ge_3000mhz_cycles %",
196 "PerPkg": "1", 216 "PerPkg": "1",
197 "Unit": "PCU" 217 "Unit": "PCU"
198 }, 218 },
@@ -203,6 +223,7 @@
203 "EventName": "UNC_P_FREQ_GE_4000MHZ_CYCLES", 223 "EventName": "UNC_P_FREQ_GE_4000MHZ_CYCLES",
204 "Filter": "filter_band3=4000", 224 "Filter": "filter_band3=4000",
205 "MetricExpr": "(UNC_P_FREQ_GE_4000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", 225 "MetricExpr": "(UNC_P_FREQ_GE_4000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.",
226 "MetricName": "freq_ge_4000mhz_cycles %",
206 "PerPkg": "1", 227 "PerPkg": "1",
207 "Unit": "PCU" 228 "Unit": "PCU"
208 }, 229 },
@@ -213,6 +234,7 @@
213 "EventName": "UNC_P_FREQ_GE_1200MHZ_TRANSITIONS", 234 "EventName": "UNC_P_FREQ_GE_1200MHZ_TRANSITIONS",
214 "Filter": "edge=1,filter_band0=1200", 235 "Filter": "edge=1,filter_band0=1200",
215 "MetricExpr": "(UNC_P_FREQ_GE_1200MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", 236 "MetricExpr": "(UNC_P_FREQ_GE_1200MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.",
237 "MetricName": "freq_ge_1200mhz_cycles %",
216 "PerPkg": "1", 238 "PerPkg": "1",
217 "Unit": "PCU" 239 "Unit": "PCU"
218 }, 240 },
@@ -223,6 +245,7 @@
223 "EventName": "UNC_P_FREQ_GE_2000MHZ_TRANSITIONS", 245 "EventName": "UNC_P_FREQ_GE_2000MHZ_TRANSITIONS",
224 "Filter": "edge=1,filter_band1=2000", 246 "Filter": "edge=1,filter_band1=2000",
225 "MetricExpr": "(UNC_P_FREQ_GE_2000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", 247 "MetricExpr": "(UNC_P_FREQ_GE_2000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.",
248 "MetricName": "freq_ge_2000mhz_cycles %",
226 "PerPkg": "1", 249 "PerPkg": "1",
227 "Unit": "PCU" 250 "Unit": "PCU"
228 }, 251 },
@@ -233,6 +256,7 @@
233 "EventName": "UNC_P_FREQ_GE_3000MHZ_TRANSITIONS", 256 "EventName": "UNC_P_FREQ_GE_3000MHZ_TRANSITIONS",
234 "Filter": "edge=1,filter_band2=4000", 257 "Filter": "edge=1,filter_band2=4000",
235 "MetricExpr": "(UNC_P_FREQ_GE_3000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", 258 "MetricExpr": "(UNC_P_FREQ_GE_3000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.",
259 "MetricName": "freq_ge_3000mhz_cycles %",
236 "PerPkg": "1", 260 "PerPkg": "1",
237 "Unit": "PCU" 261 "Unit": "PCU"
238 }, 262 },
@@ -243,6 +267,7 @@
243 "EventName": "UNC_P_FREQ_GE_4000MHZ_TRANSITIONS", 267 "EventName": "UNC_P_FREQ_GE_4000MHZ_TRANSITIONS",
244 "Filter": "edge=1,filter_band3=4000", 268 "Filter": "edge=1,filter_band3=4000",
245 "MetricExpr": "(UNC_P_FREQ_GE_4000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", 269 "MetricExpr": "(UNC_P_FREQ_GE_4000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.",
270 "MetricName": "freq_ge_4000mhz_cycles %",
246 "PerPkg": "1", 271 "PerPkg": "1",
247 "Unit": "PCU" 272 "Unit": "PCU"
248 } 273 }
diff --git a/tools/perf/pmu-events/arch/x86/jaketown/uncore-cache.json b/tools/perf/pmu-events/arch/x86/jaketown/uncore-cache.json
index 2f23cf0129e7..3fa61d962607 100644
--- a/tools/perf/pmu-events/arch/x86/jaketown/uncore-cache.json
+++ b/tools/perf/pmu-events/arch/x86/jaketown/uncore-cache.json
@@ -1,13 +1,13 @@
1[ 1[
2 { 2 {
3 "BriefDescription": "Uncore cache clock ticks. Derived from unc_c_clockticks", 3 "BriefDescription": "Uncore cache clock ticks",
4 "Counter": "0,1,2,3", 4 "Counter": "0,1,2,3",
5 "EventName": "UNC_C_CLOCKTICKS", 5 "EventName": "UNC_C_CLOCKTICKS",
6 "PerPkg": "1", 6 "PerPkg": "1",
7 "Unit": "CBO" 7 "Unit": "CBO"
8 }, 8 },
9 { 9 {
10 "BriefDescription": "All LLC Misses (code+ data rd + data wr - including demand and prefetch). Derived from unc_c_llc_lookup.any", 10 "BriefDescription": "All LLC Misses (code+ data rd + data wr - including demand and prefetch)",
11 "Counter": "0,1", 11 "Counter": "0,1",
12 "EventCode": "0x34", 12 "EventCode": "0x34",
13 "EventName": "UNC_C_LLC_LOOKUP.ANY", 13 "EventName": "UNC_C_LLC_LOOKUP.ANY",
@@ -18,7 +18,7 @@
18 "Unit": "CBO" 18 "Unit": "CBO"
19 }, 19 },
20 { 20 {
21 "BriefDescription": "M line evictions from LLC (writebacks to memory). Derived from unc_c_llc_victims.m_state", 21 "BriefDescription": "M line evictions from LLC (writebacks to memory)",
22 "Counter": "0,1", 22 "Counter": "0,1",
23 "EventCode": "0x37", 23 "EventCode": "0x37",
24 "EventName": "UNC_C_LLC_VICTIMS.M_STATE", 24 "EventName": "UNC_C_LLC_VICTIMS.M_STATE",
@@ -171,11 +171,12 @@
171 "Unit": "CBO" 171 "Unit": "CBO"
172 }, 172 },
173 { 173 {
174 "BriefDescription": "Occupancy counter for all LLC misses; we divide this by UNC_C_CLOCKTICKS to get average Q depth. Derived from unc_c_tor_occupancy.miss_all", 174 "BriefDescription": "Occupancy counter for all LLC misses; we divide this by UNC_C_CLOCKTICKS to get average Q depth",
175 "EventCode": "0x36", 175 "EventCode": "0x36",
176 "EventName": "UNC_C_TOR_OCCUPANCY.MISS_ALL", 176 "EventName": "UNC_C_TOR_OCCUPANCY.MISS_ALL",
177 "Filter": "filter_opc=0x182", 177 "Filter": "filter_opc=0x182",
178 "MetricExpr": "(UNC_C_TOR_OCCUPANCY.MISS_ALL / UNC_C_CLOCKTICKS) * 100.", 178 "MetricExpr": "(UNC_C_TOR_OCCUPANCY.MISS_ALL / UNC_C_CLOCKTICKS) * 100.",
179 "MetricName": "tor_occupancy.miss_all %",
179 "PerPkg": "1", 180 "PerPkg": "1",
180 "UMask": "0xa", 181 "UMask": "0xa",
181 "Unit": "CBO" 182 "Unit": "CBO"
@@ -189,7 +190,7 @@
189 "Unit": "CBO" 190 "Unit": "CBO"
190 }, 191 },
191 { 192 {
192 "BriefDescription": "read requests to home agent. Derived from unc_h_requests.reads", 193 "BriefDescription": "read requests to home agent",
193 "Counter": "0,1,2,3", 194 "Counter": "0,1,2,3",
194 "EventCode": "0x1", 195 "EventCode": "0x1",
195 "EventName": "UNC_H_REQUESTS.READS", 196 "EventName": "UNC_H_REQUESTS.READS",
@@ -198,7 +199,7 @@
198 "Unit": "HA" 199 "Unit": "HA"
199 }, 200 },
200 { 201 {
201 "BriefDescription": "write requests to home agent. Derived from unc_h_requests.writes", 202 "BriefDescription": "write requests to home agent",
202 "Counter": "0,1,2,3", 203 "Counter": "0,1,2,3",
203 "EventCode": "0x1", 204 "EventCode": "0x1",
204 "EventName": "UNC_H_REQUESTS.WRITES", 205 "EventName": "UNC_H_REQUESTS.WRITES",
diff --git a/tools/perf/pmu-events/arch/x86/jaketown/uncore-interconnect.json b/tools/perf/pmu-events/arch/x86/jaketown/uncore-interconnect.json
index 63351876eb57..1b53c0e609e3 100644
--- a/tools/perf/pmu-events/arch/x86/jaketown/uncore-interconnect.json
+++ b/tools/perf/pmu-events/arch/x86/jaketown/uncore-interconnect.json
@@ -1,6 +1,6 @@
1[ 1[
2 { 2 {
3 "BriefDescription": "QPI clock ticks. Used to get percentages of QPI cycles events. Derived from unc_q_clockticks", 3 "BriefDescription": "QPI clock ticks. Used to get percentages of QPI cycles events",
4 "Counter": "0,1,2,3", 4 "Counter": "0,1,2,3",
5 "EventCode": "0x14", 5 "EventCode": "0x14",
6 "EventName": "UNC_Q_CLOCKTICKS", 6 "EventName": "UNC_Q_CLOCKTICKS",
@@ -8,25 +8,27 @@
8 "Unit": "QPI LL" 8 "Unit": "QPI LL"
9 }, 9 },
10 { 10 {
11 "BriefDescription": "Cycles where receiving QPI link is in half-width mode. Derived from unc_q_rxl0p_power_cycles", 11 "BriefDescription": "Cycles where receiving QPI link is in half-width mode",
12 "Counter": "0,1,2,3", 12 "Counter": "0,1,2,3",
13 "EventCode": "0x10", 13 "EventCode": "0x10",
14 "EventName": "UNC_Q_RxL0P_POWER_CYCLES", 14 "EventName": "UNC_Q_RxL0P_POWER_CYCLES",
15 "MetricExpr": "(UNC_Q_RxL0P_POWER_CYCLES / UNC_Q_CLOCKTICKS) * 100.", 15 "MetricExpr": "(UNC_Q_RxL0P_POWER_CYCLES / UNC_Q_CLOCKTICKS) * 100.",
16 "MetricName": "rxl0p_power_cycles %",
16 "PerPkg": "1", 17 "PerPkg": "1",
17 "Unit": "QPI LL" 18 "Unit": "QPI LL"
18 }, 19 },
19 { 20 {
20 "BriefDescription": "Cycles where transmitting QPI link is in half-width mode. Derived from unc_q_txl0p_power_cycles", 21 "BriefDescription": "Cycles where transmitting QPI link is in half-width mode",
21 "Counter": "0,1,2,3", 22 "Counter": "0,1,2,3",
22 "EventCode": "0xd", 23 "EventCode": "0xd",
23 "EventName": "UNC_Q_TxL0P_POWER_CYCLES", 24 "EventName": "UNC_Q_TxL0P_POWER_CYCLES",
24 "MetricExpr": "(UNC_Q_TxL0P_POWER_CYCLES / UNC_Q_CLOCKTICKS) * 100.", 25 "MetricExpr": "(UNC_Q_TxL0P_POWER_CYCLES / UNC_Q_CLOCKTICKS) * 100.",
26 "MetricName": "txl0p_power_cycles %",
25 "PerPkg": "1", 27 "PerPkg": "1",
26 "Unit": "QPI LL" 28 "Unit": "QPI LL"
27 }, 29 },
28 { 30 {
29 "BriefDescription": "Number of data flits transmitted . Derived from unc_q_txl_flits_g0.data", 31 "BriefDescription": "Number of data flits transmitted ",
30 "Counter": "0,1,2,3", 32 "Counter": "0,1,2,3",
31 "EventName": "UNC_Q_TxL_FLITS_G0.DATA", 33 "EventName": "UNC_Q_TxL_FLITS_G0.DATA",
32 "PerPkg": "1", 34 "PerPkg": "1",
@@ -35,7 +37,7 @@
35 "Unit": "QPI LL" 37 "Unit": "QPI LL"
36 }, 38 },
37 { 39 {
38 "BriefDescription": "Number of non data (control) flits transmitted . Derived from unc_q_txl_flits_g0.non_data", 40 "BriefDescription": "Number of non data (control) flits transmitted ",
39 "Counter": "0,1,2,3", 41 "Counter": "0,1,2,3",
40 "EventName": "UNC_Q_TxL_FLITS_G0.NON_DATA", 42 "EventName": "UNC_Q_TxL_FLITS_G0.NON_DATA",
41 "PerPkg": "1", 43 "PerPkg": "1",
diff --git a/tools/perf/pmu-events/arch/x86/jaketown/uncore-memory.json b/tools/perf/pmu-events/arch/x86/jaketown/uncore-memory.json
index e2cf6daa7b37..8551cebeba23 100644
--- a/tools/perf/pmu-events/arch/x86/jaketown/uncore-memory.json
+++ b/tools/perf/pmu-events/arch/x86/jaketown/uncore-memory.json
@@ -1,6 +1,6 @@
1[ 1[
2 { 2 {
3 "BriefDescription": "Memory page activates. Derived from unc_m_act_count", 3 "BriefDescription": "Memory page activates",
4 "Counter": "0,1,2,3", 4 "Counter": "0,1,2,3",
5 "EventCode": "0x1", 5 "EventCode": "0x1",
6 "EventName": "UNC_M_ACT_COUNT", 6 "EventName": "UNC_M_ACT_COUNT",
@@ -11,7 +11,7 @@
11 "BriefDescription": "read requests to memory controller. Derived from unc_m_cas_count.rd", 11 "BriefDescription": "read requests to memory controller. Derived from unc_m_cas_count.rd",
12 "Counter": "0,1,2,3", 12 "Counter": "0,1,2,3",
13 "EventCode": "0x4", 13 "EventCode": "0x4",
14 "EventName": "UNC_M_CAS_COUNT.RD", 14 "EventName": "LLC_MISSES.MEM_READ",
15 "PerPkg": "1", 15 "PerPkg": "1",
16 "UMask": "0x3", 16 "UMask": "0x3",
17 "Unit": "iMC" 17 "Unit": "iMC"
@@ -20,47 +20,50 @@
20 "BriefDescription": "write requests to memory controller. Derived from unc_m_cas_count.wr", 20 "BriefDescription": "write requests to memory controller. Derived from unc_m_cas_count.wr",
21 "Counter": "0,1,2,3", 21 "Counter": "0,1,2,3",
22 "EventCode": "0x4", 22 "EventCode": "0x4",
23 "EventName": "UNC_M_CAS_COUNT.WR", 23 "EventName": "LLC_MISSES.MEM_WRITE",
24 "PerPkg": "1", 24 "PerPkg": "1",
25 "UMask": "0xc", 25 "UMask": "0xc",
26 "Unit": "iMC" 26 "Unit": "iMC"
27 }, 27 },
28 { 28 {
29 "BriefDescription": "Memory controller clock ticks. Used to get percentages of memory controller cycles events. Derived from unc_m_clockticks", 29 "BriefDescription": "Memory controller clock ticks. Used to get percentages of memory controller cycles events",
30 "Counter": "0,1,2,3", 30 "Counter": "0,1,2,3",
31 "EventName": "UNC_M_CLOCKTICKS", 31 "EventName": "UNC_M_CLOCKTICKS",
32 "PerPkg": "1", 32 "PerPkg": "1",
33 "Unit": "iMC" 33 "Unit": "iMC"
34 }, 34 },
35 { 35 {
36 "BriefDescription": "Cycles where DRAM ranks are in power down (CKE) mode. Derived from unc_m_power_channel_ppd", 36 "BriefDescription": "Cycles where DRAM ranks are in power down (CKE) mode",
37 "Counter": "0,1,2,3", 37 "Counter": "0,1,2,3",
38 "EventCode": "0x85", 38 "EventCode": "0x85",
39 "EventName": "UNC_M_POWER_CHANNEL_PPD", 39 "EventName": "UNC_M_POWER_CHANNEL_PPD",
40 "MetricExpr": "(UNC_M_POWER_CHANNEL_PPD / UNC_M_CLOCKTICKS) * 100.", 40 "MetricExpr": "(UNC_M_POWER_CHANNEL_PPD / UNC_M_CLOCKTICKS) * 100.",
41 "MetricName": "power_channel_ppd %",
41 "PerPkg": "1", 42 "PerPkg": "1",
42 "Unit": "iMC" 43 "Unit": "iMC"
43 }, 44 },
44 { 45 {
45 "BriefDescription": "Cycles all ranks are in critical thermal throttle. Derived from unc_m_power_critical_throttle_cycles", 46 "BriefDescription": "Cycles all ranks are in critical thermal throttle",
46 "Counter": "0,1,2,3", 47 "Counter": "0,1,2,3",
47 "EventCode": "0x86", 48 "EventCode": "0x86",
48 "EventName": "UNC_M_POWER_CRITICAL_THROTTLE_CYCLES", 49 "EventName": "UNC_M_POWER_CRITICAL_THROTTLE_CYCLES",
49 "MetricExpr": "(UNC_M_POWER_CRITICAL_THROTTLE_CYCLES / UNC_M_CLOCKTICKS) * 100.", 50 "MetricExpr": "(UNC_M_POWER_CRITICAL_THROTTLE_CYCLES / UNC_M_CLOCKTICKS) * 100.",
51 "MetricName": "power_critical_throttle_cycles %",
50 "PerPkg": "1", 52 "PerPkg": "1",
51 "Unit": "iMC" 53 "Unit": "iMC"
52 }, 54 },
53 { 55 {
54 "BriefDescription": "Cycles Memory is in self refresh power mode. Derived from unc_m_power_self_refresh", 56 "BriefDescription": "Cycles Memory is in self refresh power mode",
55 "Counter": "0,1,2,3", 57 "Counter": "0,1,2,3",
56 "EventCode": "0x43", 58 "EventCode": "0x43",
57 "EventName": "UNC_M_POWER_SELF_REFRESH", 59 "EventName": "UNC_M_POWER_SELF_REFRESH",
58 "MetricExpr": "(UNC_M_POWER_SELF_REFRESH / UNC_M_CLOCKTICKS) * 100.", 60 "MetricExpr": "(UNC_M_POWER_SELF_REFRESH / UNC_M_CLOCKTICKS) * 100.",
61 "MetricName": "power_self_refresh %",
59 "PerPkg": "1", 62 "PerPkg": "1",
60 "Unit": "iMC" 63 "Unit": "iMC"
61 }, 64 },
62 { 65 {
63 "BriefDescription": "Memory page conflicts. Derived from unc_m_pre_count.page_miss", 66 "BriefDescription": "Memory page conflicts",
64 "Counter": "0,1,2,3", 67 "Counter": "0,1,2,3",
65 "EventCode": "0x2", 68 "EventCode": "0x2",
66 "EventName": "UNC_M_PRE_COUNT.PAGE_MISS", 69 "EventName": "UNC_M_PRE_COUNT.PAGE_MISS",
@@ -69,7 +72,7 @@
69 "Unit": "iMC" 72 "Unit": "iMC"
70 }, 73 },
71 { 74 {
72 "BriefDescription": "Occupancy counter for memory read queue. Derived from unc_m_rpq_occupancy", 75 "BriefDescription": "Occupancy counter for memory read queue",
73 "Counter": "0,1,2,3", 76 "Counter": "0,1,2,3",
74 "EventCode": "0x80", 77 "EventCode": "0x80",
75 "EventName": "UNC_M_RPQ_OCCUPANCY", 78 "EventName": "UNC_M_RPQ_OCCUPANCY",
diff --git a/tools/perf/pmu-events/arch/x86/jaketown/uncore-power.json b/tools/perf/pmu-events/arch/x86/jaketown/uncore-power.json
index bbe36d547386..16034bfd06dd 100644
--- a/tools/perf/pmu-events/arch/x86/jaketown/uncore-power.json
+++ b/tools/perf/pmu-events/arch/x86/jaketown/uncore-power.json
@@ -1,44 +1,48 @@
1[ 1[
2 { 2 {
3 "BriefDescription": "PCU clock ticks. Use to get percentages of PCU cycles events. Derived from unc_p_clockticks", 3 "BriefDescription": "PCU clock ticks. Use to get percentages of PCU cycles events",
4 "Counter": "0,1,2,3", 4 "Counter": "0,1,2,3",
5 "EventName": "UNC_P_CLOCKTICKS", 5 "EventName": "UNC_P_CLOCKTICKS",
6 "PerPkg": "1", 6 "PerPkg": "1",
7 "Unit": "PCU" 7 "Unit": "PCU"
8 }, 8 },
9 { 9 {
10 "BriefDescription": "Counts the number of cycles that the uncore was running at a frequency greater than or equal to the frequency that is configured in the filter. (filter_band0=XXX with XXX in 100Mhz units). One can also use inversion (filter_inv=1) to track cycles when we were less than the configured frequency. Derived from unc_p_freq_band0_cycles", 10 "BriefDescription": "Counts the number of cycles that the uncore was running at a frequency greater than or equal to the frequency that is configured in the filter. (filter_band0=XXX with XXX in 100Mhz units). One can also use inversion (filter_inv=1) to track cycles when we were less than the configured frequency",
11 "Counter": "0,1,2,3", 11 "Counter": "0,1,2,3",
12 "EventCode": "0xb", 12 "EventCode": "0xb",
13 "EventName": "UNC_P_FREQ_BAND0_CYCLES", 13 "EventName": "UNC_P_FREQ_BAND0_CYCLES",
14 "MetricExpr": "(UNC_P_FREQ_BAND0_CYCLES / UNC_P_CLOCKTICKS) * 100.", 14 "MetricExpr": "(UNC_P_FREQ_BAND0_CYCLES / UNC_P_CLOCKTICKS) * 100.",
15 "MetricName": "freq_band0_cycles %",
15 "PerPkg": "1", 16 "PerPkg": "1",
16 "Unit": "PCU" 17 "Unit": "PCU"
17 }, 18 },
18 { 19 {
19 "BriefDescription": "Counts the number of cycles that the uncore was running at a frequency greater than or equal to the frequency that is configured in the filter. (filter_band1=XXX with XXX in 100Mhz units). One can also use inversion (filter_inv=1) to track cycles when we were less than the configured frequency. Derived from unc_p_freq_band1_cycles", 20 "BriefDescription": "Counts the number of cycles that the uncore was running at a frequency greater than or equal to the frequency that is configured in the filter. (filter_band1=XXX with XXX in 100Mhz units). One can also use inversion (filter_inv=1) to track cycles when we were less than the configured frequency",
20 "Counter": "0,1,2,3", 21 "Counter": "0,1,2,3",
21 "EventCode": "0xc", 22 "EventCode": "0xc",
22 "EventName": "UNC_P_FREQ_BAND1_CYCLES", 23 "EventName": "UNC_P_FREQ_BAND1_CYCLES",
23 "MetricExpr": "(UNC_P_FREQ_BAND1_CYCLES / UNC_P_CLOCKTICKS) * 100.", 24 "MetricExpr": "(UNC_P_FREQ_BAND1_CYCLES / UNC_P_CLOCKTICKS) * 100.",
25 "MetricName": "freq_band1_cycles %",
24 "PerPkg": "1", 26 "PerPkg": "1",
25 "Unit": "PCU" 27 "Unit": "PCU"
26 }, 28 },
27 { 29 {
28 "BriefDescription": "Counts the number of cycles that the uncore was running at a frequency greater than or equal to the frequency that is configured in the filter. (filter_band2=XXX with XXX in 100Mhz units). One can also use inversion (filter_inv=1) to track cycles when we were less than the configured frequency. Derived from unc_p_freq_band2_cycles", 30 "BriefDescription": "Counts the number of cycles that the uncore was running at a frequency greater than or equal to the frequency that is configured in the filter. (filter_band2=XXX with XXX in 100Mhz units). One can also use inversion (filter_inv=1) to track cycles when we were less than the configured frequency",
29 "Counter": "0,1,2,3", 31 "Counter": "0,1,2,3",
30 "EventCode": "0xd", 32 "EventCode": "0xd",
31 "EventName": "UNC_P_FREQ_BAND2_CYCLES", 33 "EventName": "UNC_P_FREQ_BAND2_CYCLES",
32 "MetricExpr": "(UNC_P_FREQ_BAND2_CYCLES / UNC_P_CLOCKTICKS) * 100.", 34 "MetricExpr": "(UNC_P_FREQ_BAND2_CYCLES / UNC_P_CLOCKTICKS) * 100.",
35 "MetricName": "freq_band2_cycles %",
33 "PerPkg": "1", 36 "PerPkg": "1",
34 "Unit": "PCU" 37 "Unit": "PCU"
35 }, 38 },
36 { 39 {
37 "BriefDescription": "Counts the number of cycles that the uncore was running at a frequency greater than or equal to the frequency that is configured in the filter. (filter_band3=XXX, with XXX in 100Mhz units). One can also use inversion (filter_inv=1) to track cycles when we were less than the configured frequency. Derived from unc_p_freq_band3_cycles", 40 "BriefDescription": "Counts the number of cycles that the uncore was running at a frequency greater than or equal to the frequency that is configured in the filter. (filter_band3=XXX, with XXX in 100Mhz units). One can also use inversion (filter_inv=1) to track cycles when we were less than the configured frequency",
38 "Counter": "0,1,2,3", 41 "Counter": "0,1,2,3",
39 "EventCode": "0xe", 42 "EventCode": "0xe",
40 "EventName": "UNC_P_FREQ_BAND3_CYCLES", 43 "EventName": "UNC_P_FREQ_BAND3_CYCLES",
41 "MetricExpr": "(UNC_P_FREQ_BAND3_CYCLES / UNC_P_CLOCKTICKS) * 100.", 44 "MetricExpr": "(UNC_P_FREQ_BAND3_CYCLES / UNC_P_CLOCKTICKS) * 100.",
45 "MetricName": "freq_band3_cycles %",
42 "PerPkg": "1", 46 "PerPkg": "1",
43 "Unit": "PCU" 47 "Unit": "PCU"
44 }, 48 },
@@ -49,6 +53,7 @@
49 "EventName": "UNC_P_FREQ_BAND0_TRANSITIONS", 53 "EventName": "UNC_P_FREQ_BAND0_TRANSITIONS",
50 "Filter": "edge=1", 54 "Filter": "edge=1",
51 "MetricExpr": "(UNC_P_FREQ_BAND0_CYCLES / UNC_P_CLOCKTICKS) * 100.", 55 "MetricExpr": "(UNC_P_FREQ_BAND0_CYCLES / UNC_P_CLOCKTICKS) * 100.",
56 "MetricName": "freq_band0_cycles %",
52 "PerPkg": "1", 57 "PerPkg": "1",
53 "Unit": "PCU" 58 "Unit": "PCU"
54 }, 59 },
@@ -59,6 +64,7 @@
59 "EventName": "UNC_P_FREQ_BAND1_TRANSITIONS", 64 "EventName": "UNC_P_FREQ_BAND1_TRANSITIONS",
60 "Filter": "edge=1", 65 "Filter": "edge=1",
61 "MetricExpr": "(UNC_P_FREQ_BAND1_CYCLES / UNC_P_CLOCKTICKS) * 100.", 66 "MetricExpr": "(UNC_P_FREQ_BAND1_CYCLES / UNC_P_CLOCKTICKS) * 100.",
67 "MetricName": "freq_band1_cycles %",
62 "PerPkg": "1", 68 "PerPkg": "1",
63 "Unit": "PCU" 69 "Unit": "PCU"
64 }, 70 },
@@ -69,6 +75,7 @@
69 "EventName": "UNC_P_FREQ_BAND2_TRANSITIONS", 75 "EventName": "UNC_P_FREQ_BAND2_TRANSITIONS",
70 "Filter": "edge=1", 76 "Filter": "edge=1",
71 "MetricExpr": "(UNC_P_FREQ_BAND2_CYCLES / UNC_P_CLOCKTICKS) * 100.", 77 "MetricExpr": "(UNC_P_FREQ_BAND2_CYCLES / UNC_P_CLOCKTICKS) * 100.",
78 "MetricName": "freq_band2_cycles %",
72 "PerPkg": "1", 79 "PerPkg": "1",
73 "Unit": "PCU" 80 "Unit": "PCU"
74 }, 81 },
@@ -79,89 +86,99 @@
79 "EventName": "UNC_P_FREQ_BAND3_TRANSITIONS", 86 "EventName": "UNC_P_FREQ_BAND3_TRANSITIONS",
80 "Filter": "edge=1", 87 "Filter": "edge=1",
81 "MetricExpr": "(UNC_P_FREQ_BAND3_CYCLES / UNC_P_CLOCKTICKS) * 100.", 88 "MetricExpr": "(UNC_P_FREQ_BAND3_CYCLES / UNC_P_CLOCKTICKS) * 100.",
89 "MetricName": "freq_band3_cycles %",
82 "PerPkg": "1", 90 "PerPkg": "1",
83 "Unit": "PCU" 91 "Unit": "PCU"
84 }, 92 },
85 { 93 {
86 "BriefDescription": "This is an occupancy event that tracks the number of cores that are in C0. It can be used by itself to get the average number of cores in C0, with threshholding to generate histograms, or with other PCU events and occupancy triggering to capture other details. Derived from unc_p_power_state_occupancy.cores_c0", 94 "BriefDescription": "This is an occupancy event that tracks the number of cores that are in C0. It can be used by itself to get the average number of cores in C0, with threshholding to generate histograms, or with other PCU events and occupancy triggering to capture other details",
87 "Counter": "0,1,2,3", 95 "Counter": "0,1,2,3",
88 "EventCode": "0x80", 96 "EventCode": "0x80",
89 "EventName": "UNC_P_POWER_STATE_OCCUPANCY.CORES_C0", 97 "EventName": "UNC_P_POWER_STATE_OCCUPANCY.CORES_C0",
90 "Filter": "occ_sel=1", 98 "Filter": "occ_sel=1",
91 "MetricExpr": "(UNC_P_POWER_STATE_OCCUPANCY.CORES_C0 / UNC_P_CLOCKTICKS) * 100.", 99 "MetricExpr": "(UNC_P_POWER_STATE_OCCUPANCY.CORES_C0 / UNC_P_CLOCKTICKS) * 100.",
100 "MetricName": "power_state_occupancy.cores_c0 %",
92 "PerPkg": "1", 101 "PerPkg": "1",
93 "Unit": "PCU" 102 "Unit": "PCU"
94 }, 103 },
95 { 104 {
96 "BriefDescription": "This is an occupancy event that tracks the number of cores that are in C3. It can be used by itself to get the average number of cores in C0, with threshholding to generate histograms, or with other PCU events and occupancy triggering to capture other details. Derived from unc_p_power_state_occupancy.cores_c3", 105 "BriefDescription": "This is an occupancy event that tracks the number of cores that are in C3. It can be used by itself to get the average number of cores in C0, with threshholding to generate histograms, or with other PCU events and occupancy triggering to capture other details",
97 "Counter": "0,1,2,3", 106 "Counter": "0,1,2,3",
98 "EventCode": "0x80", 107 "EventCode": "0x80",
99 "EventName": "UNC_P_POWER_STATE_OCCUPANCY.CORES_C3", 108 "EventName": "UNC_P_POWER_STATE_OCCUPANCY.CORES_C3",
100 "Filter": "occ_sel=2", 109 "Filter": "occ_sel=2",
101 "MetricExpr": "(UNC_P_POWER_STATE_OCCUPANCY.CORES_C3 / UNC_P_CLOCKTICKS) * 100.", 110 "MetricExpr": "(UNC_P_POWER_STATE_OCCUPANCY.CORES_C3 / UNC_P_CLOCKTICKS) * 100.",
111 "MetricName": "power_state_occupancy.cores_c3 %",
102 "PerPkg": "1", 112 "PerPkg": "1",
103 "Unit": "PCU" 113 "Unit": "PCU"
104 }, 114 },
105 { 115 {
106 "BriefDescription": "This is an occupancy event that tracks the number of cores that are in C6. It can be used by itself to get the average number of cores in C0, with threshholding to generate histograms, or with other PCU events . Derived from unc_p_power_state_occupancy.cores_c6", 116 "BriefDescription": "This is an occupancy event that tracks the number of cores that are in C6. It can be used by itself to get the average number of cores in C0, with threshholding to generate histograms, or with other PCU events ",
107 "Counter": "0,1,2,3", 117 "Counter": "0,1,2,3",
108 "EventCode": "0x80", 118 "EventCode": "0x80",
109 "EventName": "UNC_P_POWER_STATE_OCCUPANCY.CORES_C6", 119 "EventName": "UNC_P_POWER_STATE_OCCUPANCY.CORES_C6",
110 "Filter": "occ_sel=3", 120 "Filter": "occ_sel=3",
111 "MetricExpr": "(UNC_P_POWER_STATE_OCCUPANCY.CORES_C6 / UNC_P_CLOCKTICKS) * 100.", 121 "MetricExpr": "(UNC_P_POWER_STATE_OCCUPANCY.CORES_C6 / UNC_P_CLOCKTICKS) * 100.",
122 "MetricName": "power_state_occupancy.cores_c6 %",
112 "PerPkg": "1", 123 "PerPkg": "1",
113 "Unit": "PCU" 124 "Unit": "PCU"
114 }, 125 },
115 { 126 {
116 "BriefDescription": "Counts the number of cycles that we are in external PROCHOT mode. This mode is triggered when a sensor off the die determines that something off-die (like DRAM) is too hot and must throttle to avoid damaging the chip. Derived from unc_p_prochot_external_cycles", 127 "BriefDescription": "Counts the number of cycles that we are in external PROCHOT mode. This mode is triggered when a sensor off the die determines that something off-die (like DRAM) is too hot and must throttle to avoid damaging the chip",
117 "Counter": "0,1,2,3", 128 "Counter": "0,1,2,3",
118 "EventCode": "0xa", 129 "EventCode": "0xa",
119 "EventName": "UNC_P_PROCHOT_EXTERNAL_CYCLES", 130 "EventName": "UNC_P_PROCHOT_EXTERNAL_CYCLES",
120 "MetricExpr": "(UNC_P_PROCHOT_EXTERNAL_CYCLES / UNC_P_CLOCKTICKS) * 100.", 131 "MetricExpr": "(UNC_P_PROCHOT_EXTERNAL_CYCLES / UNC_P_CLOCKTICKS) * 100.",
132 "MetricName": "prochot_external_cycles %",
121 "PerPkg": "1", 133 "PerPkg": "1",
122 "Unit": "PCU" 134 "Unit": "PCU"
123 }, 135 },
124 { 136 {
125 "BriefDescription": "Counts the number of cycles when temperature is the upper limit on frequency. Derived from unc_p_freq_max_limit_thermal_cycles", 137 "BriefDescription": "Counts the number of cycles when temperature is the upper limit on frequency",
126 "Counter": "0,1,2,3", 138 "Counter": "0,1,2,3",
127 "EventCode": "0x4", 139 "EventCode": "0x4",
128 "EventName": "UNC_P_FREQ_MAX_LIMIT_THERMAL_CYCLES", 140 "EventName": "UNC_P_FREQ_MAX_LIMIT_THERMAL_CYCLES",
129 "MetricExpr": "(UNC_P_FREQ_MAX_LIMIT_THERMAL_CYCLES / UNC_P_CLOCKTICKS) * 100.", 141 "MetricExpr": "(UNC_P_FREQ_MAX_LIMIT_THERMAL_CYCLES / UNC_P_CLOCKTICKS) * 100.",
142 "MetricName": "freq_max_limit_thermal_cycles %",
130 "PerPkg": "1", 143 "PerPkg": "1",
131 "Unit": "PCU" 144 "Unit": "PCU"
132 }, 145 },
133 { 146 {
134 "BriefDescription": "Counts the number of cycles when the OS is the upper limit on frequency. Derived from unc_p_freq_max_os_cycles", 147 "BriefDescription": "Counts the number of cycles when the OS is the upper limit on frequency",
135 "Counter": "0,1,2,3", 148 "Counter": "0,1,2,3",
136 "EventCode": "0x6", 149 "EventCode": "0x6",
137 "EventName": "UNC_P_FREQ_MAX_OS_CYCLES", 150 "EventName": "UNC_P_FREQ_MAX_OS_CYCLES",
138 "MetricExpr": "(UNC_P_FREQ_MAX_OS_CYCLES / UNC_P_CLOCKTICKS) * 100.", 151 "MetricExpr": "(UNC_P_FREQ_MAX_OS_CYCLES / UNC_P_CLOCKTICKS) * 100.",
152 "MetricName": "freq_max_os_cycles %",
139 "PerPkg": "1", 153 "PerPkg": "1",
140 "Unit": "PCU" 154 "Unit": "PCU"
141 }, 155 },
142 { 156 {
143 "BriefDescription": "Counts the number of cycles when power is the upper limit on frequency. Derived from unc_p_freq_max_power_cycles", 157 "BriefDescription": "Counts the number of cycles when power is the upper limit on frequency",
144 "Counter": "0,1,2,3", 158 "Counter": "0,1,2,3",
145 "EventCode": "0x5", 159 "EventCode": "0x5",
146 "EventName": "UNC_P_FREQ_MAX_POWER_CYCLES", 160 "EventName": "UNC_P_FREQ_MAX_POWER_CYCLES",
147 "MetricExpr": "(UNC_P_FREQ_MAX_POWER_CYCLES / UNC_P_CLOCKTICKS) * 100.", 161 "MetricExpr": "(UNC_P_FREQ_MAX_POWER_CYCLES / UNC_P_CLOCKTICKS) * 100.",
162 "MetricName": "freq_max_power_cycles %",
148 "PerPkg": "1", 163 "PerPkg": "1",
149 "Unit": "PCU" 164 "Unit": "PCU"
150 }, 165 },
151 { 166 {
152 "BriefDescription": "Counts the number of cycles when current is the upper limit on frequency. Derived from unc_p_freq_max_current_cycles", 167 "BriefDescription": "Counts the number of cycles when current is the upper limit on frequency",
153 "Counter": "0,1,2,3", 168 "Counter": "0,1,2,3",
154 "EventCode": "0x7", 169 "EventCode": "0x7",
155 "EventName": "UNC_P_FREQ_MAX_CURRENT_CYCLES", 170 "EventName": "UNC_P_FREQ_MAX_CURRENT_CYCLES",
156 "MetricExpr": "(UNC_P_FREQ_MAX_CURRENT_CYCLES / UNC_P_CLOCKTICKS) * 100.", 171 "MetricExpr": "(UNC_P_FREQ_MAX_CURRENT_CYCLES / UNC_P_CLOCKTICKS) * 100.",
172 "MetricName": "freq_max_current_cycles %",
157 "PerPkg": "1", 173 "PerPkg": "1",
158 "Unit": "PCU" 174 "Unit": "PCU"
159 }, 175 },
160 { 176 {
161 "BriefDescription": "Cycles spent changing Frequency. Derived from unc_p_freq_trans_cycles", 177 "BriefDescription": "Cycles spent changing Frequency",
162 "Counter": "0,1,2,3", 178 "Counter": "0,1,2,3",
163 "EventName": "UNC_P_FREQ_TRANS_CYCLES", 179 "EventName": "UNC_P_FREQ_TRANS_CYCLES",
164 "MetricExpr": "(UNC_P_FREQ_TRANS_CYCLES / UNC_P_CLOCKTICKS) * 100.", 180 "MetricExpr": "(UNC_P_FREQ_TRANS_CYCLES / UNC_P_CLOCKTICKS) * 100.",
181 "MetricName": "freq_trans_cycles %",
165 "PerPkg": "1", 182 "PerPkg": "1",
166 "Unit": "PCU" 183 "Unit": "PCU"
167 }, 184 },
@@ -172,6 +189,7 @@
172 "EventName": "UNC_P_FREQ_GE_1200MHZ_CYCLES", 189 "EventName": "UNC_P_FREQ_GE_1200MHZ_CYCLES",
173 "Filter": "filter_band0=1200", 190 "Filter": "filter_band0=1200",
174 "MetricExpr": "(UNC_P_FREQ_GE_1200MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", 191 "MetricExpr": "(UNC_P_FREQ_GE_1200MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.",
192 "MetricName": "freq_ge_1200mhz_cycles %",
175 "PerPkg": "1", 193 "PerPkg": "1",
176 "Unit": "PCU" 194 "Unit": "PCU"
177 }, 195 },
@@ -182,6 +200,7 @@
182 "EventName": "UNC_P_FREQ_GE_2000MHZ_CYCLES", 200 "EventName": "UNC_P_FREQ_GE_2000MHZ_CYCLES",
183 "Filter": "filter_band1=2000", 201 "Filter": "filter_band1=2000",
184 "MetricExpr": "(UNC_P_FREQ_GE_2000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", 202 "MetricExpr": "(UNC_P_FREQ_GE_2000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.",
203 "MetricName": "freq_ge_2000mhz_cycles %",
185 "PerPkg": "1", 204 "PerPkg": "1",
186 "Unit": "PCU" 205 "Unit": "PCU"
187 }, 206 },
@@ -192,6 +211,7 @@
192 "EventName": "UNC_P_FREQ_GE_3000MHZ_CYCLES", 211 "EventName": "UNC_P_FREQ_GE_3000MHZ_CYCLES",
193 "Filter": "filter_band2=3000", 212 "Filter": "filter_band2=3000",
194 "MetricExpr": "(UNC_P_FREQ_GE_3000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", 213 "MetricExpr": "(UNC_P_FREQ_GE_3000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.",
214 "MetricName": "freq_ge_3000mhz_cycles %",
195 "PerPkg": "1", 215 "PerPkg": "1",
196 "Unit": "PCU" 216 "Unit": "PCU"
197 }, 217 },
@@ -202,6 +222,7 @@
202 "EventName": "UNC_P_FREQ_GE_4000MHZ_CYCLES", 222 "EventName": "UNC_P_FREQ_GE_4000MHZ_CYCLES",
203 "Filter": "filter_band3=4000", 223 "Filter": "filter_band3=4000",
204 "MetricExpr": "(UNC_P_FREQ_GE_4000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", 224 "MetricExpr": "(UNC_P_FREQ_GE_4000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.",
225 "MetricName": "freq_ge_4000mhz_cycles %",
205 "PerPkg": "1", 226 "PerPkg": "1",
206 "Unit": "PCU" 227 "Unit": "PCU"
207 }, 228 },
@@ -212,6 +233,7 @@
212 "EventName": "UNC_P_FREQ_GE_1200MHZ_TRANSITIONS", 233 "EventName": "UNC_P_FREQ_GE_1200MHZ_TRANSITIONS",
213 "Filter": "edge=1,filter_band0=1200", 234 "Filter": "edge=1,filter_band0=1200",
214 "MetricExpr": "(UNC_P_FREQ_GE_1200MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", 235 "MetricExpr": "(UNC_P_FREQ_GE_1200MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.",
236 "MetricName": "freq_ge_1200mhz_cycles %",
215 "PerPkg": "1", 237 "PerPkg": "1",
216 "Unit": "PCU" 238 "Unit": "PCU"
217 }, 239 },
@@ -222,6 +244,7 @@
222 "EventName": "UNC_P_FREQ_GE_2000MHZ_TRANSITIONS", 244 "EventName": "UNC_P_FREQ_GE_2000MHZ_TRANSITIONS",
223 "Filter": "edge=1,filter_band1=2000", 245 "Filter": "edge=1,filter_band1=2000",
224 "MetricExpr": "(UNC_P_FREQ_GE_2000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", 246 "MetricExpr": "(UNC_P_FREQ_GE_2000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.",
247 "MetricName": "freq_ge_2000mhz_cycles %",
225 "PerPkg": "1", 248 "PerPkg": "1",
226 "Unit": "PCU" 249 "Unit": "PCU"
227 }, 250 },
@@ -232,6 +255,7 @@
232 "EventName": "UNC_P_FREQ_GE_3000MHZ_TRANSITIONS", 255 "EventName": "UNC_P_FREQ_GE_3000MHZ_TRANSITIONS",
233 "Filter": "edge=1,filter_band2=4000", 256 "Filter": "edge=1,filter_band2=4000",
234 "MetricExpr": "(UNC_P_FREQ_GE_3000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", 257 "MetricExpr": "(UNC_P_FREQ_GE_3000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.",
258 "MetricName": "freq_ge_3000mhz_cycles %",
235 "PerPkg": "1", 259 "PerPkg": "1",
236 "Unit": "PCU" 260 "Unit": "PCU"
237 }, 261 },
@@ -242,6 +266,7 @@
242 "EventName": "UNC_P_FREQ_GE_4000MHZ_TRANSITIONS", 266 "EventName": "UNC_P_FREQ_GE_4000MHZ_TRANSITIONS",
243 "Filter": "edge=1,filter_band3=4000", 267 "Filter": "edge=1,filter_band3=4000",
244 "MetricExpr": "(UNC_P_FREQ_GE_4000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", 268 "MetricExpr": "(UNC_P_FREQ_GE_4000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.",
269 "MetricName": "freq_ge_4000mhz_cycles %",
245 "PerPkg": "1", 270 "PerPkg": "1",
246 "Unit": "PCU" 271 "Unit": "PCU"
247 } 272 }
diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
index eed09346a72a..81f2ef3b15cf 100644
--- a/tools/perf/pmu-events/jevents.c
+++ b/tools/perf/pmu-events/jevents.c
@@ -291,7 +291,9 @@ static void print_events_table_prefix(FILE *fp, const char *tblname)
291 291
292static int print_events_table_entry(void *data, char *name, char *event, 292static int print_events_table_entry(void *data, char *name, char *event,
293 char *desc, char *long_desc, 293 char *desc, char *long_desc,
294 char *pmu, char *unit, char *perpkg) 294 char *pmu, char *unit, char *perpkg,
295 char *metric_expr,
296 char *metric_name)
295{ 297{
296 struct perf_entry_data *pd = data; 298 struct perf_entry_data *pd = data;
297 FILE *outfp = pd->outfp; 299 FILE *outfp = pd->outfp;
@@ -315,6 +317,10 @@ static int print_events_table_entry(void *data, char *name, char *event,
315 fprintf(outfp, "\t.unit = \"%s\",\n", unit); 317 fprintf(outfp, "\t.unit = \"%s\",\n", unit);
316 if (perpkg) 318 if (perpkg)
317 fprintf(outfp, "\t.perpkg = \"%s\",\n", perpkg); 319 fprintf(outfp, "\t.perpkg = \"%s\",\n", perpkg);
320 if (metric_expr)
321 fprintf(outfp, "\t.metric_expr = \"%s\",\n", metric_expr);
322 if (metric_name)
323 fprintf(outfp, "\t.metric_name = \"%s\",\n", metric_name);
318 fprintf(outfp, "},\n"); 324 fprintf(outfp, "},\n");
319 325
320 return 0; 326 return 0;
@@ -362,7 +368,9 @@ static char *real_event(const char *name, char *event)
362int json_events(const char *fn, 368int json_events(const char *fn,
363 int (*func)(void *data, char *name, char *event, char *desc, 369 int (*func)(void *data, char *name, char *event, char *desc,
364 char *long_desc, 370 char *long_desc,
365 char *pmu, char *unit, char *perpkg), 371 char *pmu, char *unit, char *perpkg,
372 char *metric_expr,
373 char *metric_name),
366 void *data) 374 void *data)
367{ 375{
368 int err = -EIO; 376 int err = -EIO;
@@ -388,6 +396,8 @@ int json_events(const char *fn,
388 char *filter = NULL; 396 char *filter = NULL;
389 char *perpkg = NULL; 397 char *perpkg = NULL;
390 char *unit = NULL; 398 char *unit = NULL;
399 char *metric_expr = NULL;
400 char *metric_name = NULL;
391 unsigned long long eventcode = 0; 401 unsigned long long eventcode = 0;
392 struct msrmap *msr = NULL; 402 struct msrmap *msr = NULL;
393 jsmntok_t *msrval = NULL; 403 jsmntok_t *msrval = NULL;
@@ -398,6 +408,7 @@ int json_events(const char *fn,
398 for (j = 0; j < obj->size; j += 2) { 408 for (j = 0; j < obj->size; j += 2) {
399 jsmntok_t *field, *val; 409 jsmntok_t *field, *val;
400 int nz; 410 int nz;
411 char *s;
401 412
402 field = tok + j; 413 field = tok + j;
403 EXPECT(field->type == JSMN_STRING, tok + j, 414 EXPECT(field->type == JSMN_STRING, tok + j,
@@ -444,7 +455,6 @@ int json_events(const char *fn,
444 NULL); 455 NULL);
445 } else if (json_streq(map, field, "Unit")) { 456 } else if (json_streq(map, field, "Unit")) {
446 const char *ppmu; 457 const char *ppmu;
447 char *s;
448 458
449 ppmu = field_to_perf(unit_to_pmu, map, val); 459 ppmu = field_to_perf(unit_to_pmu, map, val);
450 if (ppmu) { 460 if (ppmu) {
@@ -464,6 +474,12 @@ int json_events(const char *fn,
464 addfield(map, &unit, "", "", val); 474 addfield(map, &unit, "", "", val);
465 } else if (json_streq(map, field, "PerPkg")) { 475 } else if (json_streq(map, field, "PerPkg")) {
466 addfield(map, &perpkg, "", "", val); 476 addfield(map, &perpkg, "", "", val);
477 } else if (json_streq(map, field, "MetricName")) {
478 addfield(map, &metric_name, "", "", val);
479 } else if (json_streq(map, field, "MetricExpr")) {
480 addfield(map, &metric_expr, "", "", val);
481 for (s = metric_expr; *s; s++)
482 *s = tolower(*s);
467 } 483 }
468 /* ignore unknown fields */ 484 /* ignore unknown fields */
469 } 485 }
@@ -488,7 +504,7 @@ int json_events(const char *fn,
488 fixname(name); 504 fixname(name);
489 505
490 err = func(data, name, real_event(name, event), desc, long_desc, 506 err = func(data, name, real_event(name, event), desc, long_desc,
491 pmu, unit, perpkg); 507 pmu, unit, perpkg, metric_expr, metric_name);
492 free(event); 508 free(event);
493 free(desc); 509 free(desc);
494 free(name); 510 free(name);
@@ -498,6 +514,8 @@ int json_events(const char *fn,
498 free(filter); 514 free(filter);
499 free(perpkg); 515 free(perpkg);
500 free(unit); 516 free(unit);
517 free(metric_expr);
518 free(metric_name);
501 if (err) 519 if (err)
502 break; 520 break;
503 tok += j; 521 tok += j;
diff --git a/tools/perf/pmu-events/jevents.h b/tools/perf/pmu-events/jevents.h
index 71e13de31092..611fac01913d 100644
--- a/tools/perf/pmu-events/jevents.h
+++ b/tools/perf/pmu-events/jevents.h
@@ -5,7 +5,8 @@ int json_events(const char *fn,
5 int (*func)(void *data, char *name, char *event, char *desc, 5 int (*func)(void *data, char *name, char *event, char *desc,
6 char *long_desc, 6 char *long_desc,
7 char *pmu, 7 char *pmu,
8 char *unit, char *perpkg), 8 char *unit, char *perpkg, char *metric_expr,
9 char *metric_name),
9 void *data); 10 void *data);
10char *get_cpu_str(void); 11char *get_cpu_str(void);
11 12
diff --git a/tools/perf/pmu-events/pmu-events.h b/tools/perf/pmu-events/pmu-events.h
index c669a3cdb9f0..569eab3688dd 100644
--- a/tools/perf/pmu-events/pmu-events.h
+++ b/tools/perf/pmu-events/pmu-events.h
@@ -13,6 +13,8 @@ struct pmu_event {
13 const char *pmu; 13 const char *pmu;
14 const char *unit; 14 const char *unit;
15 const char *perpkg; 15 const char *perpkg;
16 const char *metric_expr;
17 const char *metric_name;
16}; 18};
17 19
18/* 20/*
diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build
index 1cb3d9b540e9..af58ebc243ef 100644
--- a/tools/perf/tests/Build
+++ b/tools/perf/tests/Build
@@ -38,6 +38,7 @@ perf-y += cpumap.o
38perf-y += stat.o 38perf-y += stat.o
39perf-y += event_update.o 39perf-y += event_update.o
40perf-y += event-times.o 40perf-y += event-times.o
41perf-y += expr.o
41perf-y += backward-ring-buffer.o 42perf-y += backward-ring-buffer.o
42perf-y += sdt.o 43perf-y += sdt.o
43perf-y += is_printable_array.o 44perf-y += is_printable_array.o
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 83c4669cbc5b..86822969e8a8 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -44,6 +44,10 @@ static struct test generic_tests[] = {
44 .func = test__parse_events, 44 .func = test__parse_events,
45 }, 45 },
46 { 46 {
47 .desc = "Simple expression parser",
48 .func = test__expr,
49 },
50 {
47 .desc = "PERF_RECORD_* events & perf_sample fields", 51 .desc = "PERF_RECORD_* events & perf_sample fields",
48 .func = test__PERF_RECORD, 52 .func = test__PERF_RECORD,
49 }, 53 },
diff --git a/tools/perf/tests/expr.c b/tools/perf/tests/expr.c
new file mode 100644
index 000000000000..6c6a3749aaf6
--- /dev/null
+++ b/tools/perf/tests/expr.c
@@ -0,0 +1,56 @@
1#include "util/debug.h"
2#include "util/expr.h"
3#include "tests.h"
4#include <stdlib.h>
5
6static int test(struct parse_ctx *ctx, const char *e, double val2)
7{
8 double val;
9
10 if (expr__parse(&val, ctx, &e))
11 TEST_ASSERT_VAL("parse test failed", 0);
12 TEST_ASSERT_VAL("unexpected value", val == val2);
13 return 0;
14}
15
16int test__expr(int subtest __maybe_unused)
17{
18 const char *p;
19 const char **other;
20 double val;
21 int ret;
22 struct parse_ctx ctx;
23 int num_other;
24
25 expr__ctx_init(&ctx);
26 expr__add_id(&ctx, "FOO", 1);
27 expr__add_id(&ctx, "BAR", 2);
28
29 ret = test(&ctx, "1+1", 2);
30 ret |= test(&ctx, "FOO+BAR", 3);
31 ret |= test(&ctx, "(BAR/2)%2", 1);
32 ret |= test(&ctx, "1 - -4", 5);
33 ret |= test(&ctx, "(FOO-1)*2 + (BAR/2)%2 - -4", 5);
34
35 if (ret)
36 return ret;
37
38 p = "FOO/0";
39 ret = expr__parse(&val, &ctx, &p);
40 TEST_ASSERT_VAL("division by zero", ret == 1);
41
42 p = "BAR/";
43 ret = expr__parse(&val, &ctx, &p);
44 TEST_ASSERT_VAL("missing operand", ret == 1);
45
46 TEST_ASSERT_VAL("find other",
47 expr__find_other("FOO + BAR + BAZ + BOZO", "FOO", &other, &num_other) == 0);
48 TEST_ASSERT_VAL("find other", num_other == 3);
49 TEST_ASSERT_VAL("find other", !strcmp(other[0], "BAR"));
50 TEST_ASSERT_VAL("find other", !strcmp(other[1], "BAZ"));
51 TEST_ASSERT_VAL("find other", !strcmp(other[2], "BOZO"));
52 TEST_ASSERT_VAL("find other", other[3] == NULL);
53 free((void *)other);
54
55 return 0;
56}
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index 1fa9b9d83aa5..631859629403 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -62,6 +62,7 @@ int test__sample_parsing(int subtest);
62int test__keep_tracking(int subtest); 62int test__keep_tracking(int subtest);
63int test__parse_no_sample_id_all(int subtest); 63int test__parse_no_sample_id_all(int subtest);
64int test__dwarf_unwind(int subtest); 64int test__dwarf_unwind(int subtest);
65int test__expr(int subtest);
65int test__hists_filter(int subtest); 66int test__hists_filter(int subtest);
66int test__mmap_thread_lookup(int subtest); 67int test__mmap_thread_lookup(int subtest);
67int test__thread_mg_share(int subtest); 68int test__thread_mg_share(int subtest);
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index fb4f42f1bb38..2ae92da613dd 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -90,6 +90,7 @@ libperf-y += mem-events.o
90libperf-y += vsprintf.o 90libperf-y += vsprintf.o
91libperf-y += drv_configs.o 91libperf-y += drv_configs.o
92libperf-y += time-utils.o 92libperf-y += time-utils.o
93libperf-y += expr-bison.o
93 94
94libperf-$(CONFIG_LIBBPF) += bpf-loader.o 95libperf-$(CONFIG_LIBBPF) += bpf-loader.o
95libperf-$(CONFIG_BPF_PROLOGUE) += bpf-prologue.o 96libperf-$(CONFIG_BPF_PROLOGUE) += bpf-prologue.o
@@ -142,6 +143,10 @@ $(OUTPUT)util/parse-events-bison.c: util/parse-events.y
142 $(call rule_mkdir) 143 $(call rule_mkdir)
143 $(Q)$(call echo-cmd,bison)$(BISON) -v util/parse-events.y -d $(PARSER_DEBUG_BISON) -o $@ -p parse_events_ 144 $(Q)$(call echo-cmd,bison)$(BISON) -v util/parse-events.y -d $(PARSER_DEBUG_BISON) -o $@ -p parse_events_
144 145
146$(OUTPUT)util/expr-bison.c: util/expr.y
147 $(call rule_mkdir)
148 $(Q)$(call echo-cmd,bison)$(BISON) -v util/expr.y -d $(PARSER_DEBUG_BISON) -o $@ -p expr__
149
145$(OUTPUT)util/pmu-flex.c: util/pmu.l $(OUTPUT)util/pmu-bison.c 150$(OUTPUT)util/pmu-flex.c: util/pmu.l $(OUTPUT)util/pmu-bison.c
146 $(call rule_mkdir) 151 $(call rule_mkdir)
147 $(Q)$(call echo-cmd,flex)$(FLEX) -o $@ --header-file=$(OUTPUT)util/pmu-flex.h util/pmu.l 152 $(Q)$(call echo-cmd,flex)$(FLEX) -o $@ --header-file=$(OUTPUT)util/pmu-flex.h util/pmu.l
@@ -154,6 +159,7 @@ CFLAGS_parse-events-flex.o += -w
154CFLAGS_pmu-flex.o += -w 159CFLAGS_pmu-flex.o += -w
155CFLAGS_parse-events-bison.o += -DYYENABLE_NLS=0 -w 160CFLAGS_parse-events-bison.o += -DYYENABLE_NLS=0 -w
156CFLAGS_pmu-bison.o += -DYYENABLE_NLS=0 -DYYLTYPE_IS_TRIVIAL=0 -w 161CFLAGS_pmu-bison.o += -DYYENABLE_NLS=0 -DYYLTYPE_IS_TRIVIAL=0 -w
162CFLAGS_expr-bison.o += -DYYENABLE_NLS=0 -DYYLTYPE_IS_TRIVIAL=0 -w
157 163
158$(OUTPUT)util/parse-events.o: $(OUTPUT)util/parse-events-flex.c $(OUTPUT)util/parse-events-bison.c 164$(OUTPUT)util/parse-events.o: $(OUTPUT)util/parse-events-flex.c $(OUTPUT)util/parse-events-bison.c
159$(OUTPUT)util/pmu.o: $(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-bison.c 165$(OUTPUT)util/pmu.o: $(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-bison.c
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 273f21fa32b5..22cd1dbe724b 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1435,7 +1435,7 @@ int symbol__disassemble(struct symbol *sym, struct map *map, const char *arch_na
1435 snprintf(command, sizeof(command), 1435 snprintf(command, sizeof(command),
1436 "%s %s%s --start-address=0x%016" PRIx64 1436 "%s %s%s --start-address=0x%016" PRIx64
1437 " --stop-address=0x%016" PRIx64 1437 " --stop-address=0x%016" PRIx64
1438 " -l -d %s %s -C %s 2>/dev/null|grep -v %s|expand", 1438 " -l -d %s %s -C %s 2>/dev/null|grep -v %s:|expand",
1439 objdump_path ? objdump_path : "objdump", 1439 objdump_path ? objdump_path : "objdump",
1440 disassembler_style ? "-M " : "", 1440 disassembler_style ? "-M " : "",
1441 disassembler_style ? disassembler_style : "", 1441 disassembler_style ? disassembler_style : "",
@@ -1482,6 +1482,12 @@ int symbol__disassemble(struct symbol *sym, struct map *map, const char *arch_na
1482 1482
1483 nline = 0; 1483 nline = 0;
1484 while (!feof(file)) { 1484 while (!feof(file)) {
1485 /*
1486 * The source code line number (lineno) needs to be kept in
1487 * accross calls to symbol__parse_objdump_line(), so that it
1488 * can associate it with the instructions till the next one.
1489 * See disasm_line__new() and struct disasm_line::line_nr.
1490 */
1485 if (symbol__parse_objdump_line(sym, map, arch, file, privsize, 1491 if (symbol__parse_objdump_line(sym, map, arch, file, privsize,
1486 &lineno) < 0) 1492 &lineno) < 0)
1487 break; 1493 break;
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 175dc2305aa8..9dc7e2d6e48a 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -236,6 +236,10 @@ void perf_evsel__init(struct perf_evsel *evsel,
236 evsel->sample_size = __perf_evsel__sample_size(attr->sample_type); 236 evsel->sample_size = __perf_evsel__sample_size(attr->sample_type);
237 perf_evsel__calc_id_pos(evsel); 237 perf_evsel__calc_id_pos(evsel);
238 evsel->cmdline_group_boundary = false; 238 evsel->cmdline_group_boundary = false;
239 evsel->metric_expr = NULL;
240 evsel->metric_name = NULL;
241 evsel->metric_events = NULL;
242 evsel->collect_stat = false;
239} 243}
240 244
241struct perf_evsel *perf_evsel__new_idx(struct perf_event_attr *attr, int idx) 245struct perf_evsel *perf_evsel__new_idx(struct perf_event_attr *attr, int idx)
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 06ef6f29efa1..d101695c482c 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -131,6 +131,11 @@ struct perf_evsel {
131 bool cmdline_group_boundary; 131 bool cmdline_group_boundary;
132 struct list_head config_terms; 132 struct list_head config_terms;
133 int bpf_fd; 133 int bpf_fd;
134 bool merged_stat;
135 const char * metric_expr;
136 const char * metric_name;
137 struct perf_evsel **metric_events;
138 bool collect_stat;
134}; 139};
135 140
136union u64_swap { 141union u64_swap {
diff --git a/tools/perf/util/expr.h b/tools/perf/util/expr.h
new file mode 100644
index 000000000000..9c2760a1a96e
--- /dev/null
+++ b/tools/perf/util/expr.h
@@ -0,0 +1,25 @@
1#ifndef PARSE_CTX_H
2#define PARSE_CTX_H 1
3
4#define EXPR_MAX_OTHER 8
5#define MAX_PARSE_ID EXPR_MAX_OTHER
6
7struct parse_id {
8 const char *name;
9 double val;
10};
11
12struct parse_ctx {
13 int num_ids;
14 struct parse_id ids[MAX_PARSE_ID];
15};
16
17void expr__ctx_init(struct parse_ctx *ctx);
18void expr__add_id(struct parse_ctx *ctx, const char *id, double val);
19#ifndef IN_EXPR_Y
20int expr__parse(double *final_val, struct parse_ctx *ctx, const char **pp);
21#endif
22int expr__find_other(const char *p, const char *one, const char ***other,
23 int *num_other);
24
25#endif
diff --git a/tools/perf/util/expr.y b/tools/perf/util/expr.y
new file mode 100644
index 000000000000..954556bea36e
--- /dev/null
+++ b/tools/perf/util/expr.y
@@ -0,0 +1,173 @@
1/* Simple expression parser */
2%{
3#include "util.h"
4#include "util/debug.h"
5#define IN_EXPR_Y 1
6#include "expr.h"
7#include <string.h>
8
9#define MAXIDLEN 256
10%}
11
12%pure-parser
13%parse-param { double *final_val }
14%parse-param { struct parse_ctx *ctx }
15%parse-param { const char **pp }
16%lex-param { const char **pp }
17
18%union {
19 double num;
20 char id[MAXIDLEN+1];
21}
22
23%token <num> NUMBER
24%token <id> ID
25%left '|'
26%left '^'
27%left '&'
28%left '-' '+'
29%left '*' '/' '%'
30%left NEG NOT
31%type <num> expr
32
33%{
34static int expr__lex(YYSTYPE *res, const char **pp);
35
36static void expr__error(double *final_val __maybe_unused,
37 struct parse_ctx *ctx __maybe_unused,
38 const char **pp __maybe_unused,
39 const char *s)
40{
41 pr_debug("%s\n", s);
42}
43
44static int lookup_id(struct parse_ctx *ctx, char *id, double *val)
45{
46 int i;
47
48 for (i = 0; i < ctx->num_ids; i++) {
49 if (!strcasecmp(ctx->ids[i].name, id)) {
50 *val = ctx->ids[i].val;
51 return 0;
52 }
53 }
54 return -1;
55}
56
57%}
58%%
59
60all_expr: expr { *final_val = $1; }
61 ;
62
63expr: NUMBER
64 | ID { if (lookup_id(ctx, $1, &$$) < 0) {
65 pr_debug("%s not found", $1);
66 YYABORT;
67 }
68 }
69 | expr '+' expr { $$ = $1 + $3; }
70 | expr '-' expr { $$ = $1 - $3; }
71 | expr '*' expr { $$ = $1 * $3; }
72 | expr '/' expr { if ($3 == 0) YYABORT; $$ = $1 / $3; }
73 | expr '%' expr { if ((long)$3 == 0) YYABORT; $$ = (long)$1 % (long)$3; }
74 | '-' expr %prec NEG { $$ = -$2; }
75 | '(' expr ')' { $$ = $2; }
76 ;
77
78%%
79
80static int expr__symbol(YYSTYPE *res, const char *p, const char **pp)
81{
82 char *dst = res->id;
83 const char *s = p;
84
85 while (isalnum(*p) || *p == '_' || *p == '.') {
86 if (p - s >= MAXIDLEN)
87 return -1;
88 *dst++ = *p++;
89 }
90 *dst = 0;
91 *pp = p;
92 return ID;
93}
94
95static int expr__lex(YYSTYPE *res, const char **pp)
96{
97 int tok;
98 const char *s;
99 const char *p = *pp;
100
101 while (isspace(*p))
102 p++;
103 s = p;
104 switch (*p++) {
105 case 'a' ... 'z':
106 case 'A' ... 'Z':
107 return expr__symbol(res, p - 1, pp);
108 case '0' ... '9': case '.':
109 res->num = strtod(s, (char **)&p);
110 tok = NUMBER;
111 break;
112 default:
113 tok = *s;
114 break;
115 }
116 *pp = p;
117 return tok;
118}
119
120/* Caller must make sure id is allocated */
121void expr__add_id(struct parse_ctx *ctx, const char *name, double val)
122{
123 int idx;
124 assert(ctx->num_ids < MAX_PARSE_ID);
125 idx = ctx->num_ids++;
126 ctx->ids[idx].name = name;
127 ctx->ids[idx].val = val;
128}
129
130void expr__ctx_init(struct parse_ctx *ctx)
131{
132 ctx->num_ids = 0;
133}
134
135int expr__find_other(const char *p, const char *one, const char ***other,
136 int *num_otherp)
137{
138 const char *orig = p;
139 int err = -1;
140 int num_other;
141
142 *other = malloc((EXPR_MAX_OTHER + 1) * sizeof(char *));
143 if (!*other)
144 return -1;
145
146 num_other = 0;
147 for (;;) {
148 YYSTYPE val;
149 int tok = expr__lex(&val, &p);
150 if (tok == 0) {
151 err = 0;
152 break;
153 }
154 if (tok == ID && strcasecmp(one, val.id)) {
155 if (num_other >= EXPR_MAX_OTHER - 1) {
156 pr_debug("Too many extra events in %s\n", orig);
157 break;
158 }
159 (*other)[num_other] = strdup(val.id);
160 if (!(*other)[num_other])
161 return -1;
162 num_other++;
163 }
164 }
165 (*other)[num_other] = NULL;
166 *num_otherp = num_other;
167 if (err) {
168 *num_otherp = 0;
169 free(*other);
170 *other = NULL;
171 }
172 return err;
173}
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 54355d3caf09..6b498aea9fde 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -1255,11 +1255,59 @@ int parse_events_add_pmu(struct parse_events_evlist *data,
1255 evsel->scale = info.scale; 1255 evsel->scale = info.scale;
1256 evsel->per_pkg = info.per_pkg; 1256 evsel->per_pkg = info.per_pkg;
1257 evsel->snapshot = info.snapshot; 1257 evsel->snapshot = info.snapshot;
1258 evsel->metric_expr = info.metric_expr;
1259 evsel->metric_name = info.metric_name;
1258 } 1260 }
1259 1261
1260 return evsel ? 0 : -ENOMEM; 1262 return evsel ? 0 : -ENOMEM;
1261} 1263}
1262 1264
1265int parse_events_multi_pmu_add(struct parse_events_evlist *data,
1266 char *str, struct list_head **listp)
1267{
1268 struct list_head *head;
1269 struct parse_events_term *term;
1270 struct list_head *list;
1271 struct perf_pmu *pmu = NULL;
1272 int ok = 0;
1273
1274 *listp = NULL;
1275 /* Add it for all PMUs that support the alias */
1276 list = malloc(sizeof(struct list_head));
1277 if (!list)
1278 return -1;
1279 INIT_LIST_HEAD(list);
1280 while ((pmu = perf_pmu__scan(pmu)) != NULL) {
1281 struct perf_pmu_alias *alias;
1282
1283 list_for_each_entry(alias, &pmu->aliases, list) {
1284 if (!strcasecmp(alias->name, str)) {
1285 head = malloc(sizeof(struct list_head));
1286 if (!head)
1287 return -1;
1288 INIT_LIST_HEAD(head);
1289 if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
1290 str, 1, false, &str, NULL) < 0)
1291 return -1;
1292 list_add_tail(&term->list, head);
1293
1294 if (!parse_events_add_pmu(data, list,
1295 pmu->name, head)) {
1296 pr_debug("%s -> %s/%s/\n", str,
1297 pmu->name, alias->str);
1298 ok++;
1299 }
1300
1301 parse_events_terms__delete(head);
1302 }
1303 }
1304 }
1305 if (!ok)
1306 return -1;
1307 *listp = list;
1308 return 0;
1309}
1310
1263int parse_events__modifier_group(struct list_head *list, 1311int parse_events__modifier_group(struct list_head *list,
1264 char *event_mod) 1312 char *event_mod)
1265{ 1313{
@@ -2277,7 +2325,7 @@ out_enomem:
2277 * Print the help text for the event symbols: 2325 * Print the help text for the event symbols:
2278 */ 2326 */
2279void print_events(const char *event_glob, bool name_only, bool quiet_flag, 2327void print_events(const char *event_glob, bool name_only, bool quiet_flag,
2280 bool long_desc) 2328 bool long_desc, bool details_flag)
2281{ 2329{
2282 print_symbol_events(event_glob, PERF_TYPE_HARDWARE, 2330 print_symbol_events(event_glob, PERF_TYPE_HARDWARE,
2283 event_symbols_hw, PERF_COUNT_HW_MAX, name_only); 2331 event_symbols_hw, PERF_COUNT_HW_MAX, name_only);
@@ -2287,7 +2335,8 @@ void print_events(const char *event_glob, bool name_only, bool quiet_flag,
2287 2335
2288 print_hwcache_events(event_glob, name_only); 2336 print_hwcache_events(event_glob, name_only);
2289 2337
2290 print_pmu_events(event_glob, name_only, quiet_flag, long_desc); 2338 print_pmu_events(event_glob, name_only, quiet_flag, long_desc,
2339 details_flag);
2291 2340
2292 if (event_glob != NULL) 2341 if (event_glob != NULL)
2293 return; 2342 return;
@@ -2416,6 +2465,31 @@ int parse_events_term__clone(struct parse_events_term **new,
2416 return new_term(new, &temp, term->val.str, term->val.num); 2465 return new_term(new, &temp, term->val.str, term->val.num);
2417} 2466}
2418 2467
2468int parse_events_copy_term_list(struct list_head *old,
2469 struct list_head **new)
2470{
2471 struct parse_events_term *term, *n;
2472 int ret;
2473
2474 if (!old) {
2475 *new = NULL;
2476 return 0;
2477 }
2478
2479 *new = malloc(sizeof(struct list_head));
2480 if (!*new)
2481 return -ENOMEM;
2482 INIT_LIST_HEAD(*new);
2483
2484 list_for_each_entry (term, old, list) {
2485 ret = parse_events_term__clone(&n, term);
2486 if (ret)
2487 return ret;
2488 list_add_tail(&n->list, *new);
2489 }
2490 return 0;
2491}
2492
2419void parse_events_terms__purge(struct list_head *terms) 2493void parse_events_terms__purge(struct list_head *terms)
2420{ 2494{
2421 struct parse_events_term *term, *h; 2495 struct parse_events_term *term, *h;
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index 8c72b0ff7fcb..a235f4d6d5e5 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -167,6 +167,14 @@ int parse_events_add_breakpoint(struct list_head *list, int *idx,
167int parse_events_add_pmu(struct parse_events_evlist *data, 167int parse_events_add_pmu(struct parse_events_evlist *data,
168 struct list_head *list, char *name, 168 struct list_head *list, char *name,
169 struct list_head *head_config); 169 struct list_head *head_config);
170
171int parse_events_multi_pmu_add(struct parse_events_evlist *data,
172 char *str,
173 struct list_head **listp);
174
175int parse_events_copy_term_list(struct list_head *old,
176 struct list_head **new);
177
170enum perf_pmu_event_symbol_type 178enum perf_pmu_event_symbol_type
171perf_pmu__parse_check(const char *name); 179perf_pmu__parse_check(const char *name);
172void parse_events__set_leader(char *name, struct list_head *list); 180void parse_events__set_leader(char *name, struct list_head *list);
@@ -176,7 +184,7 @@ void parse_events_evlist_error(struct parse_events_evlist *data,
176 int idx, const char *str); 184 int idx, const char *str);
177 185
178void print_events(const char *event_glob, bool name_only, bool quiet, 186void print_events(const char *event_glob, bool name_only, bool quiet,
179 bool long_desc); 187 bool long_desc, bool details_flag);
180 188
181struct event_symbol { 189struct event_symbol {
182 const char *symbol; 190 const char *symbol;
diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index 30f018ea1370..04fd8c9af9f9 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -226,68 +226,55 @@ event_pmu:
226PE_NAME opt_event_config 226PE_NAME opt_event_config
227{ 227{
228 struct parse_events_evlist *data = _data; 228 struct parse_events_evlist *data = _data;
229 struct list_head *list; 229 struct list_head *list, *orig_terms, *terms;
230
231 if (parse_events_copy_term_list($2, &orig_terms))
232 YYABORT;
230 233
231 ALLOC_LIST(list); 234 ALLOC_LIST(list);
232 ABORT_ON(parse_events_add_pmu(data, list, $1, $2)); 235 if (parse_events_add_pmu(data, list, $1, $2)) {
236 struct perf_pmu *pmu = NULL;
237 int ok = 0;
238
239 while ((pmu = perf_pmu__scan(pmu)) != NULL) {
240 char *name = pmu->name;
241
242 if (!strncmp(name, "uncore_", 7) &&
243 strncmp($1, "uncore_", 7))
244 name += 7;
245 if (!strncmp($1, name, strlen($1))) {
246 if (parse_events_copy_term_list(orig_terms, &terms))
247 YYABORT;
248 if (!parse_events_add_pmu(data, list, pmu->name, terms))
249 ok++;
250 parse_events_terms__delete(terms);
251 }
252 }
253 if (!ok)
254 YYABORT;
255 }
233 parse_events_terms__delete($2); 256 parse_events_terms__delete($2);
257 parse_events_terms__delete(orig_terms);
234 $$ = list; 258 $$ = list;
235} 259}
236| 260|
237PE_KERNEL_PMU_EVENT sep_dc 261PE_KERNEL_PMU_EVENT sep_dc
238{ 262{
239 struct parse_events_evlist *data = _data;
240 struct list_head *head;
241 struct parse_events_term *term;
242 struct list_head *list; 263 struct list_head *list;
243 struct perf_pmu *pmu = NULL;
244 int ok = 0;
245
246 /* Add it for all PMUs that support the alias */
247 ALLOC_LIST(list);
248 while ((pmu = perf_pmu__scan(pmu)) != NULL) {
249 struct perf_pmu_alias *alias;
250
251 list_for_each_entry(alias, &pmu->aliases, list) {
252 if (!strcasecmp(alias->name, $1)) {
253 ALLOC_LIST(head);
254 ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
255 $1, 1, false, &@1, NULL));
256 list_add_tail(&term->list, head);
257
258 if (!parse_events_add_pmu(data, list,
259 pmu->name, head)) {
260 pr_debug("%s -> %s/%s/\n", $1,
261 pmu->name, alias->str);
262 ok++;
263 }
264 264
265 parse_events_terms__delete(head); 265 if (parse_events_multi_pmu_add(_data, $1, &list) < 0)
266 }
267 }
268 }
269 if (!ok)
270 YYABORT; 266 YYABORT;
271 $$ = list; 267 $$ = list;
272} 268}
273| 269|
274PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF sep_dc 270PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF sep_dc
275{ 271{
276 struct parse_events_evlist *data = _data;
277 struct list_head *head;
278 struct parse_events_term *term;
279 struct list_head *list; 272 struct list_head *list;
280 char pmu_name[128]; 273 char pmu_name[128];
281 snprintf(&pmu_name, 128, "%s-%s", $1, $3);
282 274
283 ALLOC_LIST(head); 275 snprintf(&pmu_name, 128, "%s-%s", $1, $3);
284 ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, 276 if (parse_events_multi_pmu_add(_data, pmu_name, &list) < 0)
285 &pmu_name, 1, false, &@1, NULL)); 277 YYABORT;
286 list_add_tail(&term->list, head);
287
288 ALLOC_LIST(list);
289 ABORT_ON(parse_events_add_pmu(data, list, "cpu", head));
290 parse_events_terms__delete(head);
291 $$ = list; 278 $$ = list;
292} 279}
293 280
diff --git a/tools/perf/util/perf_regs.c b/tools/perf/util/perf_regs.c
index c4023f22f287..a37e5934aa2a 100644
--- a/tools/perf/util/perf_regs.c
+++ b/tools/perf/util/perf_regs.c
@@ -6,6 +6,12 @@ const struct sample_reg __weak sample_reg_masks[] = {
6 SMPL_REG_END 6 SMPL_REG_END
7}; 7};
8 8
9int __weak sdt_rename_register(char **pdesc __maybe_unused,
10 char *old_name __maybe_unused)
11{
12 return 0;
13}
14
9#ifdef HAVE_PERF_REGS_SUPPORT 15#ifdef HAVE_PERF_REGS_SUPPORT
10int perf_reg_value(u64 *valp, struct regs_dump *regs, int id) 16int perf_reg_value(u64 *valp, struct regs_dump *regs, int id)
11{ 17{
diff --git a/tools/perf/util/perf_regs.h b/tools/perf/util/perf_regs.h
index 679d6e493962..7544a157e159 100644
--- a/tools/perf/util/perf_regs.h
+++ b/tools/perf/util/perf_regs.h
@@ -15,6 +15,12 @@ struct sample_reg {
15 15
16extern const struct sample_reg sample_reg_masks[]; 16extern const struct sample_reg sample_reg_masks[];
17 17
18/*
19 * The table sdt_reg_renamings is used for adjusting gcc/gas-generated
20 * registers before filling the uprobe tracer interface.
21 */
22int sdt_rename_register(char **pdesc, char *old_name);
23
18#ifdef HAVE_PERF_REGS_SUPPORT 24#ifdef HAVE_PERF_REGS_SUPPORT
19#include <perf_regs.h> 25#include <perf_regs.h>
20 26
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 12f84dd2ac5d..362051ea7f3d 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -231,7 +231,9 @@ static int perf_pmu__parse_snapshot(struct perf_pmu_alias *alias,
231static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name, 231static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name,
232 char *desc, char *val, 232 char *desc, char *val,
233 char *long_desc, char *topic, 233 char *long_desc, char *topic,
234 char *unit, char *perpkg) 234 char *unit, char *perpkg,
235 char *metric_expr,
236 char *metric_name)
235{ 237{
236 struct perf_pmu_alias *alias; 238 struct perf_pmu_alias *alias;
237 int ret; 239 int ret;
@@ -265,6 +267,8 @@ static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name,
265 perf_pmu__parse_snapshot(alias, dir, name); 267 perf_pmu__parse_snapshot(alias, dir, name);
266 } 268 }
267 269
270 alias->metric_expr = metric_expr ? strdup(metric_expr) : NULL;
271 alias->metric_name = metric_name ? strdup(metric_name): NULL;
268 alias->desc = desc ? strdup(desc) : NULL; 272 alias->desc = desc ? strdup(desc) : NULL;
269 alias->long_desc = long_desc ? strdup(long_desc) : 273 alias->long_desc = long_desc ? strdup(long_desc) :
270 desc ? strdup(desc) : NULL; 274 desc ? strdup(desc) : NULL;
@@ -294,7 +298,7 @@ static int perf_pmu__new_alias(struct list_head *list, char *dir, char *name, FI
294 buf[ret] = 0; 298 buf[ret] = 0;
295 299
296 return __perf_pmu__new_alias(list, dir, name, NULL, buf, NULL, NULL, NULL, 300 return __perf_pmu__new_alias(list, dir, name, NULL, buf, NULL, NULL, NULL,
297 NULL); 301 NULL, NULL, NULL);
298} 302}
299 303
300static inline bool pmu_alias_info_file(char *name) 304static inline bool pmu_alias_info_file(char *name)
@@ -564,7 +568,9 @@ static void pmu_add_cpu_aliases(struct list_head *head, const char *name)
564 __perf_pmu__new_alias(head, NULL, (char *)pe->name, 568 __perf_pmu__new_alias(head, NULL, (char *)pe->name,
565 (char *)pe->desc, (char *)pe->event, 569 (char *)pe->desc, (char *)pe->event,
566 (char *)pe->long_desc, (char *)pe->topic, 570 (char *)pe->long_desc, (char *)pe->topic,
567 (char *)pe->unit, (char *)pe->perpkg); 571 (char *)pe->unit, (char *)pe->perpkg,
572 (char *)pe->metric_expr,
573 (char *)pe->metric_name);
568 } 574 }
569 575
570out: 576out:
@@ -991,6 +997,8 @@ int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms,
991 info->unit = NULL; 997 info->unit = NULL;
992 info->scale = 0.0; 998 info->scale = 0.0;
993 info->snapshot = false; 999 info->snapshot = false;
1000 info->metric_expr = NULL;
1001 info->metric_name = NULL;
994 1002
995 list_for_each_entry_safe(term, h, head_terms, list) { 1003 list_for_each_entry_safe(term, h, head_terms, list) {
996 alias = pmu_find_alias(pmu, term); 1004 alias = pmu_find_alias(pmu, term);
@@ -1006,6 +1014,8 @@ int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms,
1006 1014
1007 if (alias->per_pkg) 1015 if (alias->per_pkg)
1008 info->per_pkg = true; 1016 info->per_pkg = true;
1017 info->metric_expr = alias->metric_expr;
1018 info->metric_name = alias->metric_name;
1009 1019
1010 list_del(&term->list); 1020 list_del(&term->list);
1011 free(term); 1021 free(term);
@@ -1100,6 +1110,8 @@ struct sevent {
1100 char *topic; 1110 char *topic;
1101 char *str; 1111 char *str;
1102 char *pmu; 1112 char *pmu;
1113 char *metric_expr;
1114 char *metric_name;
1103}; 1115};
1104 1116
1105static int cmp_sevent(const void *a, const void *b) 1117static int cmp_sevent(const void *a, const void *b)
@@ -1142,7 +1154,7 @@ static void wordwrap(char *s, int start, int max, int corr)
1142} 1154}
1143 1155
1144void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag, 1156void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag,
1145 bool long_desc) 1157 bool long_desc, bool details_flag)
1146{ 1158{
1147 struct perf_pmu *pmu; 1159 struct perf_pmu *pmu;
1148 struct perf_pmu_alias *alias; 1160 struct perf_pmu_alias *alias;
@@ -1198,6 +1210,8 @@ void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag,
1198 aliases[j].topic = alias->topic; 1210 aliases[j].topic = alias->topic;
1199 aliases[j].str = alias->str; 1211 aliases[j].str = alias->str;
1200 aliases[j].pmu = pmu->name; 1212 aliases[j].pmu = pmu->name;
1213 aliases[j].metric_expr = alias->metric_expr;
1214 aliases[j].metric_name = alias->metric_name;
1201 j++; 1215 j++;
1202 } 1216 }
1203 if (pmu->selectable && 1217 if (pmu->selectable &&
@@ -1232,8 +1246,14 @@ void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag,
1232 printf("%*s", 8, "["); 1246 printf("%*s", 8, "[");
1233 wordwrap(aliases[j].desc, 8, columns, 0); 1247 wordwrap(aliases[j].desc, 8, columns, 0);
1234 printf("]\n"); 1248 printf("]\n");
1235 if (verbose > 0) 1249 if (details_flag) {
1236 printf("%*s%s/%s/\n", 8, "", aliases[j].pmu, aliases[j].str); 1250 printf("%*s%s/%s/ ", 8, "", aliases[j].pmu, aliases[j].str);
1251 if (aliases[j].metric_name)
1252 printf(" MetricName: %s", aliases[j].metric_name);
1253 if (aliases[j].metric_expr)
1254 printf(" MetricExpr: %s", aliases[j].metric_expr);
1255 putchar('\n');
1256 }
1237 } else 1257 } else
1238 printf(" %-50s [Kernel PMU event]\n", aliases[j].name); 1258 printf(" %-50s [Kernel PMU event]\n", aliases[j].name);
1239 printed++; 1259 printed++;
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
index 00852ddc7741..ea7f450dc609 100644
--- a/tools/perf/util/pmu.h
+++ b/tools/perf/util/pmu.h
@@ -31,6 +31,8 @@ struct perf_pmu {
31 31
32struct perf_pmu_info { 32struct perf_pmu_info {
33 const char *unit; 33 const char *unit;
34 const char *metric_expr;
35 const char *metric_name;
34 double scale; 36 double scale;
35 bool per_pkg; 37 bool per_pkg;
36 bool snapshot; 38 bool snapshot;
@@ -50,6 +52,8 @@ struct perf_pmu_alias {
50 double scale; 52 double scale;
51 bool per_pkg; 53 bool per_pkg;
52 bool snapshot; 54 bool snapshot;
55 char *metric_expr;
56 char *metric_name;
53}; 57};
54 58
55struct perf_pmu *perf_pmu__find(const char *name); 59struct perf_pmu *perf_pmu__find(const char *name);
@@ -76,7 +80,7 @@ int perf_pmu__format_parse(char *dir, struct list_head *head);
76struct perf_pmu *perf_pmu__scan(struct perf_pmu *pmu); 80struct perf_pmu *perf_pmu__scan(struct perf_pmu *pmu);
77 81
78void print_pmu_events(const char *event_glob, bool name_only, bool quiet, 82void print_pmu_events(const char *event_glob, bool name_only, bool quiet,
79 bool long_desc); 83 bool long_desc, bool details_flag);
80bool pmu_have_event(const char *pname, const char *name); 84bool pmu_have_event(const char *pname, const char *name);
81 85
82int perf_pmu__scan_file(struct perf_pmu *pmu, const char *name, const char *fmt, 86int perf_pmu__scan_file(struct perf_pmu *pmu, const char *name, const char *fmt,
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 6740d6812691..e4b889444447 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -47,7 +47,6 @@
47#include "probe-file.h" 47#include "probe-file.h"
48#include "session.h" 48#include "session.h"
49 49
50#define MAX_CMDLEN 256
51#define PERFPROBE_GROUP "probe" 50#define PERFPROBE_GROUP "probe"
52 51
53bool probe_event_dry_run; /* Dry run flag */ 52bool probe_event_dry_run; /* Dry run flag */
diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c
index 1542cd0d6799..d741634cbfc0 100644
--- a/tools/perf/util/probe-file.c
+++ b/tools/perf/util/probe-file.c
@@ -27,8 +27,10 @@
27#include "probe-event.h" 27#include "probe-event.h"
28#include "probe-file.h" 28#include "probe-file.h"
29#include "session.h" 29#include "session.h"
30#include "perf_regs.h"
30 31
31#define MAX_CMDLEN 256 32/* 4096 - 2 ('\n' + '\0') */
33#define MAX_CMDLEN 4094
32 34
33static void print_open_warning(int err, bool uprobe) 35static void print_open_warning(int err, bool uprobe)
34{ 36{
@@ -687,6 +689,166 @@ static unsigned long long sdt_note__get_addr(struct sdt_note *note)
687 : (unsigned long long)note->addr.a64[0]; 689 : (unsigned long long)note->addr.a64[0];
688} 690}
689 691
692static const char * const type_to_suffix[] = {
693 ":s64", "", "", "", ":s32", "", ":s16", ":s8",
694 "", ":u8", ":u16", "", ":u32", "", "", "", ":u64"
695};
696
697static int synthesize_sdt_probe_arg(struct strbuf *buf, int i, const char *arg)
698{
699 char *tmp, *desc = strdup(arg);
700 const char *prefix = "", *suffix = "";
701 int ret = -1;
702
703 if (desc == NULL) {
704 pr_debug4("Allocation error\n");
705 return ret;
706 }
707
708 tmp = strchr(desc, '@');
709 if (tmp) {
710 long type_idx;
711 /*
712 * Isolate the string number and convert it into a
713 * binary value; this will be an index to get suffix
714 * of the uprobe name (defining the type)
715 */
716 tmp[0] = '\0';
717 type_idx = strtol(desc, NULL, 10);
718 /* Check that the conversion went OK */
719 if (type_idx == LONG_MIN || type_idx == LONG_MAX) {
720 pr_debug4("Failed to parse sdt type\n");
721 goto error;
722 }
723 /* Check that the converted value is OK */
724 if (type_idx < -8 || type_idx > 8) {
725 pr_debug4("Failed to get a valid sdt type\n");
726 goto error;
727 }
728 suffix = type_to_suffix[type_idx + 8];
729 /* Get rid of the sdt prefix which is now useless */
730 tmp++;
731 memmove(desc, tmp, strlen(tmp) + 1);
732 }
733
734 /*
735 * The uprobe tracer format does not support all the
736 * addressing modes (notably: in x86 the scaled mode); so, we
737 * detect ',' characters, if there is just one, there is no
738 * use converting the sdt arg into a uprobe one.
739 */
740 if (strchr(desc, ',')) {
741 pr_debug4("Skipping unsupported SDT argument; %s\n", desc);
742 goto out;
743 }
744
745 /*
746 * If the argument addressing mode is indirect, we must check
747 * a few things...
748 */
749 tmp = strchr(desc, '(');
750 if (tmp) {
751 int j;
752
753 /*
754 * ...if the addressing mode is indirect with a
755 * positive offset (ex.: "1608(%ax)"), we need to add
756 * a '+' prefix so as to be compliant with uprobe
757 * format.
758 */
759 if (desc[0] != '+' && desc[0] != '-')
760 prefix = "+";
761
762 /*
763 * ...or if the addressing mode is indirect with a symbol
764 * as offset, the argument will not be supported by
765 * the uprobe tracer format; so, let's skip this one.
766 */
767 for (j = 0; j < tmp - desc; j++) {
768 if (desc[j] != '+' && desc[j] != '-' &&
769 !isdigit(desc[j])) {
770 pr_debug4("Skipping unsupported SDT argument; "
771 "%s\n", desc);
772 goto out;
773 }
774 }
775 }
776
777 /*
778 * The uprobe tracer format does not support constants; if we
779 * find one in the current argument, let's skip the argument.
780 */
781 if (strchr(desc, '$')) {
782 pr_debug4("Skipping unsupported SDT argument; %s\n", desc);
783 goto out;
784 }
785
786 /*
787 * The uprobe parser does not support all gas register names;
788 * so, we have to replace them (ex. for x86_64: %rax -> %ax);
789 * the loop below looks for the register names (starting with
790 * a '%' and tries to perform the needed renamings.
791 */
792 tmp = strchr(desc, '%');
793 while (tmp) {
794 size_t offset = tmp - desc;
795
796 ret = sdt_rename_register(&desc, desc + offset);
797 if (ret < 0)
798 goto error;
799
800 /*
801 * The desc pointer might have changed; so, let's not
802 * try to reuse tmp for next lookup
803 */
804 tmp = strchr(desc + offset + 1, '%');
805 }
806
807 if (strbuf_addf(buf, " arg%d=%s%s%s", i + 1, prefix, desc, suffix) < 0)
808 goto error;
809
810out:
811 ret = 0;
812error:
813 free(desc);
814 return ret;
815}
816
817static char *synthesize_sdt_probe_command(struct sdt_note *note,
818 const char *pathname,
819 const char *sdtgrp)
820{
821 struct strbuf buf;
822 char *ret = NULL, **args;
823 int i, args_count;
824
825 if (strbuf_init(&buf, 32) < 0)
826 return NULL;
827
828 if (strbuf_addf(&buf, "p:%s/%s %s:0x%llx",
829 sdtgrp, note->name, pathname,
830 sdt_note__get_addr(note)) < 0)
831 goto error;
832
833 if (!note->args)
834 goto out;
835
836 if (note->args) {
837 args = argv_split(note->args, &args_count);
838
839 for (i = 0; i < args_count; ++i) {
840 if (synthesize_sdt_probe_arg(&buf, i, args[i]) < 0)
841 goto error;
842 }
843 }
844
845out:
846 ret = strbuf_detach(&buf, NULL);
847error:
848 strbuf_release(&buf);
849 return ret;
850}
851
690int probe_cache__scan_sdt(struct probe_cache *pcache, const char *pathname) 852int probe_cache__scan_sdt(struct probe_cache *pcache, const char *pathname)
691{ 853{
692 struct probe_cache_entry *entry = NULL; 854 struct probe_cache_entry *entry = NULL;
@@ -723,11 +885,12 @@ int probe_cache__scan_sdt(struct probe_cache *pcache, const char *pathname)
723 entry->pev.group = strdup(sdtgrp); 885 entry->pev.group = strdup(sdtgrp);
724 list_add_tail(&entry->node, &pcache->entries); 886 list_add_tail(&entry->node, &pcache->entries);
725 } 887 }
726 ret = asprintf(&buf, "p:%s/%s %s:0x%llx", 888 buf = synthesize_sdt_probe_command(note, pathname, sdtgrp);
727 sdtgrp, note->name, pathname, 889 if (!buf) {
728 sdt_note__get_addr(note)); 890 ret = -ENOMEM;
729 if (ret < 0)
730 break; 891 break;
892 }
893
731 strlist__add(entry->tevlist, buf); 894 strlist__add(entry->tevlist, buf);
732 free(buf); 895 free(buf);
733 entry = NULL; 896 entry = NULL;
diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
index 8a2bbd2a4d82..ac10cc675d39 100644
--- a/tools/perf/util/stat-shadow.c
+++ b/tools/perf/util/stat-shadow.c
@@ -3,6 +3,9 @@
3#include "stat.h" 3#include "stat.h"
4#include "color.h" 4#include "color.h"
5#include "pmu.h" 5#include "pmu.h"
6#include "rblist.h"
7#include "evlist.h"
8#include "expr.h"
6 9
7enum { 10enum {
8 CTX_BIT_USER = 1 << 0, 11 CTX_BIT_USER = 1 << 0,
@@ -41,13 +44,73 @@ static struct stats runtime_topdown_slots_issued[NUM_CTX][MAX_NR_CPUS];
41static struct stats runtime_topdown_slots_retired[NUM_CTX][MAX_NR_CPUS]; 44static struct stats runtime_topdown_slots_retired[NUM_CTX][MAX_NR_CPUS];
42static struct stats runtime_topdown_fetch_bubbles[NUM_CTX][MAX_NR_CPUS]; 45static struct stats runtime_topdown_fetch_bubbles[NUM_CTX][MAX_NR_CPUS];
43static struct stats runtime_topdown_recovery_bubbles[NUM_CTX][MAX_NR_CPUS]; 46static struct stats runtime_topdown_recovery_bubbles[NUM_CTX][MAX_NR_CPUS];
47static struct rblist runtime_saved_values;
44static bool have_frontend_stalled; 48static bool have_frontend_stalled;
45 49
46struct stats walltime_nsecs_stats; 50struct stats walltime_nsecs_stats;
47 51
52struct saved_value {
53 struct rb_node rb_node;
54 struct perf_evsel *evsel;
55 int cpu;
56 int ctx;
57 struct stats stats;
58};
59
60static int saved_value_cmp(struct rb_node *rb_node, const void *entry)
61{
62 struct saved_value *a = container_of(rb_node,
63 struct saved_value,
64 rb_node);
65 const struct saved_value *b = entry;
66
67 if (a->ctx != b->ctx)
68 return a->ctx - b->ctx;
69 if (a->cpu != b->cpu)
70 return a->cpu - b->cpu;
71 return a->evsel - b->evsel;
72}
73
74static struct rb_node *saved_value_new(struct rblist *rblist __maybe_unused,
75 const void *entry)
76{
77 struct saved_value *nd = malloc(sizeof(struct saved_value));
78
79 if (!nd)
80 return NULL;
81 memcpy(nd, entry, sizeof(struct saved_value));
82 return &nd->rb_node;
83}
84
85static struct saved_value *saved_value_lookup(struct perf_evsel *evsel,
86 int cpu, int ctx,
87 bool create)
88{
89 struct rb_node *nd;
90 struct saved_value dm = {
91 .cpu = cpu,
92 .ctx = ctx,
93 .evsel = evsel,
94 };
95 nd = rblist__find(&runtime_saved_values, &dm);
96 if (nd)
97 return container_of(nd, struct saved_value, rb_node);
98 if (create) {
99 rblist__add_node(&runtime_saved_values, &dm);
100 nd = rblist__find(&runtime_saved_values, &dm);
101 if (nd)
102 return container_of(nd, struct saved_value, rb_node);
103 }
104 return NULL;
105}
106
48void perf_stat__init_shadow_stats(void) 107void perf_stat__init_shadow_stats(void)
49{ 108{
50 have_frontend_stalled = pmu_have_event("cpu", "stalled-cycles-frontend"); 109 have_frontend_stalled = pmu_have_event("cpu", "stalled-cycles-frontend");
110 rblist__init(&runtime_saved_values);
111 runtime_saved_values.node_cmp = saved_value_cmp;
112 runtime_saved_values.node_new = saved_value_new;
113 /* No delete for now */
51} 114}
52 115
53static int evsel_context(struct perf_evsel *evsel) 116static int evsel_context(struct perf_evsel *evsel)
@@ -70,6 +133,8 @@ static int evsel_context(struct perf_evsel *evsel)
70 133
71void perf_stat__reset_shadow_stats(void) 134void perf_stat__reset_shadow_stats(void)
72{ 135{
136 struct rb_node *pos, *next;
137
73 memset(runtime_nsecs_stats, 0, sizeof(runtime_nsecs_stats)); 138 memset(runtime_nsecs_stats, 0, sizeof(runtime_nsecs_stats));
74 memset(runtime_cycles_stats, 0, sizeof(runtime_cycles_stats)); 139 memset(runtime_cycles_stats, 0, sizeof(runtime_cycles_stats));
75 memset(runtime_stalled_cycles_front_stats, 0, sizeof(runtime_stalled_cycles_front_stats)); 140 memset(runtime_stalled_cycles_front_stats, 0, sizeof(runtime_stalled_cycles_front_stats));
@@ -92,6 +157,15 @@ void perf_stat__reset_shadow_stats(void)
92 memset(runtime_topdown_slots_issued, 0, sizeof(runtime_topdown_slots_issued)); 157 memset(runtime_topdown_slots_issued, 0, sizeof(runtime_topdown_slots_issued));
93 memset(runtime_topdown_fetch_bubbles, 0, sizeof(runtime_topdown_fetch_bubbles)); 158 memset(runtime_topdown_fetch_bubbles, 0, sizeof(runtime_topdown_fetch_bubbles));
94 memset(runtime_topdown_recovery_bubbles, 0, sizeof(runtime_topdown_recovery_bubbles)); 159 memset(runtime_topdown_recovery_bubbles, 0, sizeof(runtime_topdown_recovery_bubbles));
160
161 next = rb_first(&runtime_saved_values.entries);
162 while (next) {
163 pos = next;
164 next = rb_next(pos);
165 memset(&container_of(pos, struct saved_value, rb_node)->stats,
166 0,
167 sizeof(struct stats));
168 }
95} 169}
96 170
97/* 171/*
@@ -143,6 +217,12 @@ void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 *count,
143 update_stats(&runtime_dtlb_cache_stats[ctx][cpu], count[0]); 217 update_stats(&runtime_dtlb_cache_stats[ctx][cpu], count[0]);
144 else if (perf_evsel__match(counter, HW_CACHE, HW_CACHE_ITLB)) 218 else if (perf_evsel__match(counter, HW_CACHE, HW_CACHE_ITLB))
145 update_stats(&runtime_itlb_cache_stats[ctx][cpu], count[0]); 219 update_stats(&runtime_itlb_cache_stats[ctx][cpu], count[0]);
220
221 if (counter->collect_stat) {
222 struct saved_value *v = saved_value_lookup(counter, cpu, ctx,
223 true);
224 update_stats(&v->stats, count[0]);
225 }
146} 226}
147 227
148/* used for get_ratio_color() */ 228/* used for get_ratio_color() */
@@ -172,6 +252,95 @@ static const char *get_ratio_color(enum grc_type type, double ratio)
172 return color; 252 return color;
173} 253}
174 254
255static struct perf_evsel *perf_stat__find_event(struct perf_evlist *evsel_list,
256 const char *name)
257{
258 struct perf_evsel *c2;
259
260 evlist__for_each_entry (evsel_list, c2) {
261 if (!strcasecmp(c2->name, name))
262 return c2;
263 }
264 return NULL;
265}
266
267/* Mark MetricExpr target events and link events using them to them. */
268void perf_stat__collect_metric_expr(struct perf_evlist *evsel_list)
269{
270 struct perf_evsel *counter, *leader, **metric_events, *oc;
271 bool found;
272 const char **metric_names;
273 int i;
274 int num_metric_names;
275
276 evlist__for_each_entry(evsel_list, counter) {
277 bool invalid = false;
278
279 leader = counter->leader;
280 if (!counter->metric_expr)
281 continue;
282 metric_events = counter->metric_events;
283 if (!metric_events) {
284 if (expr__find_other(counter->metric_expr, counter->name,
285 &metric_names, &num_metric_names) < 0)
286 continue;
287
288 metric_events = calloc(sizeof(struct perf_evsel *),
289 num_metric_names + 1);
290 if (!metric_events)
291 return;
292 counter->metric_events = metric_events;
293 }
294
295 for (i = 0; i < num_metric_names; i++) {
296 found = false;
297 if (leader) {
298 /* Search in group */
299 for_each_group_member (oc, leader) {
300 if (!strcasecmp(oc->name, metric_names[i])) {
301 found = true;
302 break;
303 }
304 }
305 }
306 if (!found) {
307 /* Search ignoring groups */
308 oc = perf_stat__find_event(evsel_list, metric_names[i]);
309 }
310 if (!oc) {
311 /* Deduping one is good enough to handle duplicated PMUs. */
312 static char *printed;
313
314 /*
315 * Adding events automatically would be difficult, because
316 * it would risk creating groups that are not schedulable.
317 * perf stat doesn't understand all the scheduling constraints
318 * of events. So we ask the user instead to add the missing
319 * events.
320 */
321 if (!printed || strcasecmp(printed, metric_names[i])) {
322 fprintf(stderr,
323 "Add %s event to groups to get metric expression for %s\n",
324 metric_names[i],
325 counter->name);
326 printed = strdup(metric_names[i]);
327 }
328 invalid = true;
329 continue;
330 }
331 metric_events[i] = oc;
332 oc->collect_stat = true;
333 }
334 metric_events[i] = NULL;
335 free(metric_names);
336 if (invalid) {
337 free(metric_events);
338 counter->metric_events = NULL;
339 counter->metric_expr = NULL;
340 }
341 }
342}
343
175static void print_stalled_cycles_frontend(int cpu, 344static void print_stalled_cycles_frontend(int cpu,
176 struct perf_evsel *evsel, double avg, 345 struct perf_evsel *evsel, double avg,
177 struct perf_stat_output_ctx *out) 346 struct perf_stat_output_ctx *out)
@@ -614,6 +783,34 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel,
614 be_bound * 100.); 783 be_bound * 100.);
615 else 784 else
616 print_metric(ctxp, NULL, NULL, name, 0); 785 print_metric(ctxp, NULL, NULL, name, 0);
786 } else if (evsel->metric_expr) {
787 struct parse_ctx pctx;
788 int i;
789
790 expr__ctx_init(&pctx);
791 expr__add_id(&pctx, evsel->name, avg);
792 for (i = 0; evsel->metric_events[i]; i++) {
793 struct saved_value *v;
794
795 v = saved_value_lookup(evsel->metric_events[i], cpu, ctx, false);
796 if (!v)
797 break;
798 expr__add_id(&pctx, evsel->metric_events[i]->name,
799 avg_stats(&v->stats));
800 }
801 if (!evsel->metric_events[i]) {
802 const char *p = evsel->metric_expr;
803
804 if (expr__parse(&ratio, &pctx, &p) == 0)
805 print_metric(ctxp, NULL, "%8.1f",
806 evsel->metric_name ?
807 evsel->metric_name :
808 out->force_header ? evsel->name : "",
809 ratio);
810 else
811 print_metric(ctxp, NULL, NULL, "", 0);
812 } else
813 print_metric(ctxp, NULL, NULL, "", 0);
617 } else if (runtime_nsecs_stats[cpu].n != 0) { 814 } else if (runtime_nsecs_stats[cpu].n != 0) {
618 char unit = 'M'; 815 char unit = 'M';
619 char unit_buf[10]; 816 char unit_buf[10];
diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h
index c29bb94c48a4..0a65ae23f495 100644
--- a/tools/perf/util/stat.h
+++ b/tools/perf/util/stat.h
@@ -85,11 +85,13 @@ struct perf_stat_output_ctx {
85 void *ctx; 85 void *ctx;
86 print_metric_t print_metric; 86 print_metric_t print_metric;
87 new_line_t new_line; 87 new_line_t new_line;
88 bool force_header;
88}; 89};
89 90
90void perf_stat__print_shadow_stats(struct perf_evsel *evsel, 91void perf_stat__print_shadow_stats(struct perf_evsel *evsel,
91 double avg, int cpu, 92 double avg, int cpu,
92 struct perf_stat_output_ctx *out); 93 struct perf_stat_output_ctx *out);
94void perf_stat__collect_metric_expr(struct perf_evlist *);
93 95
94int perf_evlist__alloc_stats(struct perf_evlist *evlist, bool alloc_raw); 96int perf_evlist__alloc_stats(struct perf_evlist *evlist, bool alloc_raw);
95void perf_evlist__free_stats(struct perf_evlist *evlist); 97void perf_evlist__free_stats(struct perf_evlist *evlist);
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 4e59ddeb4eda..0e660dba58ad 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -1828,7 +1828,7 @@ void kcore_extract__delete(struct kcore_extract *kce)
1828static int populate_sdt_note(Elf **elf, const char *data, size_t len, 1828static int populate_sdt_note(Elf **elf, const char *data, size_t len,
1829 struct list_head *sdt_notes) 1829 struct list_head *sdt_notes)
1830{ 1830{
1831 const char *provider, *name; 1831 const char *provider, *name, *args;
1832 struct sdt_note *tmp = NULL; 1832 struct sdt_note *tmp = NULL;
1833 GElf_Ehdr ehdr; 1833 GElf_Ehdr ehdr;
1834 GElf_Addr base_off = 0; 1834 GElf_Addr base_off = 0;
@@ -1887,6 +1887,25 @@ static int populate_sdt_note(Elf **elf, const char *data, size_t len,
1887 goto out_free_prov; 1887 goto out_free_prov;
1888 } 1888 }
1889 1889
1890 args = memchr(name, '\0', data + len - name);
1891
1892 /*
1893 * There is no argument if:
1894 * - We reached the end of the note;
1895 * - There is not enough room to hold a potential string;
1896 * - The argument string is empty or just contains ':'.
1897 */
1898 if (args == NULL || data + len - args < 2 ||
1899 args[1] == ':' || args[1] == '\0')
1900 tmp->args = NULL;
1901 else {
1902 tmp->args = strdup(++args);
1903 if (!tmp->args) {
1904 ret = -ENOMEM;
1905 goto out_free_name;
1906 }
1907 }
1908
1890 if (gelf_getclass(*elf) == ELFCLASS32) { 1909 if (gelf_getclass(*elf) == ELFCLASS32) {
1891 memcpy(&tmp->addr, &buf, 3 * sizeof(Elf32_Addr)); 1910 memcpy(&tmp->addr, &buf, 3 * sizeof(Elf32_Addr));
1892 tmp->bit32 = true; 1911 tmp->bit32 = true;
@@ -1898,7 +1917,7 @@ static int populate_sdt_note(Elf **elf, const char *data, size_t len,
1898 if (!gelf_getehdr(*elf, &ehdr)) { 1917 if (!gelf_getehdr(*elf, &ehdr)) {
1899 pr_debug("%s : cannot get elf header.\n", __func__); 1918 pr_debug("%s : cannot get elf header.\n", __func__);
1900 ret = -EBADF; 1919 ret = -EBADF;
1901 goto out_free_name; 1920 goto out_free_args;
1902 } 1921 }
1903 1922
1904 /* Adjust the prelink effect : 1923 /* Adjust the prelink effect :
@@ -1923,6 +1942,8 @@ static int populate_sdt_note(Elf **elf, const char *data, size_t len,
1923 list_add_tail(&tmp->note_list, sdt_notes); 1942 list_add_tail(&tmp->note_list, sdt_notes);
1924 return 0; 1943 return 0;
1925 1944
1945out_free_args:
1946 free(tmp->args);
1926out_free_name: 1947out_free_name:
1927 free(tmp->name); 1948 free(tmp->name);
1928out_free_prov: 1949out_free_prov:
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 6c358b7ed336..9222c7e702f3 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -351,6 +351,7 @@ int arch__choose_best_symbol(struct symbol *syma, struct symbol *symb);
351struct sdt_note { 351struct sdt_note {
352 char *name; /* name of the note*/ 352 char *name; /* name of the note*/
353 char *provider; /* provider name */ 353 char *provider; /* provider name */
354 char *args;
354 bool bit32; /* whether the location is 32 bits? */ 355 bool bit32; /* whether the location is 32 bits? */
355 union { /* location, base and semaphore addrs */ 356 union { /* location, base and semaphore addrs */
356 Elf64_Addr a64[3]; 357 Elf64_Addr a64[3];