Skip to contentSkip to conversation

perf/powerpc: Add ability to sample intr machine state in powerpc

PATCH Applied Anju T 4 participants 17 messages Feb 20, 2016 – Apr 21, 2016

Subsystems (2)
lore
Share & tools
lore

Anju T

author
#0 lore raw

v11 cover perf/powerpc: Add ability to sample intr machine state in powerpc

This short patch series adds the ability to sample the interrupted machine state for each hardware sample.

To test this patchset,
Eg:

$ perf record -I?       # list supported registers

output:
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

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 -I ls   # record machine state at interrupt
$ perf script -D      # read the perf.data file

Sample output obtained for this patchset/ output looks like as follows:

496768515470 0x1988 [0x188]: PERF_RECORD_SAMPLE(IP, 0x1): 4522/4522: 0xc0000000001e538c period: 1 addr: 0 ... intr regs: mask 0x7ffffffffff ABI 64-bit

.... r0    0xc0000000001e5e34
.... r1    0xc000000fe733f9a0
.... r2    0xc000000001523100
.... r3    0xc000000ffaadeb60
.... r4    0xc000000003456800
.... r5    0x73a9b5e000
.... r6    0x1e000000
.... r7    0x0
.... r8    0x0
.... r9    0x0
.... r10   0x1
.... r11   0x0
.... r12   0x24022822
.... r13   0xc00000000feec180
.... r14   0x0
.... r15   0xc000001e4be18800
.... r16   0x0
.... r17   0xc000000ffaac5000
.... r18   0xc000000fe733f8a0
.... r19   0xc000000001523100
.... r20   0xc00000000009fd1c
.... r21   0xc000000fcaa69000
.... r22   0xc0000000001e4968
.... r23   0xc000000001523100
.... r24   0xc000000fe733f850
.... r25   0xc000000fcaa69000
.... r26   0xc000000003b8fcf0
.... r27   0xfffffffffffffead
.... r28   0x0
.... r29   0xc000000fcaa69000
.... r30   0x1
.... r31   0x0
.... nip   0xc0000000001dd320
.... msr   0x9000000000009032
.... orig_r3 0xc0000000001e538c
.... ctr   0xc00000000009d550
.... link  0xc0000000001e5e34
.... xer   0x0
.... ccr   0x84022882

.... softe 0x0
.... trap 0xf01
.... dar 0x0
.... dsisr 0xf00040060000004
... thread: :4522:4522
...... dso: /root/.debug/.build-id/b0/ef11b1a1629e62ac9de75199117ee5ef9469e9

           :4522  4522   496.768515:          1 cycles:  c0000000001e538c .perf_event_context_sched_in (/boot/vmlinux)

Changes from v10:

- Included SOFTE as suggested by mpe
- The name of registers displayed is changed from gpr* to r* also the macro names changed from PERF_REG_POWERPC_GPR* to PERF_REG_POWERPC_R*.
- The conflict in returning the ABI is resolved.
- #define PERF_REG_SP is again changed to PERF_REG_POWERPC_R1
- Comment in tools/perf/config/Makefile is updated.
- removed the "Reviewed-By" tag as the patch has logic changes.

Changes from V9:

- Changed the name displayed for link register from "lnk" to "link" in tools/perf/arch/powerpc/include/perf_regs.h

changes from V8:

- Corrected the indentation issue in the Makefile mentioned in 3rd patch

Changes from V7:

- Addressed the new line issue in 3rd patch.

Changes from V6:

- Corrected the typo in patch tools/perf: Map the ID values with register names.
ie #define PERF_REG_SP PERF_REG_POWERPC_R1 should be #define PERF_REG_SP PERF_REG_POWERPC_GPR1

Changes from V5:

- Enabled perf_sample_regs_user also in this patch set.Functions added in arch/powerpc/perf/perf_regs.c
- Added Maddy's patch to this patchset for enabling -I? option which will list the supported register names.

Changes from V4:

- Removed the softe and MQ from all patches
- Switch case is replaced with an array in the 3rd patch

Changes from V3:

- Addressed the comments by Sukadev regarding the nits in the descriptions.
- Modified the subject of first patch.
- Included the sample output in the 3rd patch also.

Changes from V2:

- tools/perf/config/Makefile is moved to the patch tools/perf.
- The patchset is reordered.
- perf_regs_load() function is used for the dwarf unwind test.Since it is not required here, it is removed from tools/perf/arch/powerpc/include/perf_regs.h
- PERF_REGS_POWERPC_RESULT is removed.

Changes from V1:

- Solved the name missmatch issue in the from and signed-off field of the patch series.
- Added necessary comments in the 3rd patch ie perf/powerpc ,as suggested by Maddy.

Anju T (3):
perf/powerpc: assign an id to each powerpc register perf/powerpc: add support for sampling intr machine state tools/perf: Map the ID values with register names

Madhavan Srinivasan (1):
tool/perf: Add sample_reg_mask to include all perf_regs regs

 arch/powerpc/Kconfig                        |  1 +
 arch/powerpc/include/uapi/asm/perf_regs.h   | 50 ++++++++++++++++
 arch/powerpc/perf/Makefile                  |  1 +
 arch/powerpc/perf/perf_regs.c               | 91 +++++++++++++++++++++++++++++
 tools/perf/arch/powerpc/include/perf_regs.h | 69 ++++++++++++++++++++++
 tools/perf/arch/powerpc/util/Build          |  1 +
 tools/perf/arch/powerpc/util/perf_regs.c    | 49 ++++++++++++++++
 tools/perf/config/Makefile                  |  5 ++
 8 files changed, 267 insertions(+)
 create mode 100644 arch/powerpc/include/uapi/asm/perf_regs.h
 create mode 100644 arch/powerpc/perf/perf_regs.c
 create mode 100644 tools/perf/arch/powerpc/include/perf_regs.h
 create mode 100644 tools/perf/arch/powerpc/util/perf_regs.c
Signature · 1 line
2.1.0
author
#1 lore raw

PATCH v11 1/4 perf/powerpc: assign an id to each powerpc register

The enum definition assigns an 'id' to each register in "struct pt_regs" of arch/powerpc. The order of these values in the enum definition are based on the corresponding macros in arch/powerpc/include/uapi/asm/ptrace.h.

---
 arch/powerpc/include/uapi/asm/perf_regs.h | 50 +++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 arch/powerpc/include/uapi/asm/perf_regs.h
arch/powerpc/include/uapi/asm/perf_regs.h new file +50 -0
new file mode 100644
index 0000000..62b8a5e
@@ -0,0 +1,50 @@
+#ifndef _ASM_POWERPC_PERF_REGS_H
+#define _ASM_POWERPC_PERF_REGS_H
+
+enum perf_event_powerpc_regs {
+	PERF_REG_POWERPC_R0,
+	PERF_REG_POWERPC_R1,
+	PERF_REG_POWERPC_R2,
+	PERF_REG_POWERPC_R3,
+	PERF_REG_POWERPC_R4,
+	PERF_REG_POWERPC_R5,
+	PERF_REG_POWERPC_R6,
+	PERF_REG_POWERPC_R7,
+	PERF_REG_POWERPC_R8,
+	PERF_REG_POWERPC_R9,
+	PERF_REG_POWERPC_R10,
+	PERF_REG_POWERPC_R11,
+	PERF_REG_POWERPC_R12,
+	PERF_REG_POWERPC_R13,
+	PERF_REG_POWERPC_R14,
+	PERF_REG_POWERPC_R15,
+	PERF_REG_POWERPC_R16,
+	PERF_REG_POWERPC_R17,
+	PERF_REG_POWERPC_R18,
+	PERF_REG_POWERPC_R19,
+	PERF_REG_POWERPC_R20,
+	PERF_REG_POWERPC_R21,
+	PERF_REG_POWERPC_R22,
+	PERF_REG_POWERPC_R23,
+	PERF_REG_POWERPC_R24,
+	PERF_REG_POWERPC_R25,
+	PERF_REG_POWERPC_R26,
+	PERF_REG_POWERPC_R27,
+	PERF_REG_POWERPC_R28,
+	PERF_REG_POWERPC_R29,
+	PERF_REG_POWERPC_R30,
+	PERF_REG_POWERPC_R31,
+	PERF_REG_POWERPC_NIP,
+	PERF_REG_POWERPC_MSR,
+	PERF_REG_POWERPC_ORIG_R3,
+	PERF_REG_POWERPC_CTR,
+	PERF_REG_POWERPC_LNK,
+	PERF_REG_POWERPC_XER,
+	PERF_REG_POWERPC_CCR,
+	PERF_REG_POWERPC_SOFTE,
+	PERF_REG_POWERPC_TRAP,
+	PERF_REG_POWERPC_DAR,
+	PERF_REG_POWERPC_DSISR,
+	PERF_REG_POWERPC_MAX,
+};
+#endif /* _ASM_POWERPC_PERF_REGS_H */
Signature · 1 line
2.1.0
author
#4 lore raw

PATCH v11 2/4 perf/powerpc: add support for sampling intr machine state

In reply to Anju T

The perf infrastructure uses a bit mask to find out valid registers to display. Define a register mask for supported registers defined in asm/perf_regs.h. The bit positions also correspond to register IDs which is used by perf infrastructure to fetch the register values. CONFIG_HAVE_PERF_REGS enables sampling of the interrupted machine state.

---
 arch/powerpc/Kconfig          |  1 +
 arch/powerpc/perf/Makefile    |  1 +
 arch/powerpc/perf/perf_regs.c | 91 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 93 insertions(+)
 create mode 100644 arch/powerpc/perf/perf_regs.c
arch/powerpc/Kconfig +1 -0
index 9a7057e..c4ce60d 100644
@@ -119,6 +119,7 @@ config PPC
 	select GENERIC_ATOMIC64 if PPC32
 	select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
 	select HAVE_PERF_EVENTS
+	select HAVE_PERF_REGS
 	select HAVE_REGS_AND_STACK_ACCESS_API
 	select HAVE_HW_BREAKPOINT if PERF_EVENTS && PPC_BOOK3S_64
 	select ARCH_WANT_IPC_PARSE_VERSION
arch/powerpc/perf/Makefile +1 -0
index f9c083a..2f2d3d2 100644
@@ -8,6 +8,7 @@ obj64-$(CONFIG_PPC_PERF_CTRS)	+= power4-pmu.o ppc970-pmu.o power5-pmu.o \
 				   power8-pmu.o
 obj32-$(CONFIG_PPC_PERF_CTRS)	+= mpc7450-pmu.o
 
+obj-$(CONFIG_PERF_EVENTS)	+= perf_regs.o
 obj-$(CONFIG_FSL_EMB_PERF_EVENT) += core-fsl-emb.o
 obj-$(CONFIG_FSL_EMB_PERF_EVENT_E500) += e500-pmu.o e6500-pmu.o
 
arch/powerpc/perf/perf_regs.c new file +91 -0

91 lines not on this page · raw message

Signature · 1 line
2.1.0
author
#7 lore raw

PATCH v11 3/4 tools/perf: Map the ID values with register names

In reply to Anju T

Map ID values with corresponding register names. These names are then displayed when user issues perf record with the -I option followed by perf report/script with -D option.

To test this patchset,
Eg:

$ perf record -I ls   # record machine state at interrupt
$ perf script -D      # read the perf.data file

Sample output obtained for this patch / output looks like as follows:

496768515470 0x1988 [0x188]: PERF_RECORD_SAMPLE(IP, 0x1): 4522/4522: 0xc0000000001e538c period: 1 addr: 0 ... intr regs: mask 0x7ffffffffff ABI 64-bit

.... r0    0xc0000000001e5e34
.... r1    0xc000000fe733f9a0
.... r2    0xc000000001523100
.... r3    0xc000000ffaadeb60
.... r4    0xc000000003456800
.... r5    0x73a9b5e000
.... r6    0x1e000000
.... r7    0x0
.... r8    0x0
.... r9    0x0
.... r10   0x1
.... r11   0x0
.... r12   0x24022822
.... r13   0xc00000000feec180
.... r14   0x0
.... r15   0xc000001e4be18800
.... r16   0x0
.... r17   0xc000000ffaac5000
.... r18   0xc000000fe733f8a0
.... r19   0xc000000001523100
.... r20   0xc00000000009fd1c
.... r21   0xc000000fcaa69000
.... r22   0xc0000000001e4968
.... r23   0xc000000001523100
.... r24   0xc000000fe733f850
.... r25   0xc000000fcaa69000
.... r26   0xc000000003b8fcf0
.... r27   0xfffffffffffffead
.... r28   0x0
.... r29   0xc000000fcaa69000
.... r30   0x1
.... r31   0x0
.... nip   0xc0000000001dd320
.... msr   0x9000000000009032
.... orig_r3 0xc0000000001e538c
.... ctr   0xc00000000009d550
.... link  0xc0000000001e5e34
.... xer   0x0
.... ccr   0x84022882

.... softe 0x0
.... trap 0xf01
.... dar 0x0
.... dsisr 0xf00040060000004
... thread: :4522:4522
...... dso: /root/.debug/.build-id/b0/ef11b1a1629e62ac9de75199117ee5ef9469e9

           :4522  4522   496.768515:          1 cycles:  c0000000001e538c .perf_event_context_sched_in (/boot/vmlinux)
---
 tools/perf/arch/powerpc/include/perf_regs.h | 69 +++++++++++++++++++++++++++++
 tools/perf/config/Makefile                  |  5 +++
 2 files changed, 74 insertions(+)
 create mode 100644 tools/perf/arch/powerpc/include/perf_regs.h
tools/perf/arch/powerpc/include/perf_regs.h new file +69 -0
new file mode 100644
index 0000000..0b77a93
@@ -0,0 +1,69 @@
+#ifndef ARCH_PERF_REGS_H
+#define ARCH_PERF_REGS_H
+
+#include <stdlib.h>
+#include <linux/types.h>
+#include <asm/perf_regs.h>
+
+#define PERF_REGS_MASK  ((1ULL << PERF_REG_POWERPC_MAX) - 1)
+#define PERF_REGS_MAX   PERF_REG_POWERPC_MAX
+#ifdef __powerpc64__
+	#define PERF_SAMPLE_REGS_ABI	PERF_SAMPLE_REGS_ABI_64
+#else
+	#define PERF_SAMPLE_REGS_ABI	PERF_SAMPLE_REGS_ABI_32
+#endif
+
+#define PERF_REG_IP     PERF_REG_POWERPC_NIP
+#define PERF_REG_SP     PERF_REG_POWERPC_R1
+
+static const char *reg_names[] = {
+	[PERF_REG_POWERPC_R0] = "r0",
+	[PERF_REG_POWERPC_R1] = "r1",
+	[PERF_REG_POWERPC_R2] = "r2",
+	[PERF_REG_POWERPC_R3] = "r3",
+	[PERF_REG_POWERPC_R4] = "r4",
+	[PERF_REG_POWERPC_R5] = "r5",
+	[PERF_REG_POWERPC_R6] = "r6",
+	[PERF_REG_POWERPC_R7] = "r7",
+	[PERF_REG_POWERPC_R8] = "r8",
+	[PERF_REG_POWERPC_R9] = "r9",
+	[PERF_REG_POWERPC_R10] = "r10",
+	[PERF_REG_POWERPC_R11] = "r11",
+	[PERF_REG_POWERPC_R12] = "r12",
+	[PERF_REG_POWERPC_R13] = "r13",
+	[PERF_REG_POWERPC_R14] = "r14",
+	[PERF_REG_POWERPC_R15] = "r15",
+	[PERF_REG_POWERPC_R16] = "r16",
+	[PERF_REG_POWERPC_R17] = "r17",
+	[PERF_REG_POWERPC_R18] = "r18",
+	[PERF_REG_POWERPC_R19] = "r19",
+	[PERF_REG_POWERPC_R20] = "r20",
+	[PERF_REG_POWERPC_R21] = "r21",
+	[PERF_REG_POWERPC_R22] = "r22",
+	[PERF_REG_POWERPC_R23] = "r23",
+	[PERF_REG_POWERPC_R24] = "r24",
+	[PERF_REG_POWERPC_R25] = "r25",
+	[PERF_REG_POWERPC_R26] = "r26",
+	[PERF_REG_POWERPC_R27] = "r27",
+	[PERF_REG_POWERPC_R28] = "r28",
+	[PERF_REG_POWERPC_R29] = "r29",
+	[PERF_REG_POWERPC_R30] = "r30",
+	[PERF_REG_POWERPC_R31] = "r31",
+	[PERF_REG_POWERPC_NIP] = "nip",
+	[PERF_REG_POWERPC_MSR] = "msr",
+	[PERF_REG_POWERPC_ORIG_R3] = "orig_r3",
+	[PERF_REG_POWERPC_CTR] = "ctr",
+	[PERF_REG_POWERPC_LNK] = "link",
+	[PERF_REG_POWERPC_XER] = "xer",
+	[PERF_REG_POWERPC_CCR] = "ccr",
+	[PERF_REG_POWERPC_SOFTE] = "softe",
+	[PERF_REG_POWERPC_TRAP] = "trap",
+	[PERF_REG_POWERPC_DAR] = "dar",
+	[PERF_REG_POWERPC_DSISR] = "dsisr"
+};
+
+static inline const char *perf_reg_name(int id)
+{
+	return reg_names[id];
+}
+#endif /* ARCH_PERF_REGS_H */
tools/perf/config/Makefile +5 -0
index 38a0853..2de6bd4 100644
@@ -23,6 +23,11 @@ $(call detected_var,ARCH)
 
 NO_PERF_REGS := 1
 
+# Additional ARCH settings for ppc
+ifeq ($(ARCH),powerpc)
+  NO_PERF_REGS := 0
+endif
+
 # Additional ARCH settings for x86
 ifeq ($(ARCH),x86)
   $(call detected,CONFIG_X86)
Signature · 1 line
2.1.0
author
#9 lore raw

PATCH v2 4/4 tool/perf: Add sample_reg_mask to include all perf_regs

In reply to Anju T

From: Madhavan Srinivasan <[email protected]>

Add sample_reg_mask array with pt_regs registers. This is needed for printing supported regs ( -I? option).

---
 tools/perf/arch/powerpc/util/Build       |  1 +
 tools/perf/arch/powerpc/util/perf_regs.c | 49 ++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+)
 create mode 100644 tools/perf/arch/powerpc/util/perf_regs.c
tools/perf/arch/powerpc/util/Build +1 -0
index 7b8b0d1..3deb1bc 100644
@@ -1,5 +1,6 @@
 libperf-y += header.o
 libperf-y += sym-handling.o
+libperf-y += perf_regs.o
 
 libperf-$(CONFIG_DWARF) += dwarf-regs.o
 libperf-$(CONFIG_DWARF) += skip-callchain-idx.o
tools/perf/arch/powerpc/util/perf_regs.c new file +49 -0

49 lines not on this page · raw message

Signature · 1 line
2.1.0
author
#11 lore raw
In reply to Anju T

Hi,

Any updates on this?

Quoted 157 lines · Anju T

This short patch series adds the ability to sample the interrupted machine state for each hardware sample.

To test this patchset,
Eg:

$ perf record -I?       # list supported registers

output:
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

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 -I ls   # record machine state at interrupt
$ perf script -D      # read the perf.data file

Sample output obtained for this patchset/ output looks like as follows:

496768515470 0x1988 [0x188]: PERF_RECORD_SAMPLE(IP, 0x1): 4522/4522: 0xc0000000001e538c period: 1 addr: 0 ... intr regs: mask 0x7ffffffffff ABI 64-bit

.... r0    0xc0000000001e5e34
.... r1    0xc000000fe733f9a0
.... r2    0xc000000001523100
.... r3    0xc000000ffaadeb60
.... r4    0xc000000003456800
.... r5    0x73a9b5e000
.... r6    0x1e000000
.... r7    0x0
.... r8    0x0
.... r9    0x0
.... r10   0x1
.... r11   0x0
.... r12   0x24022822
.... r13   0xc00000000feec180
.... r14   0x0
.... r15   0xc000001e4be18800
.... r16   0x0
.... r17   0xc000000ffaac5000
.... r18   0xc000000fe733f8a0
.... r19   0xc000000001523100
.... r20   0xc00000000009fd1c
.... r21   0xc000000fcaa69000
.... r22   0xc0000000001e4968
.... r23   0xc000000001523100
.... r24   0xc000000fe733f850
.... r25   0xc000000fcaa69000
.... r26   0xc000000003b8fcf0
.... r27   0xfffffffffffffead
.... r28   0x0
.... r29   0xc000000fcaa69000
.... r30   0x1
.... r31   0x0
.... nip   0xc0000000001dd320
.... msr   0x9000000000009032
.... orig_r3 0xc0000000001e538c
.... ctr   0xc00000000009d550
.... link  0xc0000000001e5e34
.... xer   0x0
.... ccr   0x84022882

.... softe 0x0
.... trap 0xf01
.... dar 0x0
.... dsisr 0xf00040060000004
... thread: :4522:4522
...... dso: /root/.debug/.build-id/b0/ef11b1a1629e62ac9de75199117ee5ef9469e9

            :4522  4522   496.768515:          1 cycles:  c0000000001e538c .perf_event_context_sched_in (/boot/vmlinux)

Changes from v10:

- Included SOFTE as suggested by mpe
- The name of registers displayed is changed from gpr* to r* also the macro names changed from PERF_REG_POWERPC_GPR* to PERF_REG_POWERPC_R*.
- The conflict in returning the ABI is resolved.
- #define PERF_REG_SP is again changed to PERF_REG_POWERPC_R1
- Comment in tools/perf/config/Makefile is updated.
- removed the "Reviewed-By" tag as the patch has logic changes.

Changes from V9:

- Changed the name displayed for link register from "lnk" to "link" in tools/perf/arch/powerpc/include/perf_regs.h

changes from V8:

- Corrected the indentation issue in the Makefile mentioned in 3rd patch

Changes from V7:

- Addressed the new line issue in 3rd patch.

Changes from V6:

- Corrected the typo in patch tools/perf: Map the ID values with register names.
ie #define PERF_REG_SP PERF_REG_POWERPC_R1 should be #define PERF_REG_SP PERF_REG_POWERPC_GPR1

Changes from V5:

- Enabled perf_sample_regs_user also in this patch set.Functions added in arch/powerpc/perf/perf_regs.c
- Added Maddy's patch to this patchset for enabling -I? option which will list the supported register names.

Changes from V4:

- Removed the softe and MQ from all patches
- Switch case is replaced with an array in the 3rd patch

Changes from V3:

- Addressed the comments by Sukadev regarding the nits in the descriptions.
- Modified the subject of first patch.
- Included the sample output in the 3rd patch also.

Changes from V2:

- tools/perf/config/Makefile is moved to the patch tools/perf.
- The patchset is reordered.
- perf_regs_load() function is used for the dwarf unwind test.Since it is not required here, it is removed from tools/perf/arch/powerpc/include/perf_regs.h
- PERF_REGS_POWERPC_RESULT is removed.

Changes from V1:

- Solved the name missmatch issue in the from and signed-off field of the patch series.
- Added necessary comments in the 3rd patch ie perf/powerpc ,as suggested by Maddy.

Anju T (3):
perf/powerpc: assign an id to each powerpc register perf/powerpc: add support for sampling intr machine state tools/perf: Map the ID values with register names

Madhavan Srinivasan (1):
tool/perf: Add sample_reg_mask to include all perf_regs regs

  arch/powerpc/Kconfig                        |  1 +
  arch/powerpc/include/uapi/asm/perf_regs.h   | 50 ++++++++++++++++
  arch/powerpc/perf/Makefile                  |  1 +
  arch/powerpc/perf/perf_regs.c               | 91 +++++++++++++++++++++++++++++
  tools/perf/arch/powerpc/include/perf_regs.h | 69 ++++++++++++++++++++++
  tools/perf/arch/powerpc/util/Build          |  1 +
  tools/perf/arch/powerpc/util/perf_regs.c    | 49 ++++++++++++++++
  tools/perf/config/Makefile                  |  5 ++
  8 files changed, 267 insertions(+)
Quoted 5 lines

create mode 100644 arch/powerpc/include/uapi/asm/perf_regs.h create mode 100644 arch/powerpc/perf/perf_regs.c create mode 100644 tools/perf/arch/powerpc/include/perf_regs.h create mode 100644 tools/perf/arch/powerpc/util/perf_regs.c

Thanks
Anju

author
#12 lore raw
In reply to Anju T
Quoted 157 lines · Anju T

This short patch series adds the ability to sample the interrupted machine state for each hardware sample.

To test this patchset,
Eg:

$ perf record -I?       # list supported registers

output:
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

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 -I ls   # record machine state at interrupt
$ perf script -D      # read the perf.data file

Sample output obtained for this patchset/ output looks like as follows:

496768515470 0x1988 [0x188]: PERF_RECORD_SAMPLE(IP, 0x1): 4522/4522: 0xc0000000001e538c period: 1 addr: 0 ... intr regs: mask 0x7ffffffffff ABI 64-bit

.... r0    0xc0000000001e5e34
.... r1    0xc000000fe733f9a0
.... r2    0xc000000001523100
.... r3    0xc000000ffaadeb60
.... r4    0xc000000003456800
.... r5    0x73a9b5e000
.... r6    0x1e000000
.... r7    0x0
.... r8    0x0
.... r9    0x0
.... r10   0x1
.... r11   0x0
.... r12   0x24022822
.... r13   0xc00000000feec180
.... r14   0x0
.... r15   0xc000001e4be18800
.... r16   0x0
.... r17   0xc000000ffaac5000
.... r18   0xc000000fe733f8a0
.... r19   0xc000000001523100
.... r20   0xc00000000009fd1c
.... r21   0xc000000fcaa69000
.... r22   0xc0000000001e4968
.... r23   0xc000000001523100
.... r24   0xc000000fe733f850
.... r25   0xc000000fcaa69000
.... r26   0xc000000003b8fcf0
.... r27   0xfffffffffffffead
.... r28   0x0
.... r29   0xc000000fcaa69000
.... r30   0x1
.... r31   0x0
.... nip   0xc0000000001dd320
.... msr   0x9000000000009032
.... orig_r3 0xc0000000001e538c
.... ctr   0xc00000000009d550
.... link  0xc0000000001e5e34
.... xer   0x0
.... ccr   0x84022882

.... softe 0x0
.... trap 0xf01
.... dar 0x0
.... dsisr 0xf00040060000004
... thread: :4522:4522
...... dso: /root/.debug/.build-id/b0/ef11b1a1629e62ac9de75199117ee5ef9469e9

            :4522  4522   496.768515:          1 cycles:  c0000000001e538c .perf_event_context_sched_in (/boot/vmlinux)

Changes from v10:

- Included SOFTE as suggested by mpe
- The name of registers displayed is changed from gpr* to r* also the macro names changed from PERF_REG_POWERPC_GPR* to PERF_REG_POWERPC_R*.
- The conflict in returning the ABI is resolved.
- #define PERF_REG_SP is again changed to PERF_REG_POWERPC_R1
- Comment in tools/perf/config/Makefile is updated.
- removed the "Reviewed-By" tag as the patch has logic changes.

Changes from V9:

- Changed the name displayed for link register from "lnk" to "link" in tools/perf/arch/powerpc/include/perf_regs.h

changes from V8:

- Corrected the indentation issue in the Makefile mentioned in 3rd patch

Changes from V7:

- Addressed the new line issue in 3rd patch.

Changes from V6:

- Corrected the typo in patch tools/perf: Map the ID values with register names.
ie #define PERF_REG_SP PERF_REG_POWERPC_R1 should be #define PERF_REG_SP PERF_REG_POWERPC_GPR1

Changes from V5:

- Enabled perf_sample_regs_user also in this patch set.Functions added in arch/powerpc/perf/perf_regs.c
- Added Maddy's patch to this patchset for enabling -I? option which will list the supported register names.

Changes from V4:

- Removed the softe and MQ from all patches
- Switch case is replaced with an array in the 3rd patch

Changes from V3:

- Addressed the comments by Sukadev regarding the nits in the descriptions.
- Modified the subject of first patch.
- Included the sample output in the 3rd patch also.

Changes from V2:

- tools/perf/config/Makefile is moved to the patch tools/perf.
- The patchset is reordered.
- perf_regs_load() function is used for the dwarf unwind test.Since it is not required here, it is removed from tools/perf/arch/powerpc/include/perf_regs.h
- PERF_REGS_POWERPC_RESULT is removed.

Changes from V1:

- Solved the name missmatch issue in the from and signed-off field of the patch series.
- Added necessary comments in the 3rd patch ie perf/powerpc ,as suggested by Maddy.

Anju T (3):
perf/powerpc: assign an id to each powerpc register perf/powerpc: add support for sampling intr machine state tools/perf: Map the ID values with register names

Madhavan Srinivasan (1):
tool/perf: Add sample_reg_mask to include all perf_regs regs

  arch/powerpc/Kconfig                        |  1 +
  arch/powerpc/include/uapi/asm/perf_regs.h   | 50 ++++++++++++++++
  arch/powerpc/perf/Makefile                  |  1 +
  arch/powerpc/perf/perf_regs.c               | 91 +++++++++++++++++++++++++++++
  tools/perf/arch/powerpc/include/perf_regs.h | 69 ++++++++++++++++++++++
  tools/perf/arch/powerpc/util/Build          |  1 +
  tools/perf/arch/powerpc/util/perf_regs.c    | 49 ++++++++++++++++
  tools/perf/config/Makefile                  |  5 ++
  8 files changed, 267 insertions(+)
Quoted 5 lines

create mode 100644 arch/powerpc/include/uapi/asm/perf_regs.h create mode 100644 arch/powerpc/perf/perf_regs.c create mode 100644 tools/perf/arch/powerpc/include/perf_regs.h create mode 100644 tools/perf/arch/powerpc/util/perf_regs.c

Hi,

Can this be taken into the next tree?

Thanks
Anju.

#13 lore raw

Em Mon, Apr 18, 2016 at 03:17:11PM +0530, Anju T escreveu:

Quoted 164 lines · Anju T
Quoted 148 lines

This short patch series adds the ability to sample the interrupted machine state for each hardware sample.

To test this patchset,
Eg:

$ perf record -I?       # list supported registers

output:
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

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 -I ls   # record machine state at interrupt
$ perf script -D      # read the perf.data file

Sample output obtained for this patchset/ output looks like as follows:

496768515470 0x1988 [0x188]: PERF_RECORD_SAMPLE(IP, 0x1): 4522/4522: 0xc0000000001e538c period: 1 addr: 0 ... intr regs: mask 0x7ffffffffff ABI 64-bit

.... r0    0xc0000000001e5e34
.... r1    0xc000000fe733f9a0
.... r2    0xc000000001523100
.... r3    0xc000000ffaadeb60
.... r4    0xc000000003456800
.... r5    0x73a9b5e000
.... r6    0x1e000000
.... r7    0x0
.... r8    0x0
.... r9    0x0
.... r10   0x1
.... r11   0x0
.... r12   0x24022822
.... r13   0xc00000000feec180
.... r14   0x0
.... r15   0xc000001e4be18800
.... r16   0x0
.... r17   0xc000000ffaac5000
.... r18   0xc000000fe733f8a0
.... r19   0xc000000001523100
.... r20   0xc00000000009fd1c
.... r21   0xc000000fcaa69000
.... r22   0xc0000000001e4968
.... r23   0xc000000001523100
.... r24   0xc000000fe733f850
.... r25   0xc000000fcaa69000
.... r26   0xc000000003b8fcf0
.... r27   0xfffffffffffffead
.... r28   0x0
.... r29   0xc000000fcaa69000
.... r30   0x1
.... r31   0x0
.... nip   0xc0000000001dd320
.... msr   0x9000000000009032
.... orig_r3 0xc0000000001e538c
.... ctr   0xc00000000009d550
.... link  0xc0000000001e5e34
.... xer   0x0
.... ccr   0x84022882

.... softe 0x0
.... trap 0xf01
.... dar 0x0
.... dsisr 0xf00040060000004
... thread: :4522:4522
...... dso: /root/.debug/.build-id/b0/ef11b1a1629e62ac9de75199117ee5ef9469e9

           :4522  4522   496.768515:          1 cycles:  c0000000001e538c .perf_event_context_sched_in (/boot/vmlinux)

Changes from v10:

- Included SOFTE as suggested by mpe
- The name of registers displayed is changed from gpr* to r* also the macro names changed from PERF_REG_POWERPC_GPR* to PERF_REG_POWERPC_R*.
- The conflict in returning the ABI is resolved.
- #define PERF_REG_SP is again changed to PERF_REG_POWERPC_R1
- Comment in tools/perf/config/Makefile is updated.
- removed the "Reviewed-By" tag as the patch has logic changes.

Changes from V9:

- Changed the name displayed for link register from "lnk" to "link" in tools/perf/arch/powerpc/include/perf_regs.h

changes from V8:

- Corrected the indentation issue in the Makefile mentioned in 3rd patch

Changes from V7:

- Addressed the new line issue in 3rd patch.

Changes from V6:

- Corrected the typo in patch tools/perf: Map the ID values with register names.
ie #define PERF_REG_SP PERF_REG_POWERPC_R1 should be #define PERF_REG_SP PERF_REG_POWERPC_GPR1

Changes from V5:

- Enabled perf_sample_regs_user also in this patch set.Functions added in arch/powerpc/perf/perf_regs.c
- Added Maddy's patch to this patchset for enabling -I? option which will list the supported register names.

Changes from V4:

- Removed the softe and MQ from all patches
- Switch case is replaced with an array in the 3rd patch

Changes from V3:

- Addressed the comments by Sukadev regarding the nits in the descriptions.
- Modified the subject of first patch.
- Included the sample output in the 3rd patch also.

Changes from V2:

- tools/perf/config/Makefile is moved to the patch tools/perf.
- The patchset is reordered.
- perf_regs_load() function is used for the dwarf unwind test.Since it is not required here, it is removed from tools/perf/arch/powerpc/include/perf_regs.h
- PERF_REGS_POWERPC_RESULT is removed.

Changes from V1:

- Solved the name missmatch issue in the from and signed-off field of the patch series.
- Added necessary comments in the 3rd patch ie perf/powerpc ,as suggested by Maddy.

Anju T (3):
perf/powerpc: assign an id to each powerpc register perf/powerpc: add support for sampling intr machine state tools/perf: Map the ID values with register names

Madhavan Srinivasan (1):
tool/perf: Add sample_reg_mask to include all perf_regs regs

Quoted 14 lines
 arch/powerpc/Kconfig                        |  1 +
 arch/powerpc/include/uapi/asm/perf_regs.h   | 50 ++++++++++++++++
 arch/powerpc/perf/Makefile                  |  1 +
 arch/powerpc/perf/perf_regs.c               | 91 +++++++++++++++++++++++++++++
 tools/perf/arch/powerpc/include/perf_regs.h | 69 ++++++++++++++++++++++
 tools/perf/arch/powerpc/util/Build          |  1 +
 tools/perf/arch/powerpc/util/perf_regs.c    | 49 ++++++++++++++++
 tools/perf/config/Makefile                  |  5 ++
 8 files changed, 267 insertions(+)
 create mode 100644 arch/powerpc/include/uapi/asm/perf_regs.h
 create mode 100644 arch/powerpc/perf/perf_regs.c
 create mode 100644 tools/perf/arch/powerpc/include/perf_regs.h
 create mode 100644 tools/perf/arch/powerpc/util/perf_regs.c
Quoted 3 lines

Hi,

Can this be taken into the next tree?

Even the bits in tools/perf/ are arch specific, so I guess this goes via the powerpc tree? Michael?

- Arnaldo

#14 lore raw
Quoted 18 lines · Arnaldo Carvalho de Melo

Em Mon, Apr 18, 2016 at 03:17:11PM +0530, Anju T escreveu:

Quoted 17 lines · Anju T
Quoted 15 lines
 arch/powerpc/Kconfig                        |  1 +
 arch/powerpc/include/uapi/asm/perf_regs.h   | 50 ++++++++++++++++
 arch/powerpc/perf/Makefile                  |  1 +
 arch/powerpc/perf/perf_regs.c               | 91 +++++++++++++++++++++++++++++
 tools/perf/arch/powerpc/include/perf_regs.h | 69 ++++++++++++++++++++++
 tools/perf/arch/powerpc/util/Build          |  1 +
 tools/perf/arch/powerpc/util/perf_regs.c    | 49 ++++++++++++++++
 tools/perf/config/Makefile                  |  5 ++
 8 files changed, 267 insertions(+)
 create mode 100644 arch/powerpc/include/uapi/asm/perf_regs.h
 create mode 100644 arch/powerpc/perf/perf_regs.c
 create mode 100644 tools/perf/arch/powerpc/include/perf_regs.h
 create mode 100644 tools/perf/arch/powerpc/util/perf_regs.c
Quoted 6 lines
Quoted 3 lines

Hi,

Can this be taken into the next tree?

Even the bits in tools/perf/ are arch specific, so I guess this goes via the powerpc tree? Michael?

Yeah if that's OK with you.

It doesn't look like it will generate much in the way of merge conflicts.

Do you want to send an ack?

cheers

#15 lore raw

Em Wed, Apr 20, 2016 at 02:55:58PM +1000, Michael Ellerman escreveu:

Quoted 12 lines · Arnaldo Carvalho de Melo
Quoted 10 lines

Em Mon, Apr 18, 2016 at 03:17:11PM +0530, Anju T escreveu:

Quoted 9 lines · Anju T
Quoted 6 lines
 tools/perf/arch/powerpc/include/perf_regs.h | 69 ++++++++++++++++++++++
 tools/perf/arch/powerpc/util/Build          |  1 +
 tools/perf/arch/powerpc/util/perf_regs.c    | 49 ++++++++++++++++
 tools/perf/config/Makefile                  |  5 ++
 create mode 100644 tools/perf/arch/powerpc/include/perf_regs.h
 create mode 100644 tools/perf/arch/powerpc/util/perf_regs.c

Can this be taken into the next tree?

Quoted 8 lines
Quoted 2 lines

Even the bits in tools/perf/ are arch specific, so I guess this goes via the powerpc tree? Michael?

Yeah if that's OK with you.

It doesn't look like it will generate much in the way of merge conflicts.

Do you want to send an ack?

For the tools/perf/ bits:

- Arnaldo

#2 lore raw

Re: [PATCH V11 1/4] perf/powerpc: assign an id to each powerpc register

In reply to Anju T
Quoted 9 lines · Anju T

The enum definition assigns an 'id' to each register in "struct pt_regs" of arch/powerpc. The order of these values in the enum definition are based on the corresponding macros in arch/powerpc/include/uapi/asm/ptrace.h.

---
 arch/powerpc/include/uapi/asm/perf_regs.h | 50 +++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 arch/powerpc/include/uapi/asm/perf_regs.h

This patch doesn't enable anything and doesn't look to be useful by itself. Please merge this with your second patch.

- Naveen

Quoted 60 lines
arch/powerpc/include/uapi/asm/perf_regs.h new file +50 -0
new file mode 100644
index 0000000..62b8a5e
@@ -0,0 +1,50 @@
+#ifndef _ASM_POWERPC_PERF_REGS_H
+#define _ASM_POWERPC_PERF_REGS_H
+
+enum perf_event_powerpc_regs {
+	PERF_REG_POWERPC_R0,
+	PERF_REG_POWERPC_R1,
+	PERF_REG_POWERPC_R2,
+	PERF_REG_POWERPC_R3,
+	PERF_REG_POWERPC_R4,
+	PERF_REG_POWERPC_R5,
+	PERF_REG_POWERPC_R6,
+	PERF_REG_POWERPC_R7,
+	PERF_REG_POWERPC_R8,
+	PERF_REG_POWERPC_R9,
+	PERF_REG_POWERPC_R10,
+	PERF_REG_POWERPC_R11,
+	PERF_REG_POWERPC_R12,
+	PERF_REG_POWERPC_R13,
+	PERF_REG_POWERPC_R14,
+	PERF_REG_POWERPC_R15,
+	PERF_REG_POWERPC_R16,
+	PERF_REG_POWERPC_R17,
+	PERF_REG_POWERPC_R18,
+	PERF_REG_POWERPC_R19,
+	PERF_REG_POWERPC_R20,
+	PERF_REG_POWERPC_R21,
+	PERF_REG_POWERPC_R22,
+	PERF_REG_POWERPC_R23,
+	PERF_REG_POWERPC_R24,
+	PERF_REG_POWERPC_R25,
+	PERF_REG_POWERPC_R26,
+	PERF_REG_POWERPC_R27,
+	PERF_REG_POWERPC_R28,
+	PERF_REG_POWERPC_R29,
+	PERF_REG_POWERPC_R30,
+	PERF_REG_POWERPC_R31,
+	PERF_REG_POWERPC_NIP,
+	PERF_REG_POWERPC_MSR,
+	PERF_REG_POWERPC_ORIG_R3,
+	PERF_REG_POWERPC_CTR,
+	PERF_REG_POWERPC_LNK,
+	PERF_REG_POWERPC_XER,
+	PERF_REG_POWERPC_CCR,
+	PERF_REG_POWERPC_SOFTE,
+	PERF_REG_POWERPC_TRAP,
+	PERF_REG_POWERPC_DAR,
+	PERF_REG_POWERPC_DSISR,
+	PERF_REG_POWERPC_MAX,
+};
+#endif /* _ASM_POWERPC_PERF_REGS_H */
Signature · 1 line
2.1.0
#5 lore raw

Re: [PATCH V11 2/4] perf/powerpc: add support for sampling intr machine state

In reply to Anju T
Quoted 6 lines · Anju T

The perf infrastructure uses a bit mask to find out valid registers to display. Define a register mask for supported registers defined in asm/perf_regs.h. The bit positions also correspond to register IDs which is used by perf infrastructure to fetch the register values. CONFIG_HAVE_PERF_REGS enables sampling of the interrupted machine state.

Please also update Documentation/features/perf/perf-regs/arch-support.txt as part of this patch.

arch/powerpc/perf/perf_regs.c

Quoted 39 lines
---
 arch/powerpc/Kconfig          |  1 +
 arch/powerpc/perf/Makefile    |  1 +
 arch/powerpc/perf/perf_regs.c | 91 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 93 insertions(+)
 create mode 100644 arch/powerpc/perf/perf_regs.c
arch/powerpc/Kconfig +1 -0
index 9a7057e..c4ce60d 100644
@@ -119,6 +119,7 @@ config PPC
 	select GENERIC_ATOMIC64 if PPC32
 	select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
 	select HAVE_PERF_EVENTS
+	select HAVE_PERF_REGS
 	select HAVE_REGS_AND_STACK_ACCESS_API
 	select HAVE_HW_BREAKPOINT if PERF_EVENTS && PPC_BOOK3S_64
 	select ARCH_WANT_IPC_PARSE_VERSION
arch/powerpc/perf/Makefile +1 -0
index f9c083a..2f2d3d2 100644
@@ -8,6 +8,7 @@ obj64-$(CONFIG_PPC_PERF_CTRS)	+= power4-pmu.o ppc970-pmu.o power5-pmu.o \
 				   power8-pmu.o
 obj32-$(CONFIG_PPC_PERF_CTRS)	+= mpc7450-pmu.o
 
+obj-$(CONFIG_PERF_EVENTS)	+= perf_regs.o
 obj-$(CONFIG_FSL_EMB_PERF_EVENT) += core-fsl-emb.o
 obj-$(CONFIG_FSL_EMB_PERF_EVENT_E500) += e500-pmu.o e6500-pmu.o
 
arch/powerpc/perf/perf_regs.c new file +0 -0
new file mode 100644
index 0000000..ae0759c
@@ -0,0 +1,91 @@

You may want to add a copyright header here.

arch/powerpc/perf/perf_regs.c line 10

Quoted 10 lines
arch/powerpc/perf/perf_regs.c new file +10 -0
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/perf_event.h>
+#include <linux/bug.h>
+#include <linux/stddef.h>
+#include <asm/ptrace.h>
+#include <asm/perf_regs.h>
+
+#define PT_REGS_OFFSET(id, r) [id] = offsetof(struct pt_regs, r)

Also, run this through checkpatch.pl. There is a whitespace issue reported here.

Quoted 60 lines
arch/powerpc/perf/perf_regs.c new file +60 -0
+
+#define REG_RESERVED (~((1ULL << PERF_REG_POWERPC_MAX) - 1))
+
+static unsigned int pt_regs_offset[PERF_REG_POWERPC_MAX] = {
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R0, gpr[0]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R1, gpr[1]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R2, gpr[2]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R3, gpr[3]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R4, gpr[4]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R5, gpr[5]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R6, gpr[6]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R7, gpr[7]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R8, gpr[8]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R9, gpr[9]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R10, gpr[10]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R11, gpr[11]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R12, gpr[12]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R13, gpr[13]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R14, gpr[14]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R15, gpr[15]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R16, gpr[16]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R17, gpr[17]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R18, gpr[18]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R19, gpr[19]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R20, gpr[20]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R21, gpr[21]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R22, gpr[22]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R23, gpr[23]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R24, gpr[24]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R25, gpr[25]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R26, gpr[26]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R27, gpr[27]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R28, gpr[28]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R29, gpr[29]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R30, gpr[30]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_R31, gpr[31]),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_NIP, nip),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_MSR, msr),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_ORIG_R3, orig_gpr3),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_CTR, ctr),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_LNK, link),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_XER, xer),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_CCR, ccr),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_SOFTE, softe),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_TRAP, trap),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_DAR, dar),
+	PT_REGS_OFFSET(PERF_REG_POWERPC_DSISR, dsisr),
+};
+
+u64 perf_reg_value(struct pt_regs *regs, int idx)
+{
+	if (WARN_ON_ONCE(idx >= PERF_REG_POWERPC_MAX))
+		return 0;
+
+	return regs_get_register(regs, pt_regs_offset[idx]);
+}
+
+int perf_reg_validate(u64 mask)
+{
+	if (!mask || mask & REG_RESERVED)

arch/powerpc/perf/perf_regs.c line 80

Quoted 10 lines
arch/powerpc/perf/perf_regs.c new file +10 -0
+		return -EINVAL;
+	return 0;
+}
+
+u64 perf_reg_abi(struct task_struct *task)
+{
+#ifdef __powerpc64__
+	if (!test_tsk_thread_flag(task, TIF_32BIT))
+		return PERF_SAMPLE_REGS_ABI_64;
+	else

The 'else' above is redundant.

- Naveen

Quoted 14 lines
arch/powerpc/perf/perf_regs.c new file +11 -0
+#endif
+	return PERF_SAMPLE_REGS_ABI_32;
+}
+
+void perf_get_regs_user(struct perf_regs *regs_user,
+			struct pt_regs *regs,
+			struct pt_regs *regs_user_copy)
+{
+	regs_user->regs = task_pt_regs(current);
+	regs_user->abi  = perf_reg_abi(current);
+}
Signature · 1 line
2.1.0
reviewer Applied
#3 lore raw

Re: [V11,1/4] perf/powerpc: assign an id to each powerpc register

In reply to Anju T
Quoted 5 lines · Anju T

The enum definition assigns an 'id' to each register in "struct pt_regs" of arch/powerpc. The order of these values in the enum definition are based on the corresponding macros in arch/powerpc/include/uapi/asm/ptrace.h.

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/1bfadabfebc671a6af0f5008b5

cheers

reviewer Applied
#6 lore raw

Re: [V11,2/4] perf/powerpc: add support for sampling intr machine state

In reply to Anju T
Quoted 8 lines · Anju T

The perf infrastructure uses a bit mask to find out valid registers to display. Define a register mask for supported registers defined in asm/perf_regs.h. The bit positions also correspond to register IDs which is used by perf infrastructure to fetch the register values. CONFIG_HAVE_PERF_REGS enables sampling of the interrupted machine state.

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/ed4a4ef85cf5b7523107950103

cheers

reviewer Applied
#8 lore raw

Re: [V11,3/4] tools/perf: Map the ID values with register names

In reply to Anju T
Quoted 58 lines · Anju T

Map ID values with corresponding register names. These names are then displayed when user issues perf record with the -I option followed by perf report/script with -D option.

To test this patchset,
Eg:

$ perf record -I ls   # record machine state at interrupt
$ perf script -D      # read the perf.data file

Sample output obtained for this patch / output looks like as follows:

496768515470 0x1988 [0x188]: PERF_RECORD_SAMPLE(IP, 0x1): 4522/4522: 0xc0000000001e538c period: 1 addr: 0 ... intr regs: mask 0x7ffffffffff ABI 64-bit

.... r0    0xc0000000001e5e34
.... r1    0xc000000fe733f9a0
.... r2    0xc000000001523100
.... r3    0xc000000ffaadeb60
.... r4    0xc000000003456800
.... r5    0x73a9b5e000
.... r6    0x1e000000
.... r7    0x0
.... r8    0x0
.... r9    0x0
.... r10   0x1
.... r11   0x0
.... r12   0x24022822
.... r13   0xc00000000feec180
.... r14   0x0
.... r15   0xc000001e4be18800
.... r16   0x0
.... r17   0xc000000ffaac5000
.... r18   0xc000000fe733f8a0
.... r19   0xc000000001523100
.... r20   0xc00000000009fd1c
.... r21   0xc000000fcaa69000
.... r22   0xc0000000001e4968
.... r23   0xc000000001523100
.... r24   0xc000000fe733f850
.... r25   0xc000000fcaa69000
.... r26   0xc000000003b8fcf0
.... r27   0xfffffffffffffead
.... r28   0x0
.... r29   0xc000000fcaa69000
.... r30   0x1
.... r31   0x0
.... nip   0xc0000000001dd320
.... msr   0x9000000000009032
.... orig_r3 0xc0000000001e538c
.... ctr   0xc00000000009d550
.... link  0xc0000000001e5e34
.... xer   0x0
.... ccr   0x84022882

.... softe 0x0
.... trap 0xf01
.... dar 0x0
.... dsisr 0xf00040060000004
... thread: :4522:4522
...... dso: /root/.debug/.build-id/b0/ef11b1a1629e62ac9de75199117ee5ef9469e9

Quoted 3 lines
           :4522  4522   496.768515:          1 cycles:  c0000000001e538c .perf_event_context_sched_in (/boot/vmlinux)

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/dc642e8388b63a9a221903584b

cheers

#16 lore raw
In reply to Arnaldo Carvalho de Melo
Quoted 7 lines · Arnaldo Carvalho de Melo

Em Wed, Apr 20, 2016 at 02:55:58PM +1000, Michael Ellerman escreveu:

Quoted 6 lines · Arnaldo Carvalho de Melo
Quoted 2 lines

Even the bits in tools/perf/ are arch specific, so I guess this goes via the powerpc tree? Michael?

Yeah if that's OK with you.

Quoted 7 lines
Quoted 3 lines

It doesn't look like it will generate much in the way of merge conflicts.

Do you want to send an ack?

For the tools/perf/ bits:

Thanks.

cheers