hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/arch/powerpc/perf/power9-pmu.c
....@@ -1,14 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Performance counter support for POWER9 processors.
34 *
45 * Copyright 2009 Paul Mackerras, IBM Corporation.
56 * Copyright 2013 Michael Ellerman, IBM Corporation.
67 * Copyright 2016 Madhavan Srinivasan, IBM Corporation.
7
- *
8
- * This program is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU General Public License
10
- * as published by the Free Software Foundation; either version
11
- * 2 of the License, or later version.
128 */
139
1410 #define pr_fmt(fmt) "power9-pmu: " fmt
....@@ -63,16 +59,8 @@
6359 * MMCRA[9:11] = thresh_cmp[0:2]
6460 * MMCRA[12:18] = thresh_cmp[3:9]
6561 *
66
- * if unit == 6 or unit == 7
67
- * MMCRC[53:55] = cache_sel[1:3] (L2EVENT_SEL)
68
- * else if unit == 8 or unit == 9:
69
- * if cache_sel[0] == 0: # L3 bank
70
- * MMCRC[47:49] = cache_sel[1:3] (L3EVENT_SEL0)
71
- * else if cache_sel[0] == 1:
72
- * MMCRC[50:51] = cache_sel[2:3] (L3EVENT_SEL1)
73
- * else if cache_sel[1]: # L1 event
74
- * MMCR1[16] = cache_sel[2]
75
- * MMCR1[17] = cache_sel[3]
62
+ * MMCR1[16] = cache_sel[2]
63
+ * MMCR1[17] = cache_sel[3]
7664 *
7765 * if mark:
7866 * MMCRA[63] = 1 (SAMPLE_ENABLE)
....@@ -101,6 +89,8 @@
10189 #define POWER9_MMCRA_IFM2 0x0000000080000000UL
10290 #define POWER9_MMCRA_IFM3 0x00000000C0000000UL
10391 #define POWER9_MMCRA_BHRB_MASK 0x00000000C0000000UL
92
+
93
+extern u64 PERF_REG_EXTENDED_MASK;
10494
10595 /* Nasty Power9 specific hack */
10696 #define PVR_POWER9_CUMULUS 0x00002000
....@@ -143,11 +133,11 @@
143133
144134 /* Table of alternatives, sorted by column 0 */
145135 static const unsigned int power9_event_alternatives[][MAX_ALT] = {
146
- { PM_INST_DISP, PM_INST_DISP_ALT },
147
- { PM_RUN_CYC_ALT, PM_RUN_CYC },
148
- { PM_RUN_INST_CMPL_ALT, PM_RUN_INST_CMPL },
149
- { PM_LD_MISS_L1, PM_LD_MISS_L1_ALT },
150136 { PM_BR_2PATH, PM_BR_2PATH_ALT },
137
+ { PM_INST_DISP, PM_INST_DISP_ALT },
138
+ { PM_RUN_CYC_ALT, PM_RUN_CYC },
139
+ { PM_LD_MISS_L1, PM_LD_MISS_L1_ALT },
140
+ { PM_RUN_INST_CMPL_ALT, PM_RUN_INST_CMPL },
151141 };
152142
153143 static int power9_get_alternatives(u64 event, unsigned int flags, u64 alt[])
....@@ -169,6 +159,8 @@
169159 GENERIC_EVENT_ATTR(branch-misses, PM_BR_MPRED_CMPL);
170160 GENERIC_EVENT_ATTR(cache-references, PM_LD_REF_L1);
171161 GENERIC_EVENT_ATTR(cache-misses, PM_LD_MISS_L1_FIN);
162
+GENERIC_EVENT_ATTR(mem-loads, MEM_LOADS);
163
+GENERIC_EVENT_ATTR(mem-stores, MEM_STORES);
172164
173165 CACHE_EVENT_ATTR(L1-dcache-load-misses, PM_LD_MISS_L1_FIN);
174166 CACHE_EVENT_ATTR(L1-dcache-loads, PM_LD_REF_L1);
....@@ -180,8 +172,6 @@
180172 CACHE_EVENT_ATTR(LLC-load-misses, PM_DATA_FROM_L3MISS);
181173 CACHE_EVENT_ATTR(LLC-loads, PM_DATA_FROM_L3);
182174 CACHE_EVENT_ATTR(LLC-prefetches, PM_L3_PREF_ALL);
183
-CACHE_EVENT_ATTR(LLC-store-misses, PM_L2_ST_MISS);
184
-CACHE_EVENT_ATTR(LLC-stores, PM_L2_ST);
185175 CACHE_EVENT_ATTR(branch-load-misses, PM_BR_MPRED_CMPL);
186176 CACHE_EVENT_ATTR(branch-loads, PM_BR_CMPL);
187177 CACHE_EVENT_ATTR(dTLB-load-misses, PM_DTLB_MISS);
....@@ -196,6 +186,8 @@
196186 GENERIC_EVENT_PTR(PM_BR_MPRED_CMPL),
197187 GENERIC_EVENT_PTR(PM_LD_REF_L1),
198188 GENERIC_EVENT_PTR(PM_LD_MISS_L1_FIN),
189
+ GENERIC_EVENT_PTR(MEM_LOADS),
190
+ GENERIC_EVENT_PTR(MEM_STORES),
199191 CACHE_EVENT_PTR(PM_LD_MISS_L1_FIN),
200192 CACHE_EVENT_PTR(PM_LD_REF_L1),
201193 CACHE_EVENT_PTR(PM_L1_PREF),
....@@ -206,8 +198,6 @@
206198 CACHE_EVENT_PTR(PM_DATA_FROM_L3MISS),
207199 CACHE_EVENT_PTR(PM_DATA_FROM_L3),
208200 CACHE_EVENT_PTR(PM_L3_PREF_ALL),
209
- CACHE_EVENT_PTR(PM_L2_ST_MISS),
210
- CACHE_EVENT_PTR(PM_L2_ST),
211201 CACHE_EVENT_PTR(PM_BR_MPRED_CMPL),
212202 CACHE_EVENT_PTR(PM_BR_CMPL),
213203 CACHE_EVENT_PTR(PM_DTLB_MISS),
....@@ -322,7 +312,7 @@
322312 * 0 means not supported, -1 means nonsensical, other values
323313 * are event codes.
324314 */
325
-static int power9_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = {
315
+static u64 power9_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = {
326316 [ C(L1D) ] = {
327317 [ C(OP_READ) ] = {
328318 [ C(RESULT_ACCESS) ] = PM_LD_REF_L1,
....@@ -357,8 +347,8 @@
357347 [ C(RESULT_MISS) ] = PM_DATA_FROM_L3MISS,
358348 },
359349 [ C(OP_WRITE) ] = {
360
- [ C(RESULT_ACCESS) ] = PM_L2_ST,
361
- [ C(RESULT_MISS) ] = PM_L2_ST_MISS,
350
+ [ C(RESULT_ACCESS) ] = 0,
351
+ [ C(RESULT_MISS) ] = 0,
362352 },
363353 [ C(OP_PREFETCH) ] = {
364354 [ C(RESULT_ACCESS) ] = PM_L3_PREF_ALL,
....@@ -430,6 +420,8 @@
430420 .n_counter = MAX_PMU_COUNTERS,
431421 .add_fields = ISA207_ADD_FIELDS,
432422 .test_adder = ISA207_TEST_ADDER,
423
+ .group_constraint_mask = CNST_CACHE_PMC4_MASK,
424
+ .group_constraint_val = CNST_CACHE_PMC4_VAL,
433425 .compute_mmcr = isa207_compute_mmcr,
434426 .config_bhrb = power9_config_bhrb,
435427 .bhrb_filter_map = power9_bhrb_filter_map,
....@@ -444,9 +436,10 @@
444436 .cache_events = &power9_cache_events,
445437 .attr_groups = power9_pmu_attr_groups,
446438 .bhrb_nr = 32,
439
+ .capabilities = PERF_PMU_CAP_EXTENDED_REGS,
447440 };
448441
449
-static int __init init_power9_pmu(void)
442
+int init_power9_pmu(void)
450443 {
451444 int rc = 0;
452445 unsigned int pvr = mfspr(SPRN_PVR);
....@@ -467,6 +460,9 @@
467460 }
468461 }
469462
463
+ /* Set the PERF_REG_EXTENDED_MASK here */
464
+ PERF_REG_EXTENDED_MASK = PERF_REG_PMU_MASK_300;
465
+
470466 rc = register_power_pmu(&power9_pmu);
471467 if (rc)
472468 return rc;
....@@ -476,4 +472,3 @@
476472
477473 return 0;
478474 }
479
-early_initcall(init_power9_pmu);