Add support for perf_arch_regs
Subsystems (4)
cover Add support for perf_arch_regs
Patchset to extend PERF_SAMPLE_REGS_INTR to include platform specific PMU registers.
Patchset applies cleanly on tip:perf/core branch
It's a perennial request from hardware folks to be able to see the raw values of the pmu registers. Partly it's so that they can verify perf is doing what they want, and some of it is that they're interested in some of the more obscure info that isn't plumbed out through other perf interfaces.
Over the years internally we have used various hack to get the requested data out but this is an attempt to use a somewhat standard mechanism (using PERF_SAMPLE_REGS_INTR).
This would also be helpful for those of us working on the perf hardware backends, to be able to verify that we're programming things correctly, without resorting to debug printks etc.
Mechanism proposed:
1)perf_regs structure is extended with a perf_arch_regs structure which each arch/ can populate with their specific platform registers to sample on each perf interrupt and an arch_regs_mask variable, which is for perf tool to know about the perf_arch_regs that are supported.
2)perf/core func perf_sample_regs_intr() extended to update the perf_arch_regs structure and the perf_arch_reg_mask. Set of new support functions added perf_get_arch_regs_mask() and perf_get_arch_reg() to aid the updates from arch/ side.
3) perf/core funcs perf_prepare_sample() and perf_output_sample() are extended to support the update for the perf_arch_regs_mask and perf_arch_regs in the sample
4)perf/core func perf_output_sample_regs() extended to dump the arch_regs to the output sample.
5)Finally, perf tool side is updated to include a new element "arch_regs_mask" in the "struct regs_dump", event sample funcs and print functions are updated to support perf_arch_regs.
example usage:
$./perf record -I ls
.....
builtin-data.o builtin-list.o builtin-stat.c Documentation perf.h
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.009 MB perf.data (12 samples) ] $./perf script -D
....0x980 [0x200]: event: 9
.
. ... raw event: size 512 bytes
. 0000: 00 00 00 09 00 01 02 00 00 00 00 00 00 08 fb 4c ...............L
. 0010: 00 00 16 cb 00 00 16 cb 00 00 01 1d ca 45 9f 52 .............E.R
. 0020: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 02 ................
.......
.... dsisr 0x60000000
.... arch_regs 0x7e7f
.... pvr 0x4a0201
.... pmc1 0x7fffffff
.... pmc2 0x0
.... pmc3 0x0
.... pmc4 0x0
.... pmc5 0xa03
.... pmc6 0x38df
.... mmcr0 0x82008080
.... mmcr1 0x1e000000
.... sier 0x1e000000
.... siar 0x8fb4c
.... sdar 0xc00000241b195100
.... mmcra 0x60000000
... thread: perf:5835
...... dso: <not found>
perf 5835 1227.459239: 1 cycles:ppp: 8fb4c [unknown] ([unknown])Option to get only perf_arch_regs values:
$ ./perf record -I? available registers: r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15 r16 r17 r18 r19 r20 r21 r22 r23 r24 r25 r26 r27 r28 r29 r30 r31 nip msr orig_r3 ctr link xer ccr softe trap dar dsisr arch_regs
Usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]
-I, --intr-regs[=<any register>]
sample selected machine registers on interrupt, use -I ? to list register names
$./perf record -Iarch_regs ls
.....
$./perf script -D
.....
104621404208 0xa28 [0xa8]: PERF_RECORD_SAMPLE(IP, 0x1): 5823/5823: 0xc00000000008fb4c period: 1 addr: 0 ... intr regs: mask 0x80000000000 ABI 64-bit
.... arch_regs 0x7e7f
.... pvr 0x4a0201
.... pmc1 0x7fffffff
.... pmc2 0x0
.... pmc3 0x0
.... pmc4 0x0
.... pmc5 0x39551
.... pmc6 0xe6d99
.... mmcr0 0x82008080
.... mmcr1 0x1e000000
.... sier 0x1e000000
.... siar 0xc00000000008fb4c
.... sdar 0xc00000235f592500
.... mmcra 0x60000000
... thread: perf:5823
...... dso: /boot/vmlinux
perf 5823 104.621404: 1 cycles:ppp: c00000000008fb4c .power_check_constraints (/boot/vmlinux)....
RFC:
https://lkml.org/lkml/2015/11/4/530
https://lkml.org/lkml/2015/11/4/531
https://lkml.org/lkml/2015/11/4/532
https://lkml.org/lkml/2015/11/4/533
Patch 11 in this patchset is a fix which is already posted, but not yet to be pulled in. So I have added that to this patchset.
https://patchwork.kernel.org/patch/9285421/
Kindly let me know you comments and feedbacks.
Madhavan Srinivasan (13):
perf/core: Add perf_arch_regs and mask to perf_regs structure perf/core: Extend perf_sample_regs_intr() to include perf_arch_regs
update
perf/core: Update perf_*_sample() to include perf_arch_regs perf/core: Extend perf_output_sample_regs() to include perf_arch_regs powerpc/perf: Define enums for perf_arch_regs registers powerpc/perf: Add support for perf_arch_regs in powerpc powerpc/perf: Add support for perf_arch_regs for Power7 processor powerpc/perf: Add support for perf_arch_regs for newer Power processor powerpc/perf: Add support for perf_arch_regs for PPC970 processor tool/perf: Add support for perf_arch_regs
tools/perf: Fix the mask in regs_dump__printf and print_sample_iregs tool/perf: Add perf_arch_reg mask and arch_reg_names structure powerpc/perf: Add support to dump only arch_regs
arch/powerpc/include/asm/perf_event_server.h | 11 +++++ arch/powerpc/include/uapi/asm/perf_regs.h | 39 ++++++++++++++++++ arch/powerpc/perf/core-book3s.c | 38 ++++++++++++++++++ arch/powerpc/perf/isa207-common.c | 18 +++++++++ arch/powerpc/perf/isa207-common.h | 10 +++++ arch/powerpc/perf/perf_regs.c | 3 ++ arch/powerpc/perf/power7-pmu.c | 28 +++++++++++++ arch/powerpc/perf/power8-pmu.c | 2 + arch/powerpc/perf/power9-pmu.c | 2 + arch/powerpc/perf/ppc970-pmu.c | 23 +++++++++++ include/linux/perf_regs.h | 26 ++++++++++++ kernel/events/core.c | 53 +++++++++++++++++++++---- tools/arch/powerpc/include/uapi/asm/perf_regs.h | 40 +++++++++++++++++++ tools/include/linux/bitmap.h | 2 + tools/lib/bitmap.c | 18 +++++++++ tools/perf/arch/arm/include/perf_regs.h | 5 +++ tools/perf/arch/arm64/include/perf_regs.h | 5 +++ tools/perf/arch/powerpc/include/perf_regs.h | 28 ++++++++++++- tools/perf/arch/powerpc/util/perf_regs.c | 1 + tools/perf/arch/x86/include/perf_regs.h | 5 +++ tools/perf/builtin-script.c | 11 ++++- tools/perf/util/event.h | 1 + tools/perf/util/evsel.c | 11 +++++ tools/perf/util/perf_regs.h | 5 +++ tools/perf/util/session.c | 16 ++++++-- 25 files changed, 388 insertions(+), 13 deletions(-)
--
2.7.4
PATCH 1/13 perf/core: Add perf_arch_regs and mask to perf_regs structure
It's a perennial request from hardware folks to be able to see the raw values of the pmu registers. Partly it's so that they can verify perf is doing what they want, and some of it is that they're interested in some of the more obscure info that isn't plumbed out through other perf interfaces.
Over the years internally have used various hack to get the requested data out but this is an attempt to use a somewhat standard mechanism (using PERF_SAMPLE_REGS_INTR).
This would also be helpful for those of us working on the perf hardware backends, to be able to verify that we're programming things correctly, without resorting to debug printks etc.
Mechanism proposed:
1)perf_regs structure is extended with a perf_arch_regs structure which each arch/ can populate with their specific platform registers to sample on each perf interrupt and an arch_regs_mask variable, which is for perf tool to know about the perf_arch_regs that are supported.
2)perf/core func perf_sample_regs_intr() extended to update the perf_arch_regs structure and the perf_arch_reg_mask. Set of new support functions added perf_get_arch_regs_mask() and perf_get_arch_reg() to aid the updates from arch/ side.
3) perf/core funcs perf_prepare_sample() and perf_output_sample() are extended to support the update for the perf_arch_regs_mask and perf_arch_regs in the sample
4)perf/core func perf_output_sample_regs() extended to dump the arch_regs to the output sample.
5)Finally, perf tool side is updated a) to include a new element "arch_regs_mask" in the "struct regs_dump", b) event sample funcs to updated to include "arch_regs_mask" and c) print functions are updated.
This foundation patch just extends the perf_regs structure, defines support function and subsequent patches completes the implimentation for powerpc arch.
--- include/linux/perf_regs.h | 26 ++++++++++++++++++++++++++ kernel/events/core.c | 16 ++++++++++++++++ 2 files changed, 42 insertions(+)
include/linux/perf_regs.h +26 -0
@@ -4,8 +4,14 @@struct perf_regs {__u64 abi;struct pt_regs *regs; +struct perf_arch_regs *arch_regs; +u64 arch_regs_mask; }; +#ifndef perf_arch_regs +struct perf_arch_regs { }; +#endif +#ifdef CONFIG_HAVE_PERF_REGS #include <asm/perf_regs.h> u64 perf_reg_value (struct pt_regs *regs,int idx);
@@ -14,6 +20,11 @@ u64 perf_reg_abi(struct task_struct *task);void perf_get_regs_user (struct perf_regs *regs_user,struct pt_regs *regs,struct pt_regs *regs_user_copy); + +u64 perf_get_arch_regs_mask (void ); +struct perf_arch_regs *perf_get_arch_reg (void ); +u64 perf_arch_reg_value (struct perf_arch_regs *regs,int idx); +#else static inline u64 perf_reg_value (struct pt_regs *regs,int idx) {
@@ -37,5 +48,20 @@ static inline void perf_get_regs_user(struct perf_regs *regs_user, regs_user->regs =task_pt_regs (current); regs_user->abi =perf_reg_abi (current); } + +u64 perf_get_arch_regs_mask (void ) +{ +return 0 ; +} + +struct perf_arch_regs *perf_get_arch_reg (void ) +{ +return 0 ; +} + +u64 perf_arch_reg_value (struct perf_arch_regs *regs,int idx) +{ +return 0 ; +}#endif /* CONFIG_HAVE_PERF_REGS */ #endif /* _LINUX_PERF_REGS_H */
kernel/events/core.c +16 -0
@@ -5353,6 +5353,22 @@ int perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks *cbs) }EXPORT_SYMBOL_GPL (perf_unregister_guest_info_callbacks); +u64 __attribute__((weak))perf_get_arch_regs_mask () +{ +return 0 ; +} + +struct perf_arch_regs *__attribute__((weak)) perf_get_arch_reg() +{ +return 0 ; +} + +u64 __attribute__((weak))perf_arch_reg_value (struct perf_arch_regs *regs, +int idx) +{ +return 0 ; +} +static void perf_output_sample_regs (struct perf_output_handle *handle,struct pt_regs *regs,u64 mask)
Signature · 1 line
2.7.4
PATCH 3/13 perf/core: Update perf_*_sample() to include perf_arch_regs
In reply to Madhavan Srinivasanperf_prepare_sample is extended to include the perf_arch_regs_mask in the sample header size calculation. Update perf_output_sample() to dump the perf_arch_regs_mask to sample output.
--- kernel/events/core.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
kernel/events/core.c +12 -4
@@ -5780,12 +5780,14 @@ void perf_output_sample(struct perf_output_handle *handle,if (sample_type &PERF_SAMPLE_REGS_USER ) {u64 abi = data->regs_user.abi; +u64 arch_regs_mask = data->regs_user.arch_regs_mask;/* * If there are no regs to dump, notice it through * first u64 being zero (PERF_SAMPLE_REGS_ABI_NONE). */ perf_output_put (handle, abi); +perf_output_put (handle, arch_regs_mask);if (abi) {u64 mask = event->attr.sample_regs_user;
@@ -5812,11 +5814,14 @@ void perf_output_sample(struct perf_output_handle *handle,if (sample_type &PERF_SAMPLE_REGS_INTR ) {u64 abi = data->regs_intr.abi; +u64 arch_regs_mask = data->regs_intr.arch_regs_mask; +/* * If there are no regs to dump, notice it through * first u64 being zero (PERF_SAMPLE_REGS_ABI_NONE). */ perf_output_put (handle, abi); +perf_output_put (handle, arch_regs_mask);if (abi) {u64 mask = event->attr.sample_regs_intr;
@@ -5910,8 +5915,8 @@ void perf_prepare_sample(struct perf_event_header *header, &data->regs_user_copy);if (sample_type &PERF_SAMPLE_REGS_USER ) { -/* regs dump ABI info */ -int size =sizeof (u64); +/* regs dump ABI info and arch_regs_mask */ +int size =sizeof (u64) *2 ;if (data->regs_user.regs) {u64 mask = event->attr.sample_regs_user;
@@ -5947,8 +5952,8 @@ void perf_prepare_sample(struct perf_event_header *header, }if (sample_type &PERF_SAMPLE_REGS_INTR ) { -/* regs dump ABI info */ -int size =sizeof (u64); +/* regs dump ABI info and arch_regs_mask */ +int size =sizeof (u64) *2 ;perf_sample_regs_intr (&data->regs_intr, regs);
@@ -5956,6 +5961,9 @@ void perf_prepare_sample(struct perf_event_header *header,u64 mask = event->attr.sample_regs_intr; size +=hweight64 (mask) *sizeof (u64); + + mask = data->regs_intr.arch_regs_mask; + size +=hweight64 (mask) *sizeof (u64); } header->size += size;
Signature · 1 line
2.7.4
PATCH 2/13 perf/core: Extend perf_sample_regs_intr() to include perf_arch_regs update
In reply to Madhavan SrinivasanExtend perf_sample_regs_intr() to support the updates needed for perf_arch_reg structure and perf_arch_regs_mask. Also add code to
init the arch_regs_mask to zero incase of regs_user in perf_sample_regs_user(). Ideally this should be done in perf_sample_data_init, but due to commit 2565711fb7d7 ("perf: Improve the perf_sample_data struct layout") moving it to this function.
--- kernel/events/core.c | 5 +++++ 1 file changed, 5 insertions(+)
kernel/events/core.c +5 -0
@@ -5398,6 +5398,9 @@ static void perf_sample_regs_user(struct perf_regs *regs_user, regs_user->abi =PERF_SAMPLE_REGS_ABI_NONE ; regs_user->regs =NULL ; } + +/* Init arch_regs_mask to zero */ + regs_user->arch_regs_mask =0 ; } static void perf_sample_regs_intr(struct perf_regs *regs_intr,
@@ -5405,6 +5408,8 @@ static void perf_sample_regs_intr(struct perf_regs *regs_intr, { regs_intr->regs = regs; regs_intr->abi =perf_reg_abi (current); + regs_intr->arch_regs_mask =perf_get_arch_regs_mask (); + regs_intr->arch_regs =perf_get_arch_reg (); }
Signature · 1 line
2.7.4
PATCH 4/13 perf/core: Extend perf_output_sample_regs() to include perf_arch_regs
In reply to Madhavan SrinivasanExtend perf_output_sample_regs() to take in perf_regs structure as a parameter instead of pt_regs. Add code to check for arch_regs_mask and dump the arch registers to the output sample.
--- kernel/events/core.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
kernel/events/core.c +12 -4
@@ -5371,16 +5371,24 @@ u64 __attribute__((weak)) perf_arch_reg_value(struct perf_arch_regs *regs,static void perf_output_sample_regs (struct perf_output_handle *handle, -struct pt_regs *regs,u64 mask) +struct perf_regs *regs,u64 mask) {int bit;DECLARE_BITMAP (_mask,64 ); +u64 arch_regs_mask = regs->arch_regs_mask;bitmap_from_u64 (_mask, mask);for_each_set_bit (bit, _mask,sizeof (mask) *BITS_PER_BYTE ) {u64 val; - val =perf_reg_value (regs, bit); + val =perf_reg_value (regs->regs, bit); +perf_output_put (handle, val); + } + +bitmap_from_u64 (_mask, arch_regs_mask); +for_each_set_bit (bit, _mask,sizeof (mask) *BITS_PER_BYTE ) { +u64 val; + val =perf_arch_reg_value (regs->arch_regs, bit);perf_output_put (handle, val); } }
@@ -5792,7 +5800,7 @@ void perf_output_sample(struct perf_output_handle *handle,if (abi) {u64 mask = event->attr.sample_regs_user;perf_output_sample_regs (handle, - data->regs_user.regs, + &data->regs_user, mask); } }
@@ -5827,7 +5835,7 @@ void perf_output_sample(struct perf_output_handle *handle,u64 mask = event->attr.sample_regs_intr;perf_output_sample_regs (handle, - data->regs_intr.regs, + &data->regs_intr, mask); } }
Signature · 1 line
2.7.4
PATCH 5/13 powerpc/perf: Define enums for perf_arch_regs registers
In reply to Madhavan SrinivasanPatch creates a perf_event_powerpc_arch_regs enum and macros to include some of the powerpc pmu registers.
--- arch/powerpc/include/uapi/asm/perf_regs.h | 38 ++++++++++++++++++++++++ tools/arch/powerpc/include/uapi/asm/perf_regs.h | 39 +++++++++++++++++++++++++ 2 files changed, 77 insertions(+)
arch/powerpc/include/uapi/asm/perf_regs.h +38 -0
@@ -47,4 +47,42 @@ enum perf_event_powerpc_regs {PERF_REG_POWERPC_DSISR , PERF_REG_POWERPC_MAX, }; + +enum perf_event_powerpc_arch_regs { +PERF_ARCH_REG_POWERPC_PVR , +PERF_ARCH_REG_POWERPC_PMC1 , +PERF_ARCH_REG_POWERPC_PMC2 , +PERF_ARCH_REG_POWERPC_PMC3 , +PERF_ARCH_REG_POWERPC_PMC4 , +PERF_ARCH_REG_POWERPC_PMC5 , +PERF_ARCH_REG_POWERPC_PMC6 , +PERF_ARCH_REG_POWERPC_PMC7 , +PERF_ARCH_REG_POWERPC_PMC8 , +PERF_ARCH_REG_POWERPC_MMCR0 , +PERF_ARCH_REG_POWERPC_MMCR1 , +PERF_ARCH_REG_POWERPC_SIER , +PERF_ARCH_REG_POWERPC_SIAR , +PERF_ARCH_REG_POWERPC_SDAR , +PERF_ARCH_REG_POWERPC_MMCRA , +PERF_ARCH_REG_POWERPC_MMCR2 , +PERF_ARCH_REG_POWERPC_MAX , +}; + +#define PERF_ARCH_REG_PVR (1ULL<<PERF_ARCH_REG_POWERPC_PVR) +#define PERF_ARCH_REG_PMC1 (1ULL<<PERF_ARCH_REG_POWERPC_PMC1) +#define PERF_ARCH_REG_PMC2 (1ULL<<PERF_ARCH_REG_POWERPC_PMC2) +#define PERF_ARCH_REG_PMC3 (1ULL<<PERF_ARCH_REG_POWERPC_PMC3) +#define PERF_ARCH_REG_PMC4 (1ULL<<PERF_ARCH_REG_POWERPC_PMC4) +#define PERF_ARCH_REG_PMC5 (1ULL<<PERF_ARCH_REG_POWERPC_PMC5) +#define PERF_ARCH_REG_PMC6 (1ULL<<PERF_ARCH_REG_POWERPC_PMC6) +#define PERF_ARCH_REG_PMC7 (1ULL<<PERF_ARCH_REG_POWERPC_PMC7) +#define PERF_ARCH_REG_PMC8 (1ULL<<PERF_ARCH_REG_POWERPC_PMC8) +#define PERF_ARCH_REG_MMCR0 (1ULL<<PERF_ARCH_REG_POWERPC_MMCR0) +#define PERF_ARCH_REG_MMCR1 (1ULL<<PERF_ARCH_REG_POWERPC_MMCR1) +#define PERF_ARCH_REG_SIER (1ULL<<PERF_ARCH_REG_POWERPC_SIER) +#define PERF_ARCH_REG_SIAR (1ULL<<PERF_ARCH_REG_POWERPC_SIAR) +#define PERF_ARCH_REG_SDAR (1ULL<<PERF_ARCH_REG_POWERPC_SDAR) +#define PERF_ARCH_REG_MMCRA (1ULL<<PERF_ARCH_REG_POWERPC_MMCRA) +#define PERF_ARCH_REG_MMCR2 (1ULL<<PERF_ARCH_REG_POWERPC_MMCR2) +#endif /* _UAPI_ASM_POWERPC_PERF_REGS_H */
tools/arch/powerpc/include/uapi/asm/perf_regs.h +39 -0
@@ -47,4 +47,43 @@ enum perf_event_powerpc_regs {PERF_REG_POWERPC_DSISR , PERF_REG_POWERPC_MAX, }; + +enum perf_event_powerpc_arch_regs { +PERF_ARCH_REG_POWERPC_PVR , +PERF_ARCH_REG_POWERPC_PMC1 , +PERF_ARCH_REG_POWERPC_PMC2 , +PERF_ARCH_REG_POWERPC_PMC3 , +PERF_ARCH_REG_POWERPC_PMC4 , +PERF_ARCH_REG_POWERPC_PMC5 , +PERF_ARCH_REG_POWERPC_PMC6 , +PERF_ARCH_REG_POWERPC_PMC7 , +PERF_ARCH_REG_POWERPC_PMC8 , +PERF_ARCH_REG_POWERPC_MMCR0 , +PERF_ARCH_REG_POWERPC_MMCR1 , +PERF_ARCH_REG_POWERPC_SIER , +PERF_ARCH_REG_POWERPC_SIAR , +PERF_ARCH_REG_POWERPC_SDAR , +PERF_ARCH_REG_POWERPC_MMCRA , +PERF_ARCH_REG_POWERPC_MMCR2 , +PERF_ARCH_REG_POWERPC_MAX , +}; + +#define PERF_ARCH_REG_PVR 1ULL<<PERF_ARCH_REG_POWERPC_PVR +#define PERF_ARCH_REG_PMC1 1ULL<<PERF_ARCH_REG_POWERPC_PMC1 +#define PERF_ARCH_REG_PMC2 1ULL<<PERF_ARCH_REG_POWERPC_PMC2 +#define PERF_ARCH_REG_PMC3 1ULL<<PERF_ARCH_REG_POWERPC_PMC3 +#define PERF_ARCH_REG_PMC4 1ULL<<PERF_ARCH_REG_POWERPC_PMC4 +#define PERF_ARCH_REG_PMC5 1ULL<<PERF_ARCH_REG_POWERPC_PMC5 +#define PERF_ARCH_REG_PMC6 1ULL<<PERF_ARCH_REG_POWERPC_PMC6 +#define PERF_ARCH_REG_PMC7 1ULL<<PERF_ARCH_REG_POWERPC_PMC7 +#define PERF_ARCH_REG_PMC8 1ULL<<PERF_ARCH_REG_POWERPC_PMC8 +#define PERF_ARCH_REG_MMCR0 1ULL<<PERF_ARCH_REG_POWERPC_MMCR0 +#define PERF_ARCH_REG_MMCR1 1ULL<<PERF_ARCH_REG_POWERPC_MMCR1 +#define PERF_ARCH_REG_SIER 1ULL<<PERF_ARCH_REG_POWERPC_SIER +#define PERF_ARCH_REG_SIAR 1ULL<<PERF_ARCH_REG_POWERPC_SIAR +#define PERF_ARCH_REG_SDAR 1ULL<<PERF_ARCH_REG_POWERPC_SDAR +#define PERF_ARCH_REG_MMCRA 1ULL<<PERF_ARCH_REG_POWERPC_MMCRA +#define PERF_ARCH_REG_MMCR2 1ULL<<PERF_ARCH_REG_POWERPC_MMCR2 + +#endif /* _UAPI_ASM_POWERPC_PERF_REGS_H */
Signature · 1 line
2.7.4
PATCH 6/13 powerpc/perf: Add support for perf_arch_regs in powerpc
In reply to Madhavan SrinivasanPatch defines struct perf_arch_regs{} for powerpc and update the per-cpu perf pmu structure to include perf_arch_regs bits. perf_arch_reg_value(), perf_get_arch_reg() and perf_get_arch_regs_mask() are implemented to return proper values for powerpc. Finally adds code to call the processor specific function to update the arch_regs register values.
--- arch/powerpc/include/asm/perf_event_server.h | 11 ++++++++ arch/powerpc/perf/core-book3s.c | 38 ++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+)
arch/powerpc/include/asm/perf_event_server.h +11 -0
@@ -12,6 +12,7 @@#include <linux/types.h> #include <asm/hw_irq.h> #include <linux/device.h> +#include <uapi/asm/perf_regs.h> #include <uapi/asm/perf_event.h> /* Update perf_event_print_debug() if this changes */
@@ -21,6 +22,12 @@struct perf_event ; +struct perf_arch_regs { +unsigned long regs[PERF_ARCH_REG_POWERPC_MAX ]; +}; + +#define perf_arch_regs perf_arch_regs +/* * This struct provides the constants and functions needed to * describe the PMU on a particular POWER-family CPU.
@@ -52,6 +59,10 @@ struct power_pmu {/* BHRB entries in the PMU */ int bhrb_nr; + +/* perf_arch_regs bits */ +u64 ar_mask; +void (*get_arch_regs)(struct perf_arch_regs *regs); };/*
arch/powerpc/perf/core-book3s.c +38 -0
@@ -57,6 +57,9 @@ struct cpu_hw_events {void *bhrb_context;struct perf_branch_stack bhrb_stack;struct perf_branch_entry bhrb_entries[BHRB_MAX_ENTRIES ]; + +/* perf_arch_regs bits */ +struct perf_arch_regs ar_regs; }; static DEFINE_PER_CPU(struct cpu_hw_events, cpu_hw_events);
@@ -1928,6 +1931,33 @@ ssize_t power_events_sysfs_show(struct device *dev,return sprintf (page,"event=0x%02llx\n" , pmu_attr->id); } +u64 perf_get_arch_regs_mask (void ) +{ +return ppmu->ar_mask; +} + +struct perf_arch_regs *perf_get_arch_reg () +{ +struct cpu_hw_events *cpuhw; + + cpuhw =this_cpu_ptr (&cpu_hw_events); +if (!ppmu->ar_mask) +return NULL ; + +return &cpuhw->ar_regs; +} + +u64 perf_arch_reg_value (struct perf_arch_regs *regs,int idx) +{ +struct cpu_hw_events *cpuhw; + + cpuhw =this_cpu_ptr (&cpu_hw_events); +if (WARN_ON_ONCE (idx >=PERF_ARCH_REG_POWERPC_MAX )) +return 0 ; + +return cpuhw->ar_regs.regs[idx]; +} +static struct pmu power_pmu = { .pmu_enable = power_pmu_enable, .pmu_disable = power_pmu_disable,
@@ -2009,6 +2039,14 @@ static void record_and_restart(struct perf_event *event, unsigned long val, data.br_stack = &cpuhw->bhrb_stack; } +if (event->attr.sample_type &PERF_SAMPLE_REGS_INTR ) { +struct cpu_hw_events *cpuhw; + cpuhw =this_cpu_ptr (&cpu_hw_events); + +if (ppmu->get_arch_regs) + ppmu->get_arch_regs (&cpuhw->ar_regs); + } +if (perf_event_overflow (event, &data, regs))power_pmu_stop (event,0 ); }
Signature · 1 line
2.7.4
PATCH 7/13 powerpc/perf: Add support for perf_arch_regs for Power7 processor
In reply to Madhavan SrinivasanAdd code to define support functions and registers mask for Power7 processor.
--- arch/powerpc/perf/power7-pmu.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
arch/powerpc/perf/power7-pmu.c +28 -0
@@ -13,6 +13,7 @@#include <linux/string.h> #include <asm/reg.h> #include <asm/cputable.h> +#include <uapi/asm/perf_regs.h> /* * Bits in event code for POWER7
@@ -427,6 +428,31 @@ static const struct attribute_group *power7_pmu_attr_groups[] = { NULL, }; +#define POWER7_ARCH_REGS_MASK (PERF_ARCH_REG_PVR |\ + PERF_ARCH_REG_PMC1 | PERF_ARCH_REG_PMC2 |\ + PERF_ARCH_REG_PMC3 | PERF_ARCH_REG_PMC4 |\ + PERF_ARCH_REG_PMC5 | PERF_ARCH_REG_PMC6 |\ + PERF_ARCH_REG_MMCR0 | PERF_ARCH_REG_MMCR1 |\ + PERF_ARCH_REG_SIER | PERF_ARCH_REG_SIAR |\ + PERF_ARCH_REG_SDAR | PERF_ARCH_REG_MMCRA) + +static void power7_get_arch_regs (struct perf_arch_regs *regs) +{ + regs->regs[PERF_ARCH_REG_POWERPC_PVR ] =mfspr (SPRN_PVR ); + regs->regs[PERF_ARCH_REG_POWERPC_PMC1 ] =mfspr (SPRN_PMC1 ); + regs->regs[PERF_ARCH_REG_POWERPC_PMC2 ] =mfspr (SPRN_PMC2 ); + regs->regs[PERF_ARCH_REG_POWERPC_PMC3 ] =mfspr (SPRN_PMC3 ); + regs->regs[PERF_ARCH_REG_POWERPC_PMC4 ] =mfspr (SPRN_PMC4 ); + regs->regs[PERF_ARCH_REG_POWERPC_PMC5 ] =mfspr (SPRN_PMC5 ); + regs->regs[PERF_ARCH_REG_POWERPC_PMC6 ] =mfspr (SPRN_PMC6 ); + regs->regs[PERF_ARCH_REG_POWERPC_MMCR0 ] =mfspr (SPRN_MMCR0 ); + regs->regs[PERF_ARCH_REG_POWERPC_MMCR1 ] =mfspr (SPRN_MMCR1 ); + regs->regs[PERF_ARCH_REG_POWERPC_SIER ] =mfspr (SPRN_SIER ); + regs->regs[PERF_ARCH_REG_POWERPC_SIAR ] =mfspr (SPRN_SIAR ); + regs->regs[PERF_ARCH_REG_POWERPC_SDAR ] =mfspr (SPRN_SDAR ); + regs->regs[PERF_ARCH_REG_POWERPC_MMCRA ] =mfspr (SPRN_MMCRA ); +} +static struct power_pmu power7_pmu = { .name ="POWER7" , .n_counter =6 ,
@@ -442,6 +468,8 @@ static struct power_pmu power7_pmu = { .n_generic = ARRAY_SIZE(power7_generic_events), .generic_events = power7_generic_events, .cache_events = &power7_cache_events, + .ar_mask = POWER7_ARCH_REGS_MASK, + .get_arch_regs = power7_get_arch_regs, };static int __init init_power7_pmu (void )
Signature · 1 line
2.7.4
PATCH 8/13 powerpc/perf: Add support for perf_arch_regs for newer Power processor
In reply to Madhavan SrinivasanAdd code to define support functions and registers mask for Power8 and later processor.
--- arch/powerpc/perf/isa207-common.c | 18 ++++++++++++++++++ arch/powerpc/perf/isa207-common.h | 10 ++++++++++ arch/powerpc/perf/power8-pmu.c | 2 ++ arch/powerpc/perf/power9-pmu.c | 2 ++ 4 files changed, 32 insertions(+)
arch/powerpc/perf/isa207-common.c +18 -0
@@ -261,3 +261,21 @@ void isa207_disable_pmc(unsigned int pmc, unsigned long mmcr[])if (pmc <=3 ) mmcr[1 ] &= ~(0xffUL <<MMCR1_PMCSEL_SHIFT (pmc +1 )); } + +void isa207_get_arch_regs (struct perf_arch_regs *regs) +{ + regs->regs[PERF_ARCH_REG_POWERPC_PVR ] =mfspr (SPRN_PVR ); + regs->regs[PERF_ARCH_REG_POWERPC_PMC1 ] =mfspr (SPRN_PMC1 ); + regs->regs[PERF_ARCH_REG_POWERPC_PMC2 ] =mfspr (SPRN_PMC2 ); + regs->regs[PERF_ARCH_REG_POWERPC_PMC3 ] =mfspr (SPRN_PMC3 ); + regs->regs[PERF_ARCH_REG_POWERPC_PMC4 ] =mfspr (SPRN_PMC4 ); + regs->regs[PERF_ARCH_REG_POWERPC_PMC5 ] =mfspr (SPRN_PMC5 ); + regs->regs[PERF_ARCH_REG_POWERPC_PMC6 ] =mfspr (SPRN_PMC6 ); + regs->regs[PERF_ARCH_REG_POWERPC_MMCR0 ] =mfspr (SPRN_MMCR0 ); + regs->regs[PERF_ARCH_REG_POWERPC_MMCR1 ] =mfspr (SPRN_MMCR1 ); + regs->regs[PERF_ARCH_REG_POWERPC_SIER ] =mfspr (SPRN_SIER ); + regs->regs[PERF_ARCH_REG_POWERPC_SIAR ] =mfspr (SPRN_SIAR ); + regs->regs[PERF_ARCH_REG_POWERPC_SDAR ] =mfspr (SPRN_SDAR ); + regs->regs[PERF_ARCH_REG_POWERPC_MMCRA ] =mfspr (SPRN_MMCRA ); + regs->regs[PERF_ARCH_REG_POWERPC_MMCR2 ] =mfspr (SPRN_MMCR2 ); +}
arch/powerpc/perf/isa207-common.h +10 -0
@@ -16,6 +16,7 @@#include <linux/perf_event.h> #include <asm/firmware.h> #include <asm/cputable.h> +#include <uapi/asm/perf_regs.h> /* * Raw event encoding for PowerISA v2.07:
@@ -227,10 +228,19 @@#define MAX_ALT 2#define MAX_PMU_COUNTERS 6 +#define ISA207_ARCH_REGS_MASK (PERF_ARCH_REG_PVR |\ + PERF_ARCH_REG_PMC1 | PERF_ARCH_REG_PMC2 |\ + PERF_ARCH_REG_PMC3 | PERF_ARCH_REG_PMC4 |\ + PERF_ARCH_REG_PMC5 | PERF_ARCH_REG_PMC6 |\ + PERF_ARCH_REG_MMCR0 | PERF_ARCH_REG_MMCR1 |\ + PERF_ARCH_REG_SIER | PERF_ARCH_REG_SIAR |\ + PERF_ARCH_REG_SDAR | PERF_ARCH_REG_MMCRA | PERF_ARCH_REG_MMCR2) +int isa207_get_constraint (u64 event,unsigned long *maskp,unsigned long *valp);int isa207_compute_mmcr (u64 event[],int n_ev,unsigned int hwc[],unsigned long mmcr[],struct perf_event *pevents[]);void isa207_disable_pmc (unsigned int pmc,unsigned long mmcr[]); +void isa207_get_arch_regs (struct perf_arch_regs *regs);#endif
arch/powerpc/perf/power8-pmu.c +2 -0
@@ -394,6 +394,8 @@ static struct power_pmu power8_pmu = { .cache_events = &power8_cache_events, .attr_groups = power8_pmu_attr_groups, .bhrb_nr = 32, + .ar_mask = ISA207_ARCH_REGS_MASK, + .get_arch_regs = isa207_get_arch_regs, };static int __init init_power8_pmu (void )
arch/powerpc/perf/power9-pmu.c +2 -0
@@ -307,6 +307,8 @@ static struct power_pmu power9_pmu = { .cache_events = &power9_cache_events, .attr_groups = power9_pmu_attr_groups, .bhrb_nr = 32, + .ar_mask = ISA207_ARCH_REGS_MASK, + .get_arch_regs = isa207_get_arch_regs, };static int __init init_power9_pmu (void )
Signature · 1 line
2.7.4
PATCH 9/13 powerpc/perf: Add support for perf_arch_regs for PPC970 processor
In reply to Madhavan SrinivasanAdd code to define support functions and registers mask for PPC970 processor.
--- arch/powerpc/perf/ppc970-pmu.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
arch/powerpc/perf/ppc970-pmu.c +23 -0
@@ -12,6 +12,7 @@#include <linux/perf_event.h> #include <asm/reg.h> #include <asm/cputable.h> +#include <uapi/asm/perf_regs.h> /* * Bits in event code for PPC970
@@ -474,6 +475,26 @@ static int ppc970_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = { }, }; +#define PPC970_ARCH_REGS_MASK (PERF_ARCH_REG_PVR |\ + PERF_ARCH_REG_PMC1 | PERF_ARCH_REG_PMC2 |\ + PERF_ARCH_REG_PMC3 | PERF_ARCH_REG_PMC4 |\ + PERF_ARCH_REG_PMC5 | PERF_ARCH_REG_PMC6 |\ + PERF_ARCH_REG_MMCR0 | PERF_ARCH_REG_MMCR1 | PERF_ARCH_REG_MMCRA) + +static void ppc970_get_arch_regs (struct perf_arch_regs *regs) +{ + regs->regs[PERF_ARCH_REG_POWERPC_PVR ] =mfspr (SPRN_PVR ); + regs->regs[PERF_ARCH_REG_POWERPC_PMC1 ] =mfspr (SPRN_PMC1 ); + regs->regs[PERF_ARCH_REG_POWERPC_PMC2 ] =mfspr (SPRN_PMC2 ); + regs->regs[PERF_ARCH_REG_POWERPC_PMC3 ] =mfspr (SPRN_PMC3 ); + regs->regs[PERF_ARCH_REG_POWERPC_PMC4 ] =mfspr (SPRN_PMC4 ); + regs->regs[PERF_ARCH_REG_POWERPC_PMC5 ] =mfspr (SPRN_PMC5 ); + regs->regs[PERF_ARCH_REG_POWERPC_PMC6 ] =mfspr (SPRN_PMC6 ); + regs->regs[PERF_ARCH_REG_POWERPC_MMCR0 ] =mfspr (SPRN_MMCR0 ); + regs->regs[PERF_ARCH_REG_POWERPC_MMCR1 ] =mfspr (SPRN_MMCR1 ); + regs->regs[PERF_ARCH_REG_POWERPC_MMCRA ] =mfspr (SPRN_MMCRA ); +} +static struct power_pmu ppc970_pmu = { .name ="PPC970/FX/MP" , .n_counter =8 ,
@@ -488,6 +509,8 @@ static struct power_pmu ppc970_pmu = { .generic_events = ppc970_generic_events, .cache_events = &ppc970_cache_events, .flags = PPMU_NO_SIPR | PPMU_NO_CONT_SAMPLING, + .ar_mask = PPC970_ARCH_REGS_MASK, + .get_arch_regs = ppc970_get_arch_regs, };static int __init init_ppc970_pmu (void )
Signature · 1 line
2.7.4
PATCH 10/13 tool/perf: Add support for perf_arch_regs
In reply to Madhavan SrinivasanUpdate the structure regs_dump with the arch_regs_mask variable. Update perf_evsel__parse_sample() and perf_event__sample_event_size() to include arch_regs_mask variable.
--- tools/perf/util/event.h | 1 + tools/perf/util/evsel.c | 11 +++++++++++ 2 files changed, 12 insertions(+)
tools/perf/util/event.h +1 -0
@@ -94,6 +94,7 @@ struct sample_event {struct regs_dump {u64 abi;u64 mask; +u64 arch_regs_mask;u64 *regs;/* Cached values/mask filled by first register access. */
tools/perf/util/evsel.c +11 -0
@@ -1902,6 +1902,8 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event,OVERFLOW_CHECK_u64 (array); data->user_regs.abi = *array; array++; + data->user_regs.arch_regs_mask = *array; + array++;if (data->user_regs.abi) {u64 mask = evsel->attr.sample_regs_user;
@@ -1961,11 +1963,14 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event,OVERFLOW_CHECK_u64 (array); data->intr_regs.abi = *array; array++; + data->intr_regs.arch_regs_mask = *array; + array++;if (data->intr_regs.abi !=PERF_SAMPLE_REGS_ABI_NONE ) {u64 mask = evsel->attr.sample_regs_intr; sz =hweight_long (mask) *sizeof (u64); + sz +=hweight_long (data->intr_regs.arch_regs_mask) *sizeof (u64);OVERFLOW_CHECK (array, sz, max_size); data->intr_regs.mask = mask; data->intr_regs.regs = (u64 *)array;
@@ -2044,6 +2049,7 @@ size_t perf_event__sample_event_size(const struct perf_sample *sample, u64 type,if (sample->user_regs.abi) { result +=sizeof (u64); sz =hweight_long (sample->user_regs.mask) *sizeof (u64); + sz +=hweight_long (sample->user_regs.arch_regs_mask) *sizeof (u64); result += sz; }else { result +=sizeof (u64);
@@ -2072,6 +2078,7 @@ size_t perf_event__sample_event_size(const struct perf_sample *sample, u64 type,if (sample->intr_regs.abi) { result +=sizeof (u64); sz =hweight_long (sample->intr_regs.mask) *sizeof (u64); + sz +=hweight_long (sample->intr_regs.arch_regs_mask) *sizeof (u64); result += sz; }else { result +=sizeof (u64);
@@ -2223,7 +2230,9 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type,if (type &PERF_SAMPLE_REGS_USER ) {if (sample->user_regs.abi) { *array++ = sample->user_regs.abi; + *array++ = sample->user_regs.arch_regs_mask; sz =hweight_long (sample->user_regs.mask) *sizeof (u64); + sz +=hweight_long (sample->user_regs.arch_regs_mask) *sizeof (u64);memcpy (array, sample->user_regs.regs, sz); array = (void *)array + sz; }else {
@@ -2259,7 +2268,9 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type,if (type &PERF_SAMPLE_REGS_INTR ) {if (sample->intr_regs.abi) { *array++ = sample->intr_regs.abi; + *array++ = sample->intr_regs.arch_regs_mask; sz =hweight_long (sample->intr_regs.mask) *sizeof (u64); + sz +=hweight_long (sample->intr_regs.arch_regs_mask) *sizeof (u64);memcpy (array, sample->intr_regs.regs, sz); array = (void *)array + sz; }else {
Signature · 1 line
2.7.4
PATCH 11/13 tools/perf: Fix the mask in regs_dump__printf and print_sample_iregs
In reply to Madhavan SrinivasanWhen decoding the perf_regs mask in regs_dump__printf(),
we loop through the mask using find_first_bit and find_next_bit functions. "mask" is of type "u64", but sent as a "unsigned long *" to lib functions along with sizeof().
While the exisitng code works fine in most of the case,
the logic is broken when using a 32bit perf on a 64bit kernel (Big Endian). When reading u64 using (u32 *)(&val)[0], perf (lib/find_*_bit()) assumes it gets lower 32bits of u64 which is wrong. Proposed fix is to swap the words of the u64 to handle this case. This is _not_ endianess swap.
---
Fix already posted, but yet to be pulled in. This is needed for the subsequent patches.
https://patchwork.kernel.org/patch/9285421/
tools/include/linux/bitmap.h | 2 ++ tools/lib/bitmap.c | 18 ++++++++++++++++++ tools/perf/builtin-script.c | 4 +++- tools/perf/util/session.c | 4 +++- 4 files changed, 26 insertions(+), 2 deletions(-)
tools/include/linux/bitmap.h +2 -0
@@ -4,10 +4,12 @@#include <string.h> #include <linux/bitops.h> #include <stdlib.h> +#include <limits.h> #define DECLARE_BITMAP (name,bits) \ unsigned long name[BITS_TO_LONGS(bits)] +void bitmap_from_u64 (unsigned long *dst,u64 mask);int __bitmap_weight (const unsigned long *bitmap,int bits);void __bitmap_or (unsigned long *dst,const unsigned long *bitmap1,const unsigned long *bitmap2,int bits);
tools/lib/bitmap.c +18 -0
@@ -73,3 +73,21 @@ int __bitmap_and(unsigned long *dst, const unsigned long *bitmap1, BITMAP_LAST_WORD_MASK(bits));return result !=0 ; } + +/* +* bitmap_from_u64 - Check and swap words within u64. +* @mask: source bitmap +* @dst: destination bitmap +* +* In 32 bit big endian userspace on a 64bit kernel, 'unsigned long' is 32 bits. +* When reading u64 using (u32 *)(&val)[0] and (u32 *)(&val)[1], +* we will get wrong value for the mask. That is "(u32 *)(&val)[0]" +* gets upper 32 bits of u64, but perf may expect lower 32bits of u64. +*/ +void bitmap_from_u64 (unsigned long *dst,u64 mask) +{ + dst[0 ] = mask &ULONG_MAX ; + +if (sizeof (mask) >sizeof (unsigned long )) + dst[1 ] = mask >>32 ; +}
tools/perf/builtin-script.c +3 -1
@@ -421,11 +421,13 @@ static void print_sample_iregs(struct perf_sample *sample,struct regs_dump *regs = &sample->intr_regs;uint64_t mask = attr->sample_regs_intr;unsigned i =0 , r; +DECLARE_BITMAP (_mask,64 );if (!regs)return ; -for_each_set_bit (r, (unsigned long *) &mask,sizeof (mask) *8 ) { +bitmap_from_u64 (_mask, mask); +for_each_set_bit (r, _mask,sizeof (mask) *8 ) {u64 val = regs->regs[i++];printf ("%5s:0x%" PRIx64" " ,perf_reg_name (r), val); }
tools/perf/util/session.c +3 -1
@@ -944,8 +944,10 @@ static void branch_stack__printf(struct perf_sample *sample)static void regs_dump__printf (u64 mask,u64 *regs) {unsigned rid, i =0 ; +DECLARE_BITMAP (_mask,64 ); -for_each_set_bit (rid, (unsigned long *) &mask,sizeof (mask) *8 ) { +bitmap_from_u64 (_mask, mask); +for_each_set_bit (rid, _mask,sizeof (mask) *8 ) {u64 val = regs[i++]; printf(".... %-5s 0x%" PRIx64 "\n",
Signature · 1 line
2.7.4
PATCH 12/13 tool/perf: Add perf_arch_reg mask and arch_reg_names structure
In reply to Madhavan SrinivasanAdd arch_reg_names structure and define perf_arch_reg_name() function to aid the printing of arch_regs values. Also, extend regs_dump__printf() to include perf_arch_regs_mask to enable printing support.
--- tools/perf/arch/arm/include/perf_regs.h | 5 +++++ tools/perf/arch/arm64/include/perf_regs.h | 5 +++++ tools/perf/arch/powerpc/include/perf_regs.h | 25 +++++++++++++++++++++++++ tools/perf/arch/x86/include/perf_regs.h | 5 +++++ tools/perf/builtin-script.c | 7 +++++++ tools/perf/util/perf_regs.h | 5 +++++ tools/perf/util/session.c | 12 ++++++++++-- 7 files changed, 62 insertions(+), 2 deletions(-)
tools/perf/arch/arm/include/perf_regs.h +5 -0
@@ -56,4 +56,9 @@ static inline const char *perf_reg_name(int id) return NULL; } +static inline const char *perf_arch_reg_name (int id__maybe_unused ) +{ +return NULL ; +} +#endif /* ARCH_PERF_REGS_H */
tools/perf/arch/arm64/include/perf_regs.h +5 -0
@@ -90,4 +90,9 @@ static inline const char *perf_reg_name(int id) return NULL; } +static inline const char *perf_arch_reg_name (int id__maybe_unused ) +{ +return NULL ; +} +#endif /* ARCH_PERF_REGS_H */
tools/perf/arch/powerpc/include/perf_regs.h +25 -0
@@ -4,6 +4,7 @@#include <stdlib.h> #include <linux/types.h> #include <asm/perf_regs.h> +#include <uapi/asm/perf_regs.h> #define PERF_REGS_MASK ((1ULL << PERF_REG_POWERPC_MAX) - 1)#define PERF_REGS_MAX PERF_REG_POWERPC_MAX
@@ -66,4 +67,28 @@ static inline const char *perf_reg_name(int id) {return reg_names[id]; } + +static const char *arch_reg_names[] = { + [PERF_ARCH_REG_POWERPC_PVR ] ="pvr" , + [PERF_ARCH_REG_POWERPC_PMC1 ] ="pmc1" , + [PERF_ARCH_REG_POWERPC_PMC2 ] ="pmc2" , + [PERF_ARCH_REG_POWERPC_PMC3 ] ="pmc3" , + [PERF_ARCH_REG_POWERPC_PMC4 ] ="pmc4" , + [PERF_ARCH_REG_POWERPC_PMC5 ] ="pmc5" , + [PERF_ARCH_REG_POWERPC_PMC6 ] ="pmc6" , + [PERF_ARCH_REG_POWERPC_PMC7 ] ="pmc7" , + [PERF_ARCH_REG_POWERPC_PMC8 ] ="pmc8" , + [PERF_ARCH_REG_POWERPC_MMCR0 ] ="mmcr0" , + [PERF_ARCH_REG_POWERPC_MMCR1 ] ="mmcr1" , + [PERF_ARCH_REG_POWERPC_SIER ] ="sier" , + [PERF_ARCH_REG_POWERPC_SIAR ] ="siar" , + [PERF_ARCH_REG_POWERPC_SDAR ] ="sdar" , + [PERF_ARCH_REG_POWERPC_MMCRA ] ="mmcra" , + [PERF_ARCH_REG_POWERPC_MMCR2 ] ="mmcr2" +}; + +static inline const char *perf_arch_reg_name (int id) +{ +return arch_reg_names[id]; +}#endif /* ARCH_PERF_REGS_H */
tools/perf/arch/x86/include/perf_regs.h +5 -0
@@ -83,4 +83,9 @@ static inline const char *perf_reg_name(int id) return NULL; } +static inline const char *perf_arch_reg_name (int id__maybe_unused ) +{ +return NULL ; +} +#endif /* ARCH_PERF_REGS_H */
tools/perf/builtin-script.c +7 -0
@@ -420,6 +420,7 @@ static void print_sample_iregs(struct perf_sample *sample, {struct regs_dump *regs = &sample->intr_regs;uint64_t mask = attr->sample_regs_intr; +uint64_t arch_regs_mask = regs->arch_regs_mask;unsigned i =0 , r;DECLARE_BITMAP (_mask,64 );
@@ -431,6 +432,12 @@ static void print_sample_iregs(struct perf_sample *sample,u64 val = regs->regs[i++];printf ("%5s:0x%" PRIx64" " ,perf_reg_name (r), val); } + +bitmap_from_u64 (_mask, arch_regs_mask); +for_each_set_bit (r, _mask,sizeof (mask) *8 ) { +u64 val = regs->regs[i++]; +printf ("%5s:0x%" PRIx64" " ,perf_arch_reg_name (r), val); + } } static void print_sample_start(struct perf_sample *sample,
tools/perf/util/perf_regs.h +5 -0
@@ -29,6 +29,11 @@ static inline const char *perf_reg_name(int id __maybe_unused)return NULL ; } +static inline const char *perf_arch_reg_name (int id__maybe_unused ) +{ +return NULL ; +} +static inline int perf_reg_value (u64 *valp__maybe_unused ,struct regs_dump *regs__maybe_unused ,int id__maybe_unused )
tools/perf/util/session.c +10 -2
@@ -941,7 +941,7 @@ static void branch_stack__printf(struct perf_sample *sample) } } -static void regs_dump__printf (u64 mask,u64 *regs) +static void regs_dump__printf (u64 mask,u64 arch_regs_mask,u64 *regs) {unsigned rid, i =0 ;DECLARE_BITMAP (_mask,64 );
@@ -953,6 +953,14 @@ static void regs_dump__printf(u64 mask, u64 *regs)printf (".... %-5s 0x%" PRIx64"\n" ,perf_reg_name (rid), val); } + +bitmap_from_u64 (_mask, arch_regs_mask); +for_each_set_bit (rid, _mask,sizeof (mask) *8 ) { +u64 val = regs[i++]; + +printf (".... %-5s 0x%" PRIx64"\n" , +perf_arch_reg_name (rid), val); + } }static const char *regs_abi[] = {
@@ -978,7 +986,7 @@ static void regs__printf(const char *type, struct regs_dump *regs) mask, regs_dump_abi(regs)); -regs_dump__printf (mask, regs->regs); +regs_dump__printf (mask, regs->arch_regs_mask, regs->regs); }static void regs_user__printf (struct perf_sample *sample)
Signature · 1 line
2.7.4
PATCH 13/13 powerpc/perf: Add support to dump only arch_regs
In reply to Madhavan Srinivasanperf tool provides us an option to selective dump intr_regs. Add arch_regs option to it.
--- arch/powerpc/include/uapi/asm/perf_regs.h | 1 + arch/powerpc/perf/perf_regs.c | 3 +++ tools/arch/powerpc/include/uapi/asm/perf_regs.h | 1 + tools/perf/arch/powerpc/include/perf_regs.h | 3 ++- tools/perf/arch/powerpc/util/perf_regs.c | 1 + 5 files changed, 8 insertions(+), 1 deletion(-)
arch/powerpc/include/uapi/asm/perf_regs.h +1 -0
@@ -45,6 +45,7 @@ enum perf_event_powerpc_regs {PERF_REG_POWERPC_TRAP ,PERF_REG_POWERPC_DAR ,PERF_REG_POWERPC_DSISR , +PERF_REG_POWERPC_ARCH_REGS , PERF_REG_POWERPC_MAX, };
arch/powerpc/perf/perf_regs.c +3 -0
@@ -75,6 +75,9 @@ u64 perf_reg_value(struct pt_regs *regs, int idx)if (WARN_ON_ONCE (idx >=PERF_REG_POWERPC_MAX ))return 0 ; +if (idx ==PERF_REG_POWERPC_ARCH_REGS ) +return perf_get_arch_regs_mask (); +return regs_get_register (regs, pt_regs_offset[idx]); }
tools/arch/powerpc/include/uapi/asm/perf_regs.h +1 -0
@@ -45,6 +45,7 @@ enum perf_event_powerpc_regs {PERF_REG_POWERPC_TRAP ,PERF_REG_POWERPC_DAR ,PERF_REG_POWERPC_DSISR , +PERF_REG_POWERPC_ARCH_REGS , PERF_REG_POWERPC_MAX, };
tools/perf/arch/powerpc/include/perf_regs.h +2 -1
@@ -60,7 +60,8 @@ static const char *reg_names[] = { [PERF_REG_POWERPC_SOFTE] = "softe", [PERF_REG_POWERPC_TRAP] = "trap", [PERF_REG_POWERPC_DAR] = "dar", - [PERF_REG_POWERPC_DSISR] = "dsisr" + [PERF_REG_POWERPC_DSISR] = "dsisr", + [PERF_REG_POWERPC_ARCH_REGS] = "arch_regs" };static inline const char *perf_reg_name (int id)
tools/perf/arch/powerpc/util/perf_regs.c +1 -0
@@ -45,5 +45,6 @@ const struct sample_reg sample_reg_masks[] = {SMPL_REG (trap,PERF_REG_POWERPC_TRAP ),SMPL_REG (dar,PERF_REG_POWERPC_DAR ),SMPL_REG (dsisr,PERF_REG_POWERPC_DSISR ), +SMPL_REG (arch_regs,PERF_REG_POWERPC_ARCH_REGS ), SMPL_REG_END };
Signature · 1 line
2.7.4
kbuild test robot
build botRe: [PATCH 01/13] perf/core: Add perf_arch_regs and mask to perf_regs structure
In reply to Madhavan Srinivasanurl: https://github.com/0day-ci/linux/commits/Madhavan-Srinivasan/perf-core-Add-perf_arch_regs-and-mask-to-perf_regs-structure/20160829-050443 config: sparc64-allyesconfig (attached as .config)…
Hi Madhavan,
[auto build test ERROR on tip/perf/core]
[also build test ERROR on v4.8-rc3 next-20160825]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on] [Check https://git-scm.com/docs/git-format-patch for more information]
url: https://github.com/0day-ci/linux/commits/Madhavan-Srinivasan/perf-core-Add-perf_arch_regs-and-mask-to-perf_regs-structure/20160829-050443
config: sparc64-allyesconfig (attached as .config)
compiler: sparc64-linux-gnu-gcc (Debian 5.4.0-6) 5.4.0 20160609
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=sparc64
All errors (new ones prefixed by >>):
>> kernel/events/core.c:5356:27: error: redefinition of 'perf_get_arch_regs_mask'
u64 __attribute__((weak)) perf_get_arch_regs_mask()
^
In file included from include/linux/perf_event.h:54:0,
from include/linux/trace_events.h:9,
from include/trace/syscall.h:6,
from include/linux/syscalls.h:81,
from kernel/events/core.c:34:
include/linux/perf_regs.h:52:5: note: previous definition of 'perf_get_arch_regs_mask' was here
u64 perf_get_arch_regs_mask(void)
^
>> kernel/events/core.c:5361:46: error: redefinition of 'perf_get_arch_reg'
struct perf_arch_regs *__attribute__((weak)) perf_get_arch_reg()
^
In file included from include/linux/perf_event.h:54:0,
from include/linux/trace_events.h:9,
from include/trace/syscall.h:6,
from include/linux/syscalls.h:81,
from kernel/events/core.c:34:
include/linux/perf_regs.h:57:24: note: previous definition of 'perf_get_arch_reg' was here
struct perf_arch_regs *perf_get_arch_reg(void)
^
>> kernel/events/core.c:5366:27: error: redefinition of 'perf_arch_reg_value' u64 __attribute__((weak)) perf_arch_reg_value(struct perf_arch_regs *regs,
^
In file included from include/linux/perf_event.h:54:0,
from include/linux/trace_events.h:9,
from include/trace/syscall.h:6,
from include/linux/syscalls.h:81,
from kernel/events/core.c:34:
include/linux/perf_regs.h:62:5: note: previous definition of 'perf_arch_reg_value' was here
u64 perf_arch_reg_value(struct perf_arch_regs *regs, int idx)
^
vim +/perf_get_arch_regs_mask +5356 kernel/events/core.c
5350 {
5351 perf_guest_cbs = NULL;
5352 return 0;
5353 }
5354 EXPORT_SYMBOL_GPL(perf_unregister_guest_info_callbacks);
5355
> 5356 u64 __attribute__((weak)) perf_get_arch_regs_mask()
5357 {
5358 return 0;
5359 }
5360
> 5361 struct perf_arch_regs *__attribute__((weak)) perf_get_arch_reg()
5362 {
5363 return 0;
5364 }
5365
> 5366 u64 __attribute__((weak)) perf_arch_reg_value(struct perf_arch_regs *regs, 5367 int idx)
5368 {
5369 return 0;
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
kbuild test robot
build botRe: [PATCH 01/13] perf/core: Add perf_arch_regs and mask to perf_regs structure
In reply to Madhavan Srinivasanurl: https://github.com/0day-ci/linux/commits/Madhavan-Srinivasan/perf-core-Add-perf_arch_regs-and-mask-to-perf_regs-structure/20160829-050443 config: frv-defconfig (attached as .config) compiler…
Hi Madhavan,
[auto build test WARNING on tip/perf/core]
[also build test WARNING on v4.8-rc4 next-20160825]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on] [Check https://git-scm.com/docs/git-format-patch for more information]
url: https://github.com/0day-ci/linux/commits/Madhavan-Srinivasan/perf-core-Add-perf_arch_regs-and-mask-to-perf_regs-structure/20160829-050443
config: frv-defconfig (attached as .config)
compiler: frv-linux-gcc (GCC) 4.9.0
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=frv
All warnings (new ones prefixed by >>):
kernel/sched/idle.o: In function `perf_get_arch_regs_mask':
idle.c:(.text+0x0): multiple definition of `perf_get_arch_regs_mask' kernel/sched/core.o:core.c:(.text+0x310): first defined here
>> frv-linux-ld: Warning: size of symbol `perf_get_arch_regs_mask' changed from 44 in kernel/sched/core.o to 12 in kernel/sched/idle.o kernel/sched/idle.o: In function `perf_get_arch_reg': idle.c:(.text+0x10): multiple definition of `perf_get_arch_reg' kernel/sched/core.o:core.c:(.text+0x340): first defined here >> frv-linux-ld: Warning: size of symbol `perf_get_arch_reg' changed from 40 in kernel/sched/core.o to 8 in kernel/sched/idle.o kernel/sched/idle.o: In function `perf_arch_reg_value': idle.c:(.text+0x20): multiple definition of `perf_arch_reg_value' kernel/sched/core.o:core.c:(.text+0x370): first defined here >> frv-linux-ld: Warning: size of symbol `perf_arch_reg_value' changed from 44 in kernel/sched/core.o to 12 in kernel/sched/idle.o
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
kbuild test robot
build botRe: [PATCH 01/13] perf/core: Add perf_arch_regs and mask to perf_regs structure
In reply to Madhavan Srinivasanurl: https://github.com/0day-ci/linux/commits/Madhavan-Srinivasan/perf-core-Add-perf_arch_regs-and-mask-to-perf_regs-structure/20160829-050443 config: s390-default_defconfig (attached as .config)…
Hi Madhavan,
[auto build test ERROR on tip/perf/core]
[also build test ERROR on v4.8-rc4 next-20160825]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on] [Check https://git-scm.com/docs/git-format-patch for more information]
url: https://github.com/0day-ci/linux/commits/Madhavan-Srinivasan/perf-core-Add-perf_arch_regs-and-mask-to-perf_regs-structure/20160829-050443
config: s390-default_defconfig (attached as .config)
compiler: s390x-linux-gnu-gcc (Debian 5.4.0-6) 5.4.0 20160609
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=s390
All errors (new ones prefixed by >>):
security/keys/compat.o: In function `perf_get_arch_reg':
>> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' security/keys/keyctl.o:include/linux/perf_regs.h:60: first defined here security/keys/compat.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' security/keys/keyctl.o:include/linux/perf_regs.h:55: first defined here security/keys/compat.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value' security/keys/keyctl.o:include/linux/perf_regs.h:65: first defined here -- kernel/bpf/arraymap.o: In function `perf_get_arch_reg': >> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' kernel/bpf/syscall.o:include/linux/perf_regs.h:60: first defined here kernel/bpf/arraymap.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' kernel/bpf/syscall.o:include/linux/perf_regs.h:55: first defined here kernel/bpf/arraymap.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value' kernel/bpf/syscall.o:include/linux/perf_regs.h:65: first defined here kernel/bpf/stackmap.o: In function `perf_get_arch_reg': >> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' kernel/bpf/syscall.o:include/linux/perf_regs.h:60: first defined here kernel/bpf/stackmap.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' kernel/bpf/syscall.o:include/linux/perf_regs.h:55: first defined here kernel/bpf/stackmap.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value' kernel/bpf/syscall.o:include/linux/perf_regs.h:65: first defined here -- kernel/locking/rtmutex-debug.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' kernel/locking/lockdep.o:include/linux/perf_regs.h:55: first defined here kernel/locking/rtmutex-debug.o: In function `perf_get_arch_reg': >> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' kernel/locking/lockdep.o:include/linux/perf_regs.h:60: first defined here kernel/locking/rtmutex-debug.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value' kernel/locking/lockdep.o:include/linux/perf_regs.h:65: first defined here -- kernel/power/process.o: In function `perf_get_arch_reg': >> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' kernel/power/qos.o:include/linux/perf_regs.h:60: first defined here kernel/power/process.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' kernel/power/qos.o:include/linux/perf_regs.h:55: first defined here kernel/power/process.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value' kernel/power/qos.o:include/linux/perf_regs.h:65: first defined here kernel/power/hibernate.o: In function `perf_get_arch_reg': >> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' kernel/power/qos.o:include/linux/perf_regs.h:60: first defined here kernel/power/hibernate.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' kernel/power/qos.o:include/linux/perf_regs.h:55: first defined here kernel/power/hibernate.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value' kernel/power/qos.o:include/linux/perf_regs.h:65: first defined here kernel/power/snapshot.o: In function `perf_get_arch_reg': >> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' kernel/power/qos.o:include/linux/perf_regs.h:60: first defined here kernel/power/snapshot.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' kernel/power/qos.o:include/linux/perf_regs.h:55: first defined here kernel/power/snapshot.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value' kernel/power/qos.o:include/linux/perf_regs.h:65: first defined here kernel/power/user.o: In function `perf_get_arch_reg': >> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' kernel/power/qos.o:include/linux/perf_regs.h:60: first defined here kernel/power/user.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' kernel/power/qos.o:include/linux/perf_regs.h:55: first defined here kernel/power/user.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value' kernel/power/qos.o:include/linux/perf_regs.h:65: first defined here -- kernel/rcu/tree.o: In function `perf_get_arch_reg': >> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' kernel/rcu/update.o:include/linux/perf_regs.h:60: first defined here kernel/rcu/tree.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' kernel/rcu/update.o:include/linux/perf_regs.h:55: first defined here kernel/rcu/tree.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value' kernel/rcu/update.o:include/linux/perf_regs.h:65: first defined here -- kernel/sched/idle.o: In function `perf_get_arch_reg': >> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' kernel/sched/core.o:include/linux/perf_regs.h:60: first defined here kernel/sched/idle.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' kernel/sched/core.o:include/linux/perf_regs.h:55: first defined here kernel/sched/idle.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value' kernel/sched/core.o:include/linux/perf_regs.h:65: first defined here -- kernel/time/timer.o: In function `perf_get_arch_reg': >> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' kernel/time/time.o:include/linux/perf_regs.h:60: first defined here kernel/time/timer.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' kernel/time/time.o:include/linux/perf_regs.h:55: first defined here kernel/time/timer.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value' kernel/time/time.o:include/linux/perf_regs.h:65: first defined here kernel/time/hrtimer.o: In function `perf_get_arch_reg': >> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' kernel/time/time.o:include/linux/perf_regs.h:60: first defined here kernel/time/hrtimer.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' kernel/time/time.o:include/linux/perf_regs.h:55: first defined here kernel/time/hrtimer.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value' kernel/time/time.o:include/linux/perf_regs.h:65: first defined here kernel/time/itimer.o: In function `perf_get_arch_reg': >> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' kernel/time/time.o:include/linux/perf_regs.h:60: first defined here kernel/time/itimer.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' kernel/time/time.o:include/linux/perf_regs.h:55: first defined here kernel/time/itimer.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value' kernel/time/time.o:include/linux/perf_regs.h:65: first defined here kernel/time/posix-timers.o: In function `perf_get_arch_reg': >> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' kernel/time/time.o:include/linux/perf_regs.h:60: first defined here kernel/time/posix-timers.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' kernel/time/time.o:include/linux/perf_regs.h:55: first defined here kernel/time/posix-timers.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value' kernel/time/time.o:include/linux/perf_regs.h:65: first defined here kernel/time/posix-clock.o: In function `perf_get_arch_reg': >> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' kernel/time/time.o:include/linux/perf_regs.h:60: first defined here kernel/time/posix-clock.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' kernel/time/time.o:include/linux/perf_regs.h:55: first defined here kernel/time/posix-clock.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value' kernel/time/time.o:include/linux/perf_regs.h:65: first defined here kernel/time/tick-common.o: In function `perf_get_arch_reg': >> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' kernel/time/time.o:include/linux/perf_regs.h:60: first defined here kernel/time/tick-common.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' kernel/time/time.o:include/linux/perf_regs.h:55: first defined here kernel/time/tick-common.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value' kernel/time/time.o:include/linux/perf_regs.h:65: first defined here -- drivers/s390/scsi/zfcp_ccw.o: In function `perf_get_arch_reg': >> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' drivers/s390/scsi/zfcp_aux.o:include/linux/perf_regs.h:60: first defined here drivers/s390/scsi/zfcp_ccw.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' drivers/s390/scsi/zfcp_aux.o:include/linux/perf_regs.h:55: first defined here drivers/s390/scsi/zfcp_ccw.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value' drivers/s390/scsi/zfcp_aux.o:include/linux/perf_regs.h:65: first defined here drivers/s390/scsi/zfcp_dbf.o: In function `perf_get_arch_reg': >> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' drivers/s390/scsi/zfcp_aux.o:include/linux/perf_regs.h:60: first defined here drivers/s390/scsi/zfcp_dbf.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' drivers/s390/scsi/zfcp_aux.o:include/linux/perf_regs.h:55: first defined here drivers/s390/scsi/zfcp_dbf.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value' drivers/s390/scsi/zfcp_aux.o:include/linux/perf_regs.h:65: first defined here drivers/s390/scsi/zfcp_erp.o: In function `perf_get_arch_reg': >> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' drivers/s390/scsi/zfcp_aux.o:include/linux/perf_regs.h:60: first defined here drivers/s390/scsi/zfcp_erp.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' drivers/s390/scsi/zfcp_aux.o:include/linux/perf_regs.h:55: first defined here drivers/s390/scsi/zfcp_erp.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value' drivers/s390/scsi/zfcp_aux.o:include/linux/perf_regs.h:65: first defined here drivers/s390/scsi/zfcp_fc.o: In function `perf_get_arch_reg': >> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' drivers/s390/scsi/zfcp_aux.o:include/linux/perf_regs.h:60: first defined here drivers/s390/scsi/zfcp_fc.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' drivers/s390/scsi/zfcp_aux.o:include/linux/perf_regs.h:55: first defined here drivers/s390/scsi/zfcp_fc.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value' drivers/s390/scsi/zfcp_aux.o:include/linux/perf_regs.h:65: first defined here drivers/s390/scsi/zfcp_fsf.o: In function `perf_get_arch_reg': >> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' drivers/s390/scsi/zfcp_aux.o:include/linux/perf_regs.h:60: first defined here drivers/s390/scsi/zfcp_fsf.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' drivers/s390/scsi/zfcp_aux.o:include/linux/perf_regs.h:55: first defined here drivers/s390/scsi/zfcp_fsf.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value' drivers/s390/scsi/zfcp_aux.o:include/linux/perf_regs.h:65: first defined here drivers/s390/scsi/zfcp_qdio.o: In function `perf_get_arch_reg': >> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' drivers/s390/scsi/zfcp_aux.o:include/linux/perf_regs.h:60: first defined here drivers/s390/scsi/zfcp_qdio.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' drivers/s390/scsi/zfcp_aux.o:include/linux/perf_regs.h:55: first defined here drivers/s390/scsi/zfcp_qdio.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value' drivers/s390/scsi/zfcp_aux.o:include/linux/perf_regs.h:65: first defined here drivers/s390/scsi/zfcp_scsi.o: In function `perf_get_arch_reg': >> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' drivers/s390/scsi/zfcp_aux.o:include/linux/perf_regs.h:60: first defined here drivers/s390/scsi/zfcp_scsi.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask'
drivers/s390/scsi/zfcp_aux.o:include/linux/perf_regs.h:55: first defined here drivers/s390/scsi/zfcp_scsi.o: In function `perf_arch_reg_value':
--
kernel/trace/ring_buffer.o: In function `perf_get_arch_reg':
>> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' kernel/trace/libftrace.o:include/linux/perf_regs.h:60: first defined here kernel/trace/ring_buffer.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' kernel/trace/libftrace.o:include/linux/perf_regs.h:55: first defined here kernel/trace/ring_buffer.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value' kernel/trace/libftrace.o:include/linux/perf_regs.h:65: first defined here kernel/trace/trace.o: In function `perf_get_arch_reg': >> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' kernel/trace/libftrace.o:include/linux/perf_regs.h:60: first defined here kernel/trace/trace.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' kernel/trace/libftrace.o:include/linux/perf_regs.h:55: first defined here kernel/trace/trace.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value' kernel/trace/libftrace.o:include/linux/perf_regs.h:65: first defined here kernel/trace/trace_output.o: In function `perf_get_arch_reg': >> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' kernel/trace/libftrace.o:include/linux/perf_regs.h:60: first defined here kernel/trace/trace_output.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' kernel/trace/libftrace.o:include/linux/perf_regs.h:55: first defined here kernel/trace/trace_output.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value' kernel/trace/libftrace.o:include/linux/perf_regs.h:65: first defined here kernel/trace/trace_stat.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' kernel/trace/libftrace.o:include/linux/perf_regs.h:55: first defined here kernel/trace/trace_stat.o: In function `perf_get_arch_reg': >> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' kernel/trace/libftrace.o:include/linux/perf_regs.h:60: first defined here kernel/trace/trace_stat.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value' kernel/trace/libftrace.o:include/linux/perf_regs.h:65: first defined here kernel/trace/trace_printk.o: In function `perf_get_arch_reg': >> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' kernel/trace/libftrace.o:include/linux/perf_regs.h:60: first defined here kernel/trace/trace_printk.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' kernel/trace/libftrace.o:include/linux/perf_regs.h:55: first defined here kernel/trace/trace_printk.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value' kernel/trace/libftrace.o:include/linux/perf_regs.h:65: first defined here kernel/trace/trace_sched_switch.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' kernel/trace/libftrace.o:include/linux/perf_regs.h:55: first defined here kernel/trace/trace_sched_switch.o: In function `perf_get_arch_reg': >> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' kernel/trace/libftrace.o:include/linux/perf_regs.h:60: first defined here kernel/trace/trace_sched_switch.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value' kernel/trace/libftrace.o:include/linux/perf_regs.h:65: first defined here kernel/trace/trace_functions.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' kernel/trace/libftrace.o:include/linux/perf_regs.h:55: first defined here kernel/trace/trace_functions.o: In function `perf_get_arch_reg': >> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg'
kernel/trace/libftrace.o:include/linux/perf_regs.h:60: first defined here kernel/trace/trace_functions.o: In function `perf_arch_reg_value':
--
net/core/built-in.o: In function `perf_get_arch_reg':
>> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' net/socket.o:include/linux/perf_regs.h:60: first defined here net/core/built-in.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' net/socket.o:include/linux/perf_regs.h:55: first defined here net/core/built-in.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value' net/socket.o:include/linux/perf_regs.h:65: first defined here net/compat.o: In function `perf_get_arch_reg': >> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' net/socket.o:include/linux/perf_regs.h:60: first defined here net/compat.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' net/socket.o:include/linux/perf_regs.h:55: first defined here net/compat.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value' net/socket.o:include/linux/perf_regs.h:65: first defined here -- drivers/base/power/main.o: In function `perf_get_arch_reg': >> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' drivers/base/power/qos.o:include/linux/perf_regs.h:60: first defined here drivers/base/power/main.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' drivers/base/power/qos.o:include/linux/perf_regs.h:55: first defined here drivers/base/power/main.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value' drivers/base/power/qos.o:include/linux/perf_regs.h:65: first defined here drivers/base/power/wakeup.o: In function `perf_get_arch_reg': >> include/linux/perf_regs.h:60: multiple definition of `perf_get_arch_reg' drivers/base/power/qos.o:include/linux/perf_regs.h:60: first defined here drivers/base/power/wakeup.o: In function `perf_get_arch_regs_mask': >> include/linux/perf_regs.h:55: multiple definition of `perf_get_arch_regs_mask' drivers/base/power/qos.o:include/linux/perf_regs.h:55: first defined here drivers/base/power/wakeup.o: In function `perf_arch_reg_value': >> include/linux/perf_regs.h:65: multiple definition of `perf_arch_reg_value'
drivers/base/power/qos.o:include/linux/perf_regs.h:65: first defined here
..
vim +60 include/linux/perf_regs.h
49 regs_user->abi = perf_reg_abi(current);
50 }
51
52 u64 perf_get_arch_regs_mask(void)
53 {
54 return 0;
> 55 }
56
57 struct perf_arch_regs *perf_get_arch_reg(void)
58 {
59 return 0;
> 60 }
61
62 u64 perf_arch_reg_value(struct perf_arch_regs *regs, int idx)
63 {
64 return 0;
> 65 }
66 #endif /* CONFIG_HAVE_PERF_REGS */
67 #endif /* _LINUX_PERF_REGS_H */---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Quoted 36 lines · Madhavan Srinivasan
Patchset to extend
PERF_SAMPLE_REGS_INTRto include platform specific PMU registers.Patchset applies cleanly on tip:perf/core branch
It's a perennial request from hardware folks to be able to see the raw values of the pmu registers. Partly it's so that they can verify perf is doing what they want, and some of it is that they're interested in some of the more obscure info that isn't plumbed out through other perf interfaces.
Over the years internally we have used various hack to get the requested data out but this is an attempt to use a somewhat standard mechanism (using
PERF_SAMPLE_REGS_INTR).This would also be helpful for those of us working on the perf hardware backends, to be able to verify that we're programming things correctly, without resorting to debug printks etc.
Mechanism proposed:
1)perf_regs structure is extended with a
perf_arch_regsstructure which eacharch/can populate with their specific platform registers to sample on each perf interrupt and anarch_regs_maskvariable, which is for perf tool to know about theperf_arch_regsthat are supported.2)perf/core func
perf_sample_regs_intr()extended to update theperf_arch_regsstructure and theperf_arch_reg_mask. Set of new support functions addedperf_get_arch_regs_mask()andperf_get_arch_reg()to aid the updates fromarch/side.3) perf/core funcs
perf_prepare_sample()andperf_output_sample()are extended to support the update for theperf_arch_regs_maskandperf_arch_regsin the sample
Quoted 7 lines
4)perf/core func
perf_output_sample_regs()extended to dump thearch_regsto the output sample.5)Finally, perf tool side is updated to include a new element "
arch_regs_mask" in the "structregs_dump", event sample funcs and print functions are updated to supportperf_arch_regs.
I read the patch series and I have one suggestion to make. I think we should not use 'arch regs' to refer to these pmu registers. I think architectural registers typically refer to the ones that hold the state of the process. Can we replace arch_regs by pmu_regs, or some other choice?
Thanks
Nilay
Re: [PATCH 04/13] perf/core: Extend perf_output_sample_regs() to include perf_arch_regs
In reply to Madhavan SrinivasanQuoted 50 lines · Madhavan Srinivasan
kernel/events/core.c +12
-5@@ -5371,16 +5371,24 @@ u64 __attribute__((weak)) perf_arch_reg_value(struct perf_arch_regs *regs,static void perf_output_sample_regs (struct perf_output_handle *handle, -struct pt_regs *regs,u64 mask) +struct perf_regs *regs,u64 mask) {int bit;DECLARE_BITMAP (_mask,64 ); +u64 arch_regs_mask = regs->arch_regs_mask;bitmap_from_u64 (_mask, mask);for_each_set_bit (bit, _mask,sizeof (mask) *BITS_PER_BYTE ) {u64 val; - val =perf_reg_value (regs, bit); + val =perf_reg_value (regs->regs, bit); +perf_output_put (handle, val); + } + +bitmap_from_u64 (_mask, arch_regs_mask); +for_each_set_bit (bit, _mask,sizeof (mask) *BITS_PER_BYTE ) { +u64 val; + val =perf_arch_reg_value (regs->arch_regs, bit);perf_output_put (handle, val); } }@@ -5792,7 +5800,7 @@ void perf_output_sample(struct perf_output_handle *handle,if (abi) {u64 mask = event->attr.sample_regs_user;perf_output_sample_regs (handle, - data->regs_user.regs, + &data->regs_user, mask); } }@@ -5827,7 +5835,7 @@ void perf_output_sample(struct perf_output_handle *handle,u64 mask = event->attr.sample_regs_intr;perf_output_sample_regs (handle, - data->regs_intr.regs, + &data->regs_intr, mask); } } --
Quoted 2 lines
2.7.4
I would like to suggest a slightly different version. Would it make more sense to have something like following:
@@ -5792,7 +5800,7 @@ void perf_output_sample(struct perf_output_handle *handle,
if (abi) {
u64 mask = event->attr.sample_regs_user;
perf_output_sample_regs(handle,
data->regs_user.regs,
mask);
}+
+ if (arch_regs_mask) {
+ perf_output_pmu_regs(handle,data->regs_users.arch_regs, arch_regs_mask);
+ }
}
Somehow I don't like outputting the two sets of registers through the same function call.
--
Nilay
Quoted 41 lines · Nilay Vaish
Quoted 39 lines · Madhavan Srinivasan
Patchset to extend
PERF_SAMPLE_REGS_INTRto include platform specific PMU registers.Patchset applies cleanly on tip:perf/core branch
It's a perennial request from hardware folks to be able to see the raw values of the pmu registers. Partly it's so that they can verify perf is doing what they want, and some of it is that they're interested in some of the more obscure info that isn't plumbed out through other perf interfaces.
Over the years internally we have used various hack to get the requested data out but this is an attempt to use a somewhat standard mechanism (using
PERF_SAMPLE_REGS_INTR).This would also be helpful for those of us working on the perf hardware backends, to be able to verify that we're programming things correctly, without resorting to debug printks etc.
Mechanism proposed:
1)perf_regs structure is extended with a
perf_arch_regsstructure which eacharch/can populate with their specific platform registers to sample on each perf interrupt and anarch_regs_maskvariable, which is for perf tool to know about theperf_arch_regsthat are supported.2)perf/core func
perf_sample_regs_intr()extended to update theperf_arch_regsstructure and theperf_arch_reg_mask. Set of new support functions addedperf_get_arch_regs_mask()andperf_get_arch_reg()to aid the updates fromarch/side.3) perf/core funcs
perf_prepare_sample()andperf_output_sample()are extended to support the update for theperf_arch_regs_maskandperf_arch_regsin the sample4)perf/core func
perf_output_sample_regs()extended to dump thearch_regsto the output sample.
Quoted 6 lines
Quoted 4 lines
5)Finally, perf tool side is updated to include a new element "
arch_regs_mask" in the "structregs_dump", event sample funcs and print functions are updated to supportperf_arch_regs.I read the patch series and I have one suggestion to make. I think we should not use 'arch regs' to refer to these pmu registers. I think
Reason is that they are arch specific pmu regs. But I guess we can go with pmu_regs also. And having a "pregs" as option to list in -I? will be fine? (patch 13 in the patch series)
Maddy
Quoted 7 lines
architectural registers typically refer to the ones that hold the state of the process. Can we replace
arch_regsbypmu_regs, or some other choice?Thanks
Nilay
Re: [PATCH 04/13] perf/core: Extend perf_output_sample_regs() to include perf_arch_regs
In reply to Nilay VaishQuoted 45 lines · Nilay Vaish
Quoted 43 lines · Madhavan Srinivasan
kernel/events/core.c +11
-3@@ -5371,16 +5371,24 @@ u64 __attribute__((weak)) perf_arch_reg_value(struct perf_arch_regs *regs,static void perf_output_sample_regs (struct perf_output_handle *handle, -struct pt_regs *regs,u64 mask) +struct perf_regs *regs,u64 mask) {int bit;DECLARE_BITMAP (_mask,64 ); +u64 arch_regs_mask = regs->arch_regs_mask;bitmap_from_u64 (_mask, mask);for_each_set_bit (bit, _mask,sizeof (mask) *BITS_PER_BYTE ) {u64 val; - val =perf_reg_value (regs, bit); + val =perf_reg_value (regs->regs, bit); +perf_output_put (handle, val); + } + +bitmap_from_u64 (_mask, arch_regs_mask); +for_each_set_bit (bit, _mask,sizeof (mask) *BITS_PER_BYTE ) { +u64 val; + val =perf_arch_reg_value (regs->arch_regs, bit);perf_output_put (handle, val); } }@@ -5792,7 +5800,7 @@ void perf_output_sample(struct perf_output_handle *handle,if (abi) {u64 mask = event->attr.sample_regs_user;perf_output_sample_regs (handle, - data->regs_user.regs, + &data->regs_user, mask); } }@@ -5827,7 +5835,7 @@ void perf_output_sample(struct perf_output_handle *handle,u64 mask = event->attr.sample_regs_intr;
Quoted 11 lines
Quoted 9 lines
kernel/events/core.c +1
-2perf_output_sample_regs (handle, - data->regs_intr.regs, + &data->regs_intr, mask); } } --2.7.4
I would like to suggest a slightly different version. Would it make more sense to have something like following:
I agree we are outputting two different structures, but since we use the INTR_REG infrastructure to dump the arch pmu registers, I preferred to extend perf_output_sample_regs. But I guess I can break it up.
Maddy
Quoted 22 lines
kernel/events/core.c +3
-0@@ -5792,7 +5800,7 @@ void perf_output_sample(struct perf_output_handle *handle,if (abi) {u64 mask = event->attr.sample_regs_user;perf_output_sample_regs (handle, data->regs_user.regs, mask); } + +if (arch_regs_mask) { + perf_output_pmu_regs(handle,
data->regs_users.arch_regs,arch_regs_mask);
+ }}Somehow I don't like outputting the two sets of registers through the same function call.
--
Nilay
Peter Zijlstra
maintainerRe: [PATCH 01/13] perf/core: Add perf_arch_regs and mask to perf_regs structure
In reply to Madhavan SrinivasanQuoted 5 lines · Madhavan Srinivasan
It's a perennial request from hardware folks to be able to see the raw values of the pmu registers. Partly it's so that they can verify perf is doing what they want, and some of it is that they're interested in some of the more obscure info that isn't plumbed out through other perf interfaces.
How much and what is that? Can't we try and get interfaces sorted?
Quoted 3 lines
Over the years internally have used various hack to get the requested data out but this is an attempt to use a somewhat standard mechanism (using
PERF_SAMPLE_REGS_INTR).
Not really liking that. It assumes too much and doesn't seem to cover about half the perf use-cases.
It assumes the machine state can be captured by registers (this is false for things like Intel DS/PT, which have state in memory), it might assume <= 64 registers but I didn't look that closely, this too might become somewhat restrictive.
Worse, it doesn't work for !sampling workloads, of which you also very much want to verify programming etc.
Quoted 3 lines
This would also be helpful for those of us working on the perf hardware backends, to be able to verify that we're programming things correctly, without resorting to debug printks etc.
On x86 we can trace the MSR writes. No need to add debug printk()s. We could (and I have on occasion) added tracepoints (well trace_printk) to the Intel DS memory stores to see what was written there.
Tracing is much more flexible for debugging this stuff.
Can't you do something along those lines?
Re: [PATCH 01/13] perf/core: Add perf_arch_regs and mask to perf_regs structure
Quoted 7 lines · Peter Zijlstra
Quoted 5 lines · Madhavan Srinivasan
It's a perennial request from hardware folks to be able to see the raw values of the pmu registers. Partly it's so that they can verify perf is doing what they want, and some of it is that they're interested in some of the more obscure info that isn't plumbed out through other perf interfaces.
How much and what is that? Can't we try and get interfaces sorted?
We have bunch of registers which exports information regarding the sampled instruction like SIER/SIAR/SDAR/MMCRA. Lot of bits in these registers are not yet architected and incase of SIER register, some of the bits are not plumbed out and we are working on getting some these exposed via perf.
Quoted 7 lines
Quoted 4 lines
Over the years internally have used various hack to get the requested data out but this is an attempt to use a somewhat standard mechanism (using
PERF_SAMPLE_REGS_INTR).Not really liking that. It assumes too much and doesn't seem to cover about half the perf use-cases.
Quoted 7 lines
It assumes the machine state can be captured by registers (this is false for things like Intel DS/PT, which have state in memory), it might assume <= 64 registers but I didn't look that closely, this too might become somewhat restrictive.
Worse, it doesn't work for !sampling workloads, of which you also very much want to verify programming etc.
Yes, I agree, my bad. I did assume and implemented considering pmu registers primarily, but we can extend with additional flags on the content being copied. Good point that patchset not handling !sampling case. Let me explore on this and also the tracing options.
Thanks for the comments.
Maddy
Quoted 12 lines
Quoted 4 lines
This would also be helpful for those of us working on the perf hardware backends, to be able to verify that we're programming things correctly, without resorting to debug printks etc.
On x86 we can trace the MSR writes. No need to add debug printk()s. We could (and I have on occasion) added tracepoints (well
trace_printk) to the Intel DS memory stores to see what was written there.Tracing is much more flexible for debugging this stuff.
Can't you do something along those lines?
Peter Zijlstra
maintainerRe: [PATCH 01/13] perf/core: Add perf_arch_regs and mask to perf_regs structure
Quoted 9 lines · Madhavan Srinivasan
Quoted 6 lines · Peter Zijlstra
Quoted 5 lines · Madhavan Srinivasan
It's a perennial request from hardware folks to be able to see the raw values of the pmu registers. Partly it's so that they can verify perf is doing what they want, and some of it is that they're interested in some of the more obscure info that isn't plumbed out through other perf interfaces.
Quoted 7 lines
Quoted 1 line
How much and what is that? Can't we try and get interfaces sorted?
We have bunch of registers which exports information regarding the sampled instruction like SIER/SIAR/SDAR/MMCRA. Lot of bits in these registers are not yet architected and incase of SIER register, some of the bits are not plumbed out and we are working on getting some these exposed via perf.
What kind of information is this? I'm not familiar with the Power PMU all that much, so you'll have to spell it out, not just mention the registers its stuffed in.
Re: [PATCH 01/13] perf/core: Add perf_arch_regs and mask to perf_regs structure
Quoted 10 lines · Peter Zijlstra
Quoted 9 lines · Madhavan Srinivasan
Quoted 7 lines · Peter Zijlstra
Quoted 5 lines · Madhavan Srinivasan
It's a perennial request from hardware folks to be able to see the raw values of the pmu registers. Partly it's so that they can verify perf is doing what they want, and some of it is that they're interested in some of the more obscure info that isn't plumbed out through other perf interfaces.
How much and what is that? Can't we try and get interfaces sorted?
Quoted 8 lines
Quoted 5 lines
We have bunch of registers which exports information regarding the sampled instruction like SIER/SIAR/SDAR/MMCRA. Lot of bits in these registers are not yet architected and incase of SIER register, some of the bits are not plumbed out and we are working on getting some these exposed via perf.
What kind of information is this? I'm not familiar with the Power PMU all that much, so you'll have to spell it out, not just mention the registers its stuffed in.
Sure. When we profile for sample events,
SIER (Sampled Instruction Event Register) provides additional information about the sampled event when PMI occurred.
SIER [41:42] indicates whether the SIAR(Sampled instruction address registers) and SDAR (Sampled data address register) are valid for the sampled event.
SIER [46:48] indicates the type of intructions,
001 Load Instruction
010 Store instruction
011 Branch Instruction
100 Floating Point Instruction other than a Load or Store instruction 101 Fixed Point Instruction other than a Load or Store instruction 110 Condition Register or System Call Instruction
SIER[49:51] gives information on the source of the sampled instruction like instruction came from primary, secondary, tertiary cache or beyond.
SIER[52:55] provide information on branch type instructions Like mispredict and cause of it.
SIER[56:59] provides information on translation and also source of translation like TLB, secondary cache, tertiary or beyond
SIER[60:62] provides the interesting data on the storage access like L1/l2/L3... so on.
Most of these could be plumbed out through standard mechanisms and it's all the other bits that are more interesting, but these are not architected and not public.
Like wise, MMCRA (Monitor Mode Control Register A) is a configuration register for sampling and thresholding events. Provide data on various event configuration information.
Link to the PowerISA v2.07 and Chapters 9 describes in detail on these registers.
https://www.power.org/wp-content/uploads/2013/05/PowerISA_V2.07_PUBLIC.pdf
Maddy