1 // SPDX-License-Identifier: GPL-2.0
3 * An empty pmu-events.c file used when there is no architecture json files in
4 * arch or when the jevents.py script cannot be run.
6 * The test cpu/soc is provided for testing.
8 #include "pmu-events/pmu-events.h"
9 #include "util/header.h"
14 static const struct pmu_event pme_test_soc_cpu[] = {
16 .name = "l3_cache_rd",
17 .event = "event=0x40",
18 .desc = "L3 cache access, read",
20 .long_desc = "Attributable Level 3 cache access, read",
23 .name = "segment_reg_loads.any",
24 .event = "event=0x6,period=200000,umask=0x80",
25 .desc = "Number of segment register loads",
29 .name = "dispatch_blocked.any",
30 .event = "event=0x9,period=200000,umask=0x20",
31 .desc = "Memory cluster signals to block micro-op dispatch for any reason",
36 .event = "event=0x3a,period=200000,umask=0x0",
37 .desc = "Number of Enhanced Intel SpeedStep(R) Technology (EIST) transitions",
41 .name = "uncore_hisi_ddrc.flux_wcmd",
43 .desc = "DDRC write commands. Unit: hisi_sccl,ddrc ",
45 .long_desc = "DDRC write commands",
46 .pmu = "hisi_sccl,ddrc",
49 .name = "unc_cbo_xsnp_response.miss_eviction",
50 .event = "event=0x22,umask=0x81",
51 .desc = "A cross-core snoop resulted from L3 Eviction which misses in some processor core. Unit: uncore_cbox ",
53 .long_desc = "A cross-core snoop resulted from L3 Eviction which misses in some processor core",
57 .name = "event-hyphen",
58 .event = "event=0xe0,umask=0x00",
59 .desc = "UNC_CBO_HYPHEN. Unit: uncore_cbox ",
61 .long_desc = "UNC_CBO_HYPHEN",
65 .name = "event-two-hyph",
66 .event = "event=0xc0,umask=0x00",
67 .desc = "UNC_CBO_TWO_HYPH. Unit: uncore_cbox ",
69 .long_desc = "UNC_CBO_TWO_HYPH",
73 .name = "uncore_hisi_l3c.rd_hit_cpipe",
75 .desc = "Total read hits. Unit: hisi_sccl,l3c ",
77 .long_desc = "Total read hits",
78 .pmu = "hisi_sccl,l3c",
81 .name = "uncore_imc_free_running.cache_miss",
82 .event = "event=0x12",
83 .desc = "Total cache misses. Unit: uncore_imc_free_running ",
85 .long_desc = "Total cache misses",
86 .pmu = "uncore_imc_free_running",
89 .name = "uncore_imc.cache_hits",
90 .event = "event=0x34",
91 .desc = "Total cache hits. Unit: uncore_imc ",
93 .long_desc = "Total cache hits",
97 .name = "bp_l1_btb_correct",
98 .event = "event=0x8a",
99 .desc = "L1 BTB Correction",
103 .name = "bp_l2_btb_correct",
104 .event = "event=0x8b",
105 .desc = "L2 BTB Correction",
117 * Map a CPU to its table of PMU events. The CPU is identified by the
118 * cpuid field, which is an arch-specific identifier for the CPU.
119 * The identifier specified in tools/perf/pmu-events/arch/xxx/mapfile
120 * must match the get_cpuid_str() in tools/perf/arch/xxx/util/header.c)
122 * The cpuid can contain any character other than the comma.
124 struct pmu_events_map {
127 const struct pmu_event *table;
131 * Global table mapping each known CPU for the architecture to its
132 * table of PMU events.
134 static const struct pmu_events_map pmu_events_map[] = {
138 .table = pme_test_soc_cpu,
147 static const struct pmu_event pme_test_soc_sys[] = {
149 .name = "sys_ddr_pmu.write_cycles",
150 .event = "event=0x2b",
151 .desc = "ddr write-cycles event. Unit: uncore_sys_ddr_pmu ",
154 .pmu = "uncore_sys_ddr_pmu",
157 .name = "sys_ccn_pmu.read_cycles",
158 .event = "config=0x2c",
159 .desc = "ccn read-cycles event. Unit: uncore_sys_ccn_pmu ",
162 .pmu = "uncore_sys_ccn_pmu",
171 struct pmu_sys_events {
173 const struct pmu_event *table;
176 static const struct pmu_sys_events pmu_sys_event_tables[] = {
178 .table = pme_test_soc_sys,
179 .name = "pme_test_soc_sys",
186 const struct pmu_event *perf_pmu__find_table(struct perf_pmu *pmu)
188 const struct pmu_event *table = NULL;
189 char *cpuid = perf_pmu__getcpuid(pmu);
192 /* on some platforms which uses cpus map, cpuid can be NULL for
193 * PMUs other than CORE PMUs.
200 const struct pmu_events_map *map = &pmu_events_map[i++];
205 if (!strcmp_cpuid_str(map->cpuid, cpuid)) {
214 const struct pmu_event *find_core_events_table(const char *arch, const char *cpuid)
216 for (const struct pmu_events_map *tables = &pmu_events_map[0];
219 if (!strcmp(tables->arch, arch) && !strcmp_cpuid_str(tables->cpuid, cpuid))
220 return tables->table;
225 int pmu_for_each_core_event(pmu_event_iter_fn fn, void *data)
227 for (const struct pmu_events_map *tables = &pmu_events_map[0];
230 for (const struct pmu_event *pe = &tables->table[0];
231 pe->name || pe->metric_group || pe->metric_name;
233 int ret = fn(pe, &tables->table[0], data);
242 const struct pmu_event *find_sys_events_table(const char *name)
244 for (const struct pmu_sys_events *tables = &pmu_sys_event_tables[0];
247 if (!strcmp(tables->name, name))
248 return tables->table;
253 int pmu_for_each_sys_event(pmu_event_iter_fn fn, void *data)
255 for (const struct pmu_sys_events *tables = &pmu_sys_event_tables[0];
258 for (const struct pmu_event *pe = &tables->table[0];
259 pe->name || pe->metric_group || pe->metric_name;
261 int ret = fn(pe, &tables->table[0], data);