Skip to content

Commit 333804d

Browse files
Madhavan Srinivasanmpe
Madhavan Srinivasan
authored andcommitted
powerpc/perf: Update perf_regs structure to include SIER
On each sample, Sample Instruction Event Register (SIER) content is saved in pt_regs. SIER does not have a entry as-is in the pt_regs but instead, SIER content is saved in the "dar" register of pt_regs. Patch adds another entry to the perf_regs structure to include the "SIER" printing which internally maps to the "dar" of pt_regs. It also check for the SIER availability in the platform and present value accordingly Signed-off-by: Madhavan Srinivasan <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent 17cfccc commit 333804d

File tree

7 files changed

+23
-1
lines changed

7 files changed

+23
-1
lines changed

arch/powerpc/include/asm/perf_event.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,7 @@
3939
(regs)->gpr[1] = current_stack_pointer(); \
4040
asm volatile("mfmsr %0" : "=r" ((regs)->msr)); \
4141
} while (0)
42+
43+
/* To support perf_regs sier update */
44+
extern bool is_sier_available(void);
4245
#endif

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ enum perf_event_powerpc_regs {
4646
PERF_REG_POWERPC_TRAP,
4747
PERF_REG_POWERPC_DAR,
4848
PERF_REG_POWERPC_DSISR,
49+
PERF_REG_POWERPC_SIER,
4950
PERF_REG_POWERPC_MAX,
5051
};
5152
#endif /* _UAPI_ASM_POWERPC_PERF_REGS_H */

arch/powerpc/perf/core-book3s.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,14 @@ static inline void power_pmu_bhrb_read(struct cpu_hw_events *cpuhw) {}
130130
static void pmao_restore_workaround(bool ebb) { }
131131
#endif /* CONFIG_PPC32 */
132132

133+
bool is_sier_available(void)
134+
{
135+
if (ppmu->flags & PPMU_HAS_SIER)
136+
return true;
137+
138+
return false;
139+
}
140+
133141
static bool regs_use_siar(struct pt_regs *regs)
134142
{
135143
/*

arch/powerpc/perf/perf_regs.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,20 @@ static unsigned int pt_regs_offset[PERF_REG_POWERPC_MAX] = {
6969
PT_REGS_OFFSET(PERF_REG_POWERPC_TRAP, trap),
7070
PT_REGS_OFFSET(PERF_REG_POWERPC_DAR, dar),
7171
PT_REGS_OFFSET(PERF_REG_POWERPC_DSISR, dsisr),
72+
PT_REGS_OFFSET(PERF_REG_POWERPC_SIER, dar),
7273
};
7374

7475
u64 perf_reg_value(struct pt_regs *regs, int idx)
7576
{
7677
if (WARN_ON_ONCE(idx >= PERF_REG_POWERPC_MAX))
7778
return 0;
7879

80+
if (idx == PERF_REG_POWERPC_SIER &&
81+
(IS_ENABLED(CONFIG_FSL_EMB_PERF_EVENT) ||
82+
IS_ENABLED(CONFIG_PPC32) ||
83+
!is_sier_available()))
84+
return 0;
85+
7986
return regs_get_register(regs, pt_regs_offset[idx]);
8087
}
8188

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ enum perf_event_powerpc_regs {
4646
PERF_REG_POWERPC_TRAP,
4747
PERF_REG_POWERPC_DAR,
4848
PERF_REG_POWERPC_DSISR,
49+
PERF_REG_POWERPC_SIER,
4950
PERF_REG_POWERPC_MAX,
5051
};
5152
#endif /* _UAPI_ASM_POWERPC_PERF_REGS_H */

tools/perf/arch/powerpc/include/perf_regs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ static const char *reg_names[] = {
6262
[PERF_REG_POWERPC_SOFTE] = "softe",
6363
[PERF_REG_POWERPC_TRAP] = "trap",
6464
[PERF_REG_POWERPC_DAR] = "dar",
65-
[PERF_REG_POWERPC_DSISR] = "dsisr"
65+
[PERF_REG_POWERPC_DSISR] = "dsisr",
66+
[PERF_REG_POWERPC_SIER] = "sier"
6667
};
6768

6869
static inline const char *perf_reg_name(int id)

tools/perf/arch/powerpc/util/perf_regs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const struct sample_reg sample_reg_masks[] = {
5252
SMPL_REG(trap, PERF_REG_POWERPC_TRAP),
5353
SMPL_REG(dar, PERF_REG_POWERPC_DAR),
5454
SMPL_REG(dsisr, PERF_REG_POWERPC_DSISR),
55+
SMPL_REG(sier, PERF_REG_POWERPC_SIER),
5556
SMPL_REG_END
5657
};
5758

0 commit comments

Comments
 (0)