Skip to contentSkip to conversation

add perf-probe support on ARM

PATCH New Will Deacon 3 participants 7 messages Jun 23, 2010 – Jun 25, 2010

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover add perf-probe support on ARM

Perf-probe uses the KProbe events tracer to place and monitor probes on the running Kernel.

This patch series adds both Kernel and tool support for this feature on ARM.

Patches based on 2.6.35-rc3 [although perf record is currently broken on all architectures for probe tracepoints. These patches also apply cleanly to -tip/master where perf record works properly.]

Cc Jamie Iles <[email protected]>
Cc Jean Pihet <[email protected]>

Will Deacon (2):
ARM: Add kprobe-based event tracer
ARM: perf probe: Add ARM DWARF register number mappings

 arch/arm/Kconfig                      |    1 +
 arch/arm/include/asm/ptrace.h         |   36 ++++++++++++
 arch/arm/kernel/ptrace.c              |   96 +++++++++++++++++++++++++++++++++
 tools/perf/arch/arm/Makefile          |    4 ++
 tools/perf/arch/arm/util/dwarf-regs.c |   64 ++++++++++++++++++++++
 5 files changed, 201 insertions(+), 0 deletions(-)
 create mode 100644 tools/perf/arch/arm/Makefile
 create mode 100644 tools/perf/arch/arm/util/dwarf-regs.c
#1 lore raw

PATCH 1/2 ARM: Add kprobe-based event tracer

This patch enables the HAVE_REGS_AND_STACK_ACCESS_API option for ARM which is required by the kprobe events tracer. Code based on the PowerPC port.

Cc Jamie Iles <[email protected]>
Cc Jean Pihet <[email protected]>
---
 arch/arm/Kconfig              |    1 +
 arch/arm/include/asm/ptrace.h |   36 +++++++++++++++
 arch/arm/kernel/ptrace.c      |   96 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 133 insertions(+), 0 deletions(-)
arch/arm/Kconfig +1 -0
index e57cb24..e0e7de6 100644
@@ -24,6 +24,7 @@ config ARM
 	select HAVE_KERNEL_LZMA
 	select HAVE_PERF_EVENTS
 	select PERF_USE_VMALLOC
+	select HAVE_REGS_AND_STACK_ACCESS_API
 	help
 	  The ARM series is a line of low-power-consumption RISC chip designs
 	  licensed by ARM Ltd and targeted at embedded applications and
arch/arm/include/asm/ptrace.h +36 -0
index 9dcb11e..c974be8 100644
@@ -184,6 +184,42 @@ extern unsigned long profile_pc(struct pt_regs *regs);
 #define predicate(x)		((x) & 0xf0000000)
 #define PREDICATE_ALWAYS	0xe0000000
 
+/*
+ * kprobe-based event tracer support
+ */
+#include <linux/stddef.h>
+#include <linux/types.h>
+#define MAX_REG_OFFSET (offsetof(struct pt_regs, ARM_ORIG_r0))
+
+extern int regs_query_register_offset(const char *name);
+extern const char *regs_query_register_name(unsigned int offset);
+extern bool regs_within_kernel_stack(struct pt_regs *regs, unsigned long addr);
+extern unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs,
+					       unsigned int n);
+
+/**
+ * regs_get_register() - get register value from its offset
+ * @regs:	   pt_regs from which register value is gotten
+ * @offset:    offset number of the register.
+ *
+ * regs_get_register returns the value of a register whose offset from @regs.
+ * The @offset is the offset of the register in struct pt_regs.
+ * If @offset is bigger than MAX_REG_OFFSET, this returns 0.
+ */
+static inline unsigned long regs_get_register(struct pt_regs *regs,
+					      unsigned int offset)
+{
+	if (unlikely(offset > MAX_REG_OFFSET))
+		return 0;
+	return *(unsigned long *)((unsigned long)regs + offset);
+}
+
+/* Valid only for Kernel mode traps. */
+static inline unsigned long kernel_stack_pointer(struct pt_regs *regs)
+{
+	return regs->ARM_sp;
+}
+
 #endif /* __KERNEL__ */
 
 #endif /* __ASSEMBLY__ */
arch/arm/kernel/ptrace.c +96 -0

102 lines not on this page · raw message

Signature · 1 line
1.6.3.3
#2 lore raw

PATCH 2/2 ARM: perf probe: Add ARM DWARF register number mappings

This patch adds mappings from DWARF register numbers to the register names used by the ARM `Regs and Stack Access API'.

Cc Jamie Iles <[email protected]>
Cc Jean Pihet <[email protected]>
---
 tools/perf/arch/arm/Makefile          |    4 ++
 tools/perf/arch/arm/util/dwarf-regs.c |   64 +++++++++++++++++++++++++++++++++
 2 files changed, 68 insertions(+), 0 deletions(-)
 create mode 100644 tools/perf/arch/arm/Makefile
 create mode 100644 tools/perf/arch/arm/util/dwarf-regs.c
tools/perf/arch/arm/Makefile new file +4 -0
new file mode 100644
index 0000000..15130b5
@@ -0,0 +1,4 @@
+ifndef NO_DWARF
+PERF_HAVE_DWARF_REGS := 1
+LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o
+endif
tools/perf/arch/arm/util/dwarf-regs.c new file +64 -0

64 lines not on this page · raw message

Signature · 1 line
1.6.3.3
#3 lore raw

cover add perf-probe support on ARM

In reply to Will Deacon
Quoted 17 lines · Will Deacon

Perf-probe uses the KProbe events tracer to place and monitor probes on the running Kernel.

This patch series adds both Kernel and tool support for this feature on ARM.

Patches based on 2.6.35-rc3 [although perf record is currently broken on all architectures for probe tracepoints. These patches also apply cleanly to -tip/master where perf record works properly.]

Cc Jamie Iles <[email protected]>
Cc Jean Pihet <[email protected]>

Will Deacon (2):
ARM: Add kprobe-based event tracer
ARM: perf probe: Add ARM DWARF register number mappings

Quoted 8 lines
 arch/arm/Kconfig                      |    1 +
 arch/arm/include/asm/ptrace.h         |   36 ++++++++++++
 arch/arm/kernel/ptrace.c              |   96 +++++++++++++++++++++++++++++++++
 tools/perf/arch/arm/Makefile          |    4 ++
 tools/perf/arch/arm/util/dwarf-regs.c |   64 ++++++++++++++++++++++
 5 files changed, 201 insertions(+), 0 deletions(-)
 create mode 100644 tools/perf/arch/arm/Makefile
 create mode 100644 tools/perf/arch/arm/util/dwarf-regs.c

Hi Will,

I've had a quick play on an ARMv6 board and these patches look good and appear to work!

Jamie

#4 lore raw

cover add perf-probe support on ARM

Hi Jamie,

Quoted 4 lines

I've had a quick play on an ARMv6 board and these patches look good and appear to work!

Cracking, thanks for this. I'll stick them in the patch system.

Will

#5 lore raw

cover add perf-probe support on ARM

In reply to Will Deacon

Hi Will,

Are more tests needed for ARMv7 (OMAP3430/3530/3517)? I hope to find some time to test it if required.

Regards,
Jean

Quoted 17 lines · Will Deacon

Perf-probe uses the KProbe events tracer to place and monitor probes on the running Kernel.

This patch series adds both Kernel and tool support for this feature on ARM.

Patches based on 2.6.35-rc3 [although perf record is currently broken on all architectures for probe tracepoints. These patches also apply cleanly to -tip/master where perf record works properly.]

Cc Jamie Iles <[email protected]>
Cc Jean Pihet <[email protected]>

Will Deacon (2):
ARM: Add kprobe-based event tracer
ARM: perf probe: Add ARM DWARF register number mappings

Quoted 11 lines
 arch/arm/Kconfig                      |    1 +
 arch/arm/include/asm/ptrace.h         |   36 ++++++++++++
 arch/arm/kernel/ptrace.c              |   96
+++++++++++++++++++++++++++++++++
 tools/perf/arch/arm/Makefile          |    4 ++
 tools/perf/arch/arm/util/dwarf-regs.c |   64 ++++++++++++++++++++++
 5 files changed, 201 insertions(+), 0 deletions(-)
 create mode 100644 tools/perf/arch/arm/Makefile
 create mode 100644 tools/perf/arch/arm/util/dwarf-regs.c

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20100625/61827ff4/attachment.html>

#6 lore raw

cover add perf-probe support on ARM

Quoted 1 line

Hi Will,

Hi Jean,

Quoted 1 line

Are more tests needed for ARMv7 (OMAP3430/3530/3517)? I hope to find some time to test it if required.

The patches don't do anything special for the different architectures and I've tried it on a quad-core A9 board so I don't think you're required to test it as well. Having said that, it's a pretty neat tool so you might want to have a play :)

Thanks,

Will