powerpc/perf: Power PMU fixes for power10 DD1
cover powerpc/perf: Power PMU fixes for power10 DD1
The patch series addresses PMU fixes for power10 DD1
Patch1 introduces a new power pmu flag to include conditional code changes for power10 DD1.
Patch2 and Patch3 includes fixes in core-book3s to address issues with marked events during sampling.
Patch4 includes fix to drop kernel samples while userspace profiling.
Athira Rajeev (4):
powerpc/perf: Add new power pmu flag "PPMU_P10_DD1" for power10 DD1 powerpc/perf: Using SIER[CMPL] instead of SIER[SIAR_VALID] powerpc/perf: Use the address from SIAR register to set cpumode flags powerpc/perf: Exclude kernel samples while counting events in user
space.
arch/powerpc/include/asm/perf_event_server.h | 1 + arch/powerpc/perf/core-book3s.c | 35 +++++++++++++++++++++++++++- arch/powerpc/perf/power10-pmu.c | 6 +++++ 3 files changed, 41 insertions(+), 1 deletion(-)
Signature · 1 line
1.8.3.1
PATCH 1/4 powerpc/perf: Add new power pmu flag "PPMU_P10_DD1" for power10 DD1
Add a new power PMU flag "PPMU_P10_DD1" which can be used to conditionally add any code path for power10 DD1 processor version. Also modify power10 PMU driver code to set this flag only for DD1, based on the Processor Version Register (PVR) value.
--- arch/powerpc/include/asm/perf_event_server.h | 1 + arch/powerpc/perf/power10-pmu.c | 6 ++++++ 2 files changed, 7 insertions(+)
arch/powerpc/include/asm/perf_event_server.h +1 -0
@@ -82,6 +82,7 @@ struct power_pmu {#define PPMU_ARCH_207S 0x00000080/* PMC is architecture v2.07S */ #define PPMU_NO_SIAR 0x00000100/* Do not use SIAR */ #define PPMU_ARCH_31 0x00000200/* Has MMCR3, SIER2 and SIER3 */ +#define PPMU_P10_DD1 0x00000400/* Is power10 DD1 processor version */ /* * Values for flags to get_alternatives()
arch/powerpc/perf/power10-pmu.c +6 -0
@@ -404,6 +404,7 @@ static void power10_config_bhrb(u64 pmu_bhrb_filter)int init_power10_pmu (void ) { +unsigned int pvr;int rc;/* Comes from cpu_specs[] */
@@ -411,6 +412,11 @@ int init_power10_pmu(void) strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power10"))return -ENODEV ; + pvr =mfspr (SPRN_PVR ); +/* Add the ppmu flag for power10 DD1 */ +if ((PVR_CFG (pvr) ==1 )) + power10_pmu.flags |=PPMU_P10_DD1 ; +/* Set the PERF_REG_EXTENDED_MASK here */ PERF_REG_EXTENDED_MASK =PERF_REG_PMU_MASK_31 ;
Signature · 1 line
1.8.3.1
PATCH 2/4 powerpc/perf: Using SIER[CMPL] instead of SIER[SIAR_VALID]
In reply to Athira RajeevOn power10 DD1, there is an issue that causes the SIAR_VALID bit of Sampled Instruction Event Register(SIER) not to be set. But the SIAR_VALID bit is used for fetching the instruction address from Sampled Instruction Address Register(SIAR), and marked events are sampled only if the SIAR_VALID bit is set. So add a condition check for power10 DD1 to use SIER[CMPL] bit instead.
--- arch/powerpc/perf/core-book3s.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
arch/powerpc/perf/core-book3s.c +8 -1
@@ -350,7 +350,14 @@ static inline int siar_valid(struct pt_regs *regs)int marked = mmcra &MMCRA_SAMPLE_ENABLE ;if (marked) { -if (ppmu->flags &PPMU_HAS_SIER ) +/* +* SIER[SIAR_VALID] is not set for some +* marked events on power10 DD1, so use +* SIER[CMPL] instead. +*/ +if (ppmu->flags &PPMU_P10_DD1 ) +return regs->dar &0x1 ; +else if (ppmu->flags &PPMU_HAS_SIER )return regs->dar &SIER_SIAR_VALID ;if (ppmu->flags &PPMU_SIAR_VALID )
Signature · 1 line
1.8.3.1
PATCH 3/4 powerpc/perf: Use the address from SIAR register to set cpumode flags
In reply to Athira RajeevWhile setting the processor mode for any sample, perf_get_misc_flags expects the privilege level to differentiate the userspace and kernel address. On power10 DD1, there is an issue that causes [MSR_HV MSR_PR] bits of Sampled Instruction Event Register (SIER) not to be set for marked events. Hence add a check to use the address in Sampled Instruction Address Register (SIAR) to identify the privilege level.
--- arch/powerpc/perf/core-book3s.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
arch/powerpc/perf/core-book3s.c +14 -0
@@ -250,11 +250,25 @@ static inline u32 perf_flags_from_msr(struct pt_regs *regs)static inline u32 perf_get_misc_flags (struct pt_regs *regs) {bool use_siar =regs_use_siar (regs); +unsigned long mmcra = regs->dsisr; +int marked = mmcra &MMCRA_SAMPLE_ENABLE ;if (!use_siar)return perf_flags_from_msr (regs);/* +* Check the address in SIAR to identify the +* privilege levels since the SIER[MSR_HV, MSR_PR] +* bits are not set for marked events in power10 +* DD1. +*/ +if (marked && (ppmu->flags &PPMU_P10_DD1 )) { +if (is_kernel_addr (mfspr (SPRN_SIAR ))) +return PERF_RECORD_MISC_KERNEL ; +return PERF_RECORD_MISC_USER ; + } + +/* * If we don't have flags in MMCRA, rather than using * the MSR, we intuit the flags from the address in * SIAR which should give slightly more reliable
Signature · 1 line
1.8.3.1
PATCH 4/4 powerpc/perf: Exclude kernel samples while counting events in user space.
In reply to Athira RajeevBy setting exclude_kernel for user space profiling, we set the freeze bits in Monitor Mode Control Register. Due to hardware limitation, sometimes, Sampled Instruction Address register (SIAR) captures kernel address even when counter freeze bits are set in Monitor Mode Control Register (MMCR2). Patch adds a check to drop these samples at such conditions.
--- arch/powerpc/perf/core-book3s.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
arch/powerpc/perf/core-book3s.c +12 -0
@@ -2143,6 +2143,18 @@ static void record_and_restart(struct perf_event *event, unsigned long val,perf_event_update_userpage (event);/* +* Setting exclude_kernel will only freeze the +* Performance Monitor counters and we may have +* kernel address captured in SIAR. Hence drop +* the kernel sample captured during user space +* profiling. Setting `record` to zero will also +* make sure event throlling is handled. +*/ +if (event->attr.exclude_kernel && record) +if (is_kernel_addr (mfspr (SPRN_SIAR ))) + record =0 ; + +/* * Finally record data if requested. */ if (record) {
Signature · 1 line
1.8.3.1