powerpc/perf: Add instruction and data address registers to extended regs
Subsystems (2)
v2 cover powerpc/perf: Add instruction and data address registers to extended regs
Patch set adds PMU registers namely Sampled Instruction Address Register (SIAR) and Sampled Data Address Register (SDAR) as part of extended regs in PowerPC. These registers provides the instruction/data address and adding these to extended regs helps in debug purposes.
Patch 1/4 and 2/4 refactors the existing macro definition of PERF_REG_PMU_MASK_300 and PERF_REG_PMU_MASK_31 to make it more readable.
Patch 3/4 adds SIAR and SDAR as part of the extended regs mask. Patch 4/4 includes perf tools side changes to add the SPRs to sample_reg_mask to use with -I? option.
Changelog:
Change from v1 -> v2:
Addressed review comments from Michael Ellerman
- Refactored the perf reg extended mask value macros for PERF_REG_PMU_MASK_300 and PERF_REG_PMU_MASK_31 to make it more readable. Also moved PERF_REG_EXTENDED_MAX along with enum definition similar to PERF_REG_POWERPC_MAX.
Athira Rajeev (4):
powerpc/perf: Refactor the code definition of perf reg extended mask tools/perf: Refactor the code definition of perf reg extended mask in
tools side header file
powerpc/perf: Expose instruction and data address registers as part of
extended regs
tools/perf: Add perf tools support to expose instruction and data
address registers as part of extended regs
arch/powerpc/include/uapi/asm/perf_regs.h | 28 ++++++++++++------- arch/powerpc/perf/perf_regs.c | 4 +++ .../arch/powerpc/include/uapi/asm/perf_regs.h | 28 ++++++++++++------- tools/perf/arch/powerpc/include/perf_regs.h | 2 ++ tools/perf/arch/powerpc/util/perf_regs.c | 2 ++ 5 files changed, 44 insertions(+), 20 deletions(-)
Signature · 1 line
2.30.1 (Apple Git-130)
PATCH v2 1/4 powerpc/perf: Refactor the code definition of perf reg extended mask
PERF_REG_PMU_MASK_300 and PERF_REG_PMU_MASK_31 defines the mask value for extended registers. Current definition of these mask values uses hex constant and does not use registers by name, making it less readable. Patch refactor the macro values by or'ing together the actual register value constants. Also include PERF_REG_EXTENDED_MAX as part of enum definition.
--- arch/powerpc/include/uapi/asm/perf_regs.h | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
arch/powerpc/include/uapi/asm/perf_regs.h +13 -8
@@ -61,27 +61,32 @@ enum perf_event_powerpc_regs {PERF_REG_POWERPC_PMC4 ,PERF_REG_POWERPC_PMC5 ,PERF_REG_POWERPC_PMC6 , -/* Max regs without the extended regs */ +/* Max mask value for interrupt regs w/o extended regs */ PERF_REG_POWERPC_MAX =PERF_REG_POWERPC_MMCRA +1 , +/* Max mask value for interrupt regs including extended regs */ + PERF_REG_EXTENDED_MAX = PERF_REG_POWERPC_PMC6 + 1, };#define PERF_REG_PMU_MASK ((1ULL << PERF_REG_POWERPC_MAX) - 1) -/* Exclude MMCR3, SIER2, SIER3 for CPU_FTR_ARCH_300 */ -#define PERF_EXCLUDE_REG_EXT_300 (7ULL << PERF_REG_POWERPC_MMCR3) -/* * PERF_REG_EXTENDED_MASK value for CPU_FTR_ARCH_300 * includes 9 SPRS from MMCR0 to PMC6 excluding the -* unsupported SPRS in PERF_EXCLUDE_REG_EXT_300. +* unsupported SPRS MMCR3, SIER2 and SIER3. */ -#define PERF_REG_PMU_MASK_300 ((0xfffULL << PERF_REG_POWERPC_MMCR0) - PERF_EXCLUDE_REG_EXT_300) +#define PERF_REG_PMU_MASK_300 \ + ((1ul << PERF_REG_POWERPC_MMCR0) | (1ul << PERF_REG_POWERPC_MMCR1) | \ + (1ul << PERF_REG_POWERPC_MMCR2) | (1ul << PERF_REG_POWERPC_PMC1) | \ + (1ul << PERF_REG_POWERPC_PMC2) | (1ul << PERF_REG_POWERPC_PMC3) | \ + (1ul << PERF_REG_POWERPC_PMC4) | (1ul << PERF_REG_POWERPC_PMC5) | \ + (1ul << PERF_REG_POWERPC_PMC6))/* * PERF_REG_EXTENDED_MASK value for CPU_FTR_ARCH_31 * includes 12 SPRs from MMCR0 to PMC6. */ -#define PERF_REG_PMU_MASK_31 (0xfffULL << PERF_REG_POWERPC_MMCR0) +#define PERF_REG_PMU_MASK_31 \ + (PERF_REG_PMU_MASK_300 | (1ul << PERF_REG_POWERPC_MMCR3) | \ + (1ul << PERF_REG_POWERPC_SIER2) | (1ul << PERF_REG_POWERPC_SIER3)) -#define PERF_REG_EXTENDED_MAX (PERF_REG_POWERPC_PMC6 + 1)#endif /* _UAPI_ASM_POWERPC_PERF_REGS_H */
Signature · 1 line
2.30.1 (Apple Git-130)
Michael Ellerman
reviewerRe: [V2 1/4] powerpc/perf: Refactor the code definition of perf reg extended mask
Quoted 36 lines · Athira Rajeev
PERF_REG_PMU_MASK_300andPERF_REG_PMU_MASK_31defines the mask value for extended registers. Current definition of these mask values uses hex constant and does not use registers by name, making it less readable. Patch refactor the macro values by or'ing together the actual register value constants. Also includePERF_REG_EXTENDED_MAXas part of enum definition.Suggested-by Michael Ellerman <[email protected]>Signed-off-by Athira Rajeev <[email protected]>--- arch/powerpc/include/uapi/asm/perf_regs.h | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)arch/powerpc/include/uapi/asm/perf_regs.h +3
-4@@ -61,27 +61,32 @@ enum perf_event_powerpc_regs {PERF_REG_POWERPC_PMC4 ,PERF_REG_POWERPC_PMC5 ,PERF_REG_POWERPC_PMC6 , -/* Max regs without the extended regs */ +/* Max mask value for interrupt regs w/o extended regs */ PERF_REG_POWERPC_MAX =PERF_REG_POWERPC_MMCRA +1 , +/* Max mask value for interrupt regs including extended regs */ + PERF_REG_EXTENDED_MAX = PERF_REG_POWERPC_PMC6 + 1, };#define PERF_REG_PMU_MASK ((1ULL << PERF_REG_POWERPC_MAX) - 1) -/* Exclude MMCR3, SIER2, SIER3 for CPU_FTR_ARCH_300 */ -#define PERF_EXCLUDE_REG_EXT_300 (7ULL << PERF_REG_POWERPC_MMCR3) -/* * PERF_REG_EXTENDED_MASK value for CPU_FTR_ARCH_300 * includes 9 SPRS from MMCR0 to PMC6 excluding the
arch/powerpc/include/uapi/asm/perf_regs.h enum perf_event_powerpc_regs { · line 82
Quoted 10 lines
arch/powerpc/include/uapi/asm/perf_regs.h +7
-2-* unsupported SPRS in PERF_EXCLUDE_REG_EXT_300. +* unsupported SPRS MMCR3, SIER2 and SIER3. */ -#define PERF_REG_PMU_MASK_300 ((0xfffULL << PERF_REG_POWERPC_MMCR0) - PERF_EXCLUDE_REG_EXT_300) +#define PERF_REG_PMU_MASK_300 \ + ((1ul << PERF_REG_POWERPC_MMCR0) | (1ul << PERF_REG_POWERPC_MMCR1) | \ + (1ul << PERF_REG_POWERPC_MMCR2) | (1ul << PERF_REG_POWERPC_PMC1) | \ + (1ul << PERF_REG_POWERPC_PMC2) | (1ul << PERF_REG_POWERPC_PMC3) | \ + (1ul << PERF_REG_POWERPC_PMC4) | (1ul << PERF_REG_POWERPC_PMC5) | \ + (1ul << PERF_REG_POWERPC_PMC6))
These all need to be unsigned long long. Otherwise when building on big endian (which defaults to 32-bit), we see errors such as:
In file included from /home/michael/linux/tools/perf/arch/powerpc/include/perf_regs.h:7:0,
from arch/powerpc/util/../../../util/perf_regs.h:30,
from arch/powerpc/util/perf_regs.c:7:
arch/powerpc/util/perf_regs.c: In function ‘arch__intr_reg_mask’:
/home/michael/linux/tools/arch/powerpc/include/uapi/asm/perf_regs.h:78:8: error: left shift count >= width of type [-Werror=shift-count-overflow]
((1ul << PERF_REG_POWERPC_MMCR0) | (1ul << PERF_REG_POWERPC_MMCR1) | \
^
arch/powerpc/util/perf_regs.c:206:19: note: in expansion of macro ‘PERF_REG_PMU_MASK_300’
extended_mask = PERF_REG_PMU_MASK_300;
^cheers
PATCH v2 2/4 tools/perf: Refactor the code definition of perf reg extended mask in tools side header file
In reply to Athira RajeevPERF_REG_PMU_MASK_300 and PERF_REG_PMU_MASK_31 defines the mask value for extended registers. Current definition of these mask values uses hex constant and does not use registers by name, making it less readable. Patch refactor the macro values in perf tools side header file by or'ing together the actual register value constants.
--- .../arch/powerpc/include/uapi/asm/perf_regs.h | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-)
tools/arch/powerpc/include/uapi/asm/perf_regs.h +13 -8
@@ -61,27 +61,32 @@ enum perf_event_powerpc_regs {PERF_REG_POWERPC_PMC4 ,PERF_REG_POWERPC_PMC5 ,PERF_REG_POWERPC_PMC6 , -/* Max regs without the extended regs */ +/* Max mask value for interrupt regs w/o extended regs */ PERF_REG_POWERPC_MAX =PERF_REG_POWERPC_MMCRA +1 , +/* Max mask value for interrupt regs including extended regs */ + PERF_REG_EXTENDED_MAX = PERF_REG_POWERPC_PMC6 + 1, };#define PERF_REG_PMU_MASK ((1ULL << PERF_REG_POWERPC_MAX) - 1) -/* Exclude MMCR3, SIER2, SIER3 for CPU_FTR_ARCH_300 */ -#define PERF_EXCLUDE_REG_EXT_300 (7ULL << PERF_REG_POWERPC_MMCR3) -/* * PERF_REG_EXTENDED_MASK value for CPU_FTR_ARCH_300 * includes 9 SPRS from MMCR0 to PMC6 excluding the -* unsupported SPRS in PERF_EXCLUDE_REG_EXT_300. +* unsupported SPRS MMCR3, SIER2 and SIER3. */ -#define PERF_REG_PMU_MASK_300 ((0xfffULL << PERF_REG_POWERPC_MMCR0) - PERF_EXCLUDE_REG_EXT_300) +#define PERF_REG_PMU_MASK_300 \ + ((1ul << PERF_REG_POWERPC_MMCR0) | (1ul << PERF_REG_POWERPC_MMCR1) | \ + (1ul << PERF_REG_POWERPC_MMCR2) | (1ul << PERF_REG_POWERPC_PMC1) | \ + (1ul << PERF_REG_POWERPC_PMC2) | (1ul << PERF_REG_POWERPC_PMC3) | \ + (1ul << PERF_REG_POWERPC_PMC4) | (1ul << PERF_REG_POWERPC_PMC5) | \ + (1ul << PERF_REG_POWERPC_PMC6))/* * PERF_REG_EXTENDED_MASK value for CPU_FTR_ARCH_31 * includes 12 SPRs from MMCR0 to PMC6. */ -#define PERF_REG_PMU_MASK_31 (0xfffULL << PERF_REG_POWERPC_MMCR0) +#define PERF_REG_PMU_MASK_31 \ + (PERF_REG_PMU_MASK_300 | (1ul << PERF_REG_POWERPC_MMCR3) | \ + (1ul << PERF_REG_POWERPC_SIER2) | (1ul << PERF_REG_POWERPC_SIER3)) -#define PERF_REG_EXTENDED_MAX (PERF_REG_POWERPC_PMC6 + 1)#endif /* _UAPI_ASM_POWERPC_PERF_REGS_H */
Signature · 1 line
2.30.1 (Apple Git-130)
Re: [V2 2/4] tools/perf: Refactor the code definition of perf reg extended mask in tools side header file
Hi Athira,
Quoted 6 lines
PERF_REG_PMU_MASK_300andPERF_REG_PMU_MASK_31defines the mask value for extended registers. Current definition of these mask values uses hex constant and does not use registers by name, making it less readable. Patch refactor the macro values in perf tools side header file by or'ing together the actual register value constants.
This looks like a good simplification.
tools/arch/powerpc/include/uapi/asm/perf_regs.h enum perf_event_powerpc_regs { · line 71
Quoted 2 lines
tools/arch/powerpc/include/uapi/asm/perf_regs.h +0
-2-/* Exclude MMCR3, SIER2, SIER3 for CPU_FTR_ARCH_300 */ -#define PERF_EXCLUDE_REG_EXT_300 (7ULL << PERF_REG_POWERPC_MMCR3)
This file is uAPI - are we allowed to remove a define? Could a program built against these headers now fail to compile because we've removed it?
Quoted 15 lines
tools/arch/powerpc/include/uapi/asm/perf_regs.h +7
-3-/* * PERF_REG_EXTENDED_MASK value for CPU_FTR_ARCH_300 * includes 9 SPRS from MMCR0 to PMC6 excluding the -* unsupported SPRS in PERF_EXCLUDE_REG_EXT_300. +* unsupported SPRS MMCR3, SIER2 and SIER3. */ -#define PERF_REG_PMU_MASK_300 ((0xfffULL << PERF_REG_POWERPC_MMCR0) - PERF_EXCLUDE_REG_EXT_300) +#define PERF_REG_PMU_MASK_300 \ + ((1ul << PERF_REG_POWERPC_MMCR0) | (1ul << PERF_REG_POWERPC_MMCR1) | \ + (1ul << PERF_REG_POWERPC_MMCR2) | (1ul << PERF_REG_POWERPC_PMC1) | \ + (1ul << PERF_REG_POWERPC_PMC2) | (1ul << PERF_REG_POWERPC_PMC3) | \ + (1ul << PERF_REG_POWERPC_PMC4) | (1ul << PERF_REG_POWERPC_PMC5) | \ + (1ul << PERF_REG_POWERPC_PMC6))
tools/arch/powerpc/include/uapi/asm/perf_regs.h enum perf_event_powerpc_regs { · line 86
Quoted 10 lines
tools/arch/powerpc/include/uapi/asm/perf_regs.h +3
-2/* * PERF_REG_EXTENDED_MASK value for CPU_FTR_ARCH_31 * includes 12 SPRs from MMCR0 to PMC6. */ -#define PERF_REG_PMU_MASK_31 (0xfffULL << PERF_REG_POWERPC_MMCR0) +#define PERF_REG_PMU_MASK_31 \ + (PERF_REG_PMU_MASK_300 | (1ul << PERF_REG_POWERPC_MMCR3) | \ + (1ul << PERF_REG_POWERPC_SIER2) | (1ul << PERF_REG_POWERPC_SIER3)) -#define PERF_REG_EXTENDED_MAX (PERF_REG_POWERPC_PMC6 + 1)
Likewise for this define?
I think this might also be an issue for some of your other patches which change an include/uapi/ file.
Kind regards,
Daniel
Quoted 2 lines
Signature · 1 line
2.30.1 (Apple Git-130)
Re: [V2 2/4] tools/perf: Refactor the code definition of perf reg extended mask in tools side header file
Quoted 12 lines · Daniel Axtens
Hi Athira,
Quoted 6 lines
PERF_REG_PMU_MASK_300andPERF_REG_PMU_MASK_31defines the mask value for extended registers. Current definition of these mask values uses hex constant and does not use registers by name, making it less readable. Patch refactor the macro values in perf tools side header file by or'ing together the actual register value constants.
Quoted 7 lines
This looks like a good simplification.
tools/arch/powerpc/include/uapi/asm/perf_regs.h enum perf_event_powerpc_regs { · line 71
Quoted 2 lines
tools/arch/powerpc/include/uapi/asm/perf_regs.h +0
-2-/* Exclude MMCR3, SIER2, SIER3 for CPU_FTR_ARCH_300 */ -#define PERF_EXCLUDE_REG_EXT_300 (7ULL << PERF_REG_POWERPC_MMCR3)This file is uAPI - are we allowed to remove a define? Could a program built against these headers now fail to compile because we've removed it?
Hi Daniel,
Thanks for the review.
My bad, you are right. I will correct this in version3 by retaining this define and refactoring the macro.
Quoted 25 lines
Quoted 25 lines
-
/*
*PERF_REG_EXTENDED_MASKvalue forCPU_FTR_ARCH_300
* includes 9 SPRS from MMCR0 to PMC6 excluding the
- * unsupported SPRS inPERF_EXCLUDE_REG_EXT_300.
+ * unsupported SPRS MMCR3, SIER2 and SIER3. */tools/arch/powerpc/include/uapi/asm/perf_regs.h +6
-1-#define PERF_REG_PMU_MASK_300 ((0xfffULL << PERF_REG_POWERPC_MMCR0) - PERF_EXCLUDE_REG_EXT_300) +#define PERF_REG_PMU_MASK_300 \ + ((1ul << PERF_REG_POWERPC_MMCR0) | (1ul << PERF_REG_POWERPC_MMCR1) | \ + (1ul << PERF_REG_POWERPC_MMCR2) | (1ul << PERF_REG_POWERPC_PMC1) | \ + (1ul << PERF_REG_POWERPC_PMC2) | (1ul << PERF_REG_POWERPC_PMC3) | \ + (1ul << PERF_REG_POWERPC_PMC4) | (1ul << PERF_REG_POWERPC_PMC5) | \ + (1ul << PERF_REG_POWERPC_PMC6))/*
*PERF_REG_EXTENDED_MASKvalue forCPU_FTR_ARCH_31
* includes 12 SPRs from MMCR0 to PMC6.
*/tools/arch/powerpc/include/uapi/asm/perf_regs.h +3
-1-#define PERF_REG_PMU_MASK_31 (0xfffULL << PERF_REG_POWERPC_MMCR0) +#define PERF_REG_PMU_MASK_31 \ + (PERF_REG_PMU_MASK_300 | (1ul << PERF_REG_POWERPC_MMCR3) | \ + (1ul << PERF_REG_POWERPC_SIER2) | (1ul << PERF_REG_POWERPC_SIER3))
Quoted 6 lines
Quoted 1 line
-#define
PERF_REG_EXTENDED_MAX(PERF_REG_POWERPC_PMC6+ 1)Likewise for this define?
I think this might also be an issue for some of your other patches which change an
include/uapi/file.
Though I am removing PERF_REG_EXTENDED_MAX define from end of this uapi file, it is moved along with enum definition of perf_event_powerpc_regs. So we should be good with moving this define from this place.
Thanks
Athira
Quoted 6 lines
Kind regards,
DanielQuoted 2 lines
Signature · 1 line
2.30.1 (Apple Git-130)
Michael Ellerman
reviewerRe: [V2 2/4] tools/perf: Refactor the code definition of perf reg extended mask in tools side header file
In reply to Daniel AxtensQuoted 8 lines · Daniel Axtens
Hi Athira,
Quoted 6 lines
PERF_REG_PMU_MASK_300andPERF_REG_PMU_MASK_31defines the mask value for extended registers. Current definition of these mask values uses hex constant and does not use registers by name, making it less readable. Patch refactor the macro values in perf tools side header file by or'ing together the actual register value constants.
Quoted 7 lines
This looks like a good simplification.
tools/arch/powerpc/include/uapi/asm/perf_regs.h enum perf_event_powerpc_regs { · line 71
Quoted 2 lines
tools/arch/powerpc/include/uapi/asm/perf_regs.h +0
-2-/* Exclude MMCR3, SIER2, SIER3 for CPU_FTR_ARCH_300 */ -#define PERF_EXCLUDE_REG_EXT_300 (7ULL << PERF_REG_POWERPC_MMCR3)This file is uAPI - are we allowed to remove a define? Could a program built against these headers now fail to compile because we've removed it?
Yeah that's true.
In this case I think I'd rather we remove it though, because:
- it was never meant to be part of the uapi, it was just meant for use in the construction of PERF_REG_PMU_MASK_300, and is no longer needed for that.
- it's only been in the header since v5.12, so I think the chance of anything using it is essentially zero.
cheers
PATCH v2 3/4 powerpc/perf: Expose instruction and data address registers as part of extended regs
In reply to Athira RajeevPatch adds support to include Sampled Instruction Address Register (SIAR) and Sampled Data Address Register (SDAR) SPRs as part of extended registers. Update the definition of PERF_REG_PMU_MASK_300/31 and PERF_REG_EXTENDED_MAX to include these SPR's.
--- arch/powerpc/include/uapi/asm/perf_regs.h | 11 +++++++---- arch/powerpc/perf/perf_regs.c | 4 ++++ 2 files changed, 11 insertions(+), 4 deletions(-)
arch/powerpc/include/uapi/asm/perf_regs.h +7 -4
@@ -61,17 +61,19 @@ enum perf_event_powerpc_regs {PERF_REG_POWERPC_PMC4 ,PERF_REG_POWERPC_PMC5 ,PERF_REG_POWERPC_PMC6 , +PERF_REG_POWERPC_SDAR , +PERF_REG_POWERPC_SIAR ,/* Max mask value for interrupt regs w/o extended regs */ PERF_REG_POWERPC_MAX =PERF_REG_POWERPC_MMCRA +1 ,/* Max mask value for interrupt regs including extended regs */ - PERF_REG_EXTENDED_MAX = PERF_REG_POWERPC_PMC6 + 1, + PERF_REG_EXTENDED_MAX = PERF_REG_POWERPC_SIAR + 1, };#define PERF_REG_PMU_MASK ((1ULL << PERF_REG_POWERPC_MAX) - 1)/* * PERF_REG_EXTENDED_MASK value for CPU_FTR_ARCH_300 -* includes 9 SPRS from MMCR0 to PMC6 excluding the +* includes 11 SPRS from MMCR0 to SIAR excluding the * unsupported SPRS MMCR3, SIER2 and SIER3. */ #define PERF_REG_PMU_MASK_300 \
@@ -79,11 +81,12 @@ enum perf_event_powerpc_regs { (1ul << PERF_REG_POWERPC_MMCR2) | (1ul << PERF_REG_POWERPC_PMC1) | \ (1ul << PERF_REG_POWERPC_PMC2) | (1ul << PERF_REG_POWERPC_PMC3) | \ (1ul << PERF_REG_POWERPC_PMC4) | (1ul << PERF_REG_POWERPC_PMC5) | \ - (1ul << PERF_REG_POWERPC_PMC6)) + (1ul << PERF_REG_POWERPC_PMC6) | (1ul << PERF_REG_POWERPC_SDAR) | \ + (1ul << PERF_REG_POWERPC_SIAR))/* * PERF_REG_EXTENDED_MASK value for CPU_FTR_ARCH_31 -* includes 12 SPRs from MMCR0 to PMC6. +* includes 14 SPRs from MMCR0 to SIAR. */ #define PERF_REG_PMU_MASK_31 \ (PERF_REG_PMU_MASK_300 | (1ul << PERF_REG_POWERPC_MMCR3) | \
arch/powerpc/perf/perf_regs.c +4 -0
@@ -90,7 +90,11 @@ static u64 get_ext_regs_value(int idx)return mfspr (SPRN_SIER2 );case PERF_REG_POWERPC_SIER3 :return mfspr (SPRN_SIER3 ); +case PERF_REG_POWERPC_SDAR : +return mfspr (SPRN_SDAR );#endif +case PERF_REG_POWERPC_SIAR : +return mfspr (SPRN_SIAR );default :return 0 ; } }
Signature · 1 line
2.30.1 (Apple Git-130)
Re: [V2 3/4] powerpc/perf: Expose instruction and data address registers as part of extended regs
Quoted 1 line · Athira Rajeev
Patch adds support to include Sampled Instruction Address Register
This is a nit and doesn't require a new revision, but I think this should read "Include Sampled Instruction Address ...", not "Patch adds support to include Sampled Instruction ..." - see
https://www.kernel.org/doc/html/v5.11/process/submitting-patches.html#describe-your-changes
Quoted 9 lines
(SIAR) and Sampled Data Address Register (SDAR) SPRs as part of extended registers. Update the definition of PERF_REG_PMU_MASK_300/31 and
PERF_REG_EXTENDED_MAXto include these SPR's.arch/powerpc/perf/perf_regs.c +0
-0
arch/powerpc/perf/perf_regs.c static u64 get_ext_regs_value(int idx) · line 97
Quoted 8 lines
arch/powerpc/perf/perf_regs.c +4
-0@@ -90,7 +90,11 @@ static u64 get_ext_regs_value(int idx)return mfspr (SPRN_SIER2 );case PERF_REG_POWERPC_SIER3 :return mfspr (SPRN_SIER3 ); +case PERF_REG_POWERPC_SDAR : +return mfspr (SPRN_SDAR );#endif +case PERF_REG_POWERPC_SIAR : +return mfspr (SPRN_SIAR );
I was initially confused about why SIAR was outside the CONFIG_PPC64 block and SDAR was inside. But it turns out that SIAR is also defined for a 32 bit platform, so that makes sense.
I'm not an expert on how the perf subsystem works, but this all seems consistent with the surrounding code and it seems to do what the commit message says, so on that limited basis:
Kind regards,
Daniel
PATCH v2 4/4 tools/perf: Add perf tools support to expose instruction and data address registers as part of extended regs
In reply to Athira RajeevPatch enables presenting of Sampled Instruction Address Register (SIAR) and Sampled Data Address Register (SDAR) SPRs as part of extended regsiters for perf tool. Add these SPR's to sample_reg_mask in the tool side (to use with -I? option).
--- tools/arch/powerpc/include/uapi/asm/perf_regs.h | 11 +++++++---- tools/perf/arch/powerpc/include/perf_regs.h | 2 ++ tools/perf/arch/powerpc/util/perf_regs.c | 2 ++ 3 files changed, 11 insertions(+), 4 deletions(-)
tools/arch/powerpc/include/uapi/asm/perf_regs.h +7 -4
@@ -61,17 +61,19 @@ enum perf_event_powerpc_regs {PERF_REG_POWERPC_PMC4 ,PERF_REG_POWERPC_PMC5 ,PERF_REG_POWERPC_PMC6 , +PERF_REG_POWERPC_SDAR , +PERF_REG_POWERPC_SIAR ,/* Max mask value for interrupt regs w/o extended regs */ PERF_REG_POWERPC_MAX =PERF_REG_POWERPC_MMCRA +1 ,/* Max mask value for interrupt regs including extended regs */ - PERF_REG_EXTENDED_MAX = PERF_REG_POWERPC_PMC6 + 1, + PERF_REG_EXTENDED_MAX = PERF_REG_POWERPC_SIAR + 1, };#define PERF_REG_PMU_MASK ((1ULL << PERF_REG_POWERPC_MAX) - 1)/* * PERF_REG_EXTENDED_MASK value for CPU_FTR_ARCH_300 -* includes 9 SPRS from MMCR0 to PMC6 excluding the +* includes 11 SPRS from MMCR0 to SIAR excluding the * unsupported SPRS MMCR3, SIER2 and SIER3. */ #define PERF_REG_PMU_MASK_300 \
@@ -79,11 +81,12 @@ enum perf_event_powerpc_regs { (1ul << PERF_REG_POWERPC_MMCR2) | (1ul << PERF_REG_POWERPC_PMC1) | \ (1ul << PERF_REG_POWERPC_PMC2) | (1ul << PERF_REG_POWERPC_PMC3) | \ (1ul << PERF_REG_POWERPC_PMC4) | (1ul << PERF_REG_POWERPC_PMC5) | \ - (1ul << PERF_REG_POWERPC_PMC6)) + (1ul << PERF_REG_POWERPC_PMC6) | (1ul << PERF_REG_POWERPC_SDAR) | \ + (1ul << PERF_REG_POWERPC_SIAR))/* * PERF_REG_EXTENDED_MASK value for CPU_FTR_ARCH_31 -* includes 12 SPRs from MMCR0 to PMC6. +* includes 14 SPRs from MMCR0 to SIAR. */ #define PERF_REG_PMU_MASK_31 \ (PERF_REG_PMU_MASK_300 | (1ul << PERF_REG_POWERPC_MMCR3) | \
tools/perf/arch/powerpc/include/perf_regs.h +2 -0
@@ -77,6 +77,8 @@ static const char *reg_names[] = { [PERF_REG_POWERPC_PMC4] = "pmc4", [PERF_REG_POWERPC_PMC5] = "pmc5", [PERF_REG_POWERPC_PMC6] = "pmc6", + [PERF_REG_POWERPC_SDAR] = "sdar", + [PERF_REG_POWERPC_SIAR] = "siar", };static inline const char *__perf_reg_name (int id)
tools/perf/arch/powerpc/util/perf_regs.c +2 -0
@@ -74,6 +74,8 @@ const struct sample_reg sample_reg_masks[] = {SMPL_REG (pmc4,PERF_REG_POWERPC_PMC4 ),SMPL_REG (pmc5,PERF_REG_POWERPC_PMC5 ),SMPL_REG (pmc6,PERF_REG_POWERPC_PMC6 ), +SMPL_REG (sdar,PERF_REG_POWERPC_SDAR ), +SMPL_REG (siar,PERF_REG_POWERPC_SIAR ), SMPL_REG_END };
Signature · 1 line
2.30.1 (Apple Git-130)