Commit 6756dd9b authored by Vasily Gorbik's avatar Vasily Gorbik

s390/process: avoid custom stack unwinding in get_wchan

Currently get_wchan uses custom stack unwinding implementation which
relies on back_chain presence. Replace it with more abstract stack
unwinding api usage.
Suggested-by: default avatarIlya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
parent ea3f6dcf
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <asm/stacktrace.h> #include <asm/stacktrace.h>
#include <asm/switch_to.h> #include <asm/switch_to.h>
#include <asm/runtime_instr.h> #include <asm/runtime_instr.h>
#include <asm/unwind.h>
#include "entry.h" #include "entry.h"
asmlinkage void ret_from_fork(void) asm ("ret_from_fork"); asmlinkage void ret_from_fork(void) asm ("ret_from_fork");
...@@ -178,9 +179,8 @@ EXPORT_SYMBOL(dump_fpu); ...@@ -178,9 +179,8 @@ EXPORT_SYMBOL(dump_fpu);
unsigned long get_wchan(struct task_struct *p) unsigned long get_wchan(struct task_struct *p)
{ {
struct stack_frame *sf, *low, *high; struct unwind_state state;
unsigned long return_address; unsigned long ip = 0;
int count;
if (!p || p == current || p->state == TASK_RUNNING || !task_stack_page(p)) if (!p || p == current || p->state == TASK_RUNNING || !task_stack_page(p))
return 0; return 0;
...@@ -188,26 +188,22 @@ unsigned long get_wchan(struct task_struct *p) ...@@ -188,26 +188,22 @@ unsigned long get_wchan(struct task_struct *p)
if (!try_get_task_stack(p)) if (!try_get_task_stack(p))
return 0; return 0;
low = task_stack_page(p); unwind_for_each_frame(&state, p, NULL, 0) {
high = (struct stack_frame *) task_pt_regs(p); if (state.stack_info.type != STACK_TYPE_TASK) {
sf = (struct stack_frame *) p->thread.ksp; ip = 0;
if (sf <= low || sf > high) { break;
return_address = 0;
goto out;
}
for (count = 0; count < 16; count++) {
sf = (struct stack_frame *)READ_ONCE_NOCHECK(sf->back_chain);
if (sf <= low || sf > high) {
return_address = 0;
goto out;
} }
return_address = READ_ONCE_NOCHECK(sf->gprs[8]);
if (!in_sched_functions(return_address)) ip = unwind_get_return_address(&state);
goto out; if (!ip)
break;
if (!in_sched_functions(ip))
break;
} }
out:
put_task_stack(p); put_task_stack(p);
return return_address; return ip;
} }
unsigned long arch_align_stack(unsigned long sp) unsigned long arch_align_stack(unsigned long sp)
......
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