Skip to content

Commit 90fa9de

Browse files
Jean Pihetolsajiri
authored andcommitted
perf tests: Add dwarf unwind test on ARM
Adding dwarf unwind test, that setups live machine data over the perf test thread and does the remote unwind. Need to use -fno-optimize-sibling-calls for test compilation, otherwise 'krava_*' function calls are optimized into jumps and omitted from the stack unwind. So far it was enabled only for x86. Signed-off-by: Jean Pihet <jean.pihet@linaro.org> Reviewed-by: Will Deacon <will.deacon@arm.com> Cc: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1400229672-16104-3-git-send-email-jean.pihet@linaro.org Signed-off-by: Jiri Olsa <jolsa@kernel.org>
1 parent 3418f96 commit 90fa9de

7 files changed

Lines changed: 69 additions & 5 deletions

File tree

‎tools/perf/Makefile.perf‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ LIB_OBJS += $(OUTPUT)tests/code-reading.o
411411
LIB_OBJS += $(OUTPUT)tests/sample-parsing.o
412412
LIB_OBJS += $(OUTPUT)tests/parse-no-sample-id-all.o
413413
ifndef NO_DWARF_UNWIND
414-
ifeq ($(ARCH),x86)
414+
ifeq ($(ARCH),$(filter $(ARCH),x86 arm))
415415
LIB_OBJS += $(OUTPUT)tests/dwarf-unwind.o
416416
endif
417417
endif

‎tools/perf/arch/arm/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ endif
55
ifndef NO_LIBUNWIND
66
LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/unwind-libunwind.o
77
LIB_OBJS += $(OUTPUT)arch/$(ARCH)/tests/regs_load.o
8+
LIB_OBJS += $(OUTPUT)arch/$(ARCH)/tests/dwarf-unwind.o
89
endif

‎tools/perf/arch/arm/include/perf_regs.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
void perf_regs_load(u64 *regs);
99

1010
#define PERF_REGS_MASK ((1ULL << PERF_REG_ARM_MAX) - 1)
11+
#define PERF_REGS_MAX PERF_REG_ARM_MAX
12+
#define PERF_SAMPLE_REGS_ABI PERF_SAMPLE_REGS_ABI_32
13+
1114
#define PERF_REG_IP PERF_REG_ARM_PC
1215
#define PERF_REG_SP PERF_REG_ARM_SP
1316

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#include <string.h>
2+
#include "perf_regs.h"
3+
#include "thread.h"
4+
#include "map.h"
5+
#include "event.h"
6+
#include "tests/tests.h"
7+
8+
#define STACK_SIZE 8192
9+
10+
static int sample_ustack(struct perf_sample *sample,
11+
struct thread *thread, u64 *regs)
12+
{
13+
struct stack_dump *stack = &sample->user_stack;
14+
struct map *map;
15+
unsigned long sp;
16+
u64 stack_size, *buf;
17+
18+
buf = malloc(STACK_SIZE);
19+
if (!buf) {
20+
pr_debug("failed to allocate sample uregs data\n");
21+
return -1;
22+
}
23+
24+
sp = (unsigned long) regs[PERF_REG_ARM_SP];
25+
26+
map = map_groups__find(thread->mg, MAP__VARIABLE, (u64) sp);
27+
if (!map) {
28+
pr_debug("failed to get stack map\n");
29+
free(buf);
30+
return -1;
31+
}
32+
33+
stack_size = map->end - sp;
34+
stack_size = stack_size > STACK_SIZE ? STACK_SIZE : stack_size;
35+
36+
memcpy(buf, (void *) sp, stack_size);
37+
stack->data = (char *) buf;
38+
stack->size = stack_size;
39+
return 0;
40+
}
41+
42+
int test__arch_unwind_sample(struct perf_sample *sample,
43+
struct thread *thread)
44+
{
45+
struct regs_dump *regs = &sample->user_regs;
46+
u64 *buf;
47+
48+
buf = calloc(1, sizeof(u64) * PERF_REGS_MAX);
49+
if (!buf) {
50+
pr_debug("failed to allocate sample uregs data\n");
51+
return -1;
52+
}
53+
54+
perf_regs_load(buf);
55+
regs->abi = PERF_SAMPLE_REGS_ABI;
56+
regs->regs = buf;
57+
regs->mask = PERF_REGS_MASK;
58+
59+
return sample_ustack(sample, thread, buf);
60+
}

‎tools/perf/config/Makefile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ ifeq ($(ARCH),arm64)
4040
LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
4141
endif
4242

43-
# So far there's only x86 libdw unwind support merged in perf.
43+
# So far there's only x86 and arm libdw unwind support merged in perf.
4444
# Disable it on all other architectures in case libdw unwind
4545
# support is detected in system. Add supported architectures
4646
# to the check.
47-
ifneq ($(ARCH),x86)
47+
ifneq ($(ARCH),$(filter $(ARCH),x86 arm))
4848
NO_LIBDW_DWARF_UNWIND := 1
4949
endif
5050

‎tools/perf/tests/builtin-test.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static struct test {
115115
.desc = "Test parsing with no sample_id_all bit set",
116116
.func = test__parse_no_sample_id_all,
117117
},
118-
#if defined(__x86_64__) || defined(__i386__)
118+
#if defined(__x86_64__) || defined(__i386__) || defined(__arm__)
119119
#ifdef HAVE_DWARF_UNWIND_SUPPORT
120120
{
121121
.desc = "Test dwarf unwind",

‎tools/perf/tests/tests.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ int test__hists_filter(void);
4545
int test__mmap_thread_lookup(void);
4646
int test__thread_mg_share(void);
4747

48-
#if defined(__x86_64__) || defined(__i386__)
48+
#if defined(__x86_64__) || defined(__i386__) || defined(__arm__)
4949
#ifdef HAVE_DWARF_UNWIND_SUPPORT
5050
struct thread;
5151
struct perf_sample;

0 commit comments

Comments
 (0)