Unverified Commit 99c168fc authored by Kefeng Wang's avatar Kefeng Wang Committed by Palmer Dabbelt
Browse files

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: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: default avatarPalmer Dabbelt <palmerdabbelt@google.com>
parent 31564b8b
Loading
Loading
Loading
Loading
+17 −0
Original line number Original line Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */

#ifndef _ASM_RISCV_STACKTRACE_H
#define _ASM_RISCV_STACKTRACE_H

#include <linux/sched.h>
#include <asm/ptrace.h>

struct stackframe {
	unsigned long fp;
	unsigned long ra;
};

extern void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
				    bool (*fn)(unsigned long, void *), void *arg);

#endif /* _ASM_RISCV_STACKTRACE_H */
+2 −8
Original line number Original line Diff line number Diff line
@@ -4,11 +4,7 @@
#include <linux/perf_event.h>
#include <linux/perf_event.h>
#include <linux/uaccess.h>
#include <linux/uaccess.h>


/* Kernel callchain */
#include <asm/stacktrace.h>
struct stackframe {
	unsigned long fp;
	unsigned long ra;
};


/*
/*
 * Get the return address for a single stackframe and return a pointer to the
 * 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,
		fp = user_backtrace(entry, fp, 0);
		fp = user_backtrace(entry, fp, 0);
}
}


bool fill_callchain(unsigned long pc, void *entry)
static bool fill_callchain(unsigned long pc, void *entry)
{
{
	return perf_callchain_store(entry, pc);
	return perf_callchain_store(entry, pc);
}
}


void notrace walk_stackframe(struct task_struct *task,
	struct pt_regs *regs, bool (*fn)(unsigned long, void *), void *arg);
void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry,
void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry,
			   struct pt_regs *regs)
			   struct pt_regs *regs)
{
{
+2 −7
Original line number Original line Diff line number Diff line
@@ -12,15 +12,12 @@
#include <linux/stacktrace.h>
#include <linux/stacktrace.h>
#include <linux/ftrace.h>
#include <linux/ftrace.h>


#include <asm/stacktrace.h>

register unsigned long sp_in_global __asm__("sp");
register unsigned long sp_in_global __asm__("sp");


#ifdef CONFIG_FRAME_POINTER
#ifdef CONFIG_FRAME_POINTER


struct stackframe {
	unsigned long fp;
	unsigned long ra;
};

void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
			     bool (*fn)(unsigned long, void *), void *arg)
			     bool (*fn)(unsigned long, void *), void *arg)
{
{
@@ -96,7 +93,6 @@ void notrace walk_stackframe(struct task_struct *task,


#endif /* CONFIG_FRAME_POINTER */
#endif /* CONFIG_FRAME_POINTER */



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



#ifdef CONFIG_STACKTRACE
#ifdef CONFIG_STACKTRACE


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