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

2016-01-21 Thread Anju T

Hi mpe,
On Wednesday 20 January 2016 04:16 PM, Michael Ellerman wrote:

On Mon, 2016-01-11 at 15:58 +0530, Anju T wrote:

diff --git a/tools/perf/arch/powerpc/include/perf_regs.h 
b/tools/perf/arch/powerpc/include/perf_regs.h
new file mode 100644
index 000..93080f5
--- /dev/null
+++ b/tools/perf/arch/powerpc/include/perf_regs.h
@@ -0,0 +1,64 @@
+#ifndef ARCH_PERF_REGS_H
+#define ARCH_PERF_REGS_H
+
+#include 
+#include 
+#include 
+
+#define PERF_REGS_MASK  ((1ULL << PERF_REG_POWERPC_MAX) - 1)
+#define PERF_REGS_MAX   PERF_REG_POWERPC_MAX
+#define PERF_SAMPLE_REGS_ABI   PERF_SAMPLE_REGS_ABI_64

That looks wrong if perf is built 32-bit ?



Yes. You are right. The ABI differs for 32 bit.



+#define PERF_REG_IP PERF_REG_POWERPC_NIP
+#define PERF_REG_SP PERF_REG_POWERPC_GPR1
+
+static const char *reg_names[] = {
+   [PERF_REG_POWERPC_GPR0] = "gpr0",

Can you instead call them "r0" etc.

That is much more common on powerpc than "gpr0".


+   [PERF_REG_POWERPC_GPR1] = "gpr1",
+   [PERF_REG_POWERPC_GPR2] = "gpr2",
+   [PERF_REG_POWERPC_GPR3] = "gpr3",
+   [PERF_REG_POWERPC_GPR4] = "gpr4",
+   [PERF_REG_POWERPC_GPR5] = "gpr5",
+   [PERF_REG_POWERPC_GPR6] = "gpr6",
+   [PERF_REG_POWERPC_GPR7] = "gpr7",
+   [PERF_REG_POWERPC_GPR8] = "gpr8",
+   [PERF_REG_POWERPC_GPR9] = "gpr9",
+   [PERF_REG_POWERPC_GPR10] = "gpr10",
+   [PERF_REG_POWERPC_GPR11] = "gpr11",
+   [PERF_REG_POWERPC_GPR12] = "gpr12",
+   [PERF_REG_POWERPC_GPR13] = "gpr13",
+   [PERF_REG_POWERPC_GPR14] = "gpr14",
+   [PERF_REG_POWERPC_GPR15] = "gpr15",
+   [PERF_REG_POWERPC_GPR16] = "gpr16",
+   [PERF_REG_POWERPC_GPR17] = "gpr17",
+   [PERF_REG_POWERPC_GPR18] = "gpr18",
+   [PERF_REG_POWERPC_GPR19] = "gpr19",
+   [PERF_REG_POWERPC_GPR20] = "gpr20",
+   [PERF_REG_POWERPC_GPR21] = "gpr21",
+   [PERF_REG_POWERPC_GPR22] = "gpr22",
+   [PERF_REG_POWERPC_GPR23] = "gpr23",
+   [PERF_REG_POWERPC_GPR24] = "gpr24",
+   [PERF_REG_POWERPC_GPR25] = "gpr25",
+   [PERF_REG_POWERPC_GPR26] = "gpr26",
+   [PERF_REG_POWERPC_GPR27] = "gpr27",
+   [PERF_REG_POWERPC_GPR28] = "gpr28",
+   [PERF_REG_POWERPC_GPR29] = "gpr29",
+   [PERF_REG_POWERPC_GPR30] = "gpr30",
+   [PERF_REG_POWERPC_GPR31] = "gpr31",
+   [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_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 */
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 38a0853..62a2f2d 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -23,6 +23,11 @@ $(call detected_var,ARCH)
  
  NO_PERF_REGS := 1
  
+# Additional ARCH settings for ppc64

+ifeq ($(ARCH),powerpc)

powerpc also includes ppc, ie. 32-bit, so the comment is wrong.



I will update the comment here  in the next patch. :)



+  NO_PERF_REGS := 0
+endif
+
  # Additional ARCH settings for x86
  ifeq ($(ARCH),x86)
$(call detected,CONFIG_X86)



Thanks and Regards

Anju

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

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

2016-01-20 Thread Michael Ellerman
On Mon, 2016-01-11 at 15:58 +0530, Anju T wrote:
> diff --git a/tools/perf/arch/powerpc/include/perf_regs.h 
> b/tools/perf/arch/powerpc/include/perf_regs.h
> new file mode 100644
> index 000..93080f5
> --- /dev/null
> +++ b/tools/perf/arch/powerpc/include/perf_regs.h
> @@ -0,0 +1,64 @@
> +#ifndef ARCH_PERF_REGS_H
> +#define ARCH_PERF_REGS_H
> +
> +#include 
> +#include 
> +#include 
> +
> +#define PERF_REGS_MASK  ((1ULL << PERF_REG_POWERPC_MAX) - 1)
> +#define PERF_REGS_MAX   PERF_REG_POWERPC_MAX
> +#define PERF_SAMPLE_REGS_ABI   PERF_SAMPLE_REGS_ABI_64

That looks wrong if perf is built 32-bit ?

> +#define PERF_REG_IP PERF_REG_POWERPC_NIP
> +#define PERF_REG_SP PERF_REG_POWERPC_GPR1
> +
> +static const char *reg_names[] = {
> + [PERF_REG_POWERPC_GPR0] = "gpr0",

Can you instead call them "r0" etc.

That is much more common on powerpc than "gpr0".

> + [PERF_REG_POWERPC_GPR1] = "gpr1",
> + [PERF_REG_POWERPC_GPR2] = "gpr2",
> + [PERF_REG_POWERPC_GPR3] = "gpr3",
> + [PERF_REG_POWERPC_GPR4] = "gpr4",
> + [PERF_REG_POWERPC_GPR5] = "gpr5",
> + [PERF_REG_POWERPC_GPR6] = "gpr6",
> + [PERF_REG_POWERPC_GPR7] = "gpr7",
> + [PERF_REG_POWERPC_GPR8] = "gpr8",
> + [PERF_REG_POWERPC_GPR9] = "gpr9",
> + [PERF_REG_POWERPC_GPR10] = "gpr10",
> + [PERF_REG_POWERPC_GPR11] = "gpr11",
> + [PERF_REG_POWERPC_GPR12] = "gpr12",
> + [PERF_REG_POWERPC_GPR13] = "gpr13",
> + [PERF_REG_POWERPC_GPR14] = "gpr14",
> + [PERF_REG_POWERPC_GPR15] = "gpr15",
> + [PERF_REG_POWERPC_GPR16] = "gpr16",
> + [PERF_REG_POWERPC_GPR17] = "gpr17",
> + [PERF_REG_POWERPC_GPR18] = "gpr18",
> + [PERF_REG_POWERPC_GPR19] = "gpr19",
> + [PERF_REG_POWERPC_GPR20] = "gpr20",
> + [PERF_REG_POWERPC_GPR21] = "gpr21",
> + [PERF_REG_POWERPC_GPR22] = "gpr22",
> + [PERF_REG_POWERPC_GPR23] = "gpr23",
> + [PERF_REG_POWERPC_GPR24] = "gpr24",
> + [PERF_REG_POWERPC_GPR25] = "gpr25",
> + [PERF_REG_POWERPC_GPR26] = "gpr26",
> + [PERF_REG_POWERPC_GPR27] = "gpr27",
> + [PERF_REG_POWERPC_GPR28] = "gpr28",
> + [PERF_REG_POWERPC_GPR29] = "gpr29",
> + [PERF_REG_POWERPC_GPR30] = "gpr30",
> + [PERF_REG_POWERPC_GPR31] = "gpr31",
> + [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_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 */
> diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
> index 38a0853..62a2f2d 100644
> --- a/tools/perf/config/Makefile
> +++ b/tools/perf/config/Makefile
> @@ -23,6 +23,11 @@ $(call detected_var,ARCH)
>  
>  NO_PERF_REGS := 1
>  
> +# Additional ARCH settings for ppc64
> +ifeq ($(ARCH),powerpc)

powerpc also includes ppc, ie. 32-bit, so the comment is wrong.

> +  NO_PERF_REGS := 0
> +endif
> +
>  # Additional ARCH settings for x86
>  ifeq ($(ARCH),x86)
>$(call detected,CONFIG_X86)

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH v10 3/4] tools/perf: Map the ID values with register names

2016-01-11 Thread 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:

178329381464 0x138 [0x180]: PERF_RECORD_SAMPLE(IP, 0x1): 7803/7803: 
0xc000fd9c period: 1 addr: 0
... intr regs: mask 0x3ff ABI 64-bit
 gpr0  0xc01a6420
 gpr1  0xc01e4df039b0
 gpr2  0xc0cdd100
 gpr3  0x1
 gpr4  0xc01e4a96d000
 gpr5  0x29854255ba
 gpr6  0xc00ffa3050b8
 gpr7  0x0
 gpr8  0x0
 gpr9  0x0
 gpr10 0x0
 gpr11 0x0
 gpr12 0x24022822
 gpr13 0xcfe03000
 gpr14 0x0
 gpr15 0xc0d763f8
 gpr16 0x0
 gpr17 0xc01e4ddcf000
 gpr18 0x0
 gpr19 0xc00ffa305000
 gpr20 0xc01e4df038c0
 gpr21 0xc01e40ed7a00
 gpr22 0xc00aa28c
 gpr23 0xc0cdd100
 gpr24 0x0
 gpr25 0xc0cdd100
 gpr26 0xc01e4df038b0
 gpr27 0xfeae
 gpr28 0xc01e4df03880
 gpr29 0xc0dce900
 gpr30 0xc01e4df03890
 gpr31 0xc01e355c7a30
 nip   0xc01a62d8
 msr   0x90009032
 orig_r3 0xc01a6320
 ctr   0xc00a7be0
 link   0xc01a6428
 xer   0x0
 ccr   0x24022888
 trap  0xf01
 dar   0xc01e40ed7a00
 dsisr 0x3000c006004
 ... thread: :7803:7803
 .. dso: /root/.debug/.build-id/d0/eb47b06c0d294143af13c50616f638c2d88658
   :7803  7803   178.329381:  1 cycles:  c000fd9c 
.arch_local_irq_restore (/boot/vmlinux)


Signed-off-by: Anju T 
Reviewed-by  : Madhavan Srinivasan 
---
 tools/perf/arch/powerpc/include/perf_regs.h | 64 +
 tools/perf/config/Makefile  |  5 +++
 2 files changed, 69 insertions(+)
 create mode 100644 tools/perf/arch/powerpc/include/perf_regs.h

diff --git a/tools/perf/arch/powerpc/include/perf_regs.h 
b/tools/perf/arch/powerpc/include/perf_regs.h
new file mode 100644
index 000..93080f5
--- /dev/null
+++ b/tools/perf/arch/powerpc/include/perf_regs.h
@@ -0,0 +1,64 @@
+#ifndef ARCH_PERF_REGS_H
+#define ARCH_PERF_REGS_H
+
+#include 
+#include 
+#include 
+
+#define PERF_REGS_MASK  ((1ULL << PERF_REG_POWERPC_MAX) - 1)
+#define PERF_REGS_MAX   PERF_REG_POWERPC_MAX
+#define PERF_SAMPLE_REGS_ABI   PERF_SAMPLE_REGS_ABI_64
+
+#define PERF_REG_IP PERF_REG_POWERPC_NIP
+#define PERF_REG_SP PERF_REG_POWERPC_GPR1
+
+static const char *reg_names[] = {
+   [PERF_REG_POWERPC_GPR0] = "gpr0",
+   [PERF_REG_POWERPC_GPR1] = "gpr1",
+   [PERF_REG_POWERPC_GPR2] = "gpr2",
+   [PERF_REG_POWERPC_GPR3] = "gpr3",
+   [PERF_REG_POWERPC_GPR4] = "gpr4",
+   [PERF_REG_POWERPC_GPR5] = "gpr5",
+   [PERF_REG_POWERPC_GPR6] = "gpr6",
+   [PERF_REG_POWERPC_GPR7] = "gpr7",
+   [PERF_REG_POWERPC_GPR8] = "gpr8",
+   [PERF_REG_POWERPC_GPR9] = "gpr9",
+   [PERF_REG_POWERPC_GPR10] = "gpr10",
+   [PERF_REG_POWERPC_GPR11] = "gpr11",
+   [PERF_REG_POWERPC_GPR12] = "gpr12",
+   [PERF_REG_POWERPC_GPR13] = "gpr13",
+   [PERF_REG_POWERPC_GPR14] = "gpr14",
+   [PERF_REG_POWERPC_GPR15] = "gpr15",
+   [PERF_REG_POWERPC_GPR16] = "gpr16",
+   [PERF_REG_POWERPC_GPR17] = "gpr17",
+   [PERF_REG_POWERPC_GPR18] = "gpr18",
+   [PERF_REG_POWERPC_GPR19] = "gpr19",
+   [PERF_REG_POWERPC_GPR20] = "gpr20",
+   [PERF_REG_POWERPC_GPR21] = "gpr21",
+   [PERF_REG_POWERPC_GPR22] = "gpr22",
+   [PERF_REG_POWERPC_GPR23] = "gpr23",
+   [PERF_REG_POWERPC_GPR24] = "gpr24",
+   [PERF_REG_POWERPC_GPR25] = "gpr25",
+   [PERF_REG_POWERPC_GPR26] = "gpr26",
+   [PERF_REG_POWERPC_GPR27] = "gpr27",
+   [PERF_REG_POWERPC_GPR28] = "gpr28",
+   [PERF_REG_POWERPC_GPR29] = "gpr29",
+   [PERF_REG_POWERPC_GPR30] = "gpr30",
+   [PERF_REG_POWERPC_GPR31] = "gpr31",
+   [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_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 */
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 38a0853..62a2f2d 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -23,6 +23,11 @@ $(call detected_var,ARCH)
 
 NO_PERF_REGS := 1
 
+# Additional ARCH settings for ppc64
+ifeq ($(ARCH),powerpc)
+  

[PATCH v10 3/4] tools/perf: Map the ID values with register names

2016-01-10 Thread 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:

178329381464 0x138 [0x180]: PERF_RECORD_SAMPLE(IP, 0x1): 7803/7803: 
0xc000fd9c period: 1 addr: 0
... intr regs: mask 0x3ff ABI 64-bit
 gpr0  0xc01a6420
 gpr1  0xc01e4df039b0
 gpr2  0xc0cdd100
 gpr3  0x1
 gpr4  0xc01e4a96d000
 gpr5  0x29854255ba
 gpr6  0xc00ffa3050b8
 gpr7  0x0
 gpr8  0x0
 gpr9  0x0
 gpr10 0x0
 gpr11 0x0
 gpr12 0x24022822
 gpr13 0xcfe03000
 gpr14 0x0
 gpr15 0xc0d763f8
 gpr16 0x0
 gpr17 0xc01e4ddcf000
 gpr18 0x0
 gpr19 0xc00ffa305000
 gpr20 0xc01e4df038c0
 gpr21 0xc01e40ed7a00
 gpr22 0xc00aa28c
 gpr23 0xc0cdd100
 gpr24 0x0
 gpr25 0xc0cdd100
 gpr26 0xc01e4df038b0
 gpr27 0xfeae
 gpr28 0xc01e4df03880
 gpr29 0xc0dce900
 gpr30 0xc01e4df03890
 gpr31 0xc01e355c7a30
 nip   0xc01a62d8
 msr   0x90009032
 orig_r3 0xc01a6320
 ctr   0xc00a7be0
 link   0xc01a6428
 xer   0x0
 ccr   0x24022888
 trap  0xf01
 dar   0xc01e40ed7a00
 dsisr 0x3000c006004
 ... thread: :7803:7803
 .. dso: /root/.debug/.build-id/d0/eb47b06c0d294143af13c50616f638c2d88658
   :7803  7803   178.329381:  1 cycles:  c000fd9c 
.arch_local_irq_restore (/boot/vmlinux)


Signed-off-by: Anju T 
Reviewed-by  : Madhavan Srinivasan 
---
 tools/perf/arch/powerpc/include/perf_regs.h | 64 +
 tools/perf/config/Makefile  |  5 +++
 2 files changed, 69 insertions(+)
 create mode 100644 tools/perf/arch/powerpc/include/perf_regs.h

diff --git a/tools/perf/arch/powerpc/include/perf_regs.h 
b/tools/perf/arch/powerpc/include/perf_regs.h
new file mode 100644
index 000..93080f5
--- /dev/null
+++ b/tools/perf/arch/powerpc/include/perf_regs.h
@@ -0,0 +1,64 @@
+#ifndef ARCH_PERF_REGS_H
+#define ARCH_PERF_REGS_H
+
+#include 
+#include 
+#include 
+
+#define PERF_REGS_MASK  ((1ULL << PERF_REG_POWERPC_MAX) - 1)
+#define PERF_REGS_MAX   PERF_REG_POWERPC_MAX
+#define PERF_SAMPLE_REGS_ABI   PERF_SAMPLE_REGS_ABI_64
+
+#define PERF_REG_IP PERF_REG_POWERPC_NIP
+#define PERF_REG_SP PERF_REG_POWERPC_GPR1
+
+static const char *reg_names[] = {
+   [PERF_REG_POWERPC_GPR0] = "gpr0",
+   [PERF_REG_POWERPC_GPR1] = "gpr1",
+   [PERF_REG_POWERPC_GPR2] = "gpr2",
+   [PERF_REG_POWERPC_GPR3] = "gpr3",
+   [PERF_REG_POWERPC_GPR4] = "gpr4",
+   [PERF_REG_POWERPC_GPR5] = "gpr5",
+   [PERF_REG_POWERPC_GPR6] = "gpr6",
+   [PERF_REG_POWERPC_GPR7] = "gpr7",
+   [PERF_REG_POWERPC_GPR8] = "gpr8",
+   [PERF_REG_POWERPC_GPR9] = "gpr9",
+   [PERF_REG_POWERPC_GPR10] = "gpr10",
+   [PERF_REG_POWERPC_GPR11] = "gpr11",
+   [PERF_REG_POWERPC_GPR12] = "gpr12",
+   [PERF_REG_POWERPC_GPR13] = "gpr13",
+   [PERF_REG_POWERPC_GPR14] = "gpr14",
+   [PERF_REG_POWERPC_GPR15] = "gpr15",
+   [PERF_REG_POWERPC_GPR16] = "gpr16",
+   [PERF_REG_POWERPC_GPR17] = "gpr17",
+   [PERF_REG_POWERPC_GPR18] = "gpr18",
+   [PERF_REG_POWERPC_GPR19] = "gpr19",
+   [PERF_REG_POWERPC_GPR20] = "gpr20",
+   [PERF_REG_POWERPC_GPR21] = "gpr21",
+   [PERF_REG_POWERPC_GPR22] = "gpr22",
+   [PERF_REG_POWERPC_GPR23] = "gpr23",
+   [PERF_REG_POWERPC_GPR24] = "gpr24",
+   [PERF_REG_POWERPC_GPR25] = "gpr25",
+   [PERF_REG_POWERPC_GPR26] = "gpr26",
+   [PERF_REG_POWERPC_GPR27] = "gpr27",
+   [PERF_REG_POWERPC_GPR28] = "gpr28",
+   [PERF_REG_POWERPC_GPR29] = "gpr29",
+   [PERF_REG_POWERPC_GPR30] = "gpr30",
+   [PERF_REG_POWERPC_GPR31] = "gpr31",
+   [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_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 */
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 38a0853..62a2f2d 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -23,6 +23,11 @@ $(call detected_var,ARCH)
 
 NO_PERF_REGS := 1
 
+# Additional ARCH settings for ppc64
+ifeq ($(ARCH),powerpc)
+