Skip to content

Commit d735599

Browse files
athira-rajeevmpe
authored andcommitted
powerpc/perf: Add extended regs support for power10 platform
Include capability flag PERF_PMU_CAP_EXTENDED_REGS for power10 and expose MMCR3, SIER2, SIER3 registers as part of extended regs. Also introduce PERF_REG_PMU_MASK_31 to define extended mask value at runtime for power10. Suggested-by: Ryan Grimm <[email protected]> Signed-off-by: Athira Rajeev <[email protected]> Tested-by: Nageswara R Sastry <[email protected]> Reviewed-by: Kajol Jain <[email protected]> Reviewed-and-tested-by: Ravi Bangoria <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 781fa48 commit d735599

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

arch/powerpc/include/uapi/asm/perf_regs.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ enum perf_event_powerpc_regs {
5252
PERF_REG_POWERPC_MMCR0,
5353
PERF_REG_POWERPC_MMCR1,
5454
PERF_REG_POWERPC_MMCR2,
55+
PERF_REG_POWERPC_MMCR3,
56+
PERF_REG_POWERPC_SIER2,
57+
PERF_REG_POWERPC_SIER3,
5558
/* Max regs without the extended regs */
5659
PERF_REG_POWERPC_MAX = PERF_REG_POWERPC_MMCRA + 1,
5760
};
@@ -60,6 +63,9 @@ enum perf_event_powerpc_regs {
6063

6164
/* PERF_REG_EXTENDED_MASK value for CPU_FTR_ARCH_300 */
6265
#define PERF_REG_PMU_MASK_300 (((1ULL << (PERF_REG_POWERPC_MMCR2 + 1)) - 1) - PERF_REG_PMU_MASK)
66+
/* PERF_REG_EXTENDED_MASK value for CPU_FTR_ARCH_31 */
67+
#define PERF_REG_PMU_MASK_31 (((1ULL << (PERF_REG_POWERPC_SIER3 + 1)) - 1) - PERF_REG_PMU_MASK)
6368

6469
#define PERF_REG_MAX_ISA_300 (PERF_REG_POWERPC_MMCR2 + 1)
70+
#define PERF_REG_MAX_ISA_31 (PERF_REG_POWERPC_SIER3 + 1)
6571
#endif /* _UAPI_ASM_POWERPC_PERF_REGS_H */

arch/powerpc/perf/perf_regs.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ static u64 get_ext_regs_value(int idx)
8181
return mfspr(SPRN_MMCR1);
8282
case PERF_REG_POWERPC_MMCR2:
8383
return mfspr(SPRN_MMCR2);
84+
#ifdef CONFIG_PPC64
85+
case PERF_REG_POWERPC_MMCR3:
86+
return mfspr(SPRN_MMCR3);
87+
case PERF_REG_POWERPC_SIER2:
88+
return mfspr(SPRN_SIER2);
89+
case PERF_REG_POWERPC_SIER3:
90+
return mfspr(SPRN_SIER3);
91+
#endif
8492
default: return 0;
8593
}
8694
}
@@ -89,7 +97,9 @@ u64 perf_reg_value(struct pt_regs *regs, int idx)
8997
{
9098
u64 perf_reg_extended_max = PERF_REG_POWERPC_MAX;
9199

92-
if (cpu_has_feature(CPU_FTR_ARCH_300))
100+
if (cpu_has_feature(CPU_FTR_ARCH_31))
101+
perf_reg_extended_max = PERF_REG_MAX_ISA_31;
102+
else if (cpu_has_feature(CPU_FTR_ARCH_300))
93103
perf_reg_extended_max = PERF_REG_MAX_ISA_300;
94104

95105
if (idx == PERF_REG_POWERPC_SIER &&

arch/powerpc/perf/power10-pmu.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@
8787
#define POWER10_MMCRA_IFM3 0x00000000C0000000UL
8888
#define POWER10_MMCRA_BHRB_MASK 0x00000000C0000000UL
8989

90+
extern u64 PERF_REG_EXTENDED_MASK;
91+
9092
/* Table of alternatives, sorted by column 0 */
9193
static const unsigned int power10_event_alternatives[][MAX_ALT] = {
9294
{ PM_RUN_CYC_ALT, PM_RUN_CYC },
@@ -397,6 +399,7 @@ static struct power_pmu power10_pmu = {
397399
.cache_events = &power10_cache_events,
398400
.attr_groups = power10_pmu_attr_groups,
399401
.bhrb_nr = 32,
402+
.capabilities = PERF_PMU_CAP_EXTENDED_REGS,
400403
};
401404

402405
int init_power10_pmu(void)
@@ -408,6 +411,9 @@ int init_power10_pmu(void)
408411
strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power10"))
409412
return -ENODEV;
410413

414+
/* Set the PERF_REG_EXTENDED_MASK here */
415+
PERF_REG_EXTENDED_MASK = PERF_REG_PMU_MASK_31;
416+
411417
rc = register_power_pmu(&power10_pmu);
412418
if (rc)
413419
return rc;

0 commit comments

Comments
 (0)