aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/perf
diff options
context:
space:
mode:
authorMichael Ellerman <mpe@ellerman.id.au>2014-03-14 01:00:33 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2014-03-23 18:48:27 -0400
commitba969237cfba17fcf0de8596b128f68259293137 (patch)
tree5eadd4eca60e37f3cb16e6304bfa6540d89f8d5d /arch/powerpc/perf
parent7cbba630288112e231558d055123cfc3e19feeb6 (diff)
powerpc/perf: Add BHRB constraint and IFM MMCRA handling for EBB
We want a way for users of EBB (Event Based Branches) to also access the BHRB (Branch History Rolling Buffer). EBB does not interoperate with our existing BHRB support, which is wired into the generic Linux branch stack sampling support. To support EBB & BHRB we add three new bits to the event code. The first bit indicates that the event wants access to the BHRB, and the other two bits indicate the desired IFM (Instruction Filtering Mode). We allow multiple events to request access to the BHRB, but they must agree on the IFM value. Events which are not interested in the BHRB can also interoperate with events which do. Finally we program the desired IFM value into MMCRA. Although we do this for every event, we know that the value will be identical for all events that request BHRB access. Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/perf')
-rw-r--r--arch/powerpc/perf/power8-pmu.c53
1 files changed, 44 insertions, 9 deletions
diff --git a/arch/powerpc/perf/power8-pmu.c b/arch/powerpc/perf/power8-pmu.c
index 67aab104b9fe..3ad363da05f6 100644
--- a/arch/powerpc/perf/power8-pmu.c
+++ b/arch/powerpc/perf/power8-pmu.c
@@ -64,9 +64,11 @@
64 * 64 *
65 * 60 56 52 48 44 40 36 32 65 * 60 56 52 48 44 40 36 32
66 * | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | 66 * | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - |
67 * | [ thresh_cmp ] [ thresh_ctl ] 67 * | | [ ] [ thresh_cmp ] [ thresh_ctl ]
68 * | | 68 * | | | |
69 * *- EBB (Linux) thresh start/stop OR FAB match -* 69 * | | *- IFM (Linux) thresh start/stop OR FAB match -*
70 * | *- BHRB (Linux)
71 * *- EBB (Linux)
70 * 72 *
71 * 28 24 20 16 12 8 4 0 73 * 28 24 20 16 12 8 4 0
72 * | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | 74 * | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - |
@@ -116,10 +118,18 @@
116 * MMCRA[57:59] = sample[0:2] (RAND_SAMP_ELIG) 118 * MMCRA[57:59] = sample[0:2] (RAND_SAMP_ELIG)
117 * MMCRA[61:62] = sample[3:4] (RAND_SAMP_MODE) 119 * MMCRA[61:62] = sample[3:4] (RAND_SAMP_MODE)
118 * 120 *
121 * if EBB and BHRB:
122 * MMCRA[32:33] = IFM
123 *
119 */ 124 */
120 125
121#define EVENT_EBB_MASK 1ull 126#define EVENT_EBB_MASK 1ull
122#define EVENT_EBB_SHIFT PERF_EVENT_CONFIG_EBB_SHIFT 127#define EVENT_EBB_SHIFT PERF_EVENT_CONFIG_EBB_SHIFT
128#define EVENT_BHRB_MASK 1ull
129#define EVENT_BHRB_SHIFT 62
130#define EVENT_WANTS_BHRB (EVENT_BHRB_MASK << EVENT_BHRB_SHIFT)
131#define EVENT_IFM_MASK 3ull
132#define EVENT_IFM_SHIFT 60
123#define EVENT_THR_CMP_SHIFT 40 /* Threshold CMP value */ 133#define EVENT_THR_CMP_SHIFT 40 /* Threshold CMP value */
124#define EVENT_THR_CMP_MASK 0x3ff 134#define EVENT_THR_CMP_MASK 0x3ff
125#define EVENT_THR_CTL_SHIFT 32 /* Threshold control value (start/stop) */ 135#define EVENT_THR_CTL_SHIFT 32 /* Threshold control value (start/stop) */
@@ -144,6 +154,12 @@
144#define EVENT_IS_MARKED (EVENT_MARKED_MASK << EVENT_MARKED_SHIFT) 154#define EVENT_IS_MARKED (EVENT_MARKED_MASK << EVENT_MARKED_SHIFT)
145#define EVENT_PSEL_MASK 0xff /* PMCxSEL value */ 155#define EVENT_PSEL_MASK 0xff /* PMCxSEL value */
146 156
157/* Bits defined by Linux */
158#define EVENT_LINUX_MASK \
159 ((EVENT_EBB_MASK << EVENT_EBB_SHIFT) | \
160 (EVENT_BHRB_MASK << EVENT_BHRB_SHIFT) | \
161 (EVENT_IFM_MASK << EVENT_IFM_SHIFT))
162
147#define EVENT_VALID_MASK \ 163#define EVENT_VALID_MASK \
148 ((EVENT_THRESH_MASK << EVENT_THRESH_SHIFT) | \ 164 ((EVENT_THRESH_MASK << EVENT_THRESH_SHIFT) | \
149 (EVENT_SAMPLE_MASK << EVENT_SAMPLE_SHIFT) | \ 165 (EVENT_SAMPLE_MASK << EVENT_SAMPLE_SHIFT) | \
@@ -152,7 +168,7 @@
152 (EVENT_UNIT_MASK << EVENT_UNIT_SHIFT) | \ 168 (EVENT_UNIT_MASK << EVENT_UNIT_SHIFT) | \
153 (EVENT_COMBINE_MASK << EVENT_COMBINE_SHIFT) | \ 169 (EVENT_COMBINE_MASK << EVENT_COMBINE_SHIFT) | \
154 (EVENT_MARKED_MASK << EVENT_MARKED_SHIFT) | \ 170 (EVENT_MARKED_MASK << EVENT_MARKED_SHIFT) | \
155 (EVENT_EBB_MASK << EVENT_EBB_SHIFT) | \ 171 EVENT_LINUX_MASK | \
156 EVENT_PSEL_MASK) 172 EVENT_PSEL_MASK)
157 173
158/* MMCRA IFM bits - POWER8 */ 174/* MMCRA IFM bits - POWER8 */
@@ -176,10 +192,11 @@
176 * 192 *
177 * 28 24 20 16 12 8 4 0 193 * 28 24 20 16 12 8 4 0
178 * | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | 194 * | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - |
179 * | [ ] [ sample ] [ ] [6] [5] [4] [3] [2] [1] 195 * [ ] | [ ] [ sample ] [ ] [6] [5] [4] [3] [2] [1]
180 * EBB -* | | 196 * | | | |
181 * | | Count of events for each PMC. 197 * BHRB IFM -* | | | Count of events for each PMC.
182 * L1 I/D qualifier -* | p1, p2, p3, p4, p5, p6. 198 * EBB -* | | p1, p2, p3, p4, p5, p6.
199 * L1 I/D qualifier -* |
183 * nc - number of counters -* 200 * nc - number of counters -*
184 * 201 *
185 * The PMC fields P1..P6, and NC, are adder fields. As we accumulate constraints 202 * The PMC fields P1..P6, and NC, are adder fields. As we accumulate constraints
@@ -198,6 +215,9 @@
198#define CNST_EBB_VAL(v) (((v) & EVENT_EBB_MASK) << 24) 215#define CNST_EBB_VAL(v) (((v) & EVENT_EBB_MASK) << 24)
199#define CNST_EBB_MASK CNST_EBB_VAL(EVENT_EBB_MASK) 216#define CNST_EBB_MASK CNST_EBB_VAL(EVENT_EBB_MASK)
200 217
218#define CNST_IFM_VAL(v) (((v) & EVENT_IFM_MASK) << 25)
219#define CNST_IFM_MASK CNST_IFM_VAL(EVENT_IFM_MASK)
220
201#define CNST_L1_QUAL_VAL(v) (((v) & 3) << 22) 221#define CNST_L1_QUAL_VAL(v) (((v) & 3) << 22)
202#define CNST_L1_QUAL_MASK CNST_L1_QUAL_VAL(3) 222#define CNST_L1_QUAL_MASK CNST_L1_QUAL_VAL(3)
203 223
@@ -244,6 +264,7 @@
244#define MMCRA_THR_SEL_SHIFT 16 264#define MMCRA_THR_SEL_SHIFT 16
245#define MMCRA_THR_CMP_SHIFT 32 265#define MMCRA_THR_CMP_SHIFT 32
246#define MMCRA_SDAR_MODE_TLB (1ull << 42) 266#define MMCRA_SDAR_MODE_TLB (1ull << 42)
267#define MMCRA_IFM_SHIFT 30
247 268
248 269
249static inline bool event_is_fab_match(u64 event) 270static inline bool event_is_fab_match(u64 event)
@@ -277,7 +298,7 @@ static int power8_get_constraint(u64 event, unsigned long *maskp, unsigned long
277 return -1; 298 return -1;
278 299
279 /* Ignore Linux defined bits when checking event below */ 300 /* Ignore Linux defined bits when checking event below */
280 base_event = event & ~(EVENT_EBB_MASK << EVENT_EBB_SHIFT); 301 base_event = event & ~EVENT_LINUX_MASK;
281 302
282 if (pmc >= 5 && base_event != 0x500fa && base_event != 0x600f4) 303 if (pmc >= 5 && base_event != 0x500fa && base_event != 0x600f4)
283 return -1; 304 return -1;
@@ -347,6 +368,15 @@ static int power8_get_constraint(u64 event, unsigned long *maskp, unsigned long
347 /* EBB events must specify the PMC */ 368 /* EBB events must specify the PMC */
348 return -1; 369 return -1;
349 370
371 if (event & EVENT_WANTS_BHRB) {
372 if (!ebb)
373 /* Only EBB events can request BHRB */
374 return -1;
375
376 mask |= CNST_IFM_MASK;
377 value |= CNST_IFM_VAL(event >> EVENT_IFM_SHIFT);
378 }
379
350 /* 380 /*
351 * All events must agree on EBB, either all request it or none. 381 * All events must agree on EBB, either all request it or none.
352 * EBB events are pinned & exclusive, so this should never actually 382 * EBB events are pinned & exclusive, so this should never actually
@@ -436,6 +466,11 @@ static int power8_compute_mmcr(u64 event[], int n_ev,
436 mmcra |= val << MMCRA_THR_CMP_SHIFT; 466 mmcra |= val << MMCRA_THR_CMP_SHIFT;
437 } 467 }
438 468
469 if (event[i] & EVENT_WANTS_BHRB) {
470 val = (event[i] >> EVENT_IFM_SHIFT) & EVENT_IFM_MASK;
471 mmcra |= val << MMCRA_IFM_SHIFT;
472 }
473
439 hwc[i] = pmc - 1; 474 hwc[i] = pmc - 1;
440 } 475 }
441 476