diff options
author | Jungseok Lee <jungseoklee85@gmail.com> | 2015-10-17 10:28:11 -0400 |
---|---|---|
committer | Catalin Marinas <catalin.marinas@arm.com> | 2015-10-19 13:51:52 -0400 |
commit | 9f93f3e9461a30f425fdba15784db67ce878ce00 (patch) | |
tree | e10ac4b4f0304701b68123c2ff56194c26c60b96 | |
parent | 096b3224d5e7239ec3e5033bbc7612ac2d5dec3a (diff) |
arm64: Synchronise dump_backtrace() with perf callchain
Unlike perf callchain relying on walk_stackframe(), dump_backtrace()
has its own backtrace logic. A major difference between them is the
moment a symbol is recorded. Perf writes down a symbol *before*
calling unwind_frame(), but dump_backtrace() prints it out *after*
unwind_frame(). As a result, the last valid symbol cannot be hooked
in case of dump_backtrace(). This patch addresses the issue as
synchronising dump_backtrace() with perf callchain.
A simple test and its results are as follows:
- crash trigger
$ sudo echo c > /proc/sysrq-trigger
- current status
Call trace:
[<fffffe00003dc738>] sysrq_handle_crash+0x24/0x30
[<fffffe00003dd2ac>] __handle_sysrq+0x128/0x19c
[<fffffe00003dd730>] write_sysrq_trigger+0x60/0x74
[<fffffe0000249fc4>] proc_reg_write+0x84/0xc0
[<fffffe00001f2638>] __vfs_write+0x44/0x104
[<fffffe00001f2e60>] vfs_write+0x98/0x1a8
[<fffffe00001f3730>] SyS_write+0x50/0xb0
- with this change
Call trace:
[<fffffe00003dc738>] sysrq_handle_crash+0x24/0x30
[<fffffe00003dd2ac>] __handle_sysrq+0x128/0x19c
[<fffffe00003dd730>] write_sysrq_trigger+0x60/0x74
[<fffffe0000249fc4>] proc_reg_write+0x84/0xc0
[<fffffe00001f2638>] __vfs_write+0x44/0x104
[<fffffe00001f2e60>] vfs_write+0x98/0x1a8
[<fffffe00001f3730>] SyS_write+0x50/0xb0
[<fffffe00000939ec>] el0_svc_naked+0x20/0x28
Note that this patch does not cover a case where MMU is disabled. The
last stack frame of swapper, for example, has PC in a form of physical
address. Unfortunately, a simple conversion using phys_to_virt() cannot
cover all scenarios since PC is retrieved from LR - 4, not LR. It is
a big tradeoff to change both head.S and unwind_frame() for only a few
of symbols in *.S. Thus, this hunk does not take care of the case.
Cc: AKASHI Takahiro <takahiro.akashi@linaro.org>
Cc: James Morse <james.morse@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Jungseok Lee <jungseoklee85@gmail.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
-rw-r--r-- | arch/arm64/kernel/traps.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index f93aae5e4307..e9b9b5364393 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c | |||
@@ -103,12 +103,12 @@ static void dump_mem(const char *lvl, const char *str, unsigned long bottom, | |||
103 | set_fs(fs); | 103 | set_fs(fs); |
104 | } | 104 | } |
105 | 105 | ||
106 | static void dump_backtrace_entry(unsigned long where, unsigned long stack) | 106 | static void dump_backtrace_entry(unsigned long where) |
107 | { | 107 | { |
108 | /* | ||
109 | * Note that 'where' can have a physical address, but it's not handled. | ||
110 | */ | ||
108 | print_ip_sym(where); | 111 | print_ip_sym(where); |
109 | if (in_exception_text(where)) | ||
110 | dump_mem("", "Exception stack", stack, | ||
111 | stack + sizeof(struct pt_regs), false); | ||
112 | } | 112 | } |
113 | 113 | ||
114 | static void dump_instr(const char *lvl, struct pt_regs *regs) | 114 | static void dump_instr(const char *lvl, struct pt_regs *regs) |
@@ -172,12 +172,17 @@ static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk) | |||
172 | pr_emerg("Call trace:\n"); | 172 | pr_emerg("Call trace:\n"); |
173 | while (1) { | 173 | while (1) { |
174 | unsigned long where = frame.pc; | 174 | unsigned long where = frame.pc; |
175 | unsigned long stack; | ||
175 | int ret; | 176 | int ret; |
176 | 177 | ||
178 | dump_backtrace_entry(where); | ||
177 | ret = unwind_frame(&frame); | 179 | ret = unwind_frame(&frame); |
178 | if (ret < 0) | 180 | if (ret < 0) |
179 | break; | 181 | break; |
180 | dump_backtrace_entry(where, frame.sp); | 182 | stack = frame.sp; |
183 | if (in_exception_text(where)) | ||
184 | dump_mem("", "Exception stack", stack, | ||
185 | stack + sizeof(struct pt_regs), false); | ||
181 | } | 186 | } |
182 | } | 187 | } |
183 | 188 | ||