Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: 9258/1: stacktrace: Make stack walk callback consistent with generic code

As with the generic arch_stack_walk() code the ARM stack walk code takes
a callback that is called per stack frame. Currently the ARM code always
passes a struct stackframe to the callback and the generic code just
passes the pc, however none of the users ever reference anything in the
struct other than the pc value. The ARM code also uses a return type of
int while the generic code uses a return type of bool though in both
cases the return value is a boolean value and the sense is inverted
between the two.

In order to reduce code duplication when ARM is converted to use
arch_stack_walk() change the signature and return sense of the ARM
specific callback to match that of the generic code.

Signed-off-by: Li Huafei <lihuafei1@huawei.com>
Reviewed-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Linus Waleij <linus.walleij@linaro.org>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

authored by

Li Huafei and committed by
Russell King (Oracle)
70ccc7c0 1d2e9b67

+15 -17
+1 -1
arch/arm/include/asm/stacktrace.h
··· 44 44 45 45 extern int unwind_frame(struct stackframe *frame); 46 46 extern void walk_stackframe(struct stackframe *frame, 47 - int (*fn)(struct stackframe *, void *), void *data); 47 + bool (*fn)(void *, unsigned long), void *data); 48 48 extern void dump_mem(const char *lvl, const char *str, unsigned long bottom, 49 49 unsigned long top); 50 50 extern void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk,
+4 -5
arch/arm/kernel/perf_callchain.c
··· 81 81 * whist unwinding the stackframe and is like a subroutine return so we use 82 82 * the PC. 83 83 */ 84 - static int 85 - callchain_trace(struct stackframe *fr, 86 - void *data) 84 + static bool 85 + callchain_trace(void *data, unsigned long pc) 87 86 { 88 87 struct perf_callchain_entry_ctx *entry = data; 89 - perf_callchain_store(entry, fr->pc); 90 - return 0; 88 + perf_callchain_store(entry, pc); 89 + return true; 91 90 } 92 91 93 92 void
+4 -4
arch/arm/kernel/return_address.c
··· 16 16 void *addr; 17 17 }; 18 18 19 - static int save_return_addr(struct stackframe *frame, void *d) 19 + static bool save_return_addr(void *d, unsigned long pc) 20 20 { 21 21 struct return_address_data *data = d; 22 22 23 23 if (!data->level) { 24 - data->addr = (void *)frame->pc; 24 + data->addr = (void *)pc; 25 25 26 - return 1; 26 + return false; 27 27 } else { 28 28 --data->level; 29 - return 0; 29 + return true; 30 30 } 31 31 } 32 32
+6 -7
arch/arm/kernel/stacktrace.c
··· 127 127 #endif 128 128 129 129 void notrace walk_stackframe(struct stackframe *frame, 130 - int (*fn)(struct stackframe *, void *), void *data) 130 + bool (*fn)(void *, unsigned long), void *data) 131 131 { 132 132 while (1) { 133 133 int ret; 134 134 135 - if (fn(frame, data)) 135 + if (!fn(data, frame->pc)) 136 136 break; 137 137 ret = unwind_frame(frame); 138 138 if (ret < 0) ··· 148 148 unsigned int skip; 149 149 }; 150 150 151 - static int save_trace(struct stackframe *frame, void *d) 151 + static bool save_trace(void *d, unsigned long addr) 152 152 { 153 153 struct stack_trace_data *data = d; 154 154 struct stack_trace *trace = data->trace; 155 - unsigned long addr = frame->pc; 156 155 157 156 if (data->no_sched_functions && in_sched_functions(addr)) 158 - return 0; 157 + return true; 159 158 if (data->skip) { 160 159 data->skip--; 161 - return 0; 160 + return true; 162 161 } 163 162 164 163 trace->entries[trace->nr_entries++] = addr; 165 - return trace->nr_entries >= trace->max_entries; 164 + return trace->nr_entries < trace->max_entries; 166 165 } 167 166 168 167 /* This must be noinline to so that our skip calculation works correctly */