Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.garry@huawei.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Will Deacon <will@kernel.org>
Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20220812230949.683239-10-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
7ae5c03a 64234c14

+132 -81
+64
tools/perf/pmu-events/arch/test/test_soc/cpu/metrics.json
··· 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 + ]
+64
tools/perf/pmu-events/empty-pmu-events.c
··· 106 106 .topic = "branch", 107 107 }, 108 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 + }, 172 + { 109 173 .name = 0, 110 174 .event = 0, 111 175 .desc = 0,
+2 -15
tools/perf/tests/expand-cgroup.c
··· 180 180 struct evlist *evlist; 181 181 struct rblist metric_events; 182 182 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; 198 184 199 185 evlist = evlist__new(); 200 186 TEST_ASSERT_VAL("failed to get evlist", evlist); 201 187 202 188 rblist__init(&metric_events); 189 + pme_test = find_core_events_table("testarch", "testcpu"); 203 190 ret = metricgroup__parse_groups_test(evlist, pme_test, metric_str, 204 191 false, false, &metric_events); 205 192 if (ret < 0) {
+2 -66
tools/perf/tests/parse-metric.c
··· 13 13 #include "stat.h" 14 14 #include "pmu.h" 15 15 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 - 82 16 struct value { 83 17 const char *event; 84 18 u64 val; ··· 72 138 struct rblist metric_events = { 73 139 .nr_entries = 0, 74 140 }; 141 + const struct pmu_event *pme_test; 75 142 struct perf_cpu_map *cpus; 76 143 struct runtime_stat st; 77 144 struct evlist *evlist; ··· 96 161 runtime_stat__init(&st); 97 162 98 163 /* Parse the metric into metric_events list. */ 164 + pme_test = find_core_events_table("testarch", "testcpu"); 99 165 err = metricgroup__parse_groups_test(evlist, pme_test, name, 100 166 false, false, 101 167 &metric_events);