Skip to content

Commit 2169463

Browse files
committed
Merge: Updates for powerpc perf mem data
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/6547 Description: Updates for powerpc perf mem data JIRA: https://issues.redhat.com/browse/RHEL-80602 Build Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=66923908 Tested: Verified Brew build test kernel RPMs Signed-off-by: Mamatha Inamdar <[email protected]> Approved-by: Steve Best <[email protected]> Approved-by: Tony Camuso <[email protected]> Approved-by: CKI KWF Bot <[email protected]> Merged-by: Augusto Caringi <[email protected]>
2 parents b88709c + 287840f commit 2169463

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

arch/powerpc/perf/core-book3s.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,6 +2212,10 @@ static struct pmu power_pmu = {
22122212
#define PERF_SAMPLE_ADDR_TYPE (PERF_SAMPLE_ADDR | \
22132213
PERF_SAMPLE_PHYS_ADDR | \
22142214
PERF_SAMPLE_DATA_PAGE_SIZE)
2215+
2216+
#define SIER_TYPE_SHIFT 15
2217+
#define SIER_TYPE_MASK (0x7ull << SIER_TYPE_SHIFT)
2218+
22152219
/*
22162220
* A counter has overflowed; update its count and record
22172221
* things if requested. Note that interrupts are hard-disabled
@@ -2280,6 +2284,22 @@ static void record_and_restart(struct perf_event *event, unsigned long val,
22802284
is_kernel_addr(mfspr(SPRN_SIAR)))
22812285
record = 0;
22822286

2287+
/*
2288+
* SIER[46-48] presents instruction type of the sampled instruction.
2289+
* In ISA v3.0 and before values "0" and "7" are considered reserved.
2290+
* In ISA v3.1, value "7" has been used to indicate "larx/stcx".
2291+
* Drop the sample if "type" has reserved values for this field with a
2292+
* ISA version check.
2293+
*/
2294+
if (event->attr.sample_type & PERF_SAMPLE_DATA_SRC &&
2295+
ppmu->get_mem_data_src) {
2296+
val = (regs->dar & SIER_TYPE_MASK) >> SIER_TYPE_SHIFT;
2297+
if (val == 0 || (val == 7 && !cpu_has_feature(CPU_FTR_ARCH_31))) {
2298+
record = 0;
2299+
atomic64_inc(&event->lost_samples);
2300+
}
2301+
}
2302+
22832303
/*
22842304
* Finally record data if requested.
22852305
*/

arch/powerpc/perf/isa207-common.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,18 @@ void isa207_get_mem_data_src(union perf_mem_data_src *dsrc, u32 flags,
319319
return;
320320
}
321321

322-
sier = mfspr(SPRN_SIER);
322+
/*
323+
* Use regs-dar for SPRN_SIER which is saved
324+
* during perf_read_regs at the beginning
325+
* of the PMU interrupt handler to avoid multiple
326+
* reads of SPRN_SIER
327+
*/
328+
sier = regs->dar;
323329
val = (sier & ISA207_SIER_TYPE_MASK) >> ISA207_SIER_TYPE_SHIFT;
324-
if (val != 1 && val != 2 && !(val == 7 && cpu_has_feature(CPU_FTR_ARCH_31)))
330+
if (val != 1 && val != 2 && !(val == 7 && cpu_has_feature(CPU_FTR_ARCH_31))) {
331+
dsrc->val = 0;
325332
return;
333+
}
326334

327335
idx = (sier & ISA207_SIER_LDST_MASK) >> ISA207_SIER_LDST_SHIFT;
328336
sub_idx = (sier & ISA207_SIER_DATA_SRC_MASK) >> ISA207_SIER_DATA_SRC_SHIFT;
@@ -338,8 +346,12 @@ void isa207_get_mem_data_src(union perf_mem_data_src *dsrc, u32 flags,
338346
* to determine the exact instruction type. If the sampling
339347
* criteria is neither load or store, set the type as default
340348
* to NA.
349+
*
350+
* Use regs->dsisr for MMCRA which is saved during perf_read_regs
351+
* at the beginning of the PMU interrupt handler to avoid
352+
* multiple reads of SPRN_MMCRA
341353
*/
342-
mmcra = mfspr(SPRN_MMCRA);
354+
mmcra = regs->dsisr;
343355

344356
op_type = (mmcra >> MMCRA_SAMP_ELIG_SHIFT) & MMCRA_SAMP_ELIG_MASK;
345357
switch (op_type) {

0 commit comments

Comments
 (0)