Commit baa2cd41 authored by Mark Brown's avatar Mark Brown Committed by Will Deacon

arm64: stacktrace: Make stack walk callback consistent with generic code

As with the generic arch_stack_walk() code the arm64 stack walk code takes
a callback that is called per stack frame. Currently the arm64 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 arm64 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 arm64 is converted to use
arch_stack_walk() change the signature and return sense of the arm64
specific callback to match that of the generic code.
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
Reviewed-by: default avatarMiroslav Benes <mbenes@suse.cz>
Link: https://lore.kernel.org/r/20200914153409.25097-3-broonie@kernel.orgSigned-off-by: default avatarWill Deacon <will@kernel.org>
parent 264c03a2
...@@ -63,7 +63,7 @@ struct stackframe { ...@@ -63,7 +63,7 @@ struct stackframe {
extern int unwind_frame(struct task_struct *tsk, struct stackframe *frame); extern int unwind_frame(struct task_struct *tsk, struct stackframe *frame);
extern void walk_stackframe(struct task_struct *tsk, struct stackframe *frame, extern void walk_stackframe(struct task_struct *tsk, struct stackframe *frame,
int (*fn)(struct stackframe *, void *), void *data); bool (*fn)(void *, unsigned long), void *data);
extern void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk, extern void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk,
const char *loglvl); const char *loglvl);
......
...@@ -137,11 +137,11 @@ void perf_callchain_user(struct perf_callchain_entry_ctx *entry, ...@@ -137,11 +137,11 @@ void perf_callchain_user(struct perf_callchain_entry_ctx *entry,
* whist unwinding the stackframe and is like a subroutine return so we use * whist unwinding the stackframe and is like a subroutine return so we use
* the PC. * the PC.
*/ */
static int callchain_trace(struct stackframe *frame, void *data) static bool callchain_trace(void *data, unsigned long pc)
{ {
struct perf_callchain_entry_ctx *entry = data; struct perf_callchain_entry_ctx *entry = data;
perf_callchain_store(entry, frame->pc); perf_callchain_store(entry, pc);
return 0; return true;
} }
void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry,
......
...@@ -18,16 +18,16 @@ struct return_address_data { ...@@ -18,16 +18,16 @@ struct return_address_data {
void *addr; void *addr;
}; };
static int save_return_addr(struct stackframe *frame, void *d) static bool save_return_addr(void *d, unsigned long pc)
{ {
struct return_address_data *data = d; struct return_address_data *data = d;
if (!data->level) { if (!data->level) {
data->addr = (void *)frame->pc; data->addr = (void *)pc;
return 1; return false;
} else { } else {
--data->level; --data->level;
return 0; return true;
} }
} }
NOKPROBE_SYMBOL(save_return_addr); NOKPROBE_SYMBOL(save_return_addr);
......
...@@ -118,12 +118,12 @@ int notrace unwind_frame(struct task_struct *tsk, struct stackframe *frame) ...@@ -118,12 +118,12 @@ int notrace unwind_frame(struct task_struct *tsk, struct stackframe *frame)
NOKPROBE_SYMBOL(unwind_frame); NOKPROBE_SYMBOL(unwind_frame);
void notrace walk_stackframe(struct task_struct *tsk, struct stackframe *frame, void notrace walk_stackframe(struct task_struct *tsk, struct stackframe *frame,
int (*fn)(struct stackframe *, void *), void *data) bool (*fn)(void *, unsigned long), void *data)
{ {
while (1) { while (1) {
int ret; int ret;
if (fn(frame, data)) if (!fn(data, frame->pc))
break; break;
ret = unwind_frame(tsk, frame); ret = unwind_frame(tsk, frame);
if (ret < 0) if (ret < 0)
...@@ -139,17 +139,16 @@ struct stack_trace_data { ...@@ -139,17 +139,16 @@ struct stack_trace_data {
unsigned int skip; unsigned int skip;
}; };
static int save_trace(struct stackframe *frame, void *d) static bool save_trace(void *d, unsigned long addr)
{ {
struct stack_trace_data *data = d; struct stack_trace_data *data = d;
struct stack_trace *trace = data->trace; struct stack_trace *trace = data->trace;
unsigned long addr = frame->pc;
if (data->no_sched_functions && in_sched_functions(addr)) if (data->no_sched_functions && in_sched_functions(addr))
return 0; return false;
if (data->skip) { if (data->skip) {
data->skip--; data->skip--;
return 0; return false;
} }
trace->entries[trace->nr_entries++] = addr; trace->entries[trace->nr_entries++] = addr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment