Commit e991e5bb authored by Vasily Gorbik's avatar Vasily Gorbik

s390/stacktrace: use common arch_stack_walk infrastructure

Use common arch_stack_walk infrastructure to avoid duplicated code and
avoid taking care of the stack storage and filtering.

Common code also uses try_get_task_stack/put_task_stack when needed which
have been missing in our code, which also solves potential problem for us.
Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
parent 2c7fa8a1
...@@ -105,6 +105,7 @@ config S390 ...@@ -105,6 +105,7 @@ config S390
select ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE select ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE
select ARCH_KEEP_MEMBLOCK select ARCH_KEEP_MEMBLOCK
select ARCH_SAVE_PAGE_KEYS if HIBERNATION select ARCH_SAVE_PAGE_KEYS if HIBERNATION
select ARCH_STACKWALK
select ARCH_SUPPORTS_ATOMIC_RMW select ARCH_SUPPORTS_ATOMIC_RMW
select ARCH_SUPPORTS_NUMA_BALANCING select ARCH_SUPPORTS_NUMA_BALANCING
select ARCH_USE_BUILTIN_BSWAP select ARCH_USE_BUILTIN_BSWAP
......
...@@ -6,57 +6,19 @@ ...@@ -6,57 +6,19 @@
* Author(s): Heiko Carstens <heiko.carstens@de.ibm.com> * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>
*/ */
#include <linux/sched.h>
#include <linux/sched/debug.h>
#include <linux/stacktrace.h> #include <linux/stacktrace.h>
#include <linux/kallsyms.h>
#include <linux/export.h>
#include <asm/stacktrace.h> #include <asm/stacktrace.h>
#include <asm/unwind.h> #include <asm/unwind.h>
void save_stack_trace(struct stack_trace *trace) void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie,
struct task_struct *task, struct pt_regs *regs)
{ {
struct unwind_state state; struct unwind_state state;
unsigned long addr;
unwind_for_each_frame(&state, current, NULL, 0) { unwind_for_each_frame(&state, task, regs, 0) {
if (trace->nr_entries >= trace->max_entries) addr = unwind_get_return_address(&state);
if (!addr || !consume_entry(cookie, addr, false))
break; break;
if (trace->skip > 0)
trace->skip--;
else
trace->entries[trace->nr_entries++] = state.ip;
} }
} }
EXPORT_SYMBOL_GPL(save_stack_trace);
void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
{
struct unwind_state state;
unwind_for_each_frame(&state, tsk, NULL, 0) {
if (trace->nr_entries >= trace->max_entries)
break;
if (in_sched_functions(state.ip))
continue;
if (trace->skip > 0)
trace->skip--;
else
trace->entries[trace->nr_entries++] = state.ip;
}
}
EXPORT_SYMBOL_GPL(save_stack_trace_tsk);
void save_stack_trace_regs(struct pt_regs *regs, struct stack_trace *trace)
{
struct unwind_state state;
unwind_for_each_frame(&state, current, regs, 0) {
if (trace->nr_entries >= trace->max_entries)
break;
if (trace->skip > 0)
trace->skip--;
else
trace->entries[trace->nr_entries++] = state.ip;
}
}
EXPORT_SYMBOL_GPL(save_stack_trace_regs);
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