From: Jean Pihet jean.pihet@newoldbits.com
This patch implements the functions required for the perf registers API, allowing the perf tool to interface kernel register dumps with libunwind in order to provide userspace backtracing. Only the general purpose user space registers are exported, i.e.: PERF_REG_ARM_X0, ... PERF_REG_ARM_X28, PERF_REG_ARM_FP, PERF_REG_ARM_LR, PERF_REG_ARM_SP, PERF_REG_ARM_PC and not the PERF_REG_ARM_V* registers.
Dependencies: . if present, libunwind >= 1.1 is needed to prevent a segfault when parsing the dwarf info, . libunwind needs to be configured with --enable-debug-frame. Note: --enable-debug-frame is automatically selected on ARM, NOT on ARM64.
The generated perf binary has been tested on ARMv8 (using the foundation model simulator) and x86_64, using the following commands: perf record -g [fp,dwarf] -- <binary> perf report --sort symbol --call-graph --stdio
Jean Pihet (2): ARM64: perf: add support for perf registers API ARM64: perf: wire up perf_regs and unwind support
arch/arm64/Kconfig | 2 + arch/arm64/include/uapi/asm/Kbuild | 1 + arch/arm64/include/uapi/asm/perf_regs.h | 40 ++++++++++++++ arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/perf_regs.c | 29 ++++++++++ tools/perf/arch/arm64/Makefile | 7 +++ tools/perf/arch/arm64/include/perf_regs.h | 88 +++++++++++++++++++++++++++++++ tools/perf/arch/arm64/util/dwarf-regs.c | 81 ++++++++++++++++++++++++++++ tools/perf/arch/arm64/util/unwind.c | 82 ++++++++++++++++++++++++++++ tools/perf/config/Makefile | 6 +++ 10 files changed, 337 insertions(+) create mode 100644 arch/arm64/include/uapi/asm/perf_regs.h create mode 100644 arch/arm64/kernel/perf_regs.c create mode 100644 tools/perf/arch/arm64/Makefile create mode 100644 tools/perf/arch/arm64/include/perf_regs.h create mode 100644 tools/perf/arch/arm64/util/dwarf-regs.c create mode 100644 tools/perf/arch/arm64/util/unwind.c
From: Jean Pihet jean.pihet@newoldbits.com
This patch implements the functions required for the perf registers API, allowing the perf tool to interface kernel register dumps with libunwind in order to provide userspace backtracing. Only the general purpose user space registers are exported, i.e.: PERF_REG_ARM_X0, ... PERF_REG_ARM_X28, PERF_REG_ARM_FP, PERF_REG_ARM_LR, PERF_REG_ARM_SP, PERF_REG_ARM_PC and not the PERF_REG_ARM_V* registers.
Signed-off-by: Jean Pihet jean.pihet@linaro.org Cc: Will Deacon will.deacon@arm.com --- arch/arm64/Kconfig | 2 ++ arch/arm64/include/uapi/asm/Kbuild | 1 + arch/arm64/include/uapi/asm/perf_regs.h | 40 +++++++++++++++++++++++++++++++++ arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/perf_regs.c | 29 ++++++++++++++++++++++++ 5 files changed, 73 insertions(+) create mode 100644 arch/arm64/include/uapi/asm/perf_regs.h create mode 100644 arch/arm64/kernel/perf_regs.c
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index c044548..9bb5bc0 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -26,6 +26,8 @@ config ARM64 select HAVE_HW_BREAKPOINT if PERF_EVENTS select HAVE_MEMBLOCK select HAVE_PERF_EVENTS + select HAVE_PERF_REGS + select HAVE_PERF_USER_STACK_DUMP select IRQ_DOMAIN select MODULES_USE_ELF_RELA select NO_BOOTMEM diff --git a/arch/arm64/include/uapi/asm/Kbuild b/arch/arm64/include/uapi/asm/Kbuild index e4b78bd..942376d 100644 --- a/arch/arm64/include/uapi/asm/Kbuild +++ b/arch/arm64/include/uapi/asm/Kbuild @@ -9,6 +9,7 @@ header-y += byteorder.h header-y += fcntl.h header-y += hwcap.h header-y += kvm_para.h +header-y += perf_regs.h header-y += param.h header-y += ptrace.h header-y += setup.h diff --git a/arch/arm64/include/uapi/asm/perf_regs.h b/arch/arm64/include/uapi/asm/perf_regs.h new file mode 100644 index 0000000..06bf360 --- /dev/null +++ b/arch/arm64/include/uapi/asm/perf_regs.h @@ -0,0 +1,40 @@ +#ifndef _ASM_ARM_PERF_REGS_H +#define _ASM_ARM_PERF_REGS_H + +enum perf_event_arm_regs { + PERF_REG_ARM_X0, + PERF_REG_ARM_X1, + PERF_REG_ARM_X2, + PERF_REG_ARM_X3, + PERF_REG_ARM_X4, + PERF_REG_ARM_X5, + PERF_REG_ARM_X6, + PERF_REG_ARM_X7, + PERF_REG_ARM_X8, + PERF_REG_ARM_X9, + PERF_REG_ARM_X10, + PERF_REG_ARM_X11, + PERF_REG_ARM_X12, + PERF_REG_ARM_X13, + PERF_REG_ARM_X14, + PERF_REG_ARM_X15, + PERF_REG_ARM_X16, + PERF_REG_ARM_X17, + PERF_REG_ARM_X18, + PERF_REG_ARM_X19, + PERF_REG_ARM_X20, + PERF_REG_ARM_X21, + PERF_REG_ARM_X22, + PERF_REG_ARM_X23, + PERF_REG_ARM_X24, + PERF_REG_ARM_X25, + PERF_REG_ARM_X26, + PERF_REG_ARM_X27, + PERF_REG_ARM_X28, + PERF_REG_ARM_FP, + PERF_REG_ARM_LR, + PERF_REG_ARM_SP, + PERF_REG_ARM_PC, + PERF_REG_ARM_MAX, +}; +#endif /* _ASM_ARM_PERF_REGS_H */ diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index 7b4b564..c42df09 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -15,6 +15,7 @@ arm64-obj-$(CONFIG_COMPAT) += sys32.o kuser32.o signal32.o \ sys_compat.o arm64-obj-$(CONFIG_MODULES) += arm64ksyms.o module.o arm64-obj-$(CONFIG_SMP) += smp.o smp_spin_table.o smp_psci.o +arm64-obj-$(CONFIG_PERF_EVENTS) += perf_regs.o arm64-obj-$(CONFIG_HW_PERF_EVENTS) += perf_event.o arm64-obj-$(CONFIG_HAVE_HW_BREAKPOINT)+= hw_breakpoint.o arm64-obj-$(CONFIG_EARLY_PRINTK) += early_printk.o diff --git a/arch/arm64/kernel/perf_regs.c b/arch/arm64/kernel/perf_regs.c new file mode 100644 index 0000000..bbcf63c --- /dev/null +++ b/arch/arm64/kernel/perf_regs.c @@ -0,0 +1,29 @@ +#include <linux/errno.h> +#include <linux/kernel.h> +#include <linux/perf_event.h> +#include <linux/bug.h> +#include <asm/perf_regs.h> +#include <asm/ptrace.h> + +u64 perf_reg_value(struct pt_regs *regs, int idx) +{ + if (WARN_ON_ONCE((u32)idx >= PERF_REG_ARM_MAX)) + return 0; + + return regs->regs[idx]; +} + +#define REG_RESERVED (~((1ULL << PERF_REG_ARM_MAX) - 1)) + +int perf_reg_validate(u64 mask) +{ + if (!mask || mask & REG_RESERVED) + return -EINVAL; + + return 0; +} + +u64 perf_reg_abi(struct task_struct *task) +{ + return PERF_SAMPLE_REGS_ABI_64; +}
On Fri, Oct 18, 2013 at 03:54:37PM +0100, Jean Pihet wrote:
From: Jean Pihet jean.pihet@newoldbits.com
This patch implements the functions required for the perf registers API, allowing the perf tool to interface kernel register dumps with libunwind in order to provide userspace backtracing. Only the general purpose user space registers are exported, i.e.: PERF_REG_ARM_X0, ... PERF_REG_ARM_X28, PERF_REG_ARM_FP, PERF_REG_ARM_LR, PERF_REG_ARM_SP, PERF_REG_ARM_PC and not the PERF_REG_ARM_V* registers.
[...]
diff --git a/arch/arm64/kernel/perf_regs.c b/arch/arm64/kernel/perf_regs.c new file mode 100644 index 0000000..bbcf63c --- /dev/null +++ b/arch/arm64/kernel/perf_regs.c @@ -0,0 +1,29 @@ +#include <linux/errno.h> +#include <linux/kernel.h> +#include <linux/perf_event.h> +#include <linux/bug.h> +#include <asm/perf_regs.h> +#include <asm/ptrace.h>
+u64 perf_reg_value(struct pt_regs *regs, int idx) +{
- if (WARN_ON_ONCE((u32)idx >= PERF_REG_ARM_MAX))
return 0;
- return regs->regs[idx];
+}
+#define REG_RESERVED (~((1ULL << PERF_REG_ARM_MAX) - 1))
+int perf_reg_validate(u64 mask) +{
- if (!mask || mask & REG_RESERVED)
return -EINVAL;
- return 0;
+}
+u64 perf_reg_abi(struct task_struct *task) +{
- return PERF_SAMPLE_REGS_ABI_64;
+}
You need to deal with compat (AArch32) tasks here too, which means providing something compatible with what we do on arch/arm/ depending on the thread flags.
Will
From: Jean Pihet jean.pihet@newoldbits.com
This patch hooks in the perf_regs and libunwind code for ARM64. The tools/perf/arch/arm64 is created; it contains the arch specific code for DWARF unwinding.
Signed-off-by: Jean Pihet jean.pihet@linaro.org Cc: Will Deacon will.deacon@arm.com --- tools/perf/arch/arm64/Makefile | 7 +++ tools/perf/arch/arm64/include/perf_regs.h | 88 +++++++++++++++++++++++++++++++ tools/perf/arch/arm64/util/dwarf-regs.c | 81 ++++++++++++++++++++++++++++ tools/perf/arch/arm64/util/unwind.c | 82 ++++++++++++++++++++++++++++ tools/perf/config/Makefile | 6 +++ 5 files changed, 264 insertions(+) create mode 100644 tools/perf/arch/arm64/Makefile create mode 100644 tools/perf/arch/arm64/include/perf_regs.h create mode 100644 tools/perf/arch/arm64/util/dwarf-regs.c create mode 100644 tools/perf/arch/arm64/util/unwind.c
diff --git a/tools/perf/arch/arm64/Makefile b/tools/perf/arch/arm64/Makefile new file mode 100644 index 0000000..fe9b61e --- /dev/null +++ b/tools/perf/arch/arm64/Makefile @@ -0,0 +1,7 @@ +ifndef NO_DWARF +PERF_HAVE_DWARF_REGS := 1 +LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o +endif +ifndef NO_LIBUNWIND +LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/unwind.o +endif diff --git a/tools/perf/arch/arm64/include/perf_regs.h b/tools/perf/arch/arm64/include/perf_regs.h new file mode 100644 index 0000000..a8a9683 --- /dev/null +++ b/tools/perf/arch/arm64/include/perf_regs.h @@ -0,0 +1,88 @@ +#ifndef ARCH_PERF_REGS_H +#define ARCH_PERF_REGS_H + +#include <stdlib.h> +#include "../../util/types.h" +#include <asm/perf_regs.h> + +#define PERF_REGS_MASK ((1ULL << PERF_REG_ARM_MAX) - 1) +#define PERF_REG_IP PERF_REG_ARM_PC +#define PERF_REG_SP PERF_REG_ARM_SP + +static inline const char *perf_reg_name(int id) +{ + switch (id) { + case PERF_REG_ARM_X0: + return "x0"; + case PERF_REG_ARM_X1: + return "x1"; + case PERF_REG_ARM_X2: + return "x2"; + case PERF_REG_ARM_X3: + return "x3"; + case PERF_REG_ARM_X4: + return "x4"; + case PERF_REG_ARM_X5: + return "x5"; + case PERF_REG_ARM_X6: + return "x6"; + case PERF_REG_ARM_X7: + return "x7"; + case PERF_REG_ARM_X8: + return "x8"; + case PERF_REG_ARM_X9: + return "x9"; + case PERF_REG_ARM_X10: + return "x10"; + case PERF_REG_ARM_X11: + return "x11"; + case PERF_REG_ARM_X12: + return "x12"; + case PERF_REG_ARM_X13: + return "x13"; + case PERF_REG_ARM_X14: + return "x14"; + case PERF_REG_ARM_X15: + return "x15"; + case PERF_REG_ARM_X16: + return "x16"; + case PERF_REG_ARM_X17: + return "x17"; + case PERF_REG_ARM_X18: + return "x18"; + case PERF_REG_ARM_X19: + return "x19"; + case PERF_REG_ARM_X20: + return "x20"; + case PERF_REG_ARM_X21: + return "x21"; + case PERF_REG_ARM_X22: + return "x22"; + case PERF_REG_ARM_X23: + return "x23"; + case PERF_REG_ARM_X24: + return "x24"; + case PERF_REG_ARM_X25: + return "x25"; + case PERF_REG_ARM_X26: + return "x26"; + case PERF_REG_ARM_X27: + return "x27"; + case PERF_REG_ARM_X28: + return "x28"; + case PERF_REG_ARM_FP: + return "fp"; + case PERF_REG_ARM_SP: + return "sp"; + case PERF_REG_ARM_LR: + return "lr"; + case PERF_REG_ARM_PC: + return "pc"; + default: + return NULL; + } + + return NULL; +} + +#endif /* ARCH_PERF_REGS_H */ diff --git a/tools/perf/arch/arm64/util/dwarf-regs.c b/tools/perf/arch/arm64/util/dwarf-regs.c new file mode 100644 index 0000000..23d319e --- /dev/null +++ b/tools/perf/arch/arm64/util/dwarf-regs.c @@ -0,0 +1,81 @@ +/* + * Mapping of DWARF debug register numbers into register names. + * + * Copyright (C) 2010 Will Deacon, ARM Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include <stddef.h> +#include <dwarf-regs.h> + +struct pt_regs_dwarfnum { + const char *name; + unsigned int dwarfnum; +}; + +#define STR(s) #s +#define REG_DWARFNUM_NAME(r, num) {.name = r, .dwarfnum = num} +#define GPR_DWARFNUM_NAME(num) \ + {.name = STR(%r##num), .dwarfnum = num} +#define REG_DWARFNUM_END {.name = NULL, .dwarfnum = 0} + +/* + * Reference: + * http://infocenter.arm.com/help/topic/com.arm.doc.ihi0057b/IHI0057B_aadwarf64... + */ +static const struct pt_regs_dwarfnum regdwarfnum_table[] = { + GPR_DWARFNUM_NAME(0), + GPR_DWARFNUM_NAME(1), + GPR_DWARFNUM_NAME(2), + GPR_DWARFNUM_NAME(3), + GPR_DWARFNUM_NAME(4), + GPR_DWARFNUM_NAME(5), + GPR_DWARFNUM_NAME(6), + GPR_DWARFNUM_NAME(7), + GPR_DWARFNUM_NAME(8), + GPR_DWARFNUM_NAME(9), + GPR_DWARFNUM_NAME(10), + GPR_DWARFNUM_NAME(11), + GPR_DWARFNUM_NAME(12), + GPR_DWARFNUM_NAME(13), + GPR_DWARFNUM_NAME(14), + GPR_DWARFNUM_NAME(15), + GPR_DWARFNUM_NAME(16), + GPR_DWARFNUM_NAME(17), + GPR_DWARFNUM_NAME(18), + GPR_DWARFNUM_NAME(19), + GPR_DWARFNUM_NAME(20), + GPR_DWARFNUM_NAME(21), + GPR_DWARFNUM_NAME(22), + GPR_DWARFNUM_NAME(23), + GPR_DWARFNUM_NAME(24), + GPR_DWARFNUM_NAME(25), + GPR_DWARFNUM_NAME(26), + GPR_DWARFNUM_NAME(27), + GPR_DWARFNUM_NAME(28), + REG_DWARFNUM_NAME("%fp", 29), + REG_DWARFNUM_NAME("%lr", 30), + REG_DWARFNUM_NAME("%sp", 31), + REG_DWARFNUM_NAME("%pc", 32), + REG_DWARFNUM_END, +}; + +/** + * get_arch_regstr() - lookup register name from it's DWARF register number + * @n: the DWARF register number + * + * get_arch_regstr() returns the name of the register in struct + * regdwarfnum_table from it's DWARF register number. If the register is not + * found in the table, this returns NULL; + */ +const char *get_arch_regstr(unsigned int n) +{ + const struct pt_regs_dwarfnum *roff; + for (roff = regdwarfnum_table; roff->name != NULL; roff++) + if (roff->dwarfnum == n) + return roff->name; + return NULL; +} diff --git a/tools/perf/arch/arm64/util/unwind.c b/tools/perf/arch/arm64/util/unwind.c new file mode 100644 index 0000000..490bd5b --- /dev/null +++ b/tools/perf/arch/arm64/util/unwind.c @@ -0,0 +1,82 @@ + +#include <errno.h> +#include <libunwind.h> +#include "perf_regs.h" +#include "../../util/unwind.h" + +int unwind__arch_reg_id(int regnum) +{ + switch (regnum) { + case UNW_AARCH64_X0: + return PERF_REG_ARM_X0; + case UNW_AARCH64_X1: + return PERF_REG_ARM_X1; + case UNW_AARCH64_X2: + return PERF_REG_ARM_X2; + case UNW_AARCH64_X3: + return PERF_REG_ARM_X3; + case UNW_AARCH64_X4: + return PERF_REG_ARM_X4; + case UNW_AARCH64_X5: + return PERF_REG_ARM_X5; + case UNW_AARCH64_X6: + return PERF_REG_ARM_X6; + case UNW_AARCH64_X7: + return PERF_REG_ARM_X7; + case UNW_AARCH64_X8: + return PERF_REG_ARM_X8; + case UNW_AARCH64_X9: + return PERF_REG_ARM_X9; + case UNW_AARCH64_X10: + return PERF_REG_ARM_X10; + case UNW_AARCH64_X11: + return PERF_REG_ARM_X11; + case UNW_AARCH64_X12: + return PERF_REG_ARM_X12; + case UNW_AARCH64_X13: + return PERF_REG_ARM_X13; + case UNW_AARCH64_X14: + return PERF_REG_ARM_X14; + case UNW_AARCH64_X15: + return PERF_REG_ARM_X15; + case UNW_AARCH64_X16: + return PERF_REG_ARM_X16; + case UNW_AARCH64_X17: + return PERF_REG_ARM_X17; + case UNW_AARCH64_X18: + return PERF_REG_ARM_X18; + case UNW_AARCH64_X19: + return PERF_REG_ARM_X19; + case UNW_AARCH64_X20: + return PERF_REG_ARM_X20; + case UNW_AARCH64_X21: + return PERF_REG_ARM_X21; + case UNW_AARCH64_X22: + return PERF_REG_ARM_X22; + case UNW_AARCH64_X23: + return PERF_REG_ARM_X23; + case UNW_AARCH64_X24: + return PERF_REG_ARM_X24; + case UNW_AARCH64_X25: + return PERF_REG_ARM_X25; + case UNW_AARCH64_X26: + return PERF_REG_ARM_X26; + case UNW_AARCH64_X27: + return PERF_REG_ARM_X27; + case UNW_AARCH64_X28: + return PERF_REG_ARM_X28; + case UNW_AARCH64_X29: + return PERF_REG_ARM_FP; + case UNW_AARCH64_X30: + return PERF_REG_ARM_LR; + case UNW_AARCH64_SP: + return PERF_REG_ARM_SP; + case UNW_AARCH64_PC: + return PERF_REG_ARM_PC; + default: + pr_err("unwind: invalid reg id %d\n", regnum); + return -EINVAL; + } + + return -EINVAL; +} diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 75b93d7..15a69a5 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -29,11 +29,17 @@ ifeq ($(ARCH),x86_64) NO_PERF_REGS := 0 LIBUNWIND_LIBS = -lunwind -lunwind-x86_64 endif + ifeq ($(ARCH),arm) NO_PERF_REGS := 0 LIBUNWIND_LIBS = -lunwind -lunwind-arm endif
+ifeq ($(ARCH),arm64) + NO_PERF_REGS := 0 + LIBUNWIND_LIBS = -lunwind -lunwind-aarch64 +endif + ifeq ($(NO_PERF_REGS),0) CFLAGS += -DHAVE_PERF_REGS endif
On Fri, Oct 18, 2013 at 04:54:38PM +0200, Jean Pihet wrote:
SNIP
- return -EINVAL;
+} diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 75b93d7..15a69a5 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -29,11 +29,17 @@ ifeq ($(ARCH),x86_64) NO_PERF_REGS := 0 LIBUNWIND_LIBS = -lunwind -lunwind-x86_64 endif
ifeq ($(ARCH),arm) NO_PERF_REGS := 0 LIBUNWIND_LIBS = -lunwind -lunwind-arm endif
I dont see above 'ifeq' in acme's or in tip tree, so hunk below fails to apply.. what tree was this based on?
otherwise the change looks good to me
jirka
Hi Jiri, Will,
On 24 October 2013 16:50, Jiri Olsa jolsa@redhat.com wrote:
On Fri, Oct 18, 2013 at 04:54:38PM +0200, Jean Pihet wrote:
SNIP
return -EINVAL;
+} diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 75b93d7..15a69a5 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -29,11 +29,17 @@ ifeq ($(ARCH),x86_64) NO_PERF_REGS := 0 LIBUNWIND_LIBS = -lunwind -lunwind-x86_64 endif
ifeq ($(ARCH),arm) NO_PERF_REGS := 0 LIBUNWIND_LIBS = -lunwind -lunwind-arm endif
I dont see above 'ifeq' in acme's or in tip tree, so hunk below fails to apply.. what tree was this based on?
I am using 3.12-rc4. Let me rebase on the latest mainline.
Will, what do you think? I will post a rebased version asap.
otherwise the change looks good to me
Great, thanks for reviewing!
jirka
Jean
Hi Jean,
I have applied this patchset on aarch64 upstream branch,cross-compiled for arm64 and try running some tests for hardware breakpoints.
I cross-compiled perf using linaro toolchain "gcc-linaro-aarch64-linux-gnu-4.7-2013.04-20130415_linux" as $ cd tools/perf/ $ make LDFLAGS=-static ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
Copied the static binary to my initrd image and tried running tests to place hw_breakpoint on an kernel symbol as:
# perf record -e "mem:0xffffffc00013f640:x" 737 738 usage: perf record [<options>] [<command>] 739 or: perf record [<options>] -- <command> [<options>] 740 741 -e, --event <event> event selector. use 'perf list' to list available events 742 --filter <filter> 743 event filter 744 -p, --pid <pid> record events on existing process id .....
Somehow perf is not able run record, seems not accepting any arguments. Do you have any idea what could be going wrong? How did you verify/cross-compile perf? Is the tool-chain version wrong?
Thanks, Sandeepa
On 18 October 2013 20:24, Jean Pihet jean.pihet@linaro.org wrote:
From: Jean Pihet jean.pihet@newoldbits.com
This patch implements the functions required for the perf registers API, allowing the perf tool to interface kernel register dumps with libunwind in order to provide userspace backtracing. Only the general purpose user space registers are exported, i.e.: PERF_REG_ARM_X0, ... PERF_REG_ARM_X28, PERF_REG_ARM_FP, PERF_REG_ARM_LR, PERF_REG_ARM_SP, PERF_REG_ARM_PC and not the PERF_REG_ARM_V* registers.
Dependencies: . if present, libunwind >= 1.1 is needed to prevent a segfault when parsing the dwarf info, . libunwind needs to be configured with --enable-debug-frame. Note: --enable-debug-frame is automatically selected on ARM, NOT on ARM64.
The generated perf binary has been tested on ARMv8 (using the foundation model simulator) and x86_64, using the following commands: perf record -g [fp,dwarf] -- <binary> perf report --sort symbol --call-graph --stdio
Jean Pihet (2): ARM64: perf: add support for perf registers API ARM64: perf: wire up perf_regs and unwind support
arch/arm64/Kconfig | 2 + arch/arm64/include/uapi/asm/Kbuild | 1 + arch/arm64/include/uapi/asm/perf_regs.h | 40 ++++++++++++++ arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/perf_regs.c | 29 ++++++++++ tools/perf/arch/arm64/Makefile | 7 +++ tools/perf/arch/arm64/include/perf_regs.h | 88 +++++++++++++++++++++++++++++++ tools/perf/arch/arm64/util/dwarf-regs.c | 81 ++++++++++++++++++++++++++++ tools/perf/arch/arm64/util/unwind.c | 82 ++++++++++++++++++++++++++++ tools/perf/config/Makefile | 6 +++ 10 files changed, 337 insertions(+) create mode 100644 arch/arm64/include/uapi/asm/perf_regs.h create mode 100644 arch/arm64/kernel/perf_regs.c create mode 100644 tools/perf/arch/arm64/Makefile create mode 100644 tools/perf/arch/arm64/include/perf_regs.h create mode 100644 tools/perf/arch/arm64/util/dwarf-regs.c create mode 100644 tools/perf/arch/arm64/util/unwind.c
-- 1.7.11.7
-- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Hi Sandeepa,
On Thu, Nov 14, 2013 at 12:04 PM, Sandeepa Prabhu sandeepa.prabhu@linaro.org wrote:
Hi Jean,
I have applied this patchset on aarch64 upstream branch,cross-compiled for arm64 and try running some tests for hardware breakpoints.
I cross-compiled perf using linaro toolchain "gcc-linaro-aarch64-linux-gnu-4.7-2013.04-20130415_linux" as $ cd tools/perf/ $ make LDFLAGS=-static ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
Copied the static binary to my initrd image and tried running tests to place hw_breakpoint on an kernel symbol as:
# perf record -e "mem:0xffffffc00013f640:x" 737 738 usage: perf record [<options>] [<command>] 739 or: perf record [<options>] -- <command> [<options>] 740 741 -e, --event <event> event selector. use 'perf list' to list available events 742 --filter <filter> 743 event filter 744 -p, --pid <pid> record events on existing process id .....
Somehow perf is not able run record, seems not accepting any arguments. Do you have any idea what could be going wrong?
Is the behavior caused by this very patch set? This patch set is about callchain unwinding, which is unrelated to the hardward breakpoint feature. Is perf list reporting something? Can you check the '-e mem' command correctness?
How did you verify/cross-compile perf? Is the tool-chain version wrong?
Since perf depends on external libraries it is not straight forward to cross compile it. You can compile it as part of a build system (for example an OE based build system), or compile it natively on the target. I am compiling perf and the libraries (libunwind) natively in my case.
Thanks, Sandeepa
Please let me know how it goes.
Jean
On 18 October 2013 20:24, Jean Pihet jean.pihet@linaro.org wrote:
From: Jean Pihet jean.pihet@newoldbits.com
This patch implements the functions required for the perf registers API, allowing the perf tool to interface kernel register dumps with libunwind in order to provide userspace backtracing. Only the general purpose user space registers are exported, i.e.: PERF_REG_ARM_X0, ... PERF_REG_ARM_X28, PERF_REG_ARM_FP, PERF_REG_ARM_LR, PERF_REG_ARM_SP, PERF_REG_ARM_PC and not the PERF_REG_ARM_V* registers.
Dependencies: . if present, libunwind >= 1.1 is needed to prevent a segfault when parsing the dwarf info, . libunwind needs to be configured with --enable-debug-frame. Note: --enable-debug-frame is automatically selected on ARM, NOT on ARM64.
The generated perf binary has been tested on ARMv8 (using the foundation model simulator) and x86_64, using the following commands: perf record -g [fp,dwarf] -- <binary> perf report --sort symbol --call-graph --stdio
Jean Pihet (2): ARM64: perf: add support for perf registers API ARM64: perf: wire up perf_regs and unwind support
arch/arm64/Kconfig | 2 + arch/arm64/include/uapi/asm/Kbuild | 1 + arch/arm64/include/uapi/asm/perf_regs.h | 40 ++++++++++++++ arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/perf_regs.c | 29 ++++++++++ tools/perf/arch/arm64/Makefile | 7 +++ tools/perf/arch/arm64/include/perf_regs.h | 88 +++++++++++++++++++++++++++++++ tools/perf/arch/arm64/util/dwarf-regs.c | 81 ++++++++++++++++++++++++++++ tools/perf/arch/arm64/util/unwind.c | 82 ++++++++++++++++++++++++++++ tools/perf/config/Makefile | 6 +++ 10 files changed, 337 insertions(+) create mode 100644 arch/arm64/include/uapi/asm/perf_regs.h create mode 100644 arch/arm64/kernel/perf_regs.c create mode 100644 tools/perf/arch/arm64/Makefile create mode 100644 tools/perf/arch/arm64/include/perf_regs.h create mode 100644 tools/perf/arch/arm64/util/dwarf-regs.c create mode 100644 tools/perf/arch/arm64/util/unwind.c
-- 1.7.11.7
-- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
On 14 November 2013 16:45, Jean Pihet jean.pihet@newoldbits.com wrote:
Hi Sandeepa,
On Thu, Nov 14, 2013 at 12:04 PM, Sandeepa Prabhu sandeepa.prabhu@linaro.org wrote:
Hi Jean,
I have applied this patchset on aarch64 upstream branch,cross-compiled for arm64 and try running some tests for hardware breakpoints.
I cross-compiled perf using linaro toolchain "gcc-linaro-aarch64-linux-gnu-4.7-2013.04-20130415_linux" as $ cd tools/perf/ $ make LDFLAGS=-static ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
Copied the static binary to my initrd image and tried running tests to place hw_breakpoint on an kernel symbol as:
# perf record -e "mem:0xffffffc00013f640:x" 737 738 usage: perf record [<options>] [<command>] 739 or: perf record [<options>] -- <command> [<options>] 740 741 -e, --event <event> event selector. use 'perf list' to list available events 742 --filter <filter> 743 event filter 744 -p, --pid <pid> record events on existing process id .....
Somehow perf is not able run record, seems not accepting any arguments. Do you have any idea what could be going wrong?
Is the behavior caused by this very patch set? This patch set is about callchain unwinding, which is unrelated to the hardward breakpoint feature. Is perf list reporting something? Can you check the '-e mem' command correctness?
How did you verify/cross-compile perf? Is the tool-chain version wrong?
Since perf depends on external libraries it is not straight forward to cross compile it. You can compile it as part of a build system (for example an OE based build system), or compile it natively on the target. I am compiling perf and the libraries (libunwind) natively in my case.
Hmm, looks like cross-compiling is not good option.
Thanks, Sandeepa
Please let me know how it goes.
Jean
I tried this and workig: # ./perf record -- /bin/ls
214 ^[[1;34mbin^[[0m ^[[0;0mkprobe_dbg_addr.ko^[[0m ^[[1;34mroot^[[0m 215 ^[[1;34mdata^[[0m ^[[0;0mkprobe_dbg_sym.ko^[[0m ^[[1;34msdcard^[[0m 216 ^[[0;0mdata_breakpoint.ko^[[0m ^[[0;0mkprobe_example.ko^[[0m ^[[1;34msys^[[0m 217 ^[[1;36mdebug^[[0m ^[[0;0mkretprobe_example.ko^[[0m ^[[1;34msystem^[[0m 218 ^[[1;34mdev^[[0m ^[[1;32mperf^[[0m ^[[0;0mtext_breakpoint.ko^[[0m 219 ^[[1;34mhome^[[0m ^[[0;0mperf.data^[[0m ^[[1;34mtmp^[[0m 220 ^[[1;32minit^[[0m ^[[0;0mperf.data.old^[[0m 221 ^[[0;0mjprobe_example.ko^[[0m ^[[1;34mproc^[[0m 222 [ perf record: Woken up 1 times to write data ] 223 [ perf record: Captured and wrote 0.002 MB perf.data (~104 samples) ] 224 / #
Also perf list shows "mem" option and checked the command format also correct. [perf record -e "mem:0xffffffc00013f640:x"] In fact none of the options under -e are functioning.
[I had tried without your patchset and behavior was same]
On 18 October 2013 20:24, Jean Pihet jean.pihet@linaro.org wrote:
From: Jean Pihet jean.pihet@newoldbits.com
This patch implements the functions required for the perf registers API, allowing the perf tool to interface kernel register dumps with libunwind in order to provide userspace backtracing. Only the general purpose user space registers are exported, i.e.: PERF_REG_ARM_X0, ... PERF_REG_ARM_X28, PERF_REG_ARM_FP, PERF_REG_ARM_LR, PERF_REG_ARM_SP, PERF_REG_ARM_PC and not the PERF_REG_ARM_V* registers.
Dependencies: . if present, libunwind >= 1.1 is needed to prevent a segfault when parsing the dwarf info, . libunwind needs to be configured with --enable-debug-frame. Note: --enable-debug-frame is automatically selected on ARM, NOT on ARM64.
The generated perf binary has been tested on ARMv8 (using the foundation model simulator) and x86_64, using the following commands: perf record -g [fp,dwarf] -- <binary> perf report --sort symbol --call-graph --stdio
Jean Pihet (2): ARM64: perf: add support for perf registers API ARM64: perf: wire up perf_regs and unwind support
arch/arm64/Kconfig | 2 + arch/arm64/include/uapi/asm/Kbuild | 1 + arch/arm64/include/uapi/asm/perf_regs.h | 40 ++++++++++++++ arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/perf_regs.c | 29 ++++++++++ tools/perf/arch/arm64/Makefile | 7 +++ tools/perf/arch/arm64/include/perf_regs.h | 88 +++++++++++++++++++++++++++++++ tools/perf/arch/arm64/util/dwarf-regs.c | 81 ++++++++++++++++++++++++++++ tools/perf/arch/arm64/util/unwind.c | 82 ++++++++++++++++++++++++++++ tools/perf/config/Makefile | 6 +++ 10 files changed, 337 insertions(+) create mode 100644 arch/arm64/include/uapi/asm/perf_regs.h create mode 100644 arch/arm64/kernel/perf_regs.c create mode 100644 tools/perf/arch/arm64/Makefile create mode 100644 tools/perf/arch/arm64/include/perf_regs.h create mode 100644 tools/perf/arch/arm64/util/dwarf-regs.c create mode 100644 tools/perf/arch/arm64/util/unwind.c
-- 1.7.11.7
-- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
On Thu, Nov 14, 2013 at 11:04:04AM +0000, Sandeepa Prabhu wrote:
Hi Jean,
I have applied this patchset on aarch64 upstream branch,cross-compiled for arm64 and try running some tests for hardware breakpoints.
I cross-compiled perf using linaro toolchain "gcc-linaro-aarch64-linux-gnu-4.7-2013.04-20130415_linux" as $ cd tools/perf/ $ make LDFLAGS=-static ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
Copied the static binary to my initrd image and tried running tests to place hw_breakpoint on an kernel symbol as:
# perf record -e "mem:0xffffffc00013f640:x"
Right, but that's not a valid invocation of perf. You have to give it something to record. Something like:
# perf record -e mem:0xffffffc00013f640:x -a -- sleep 10
for example.
Will
On 15 November 2013 22:12, Will Deacon will.deacon@arm.com wrote:
On Thu, Nov 14, 2013 at 11:04:04AM +0000, Sandeepa Prabhu wrote:
Hi Jean,
I have applied this patchset on aarch64 upstream branch,cross-compiled for arm64 and try running some tests for hardware breakpoints.
I cross-compiled perf using linaro toolchain "gcc-linaro-aarch64-linux-gnu-4.7-2013.04-20130415_linux" as $ cd tools/perf/ $ make LDFLAGS=-static ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
Copied the static binary to my initrd image and tried running tests to place hw_breakpoint on an kernel symbol as:
# perf record -e "mem:0xffffffc00013f640:x"
Right, but that's not a valid invocation of perf. You have to give it something to record. Something like:
# perf record -e mem:0xffffffc00013f640:x -a -- sleep 10
Hi Will,
Thanks for correcting me, now I see perf record working :)
~Sandeepa
for example.
Will
linaro-kernel@lists.linaro.org