Skip to content

Commit 99c168f

Browse files
Kefeng Wangpalmer-dabbelt
authored andcommitted
riscv: Cleanup stacktrace
1. add asm/stacktrace.h for walk_stackframe and struct stackframe 2. remove unnecessary blank lines in stacktrace.c 3. fix warning "no previous prototype for ‘fill_callchain’" Signed-off-by: Kefeng Wang <[email protected]> Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 31564b8 commit 99c168f

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

arch/riscv/include/asm/stacktrace.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
3+
#ifndef _ASM_RISCV_STACKTRACE_H
4+
#define _ASM_RISCV_STACKTRACE_H
5+
6+
#include <linux/sched.h>
7+
#include <asm/ptrace.h>
8+
9+
struct stackframe {
10+
unsigned long fp;
11+
unsigned long ra;
12+
};
13+
14+
extern void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
15+
bool (*fn)(unsigned long, void *), void *arg);
16+
17+
#endif /* _ASM_RISCV_STACKTRACE_H */

arch/riscv/kernel/perf_callchain.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44
#include <linux/perf_event.h>
55
#include <linux/uaccess.h>
66

7-
/* Kernel callchain */
8-
struct stackframe {
9-
unsigned long fp;
10-
unsigned long ra;
11-
};
7+
#include <asm/stacktrace.h>
128

139
/*
1410
* Get the return address for a single stackframe and return a pointer to the
@@ -74,13 +70,11 @@ void perf_callchain_user(struct perf_callchain_entry_ctx *entry,
7470
fp = user_backtrace(entry, fp, 0);
7571
}
7672

77-
bool fill_callchain(unsigned long pc, void *entry)
73+
static bool fill_callchain(unsigned long pc, void *entry)
7874
{
7975
return perf_callchain_store(entry, pc);
8076
}
8177

82-
void notrace walk_stackframe(struct task_struct *task,
83-
struct pt_regs *regs, bool (*fn)(unsigned long, void *), void *arg);
8478
void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry,
8579
struct pt_regs *regs)
8680
{

arch/riscv/kernel/stacktrace.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,12 @@
1212
#include <linux/stacktrace.h>
1313
#include <linux/ftrace.h>
1414

15+
#include <asm/stacktrace.h>
16+
1517
register unsigned long sp_in_global __asm__("sp");
1618

1719
#ifdef CONFIG_FRAME_POINTER
1820

19-
struct stackframe {
20-
unsigned long fp;
21-
unsigned long ra;
22-
};
23-
2421
void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
2522
bool (*fn)(unsigned long, void *), void *arg)
2623
{
@@ -96,7 +93,6 @@ void notrace walk_stackframe(struct task_struct *task,
9693

9794
#endif /* CONFIG_FRAME_POINTER */
9895

99-
10096
static bool print_trace_address(unsigned long pc, void *arg)
10197
{
10298
const char *loglvl = arg;
@@ -130,7 +126,6 @@ unsigned long get_wchan(struct task_struct *task)
130126
return pc;
131127
}
132128

133-
134129
#ifdef CONFIG_STACKTRACE
135130

136131
static bool __save_trace(unsigned long pc, void *arg, bool nosched)

0 commit comments

Comments
 (0)