Skip to content

Commit 7ae5c03

Browse files
captain5050acmel
authored andcommitted
perf pmu-events: Move test events/metrics to JSON
Move arrays of pmu_events into the JSON code so that it may be regenerated and modified by the jevents.py script. Signed-off-by: Ian Rogers <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: James Clark <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: John Garry <[email protected]> Cc: Kan Liang <[email protected]> Cc: Leo Yan <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Mike Leach <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Ravi Bangoria <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Will Deacon <[email protected]> Cc: Xing Zhengjun <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 64234c1 commit 7ae5c03

File tree

4 files changed

+132
-81
lines changed

4 files changed

+132
-81
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
[
2+
{
3+
"MetricExpr": "1 / IPC",
4+
"MetricName": "CPI"
5+
},
6+
{
7+
"MetricExpr": "inst_retired.any / cpu_clk_unhalted.thread",
8+
"MetricName": "IPC",
9+
"MetricGroup": "group1"
10+
},
11+
{
12+
"MetricExpr": "idq_uops_not_delivered.core / (4 * (( ( cpu_clk_unhalted.thread / 2 ) * ( 1 + cpu_clk_unhalted.one_thread_active / cpu_clk_unhalted.ref_xclk ) )))",
13+
"MetricName": "Frontend_Bound_SMT"
14+
},
15+
{
16+
"MetricExpr": "l1d\\-loads\\-misses / inst_retired.any",
17+
"MetricName": "dcache_miss_cpi"
18+
},
19+
{
20+
"MetricExpr": "l1i\\-loads\\-misses / inst_retired.any",
21+
"MetricName": "icache_miss_cycles"
22+
},
23+
{
24+
"MetricExpr": "(dcache_miss_cpi + icache_miss_cycles)",
25+
"MetricName": "cache_miss_cycles",
26+
"MetricGroup": "group1"
27+
},
28+
{
29+
"MetricExpr": "l2_rqsts.demand_data_rd_hit + l2_rqsts.pf_hit + l2_rqsts.rfo_hit",
30+
"MetricName": "DCache_L2_All_Hits"
31+
},
32+
{
33+
"MetricExpr": "max(l2_rqsts.all_demand_data_rd - l2_rqsts.demand_data_rd_hit, 0) + l2_rqsts.pf_miss + l2_rqsts.rfo_miss",
34+
"MetricName": "DCache_L2_All_Miss"
35+
},
36+
{
37+
"MetricExpr": "dcache_l2_all_hits + dcache_l2_all_miss",
38+
"MetricName": "DCache_L2_All"
39+
},
40+
{
41+
"MetricExpr": "d_ratio(dcache_l2_all_hits, dcache_l2_all)",
42+
"MetricName": "DCache_L2_Hits"
43+
},
44+
{
45+
"MetricExpr": "d_ratio(dcache_l2_all_miss, dcache_l2_all)",
46+
"MetricName": "DCache_L2_Misses"
47+
},
48+
{
49+
"MetricExpr": "ipc + M2",
50+
"MetricName": "M1"
51+
},
52+
{
53+
"MetricExpr": "ipc + M1",
54+
"MetricName": "M2"
55+
},
56+
{
57+
"MetricExpr": "1/M3",
58+
"MetricName": "M3"
59+
},
60+
{
61+
"MetricExpr": "64 * l1d.replacement / 1000000000 / duration_time",
62+
"MetricName": "L1D_Cache_Fill_BW"
63+
}
64+
]

tools/perf/pmu-events/empty-pmu-events.c

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,70 @@ static const struct pmu_event pme_test_soc_cpu[] = {
105105
.desc = "L2 BTB Correction",
106106
.topic = "branch",
107107
},
108+
{
109+
.metric_expr = "1 / IPC",
110+
.metric_name = "CPI",
111+
},
112+
{
113+
.metric_expr = "inst_retired.any / cpu_clk_unhalted.thread",
114+
.metric_name = "IPC",
115+
.metric_group = "group1",
116+
},
117+
{
118+
.metric_expr = "idq_uops_not_delivered.core / (4 * (( ( cpu_clk_unhalted.thread / 2 ) * "
119+
"( 1 + cpu_clk_unhalted.one_thread_active / cpu_clk_unhalted.ref_xclk ) )))",
120+
.metric_name = "Frontend_Bound_SMT",
121+
},
122+
{
123+
.metric_expr = "l1d\\-loads\\-misses / inst_retired.any",
124+
.metric_name = "dcache_miss_cpi",
125+
},
126+
{
127+
.metric_expr = "l1i\\-loads\\-misses / inst_retired.any",
128+
.metric_name = "icache_miss_cycles",
129+
},
130+
{
131+
.metric_expr = "(dcache_miss_cpi + icache_miss_cycles)",
132+
.metric_name = "cache_miss_cycles",
133+
.metric_group = "group1",
134+
},
135+
{
136+
.metric_expr = "l2_rqsts.demand_data_rd_hit + l2_rqsts.pf_hit + l2_rqsts.rfo_hit",
137+
.metric_name = "DCache_L2_All_Hits",
138+
},
139+
{
140+
.metric_expr = "max(l2_rqsts.all_demand_data_rd - l2_rqsts.demand_data_rd_hit, 0) + "
141+
"l2_rqsts.pf_miss + l2_rqsts.rfo_miss",
142+
.metric_name = "DCache_L2_All_Miss",
143+
},
144+
{
145+
.metric_expr = "dcache_l2_all_hits + dcache_l2_all_miss",
146+
.metric_name = "DCache_L2_All",
147+
},
148+
{
149+
.metric_expr = "d_ratio(dcache_l2_all_hits, dcache_l2_all)",
150+
.metric_name = "DCache_L2_Hits",
151+
},
152+
{
153+
.metric_expr = "d_ratio(dcache_l2_all_miss, dcache_l2_all)",
154+
.metric_name = "DCache_L2_Misses",
155+
},
156+
{
157+
.metric_expr = "ipc + M2",
158+
.metric_name = "M1",
159+
},
160+
{
161+
.metric_expr = "ipc + M1",
162+
.metric_name = "M2",
163+
},
164+
{
165+
.metric_expr = "1/M3",
166+
.metric_name = "M3",
167+
},
168+
{
169+
.metric_expr = "64 * l1d.replacement / 1000000000 / duration_time",
170+
.metric_name = "L1D_Cache_Fill_BW",
171+
},
108172
{
109173
.name = 0,
110174
.event = 0,

tools/perf/tests/expand-cgroup.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -180,26 +180,13 @@ static int expand_metric_events(void)
180180
struct evlist *evlist;
181181
struct rblist metric_events;
182182
const char metric_str[] = "CPI";
183-
184-
struct pmu_event pme_test[] = {
185-
{
186-
.metric_expr = "instructions / cycles",
187-
.metric_name = "IPC",
188-
},
189-
{
190-
.metric_expr = "1 / IPC",
191-
.metric_name = "CPI",
192-
},
193-
{
194-
.metric_expr = NULL,
195-
.metric_name = NULL,
196-
},
197-
};
183+
const struct pmu_event *pme_test;
198184

199185
evlist = evlist__new();
200186
TEST_ASSERT_VAL("failed to get evlist", evlist);
201187

202188
rblist__init(&metric_events);
189+
pme_test = find_core_events_table("testarch", "testcpu");
203190
ret = metricgroup__parse_groups_test(evlist, pme_test, metric_str,
204191
false, false, &metric_events);
205192
if (ret < 0) {

tools/perf/tests/parse-metric.c

Lines changed: 2 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -13,72 +13,6 @@
1313
#include "stat.h"
1414
#include "pmu.h"
1515

16-
static struct pmu_event pme_test[] = {
17-
{
18-
.metric_expr = "inst_retired.any / cpu_clk_unhalted.thread",
19-
.metric_name = "IPC",
20-
.metric_group = "group1",
21-
},
22-
{
23-
.metric_expr = "idq_uops_not_delivered.core / (4 * (( ( cpu_clk_unhalted.thread / 2 ) * "
24-
"( 1 + cpu_clk_unhalted.one_thread_active / cpu_clk_unhalted.ref_xclk ) )))",
25-
.metric_name = "Frontend_Bound_SMT",
26-
},
27-
{
28-
.metric_expr = "l1d\\-loads\\-misses / inst_retired.any",
29-
.metric_name = "dcache_miss_cpi",
30-
},
31-
{
32-
.metric_expr = "l1i\\-loads\\-misses / inst_retired.any",
33-
.metric_name = "icache_miss_cycles",
34-
},
35-
{
36-
.metric_expr = "(dcache_miss_cpi + icache_miss_cycles)",
37-
.metric_name = "cache_miss_cycles",
38-
.metric_group = "group1",
39-
},
40-
{
41-
.metric_expr = "l2_rqsts.demand_data_rd_hit + l2_rqsts.pf_hit + l2_rqsts.rfo_hit",
42-
.metric_name = "DCache_L2_All_Hits",
43-
},
44-
{
45-
.metric_expr = "max(l2_rqsts.all_demand_data_rd - l2_rqsts.demand_data_rd_hit, 0) + "
46-
"l2_rqsts.pf_miss + l2_rqsts.rfo_miss",
47-
.metric_name = "DCache_L2_All_Miss",
48-
},
49-
{
50-
.metric_expr = "dcache_l2_all_hits + dcache_l2_all_miss",
51-
.metric_name = "DCache_L2_All",
52-
},
53-
{
54-
.metric_expr = "d_ratio(dcache_l2_all_hits, dcache_l2_all)",
55-
.metric_name = "DCache_L2_Hits",
56-
},
57-
{
58-
.metric_expr = "d_ratio(dcache_l2_all_miss, dcache_l2_all)",
59-
.metric_name = "DCache_L2_Misses",
60-
},
61-
{
62-
.metric_expr = "ipc + m2",
63-
.metric_name = "M1",
64-
},
65-
{
66-
.metric_expr = "ipc + m1",
67-
.metric_name = "M2",
68-
},
69-
{
70-
.metric_expr = "1/m3",
71-
.metric_name = "M3",
72-
},
73-
{
74-
.metric_expr = "64 * l1d.replacement / 1000000000 / duration_time",
75-
.metric_name = "L1D_Cache_Fill_BW",
76-
},
77-
{
78-
.name = NULL,
79-
}
80-
};
81-
8216
struct value {
8317
const char *event;
8418
u64 val;
@@ -138,6 +72,7 @@ static int __compute_metric(const char *name, struct value *vals,
13872
struct rblist metric_events = {
13973
.nr_entries = 0,
14074
};
75+
const struct pmu_event *pme_test;
14176
struct perf_cpu_map *cpus;
14277
struct runtime_stat st;
14378
struct evlist *evlist;
@@ -161,6 +96,7 @@ static int __compute_metric(const char *name, struct value *vals,
16196
runtime_stat__init(&st);
16297

16398
/* Parse the metric into metric_events list. */
99+
pme_test = find_core_events_table("testarch", "testcpu");
164100
err = metricgroup__parse_groups_test(evlist, pme_test, name,
165101
false, false,
166102
&metric_events);

0 commit comments

Comments
 (0)