diff options
author | Samuli Piippo <samuli.piippo@theqtcompany.com> | 2015-02-12 14:44:25 +0200 |
---|---|---|
committer | Samuli Piippo <samuli.piippo@theqtcompany.com> | 2015-02-26 08:55:46 +0200 |
commit | b2397a823399be9ae901d02f0073df5001b75c55 (patch) | |
tree | 9f12adaad26c1c29237e70e9a6d25bacc9b4927c /recipes | |
parent | d025004a0d1a78ed67131d30f4251e1faf2d4083 (diff) | |
download | meta-boot2qt-b2397a823399be9ae901d02f0073df5001b75c55.tar.gz |
Performance analysis tools for Linux
Build perf with DWARF unwinding support. Kernels older then 3.14
need to be patched to add ARM support. Kernels for tibidabo (3.0)
and imx53 (2.6) are too old and would require more patches to be
backported, so they are left without unwinding support.
RPi needed extra layer to modify the kernel recipe, and linux-imx
recipe was renamed so that it doesn't conflict with older tibidabo
kernel recipe.
Change-Id: Ic8331f8feeace67b32a5ce99ffd3fda517d595d1
Reviewed-by: Andy Nichols <andy.nichols@theqtcompany.com>
Reviewed-by: Ulf Hermann <ulf.hermann@theqtcompany.com>
Diffstat (limited to 'recipes')
4 files changed, 301 insertions, 0 deletions
diff --git a/recipes/linux/linux/ARM-perf-add-support-for-perf-registers-API.diff b/recipes/linux/linux/ARM-perf-add-support-for-perf-registers-API.diff new file mode 100644 index 0000000..e6f44fd --- /dev/null +++ b/recipes/linux/linux/ARM-perf-add-support-for-perf-registers-API.diff | |||
@@ -0,0 +1,126 @@ | |||
1 | From 49863894db3ed7bd41541b1c17733273966cea71 Mon Sep 17 00:00:00 2001 | ||
2 | From: Will Deacon <will.deacon@arm.com> | ||
3 | Date: Thu, 26 Sep 2013 12:36:35 +0100 | ||
4 | Subject: [PATCH] ARM: perf: add support for perf registers API | ||
5 | |||
6 | This patch implements the functions required for the perf registers API, | ||
7 | allowing the perf tool to interface kernel register dumps with libunwind | ||
8 | in order to provide userspace backtracing. | ||
9 | |||
10 | Cc: Jean Pihet <jean.pihet@linaro.org> | ||
11 | Signed-off-by: Will Deacon <will.deacon@arm.com> | ||
12 | --- | ||
13 | arch/arm/Kconfig | 2 ++ | ||
14 | arch/arm/include/uapi/asm/Kbuild | 1 + | ||
15 | arch/arm/include/uapi/asm/perf_regs.h | 23 +++++++++++++++++++++++ | ||
16 | arch/arm/kernel/Makefile | 1 + | ||
17 | arch/arm/kernel/perf_regs.c | 30 ++++++++++++++++++++++++++++++ | ||
18 | 5 files changed, 57 insertions(+) | ||
19 | create mode 100644 arch/arm/include/uapi/asm/perf_regs.h | ||
20 | create mode 100644 arch/arm/kernel/perf_regs.c | ||
21 | |||
22 | diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig | ||
23 | index 1ad6fb6..899d0c6 100644 | ||
24 | --- a/arch/arm/Kconfig | ||
25 | +++ b/arch/arm/Kconfig | ||
26 | @@ -51,6 +51,8 @@ config ARM | ||
27 | select HAVE_MOD_ARCH_SPECIFIC if ARM_UNWIND | ||
28 | select HAVE_OPROFILE if (HAVE_PERF_EVENTS) | ||
29 | select HAVE_PERF_EVENTS | ||
30 | + select HAVE_PERF_REGS | ||
31 | + select HAVE_PERF_USER_STACK_DUMP | ||
32 | select HAVE_REGS_AND_STACK_ACCESS_API | ||
33 | select HAVE_SYSCALL_TRACEPOINTS | ||
34 | select HAVE_UID16 | ||
35 | diff --git a/arch/arm/include/uapi/asm/Kbuild b/arch/arm/include/uapi/asm/Kbuild | ||
36 | index 18d76fd..70a1c9d 100644 | ||
37 | --- a/arch/arm/include/uapi/asm/Kbuild | ||
38 | +++ b/arch/arm/include/uapi/asm/Kbuild | ||
39 | @@ -7,6 +7,7 @@ header-y += hwcap.h | ||
40 | header-y += ioctls.h | ||
41 | header-y += kvm_para.h | ||
42 | header-y += mman.h | ||
43 | +header-y += perf_regs.h | ||
44 | header-y += posix_types.h | ||
45 | header-y += ptrace.h | ||
46 | header-y += setup.h | ||
47 | diff --git a/arch/arm/include/uapi/asm/perf_regs.h b/arch/arm/include/uapi/asm/perf_regs.h | ||
48 | new file mode 100644 | ||
49 | index 0000000..ce59448 | ||
50 | --- /dev/null | ||
51 | +++ b/arch/arm/include/uapi/asm/perf_regs.h | ||
52 | @@ -0,0 +1,23 @@ | ||
53 | +#ifndef _ASM_ARM_PERF_REGS_H | ||
54 | +#define _ASM_ARM_PERF_REGS_H | ||
55 | + | ||
56 | +enum perf_event_arm_regs { | ||
57 | + PERF_REG_ARM_R0, | ||
58 | + PERF_REG_ARM_R1, | ||
59 | + PERF_REG_ARM_R2, | ||
60 | + PERF_REG_ARM_R3, | ||
61 | + PERF_REG_ARM_R4, | ||
62 | + PERF_REG_ARM_R5, | ||
63 | + PERF_REG_ARM_R6, | ||
64 | + PERF_REG_ARM_R7, | ||
65 | + PERF_REG_ARM_R8, | ||
66 | + PERF_REG_ARM_R9, | ||
67 | + PERF_REG_ARM_R10, | ||
68 | + PERF_REG_ARM_FP, | ||
69 | + PERF_REG_ARM_IP, | ||
70 | + PERF_REG_ARM_SP, | ||
71 | + PERF_REG_ARM_LR, | ||
72 | + PERF_REG_ARM_PC, | ||
73 | + PERF_REG_ARM_MAX, | ||
74 | +}; | ||
75 | +#endif /* _ASM_ARM_PERF_REGS_H */ | ||
76 | diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile | ||
77 | index 5140df5f..9b818ca 100644 | ||
78 | --- a/arch/arm/kernel/Makefile | ||
79 | +++ b/arch/arm/kernel/Makefile | ||
80 | @@ -78,6 +78,7 @@ obj-$(CONFIG_CPU_XSC3) += xscale-cp0.o | ||
81 | obj-$(CONFIG_CPU_MOHAWK) += xscale-cp0.o | ||
82 | obj-$(CONFIG_CPU_PJ4) += pj4-cp0.o | ||
83 | obj-$(CONFIG_IWMMXT) += iwmmxt.o | ||
84 | +obj-$(CONFIG_PERF_EVENTS) += perf_regs.o | ||
85 | obj-$(CONFIG_HW_PERF_EVENTS) += perf_event.o perf_event_cpu.o | ||
86 | AFLAGS_iwmmxt.o := -Wa,-mcpu=iwmmxt | ||
87 | obj-$(CONFIG_ARM_CPU_TOPOLOGY) += topology.o | ||
88 | diff --git a/arch/arm/kernel/perf_regs.c b/arch/arm/kernel/perf_regs.c | ||
89 | new file mode 100644 | ||
90 | index 0000000..6e4379c | ||
91 | --- /dev/null | ||
92 | +++ b/arch/arm/kernel/perf_regs.c | ||
93 | @@ -0,0 +1,30 @@ | ||
94 | + | ||
95 | +#include <linux/errno.h> | ||
96 | +#include <linux/kernel.h> | ||
97 | +#include <linux/perf_event.h> | ||
98 | +#include <linux/bug.h> | ||
99 | +#include <asm/perf_regs.h> | ||
100 | +#include <asm/ptrace.h> | ||
101 | + | ||
102 | +u64 perf_reg_value(struct pt_regs *regs, int idx) | ||
103 | +{ | ||
104 | + if (WARN_ON_ONCE((u32)idx >= PERF_REG_ARM_MAX)) | ||
105 | + return 0; | ||
106 | + | ||
107 | + return regs->uregs[idx]; | ||
108 | +} | ||
109 | + | ||
110 | +#define REG_RESERVED (~((1ULL << PERF_REG_ARM_MAX) - 1)) | ||
111 | + | ||
112 | +int perf_reg_validate(u64 mask) | ||
113 | +{ | ||
114 | + if (!mask || mask & REG_RESERVED) | ||
115 | + return -EINVAL; | ||
116 | + | ||
117 | + return 0; | ||
118 | +} | ||
119 | + | ||
120 | +u64 perf_reg_abi(struct task_struct *task) | ||
121 | +{ | ||
122 | + return PERF_SAMPLE_REGS_ABI_32; | ||
123 | +} | ||
124 | -- | ||
125 | 1.9.1 | ||
126 | |||
diff --git a/recipes/linux/linux/ARM-perf-wire-up-perf_regs-and-unwind-support-for-AR.patch b/recipes/linux/linux/ARM-perf-wire-up-perf_regs-and-unwind-support-for-AR.patch new file mode 100644 index 0000000..1e497c6 --- /dev/null +++ b/recipes/linux/linux/ARM-perf-wire-up-perf_regs-and-unwind-support-for-AR.patch | |||
@@ -0,0 +1,172 @@ | |||
1 | From 8abd7519c1fd2b6ae35eddbb41f93f44d3886000 Mon Sep 17 00:00:00 2001 | ||
2 | From: Will Deacon <will.deacon@arm.com> | ||
3 | Date: Thu, 26 Sep 2013 12:36:36 +0100 | ||
4 | Subject: [PATCH] ARM: perf: wire up perf_regs and unwind support for ARM | ||
5 | |||
6 | This patch hooks in the perf_regs and libunwind code for ARM. | ||
7 | |||
8 | B2Qt: Backported for 3.10 kernel | ||
9 | |||
10 | Cc: Jean Pihet <jean.pihet@linaro.org> | ||
11 | Signed-off-by: Will Deacon <will.deacon@arm.com> | ||
12 | --- | ||
13 | tools/perf/Makefile | 6 +++- | ||
14 | tools/perf/arch/arm/Makefile | 3 ++ | ||
15 | tools/perf/arch/arm/include/perf_regs.h | 54 +++++++++++++++++++++++++++++++++ | ||
16 | tools/perf/arch/arm/util/unwind.c | 48 +++++++++++++++++++++++++++++ | ||
17 | 4 files changed, 110 insertions(+), 1 deletion(-) | ||
18 | create mode 100644 tools/perf/arch/arm/include/perf_regs.h | ||
19 | create mode 100644 tools/perf/arch/arm/util/unwind.c | ||
20 | |||
21 | diff --git a/tools/perf/Makefile b/tools/perf/Makefile | ||
22 | index b0f164b..f8fdad5 100644 | ||
23 | --- a/tools/perf/Makefile | ||
24 | +++ b/tools/perf/Makefile | ||
25 | @@ -87,6 +87,10 @@ ifeq ($(ARCH),x86_64) | ||
26 | NO_PERF_REGS := 0 | ||
27 | LIBUNWIND_LIBS = -lunwind -lunwind-x86_64 | ||
28 | endif | ||
29 | +ifeq ($(ARCH),arm) | ||
30 | + NO_PERF_REGS := 0 | ||
31 | + LIBUNWIND_LIBS = -lunwind -lunwind-arm | ||
32 | +endif | ||
33 | |||
34 | # Treat warnings as errors unless directed not to | ||
35 | ifneq ($(WERROR),0) | ||
36 | @@ -607,7 +611,7 @@ endif # SOURCE_LIBELF | ||
37 | endif # NO_LIBELF | ||
38 | |||
39 | # There's only x86 (both 32 and 64) support for CFI unwind so far | ||
40 | -ifneq ($(ARCH),x86) | ||
41 | +ifeq ($(LIBUNWIND_LIBS),) | ||
42 | NO_LIBUNWIND := 1 | ||
43 | endif | ||
44 | |||
45 | diff --git a/tools/perf/arch/arm/Makefile b/tools/perf/arch/arm/Makefile | ||
46 | index 15130b5..fe9b61e 100644 | ||
47 | --- a/tools/perf/arch/arm/Makefile | ||
48 | +++ b/tools/perf/arch/arm/Makefile | ||
49 | @@ -2,3 +2,6 @@ ifndef NO_DWARF | ||
50 | PERF_HAVE_DWARF_REGS := 1 | ||
51 | LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o | ||
52 | endif | ||
53 | +ifndef NO_LIBUNWIND | ||
54 | +LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/unwind.o | ||
55 | +endif | ||
56 | diff --git a/tools/perf/arch/arm/include/perf_regs.h b/tools/perf/arch/arm/include/perf_regs.h | ||
57 | new file mode 100644 | ||
58 | index 0000000..2a1cfde | ||
59 | --- /dev/null | ||
60 | +++ b/tools/perf/arch/arm/include/perf_regs.h | ||
61 | @@ -0,0 +1,54 @@ | ||
62 | +#ifndef ARCH_PERF_REGS_H | ||
63 | +#define ARCH_PERF_REGS_H | ||
64 | + | ||
65 | +#include <stdlib.h> | ||
66 | +#include "../../util/types.h" | ||
67 | +#include <asm/perf_regs.h> | ||
68 | + | ||
69 | +#define PERF_REGS_MASK ((1ULL << PERF_REG_ARM_MAX) - 1) | ||
70 | +#define PERF_REG_IP PERF_REG_ARM_PC | ||
71 | +#define PERF_REG_SP PERF_REG_ARM_SP | ||
72 | + | ||
73 | +static inline const char *perf_reg_name(int id) | ||
74 | +{ | ||
75 | + switch (id) { | ||
76 | + case PERF_REG_ARM_R0: | ||
77 | + return "r0"; | ||
78 | + case PERF_REG_ARM_R1: | ||
79 | + return "r1"; | ||
80 | + case PERF_REG_ARM_R2: | ||
81 | + return "r2"; | ||
82 | + case PERF_REG_ARM_R3: | ||
83 | + return "r3"; | ||
84 | + case PERF_REG_ARM_R4: | ||
85 | + return "r4"; | ||
86 | + case PERF_REG_ARM_R5: | ||
87 | + return "r5"; | ||
88 | + case PERF_REG_ARM_R6: | ||
89 | + return "r6"; | ||
90 | + case PERF_REG_ARM_R7: | ||
91 | + return "r7"; | ||
92 | + case PERF_REG_ARM_R8: | ||
93 | + return "r8"; | ||
94 | + case PERF_REG_ARM_R9: | ||
95 | + return "r9"; | ||
96 | + case PERF_REG_ARM_R10: | ||
97 | + return "r10"; | ||
98 | + case PERF_REG_ARM_FP: | ||
99 | + return "fp"; | ||
100 | + case PERF_REG_ARM_IP: | ||
101 | + return "ip"; | ||
102 | + case PERF_REG_ARM_SP: | ||
103 | + return "sp"; | ||
104 | + case PERF_REG_ARM_LR: | ||
105 | + return "lr"; | ||
106 | + case PERF_REG_ARM_PC: | ||
107 | + return "pc"; | ||
108 | + default: | ||
109 | + return NULL; | ||
110 | + } | ||
111 | + | ||
112 | + return NULL; | ||
113 | +} | ||
114 | + | ||
115 | +#endif /* ARCH_PERF_REGS_H */ | ||
116 | diff --git a/tools/perf/arch/arm/util/unwind.c b/tools/perf/arch/arm/util/unwind.c | ||
117 | new file mode 100644 | ||
118 | index 0000000..da3dc95 | ||
119 | --- /dev/null | ||
120 | +++ b/tools/perf/arch/arm/util/unwind.c | ||
121 | @@ -0,0 +1,48 @@ | ||
122 | + | ||
123 | +#include <errno.h> | ||
124 | +#include <libunwind.h> | ||
125 | +#include "perf_regs.h" | ||
126 | +#include "../../util/unwind.h" | ||
127 | + | ||
128 | +int unwind__arch_reg_id(int regnum) | ||
129 | +{ | ||
130 | + switch (regnum) { | ||
131 | + case UNW_ARM_R0: | ||
132 | + return PERF_REG_ARM_R0; | ||
133 | + case UNW_ARM_R1: | ||
134 | + return PERF_REG_ARM_R1; | ||
135 | + case UNW_ARM_R2: | ||
136 | + return PERF_REG_ARM_R2; | ||
137 | + case UNW_ARM_R3: | ||
138 | + return PERF_REG_ARM_R3; | ||
139 | + case UNW_ARM_R4: | ||
140 | + return PERF_REG_ARM_R4; | ||
141 | + case UNW_ARM_R5: | ||
142 | + return PERF_REG_ARM_R5; | ||
143 | + case UNW_ARM_R6: | ||
144 | + return PERF_REG_ARM_R6; | ||
145 | + case UNW_ARM_R7: | ||
146 | + return PERF_REG_ARM_R7; | ||
147 | + case UNW_ARM_R8: | ||
148 | + return PERF_REG_ARM_R8; | ||
149 | + case UNW_ARM_R9: | ||
150 | + return PERF_REG_ARM_R9; | ||
151 | + case UNW_ARM_R10: | ||
152 | + return PERF_REG_ARM_R10; | ||
153 | + case UNW_ARM_R11: | ||
154 | + return PERF_REG_ARM_FP; | ||
155 | + case UNW_ARM_R12: | ||
156 | + return PERF_REG_ARM_IP; | ||
157 | + case UNW_ARM_R13: | ||
158 | + return PERF_REG_ARM_SP; | ||
159 | + case UNW_ARM_R14: | ||
160 | + return PERF_REG_ARM_LR; | ||
161 | + case UNW_ARM_R15: | ||
162 | + return PERF_REG_ARM_PC; | ||
163 | + default: | ||
164 | + pr_err("unwind: invalid reg id %d\n", regnum); | ||
165 | + return -EINVAL; | ||
166 | + } | ||
167 | + | ||
168 | + return -EINVAL; | ||
169 | +} | ||
170 | -- | ||
171 | 1.9.1 | ||
172 | |||
diff --git a/recipes/packagegroup/packagegroup-b2qt-embedded-tools.bb b/recipes/packagegroup/packagegroup-b2qt-embedded-tools.bb index bce34ab..abd2d66 100644 --- a/recipes/packagegroup/packagegroup-b2qt-embedded-tools.bb +++ b/recipes/packagegroup/packagegroup-b2qt-embedded-tools.bb | |||
@@ -31,4 +31,5 @@ RDEPENDS_${PN} = "\ | |||
31 | binutils \ | 31 | binutils \ |
32 | binutils-symlinks \ | 32 | binutils-symlinks \ |
33 | i2c-tools \ | 33 | i2c-tools \ |
34 | perf \ | ||
34 | " | 35 | " |
diff --git a/recipes/perf/perf.bbappend b/recipes/perf/perf.bbappend new file mode 100644 index 0000000..1eec18d --- /dev/null +++ b/recipes/perf/perf.bbappend | |||
@@ -0,0 +1,2 @@ | |||
1 | PERF_FEATURES_ENABLE = "perf-libunwind" | ||
2 | EXTRA_OEMAKE_remove = "NO_DWARF=1" | ||