Skip to content

Commit baa2cd4

Browse files
brooniewilldeacon
authored andcommitted
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: Mark Brown <broonie@kernel.org> Reviewed-by: Miroslav Benes <mbenes@suse.cz> Link: https://lore.kernel.org/r/20200914153409.25097-3-broonie@kernel.org Signed-off-by: Will Deacon <will@kernel.org>
1 parent 264c03a commit baa2cd4

4 files changed

Lines changed: 13 additions & 14 deletions

File tree

arch/arm64/include/asm/stacktrace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ struct stackframe {
6363

6464
extern int unwind_frame(struct task_struct *tsk, struct stackframe *frame);
6565
extern void walk_stackframe(struct task_struct *tsk, struct stackframe *frame,
66-
int (*fn)(struct stackframe *, void *), void *data);
66+
bool (*fn)(void *, unsigned long), void *data);
6767
extern void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk,
6868
const char *loglvl);
6969

arch/arm64/kernel/perf_callchain.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,11 @@ void perf_callchain_user(struct perf_callchain_entry_ctx *entry,
137137
* whist unwinding the stackframe and is like a subroutine return so we use
138138
* the PC.
139139
*/
140-
static int callchain_trace(struct stackframe *frame, void *data)
140+
static bool callchain_trace(void *data, unsigned long pc)
141141
{
142142
struct perf_callchain_entry_ctx *entry = data;
143-
perf_callchain_store(entry, frame->pc);
144-
return 0;
143+
perf_callchain_store(entry, pc);
144+
return true;
145145
}
146146

147147
void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry,

arch/arm64/kernel/return_address.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ struct return_address_data {
1818
void *addr;
1919
};
2020

21-
static int save_return_addr(struct stackframe *frame, void *d)
21+
static bool save_return_addr(void *d, unsigned long pc)
2222
{
2323
struct return_address_data *data = d;
2424

2525
if (!data->level) {
26-
data->addr = (void *)frame->pc;
27-
return 1;
26+
data->addr = (void *)pc;
27+
return false;
2828
} else {
2929
--data->level;
30-
return 0;
30+
return true;
3131
}
3232
}
3333
NOKPROBE_SYMBOL(save_return_addr);

arch/arm64/kernel/stacktrace.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ int notrace unwind_frame(struct task_struct *tsk, struct stackframe *frame)
118118
NOKPROBE_SYMBOL(unwind_frame);
119119

120120
void notrace walk_stackframe(struct task_struct *tsk, struct stackframe *frame,
121-
int (*fn)(struct stackframe *, void *), void *data)
121+
bool (*fn)(void *, unsigned long), void *data)
122122
{
123123
while (1) {
124124
int ret;
125125

126-
if (fn(frame, data))
126+
if (!fn(data, frame->pc))
127127
break;
128128
ret = unwind_frame(tsk, frame);
129129
if (ret < 0)
@@ -139,17 +139,16 @@ struct stack_trace_data {
139139
unsigned int skip;
140140
};
141141

142-
static int save_trace(struct stackframe *frame, void *d)
142+
static bool save_trace(void *d, unsigned long addr)
143143
{
144144
struct stack_trace_data *data = d;
145145
struct stack_trace *trace = data->trace;
146-
unsigned long addr = frame->pc;
147146

148147
if (data->no_sched_functions && in_sched_functions(addr))
149-
return 0;
148+
return false;
150149
if (data->skip) {
151150
data->skip--;
152-
return 0;
151+
return false;
153152
}
154153

155154
trace->entries[trace->nr_entries++] = addr;

0 commit comments

Comments
 (0)