Commit ab1b6f03 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Linus Torvalds

simplify the stacktrace code

Simplify the stacktrace code:

 - remove the unused task argument to save_stack_trace, it's always
   current
 - remove the all_contexts flag, it's alwasy 0
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Andi Kleen <ak@suse.de>
Cc: Akinobu Mita <akinobu.mita@gmail.com>
Acked-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 7e4c3690
...@@ -31,8 +31,7 @@ static void save_raw_context_stack(struct stack_trace *trace, ...@@ -31,8 +31,7 @@ static void save_raw_context_stack(struct stack_trace *trace,
} }
} }
static void save_context_stack(struct stack_trace *trace, static void save_context_stack(struct stack_trace *trace, struct pt_regs *regs)
struct task_struct *task, struct pt_regs *regs)
{ {
unsigned long sp = regs->regs[29]; unsigned long sp = regs->regs[29];
#ifdef CONFIG_KALLSYMS #ifdef CONFIG_KALLSYMS
...@@ -41,7 +40,7 @@ static void save_context_stack(struct stack_trace *trace, ...@@ -41,7 +40,7 @@ static void save_context_stack(struct stack_trace *trace,
if (raw_show_trace || !__kernel_text_address(pc)) { if (raw_show_trace || !__kernel_text_address(pc)) {
unsigned long stack_page = unsigned long stack_page =
(unsigned long)task_stack_page(task); (unsigned long)task_stack_page(current);
if (stack_page && sp >= stack_page && if (stack_page && sp >= stack_page &&
sp <= stack_page + THREAD_SIZE - 32) sp <= stack_page + THREAD_SIZE - 32)
save_raw_context_stack(trace, sp); save_raw_context_stack(trace, sp);
...@@ -54,7 +53,7 @@ static void save_context_stack(struct stack_trace *trace, ...@@ -54,7 +53,7 @@ static void save_context_stack(struct stack_trace *trace,
trace->entries[trace->nr_entries++] = pc; trace->entries[trace->nr_entries++] = pc;
if (trace->nr_entries >= trace->max_entries) if (trace->nr_entries >= trace->max_entries)
break; break;
pc = unwind_stack(task, &sp, pc, &ra); pc = unwind_stack(current, &sp, pc, &ra);
} while (pc); } while (pc);
#else #else
save_raw_context_stack(trace, sp); save_raw_context_stack(trace, sp);
...@@ -64,22 +63,13 @@ static void save_context_stack(struct stack_trace *trace, ...@@ -64,22 +63,13 @@ static void save_context_stack(struct stack_trace *trace,
/* /*
* Save stack-backtrace addresses into a stack_trace buffer. * Save stack-backtrace addresses into a stack_trace buffer.
*/ */
void save_stack_trace(struct stack_trace *trace, struct task_struct *task) void save_stack_trace(struct stack_trace *trace)
{ {
struct pt_regs dummyregs; struct pt_regs dummyregs;
struct pt_regs *regs = &dummyregs; struct pt_regs *regs = &dummyregs;
WARN_ON(trace->nr_entries || !trace->max_entries); WARN_ON(trace->nr_entries || !trace->max_entries);
if (task && task != current) { prepare_frametrace(regs);
regs->regs[29] = task->thread.reg29; save_context_stack(trace, regs);
regs->regs[31] = 0;
regs->cp0_epc = task->thread.reg31;
} else {
if (!task)
task = current;
prepare_frametrace(regs);
}
save_context_stack(trace, task, regs);
} }
...@@ -59,7 +59,7 @@ static unsigned long save_context_stack(struct stack_trace *trace, ...@@ -59,7 +59,7 @@ static unsigned long save_context_stack(struct stack_trace *trace,
} }
} }
void save_stack_trace(struct stack_trace *trace, struct task_struct *task) void save_stack_trace(struct stack_trace *trace)
{ {
register unsigned long sp asm ("15"); register unsigned long sp asm ("15");
unsigned long orig_sp, new_sp; unsigned long orig_sp, new_sp;
...@@ -69,20 +69,16 @@ void save_stack_trace(struct stack_trace *trace, struct task_struct *task) ...@@ -69,20 +69,16 @@ void save_stack_trace(struct stack_trace *trace, struct task_struct *task)
new_sp = save_context_stack(trace, &trace->skip, orig_sp, new_sp = save_context_stack(trace, &trace->skip, orig_sp,
S390_lowcore.panic_stack - PAGE_SIZE, S390_lowcore.panic_stack - PAGE_SIZE,
S390_lowcore.panic_stack); S390_lowcore.panic_stack);
if ((new_sp != orig_sp) && !trace->all_contexts) if (new_sp != orig_sp)
return; return;
new_sp = save_context_stack(trace, &trace->skip, new_sp, new_sp = save_context_stack(trace, &trace->skip, new_sp,
S390_lowcore.async_stack - ASYNC_SIZE, S390_lowcore.async_stack - ASYNC_SIZE,
S390_lowcore.async_stack); S390_lowcore.async_stack);
if ((new_sp != orig_sp) && !trace->all_contexts) if (new_sp != orig_sp)
return; return;
if (task)
save_context_stack(trace, &trace->skip, new_sp, save_context_stack(trace, &trace->skip, new_sp,
(unsigned long) task_stack_page(task), S390_lowcore.thread_info,
(unsigned long) task_stack_page(task) + THREAD_SIZE); S390_lowcore.thread_info + THREAD_SIZE);
else
save_context_stack(trace, &trace->skip, new_sp,
S390_lowcore.thread_info,
S390_lowcore.thread_info + THREAD_SIZE);
return; return;
} }
...@@ -19,14 +19,7 @@ ...@@ -19,14 +19,7 @@
*/ */
void save_stack_trace(struct stack_trace *trace, struct task_struct *task) void save_stack_trace(struct stack_trace *trace, struct task_struct *task)
{ {
unsigned long *sp; unsigned long *sp = (unsigned long *)current_stack_pointer;
if (!task)
task = current;
if (task == current)
sp = (unsigned long *)current_stack_pointer;
else
sp = (unsigned long *)task->thread.sp;
while (!kstack_end(sp)) { while (!kstack_end(sp)) {
unsigned long addr = *sp++; unsigned long addr = *sp++;
......
...@@ -3,22 +3,16 @@ ...@@ -3,22 +3,16 @@
#include <linux/thread_info.h> #include <linux/thread_info.h>
#include <asm/ptrace.h> #include <asm/ptrace.h>
void save_stack_trace(struct stack_trace *trace, struct task_struct *task) void save_stack_trace(struct stack_trace *trace)
{ {
unsigned long ksp, fp, thread_base; unsigned long ksp, fp, thread_base;
struct thread_info *tp; struct thread_info *tp = task_thread_info(current);
if (!task) flushw_all();
task = current; __asm__ __volatile__(
tp = task_thread_info(task); "mov %%fp, %0"
if (task == current) { : "=r" (ksp)
flushw_all(); );
__asm__ __volatile__(
"mov %%fp, %0"
: "=r" (ksp)
);
} else
ksp = tp->ksp;
fp = ksp + STACK_BIAS; fp = ksp + STACK_BIAS;
thread_base = (unsigned long) tp; thread_base = (unsigned long) tp;
......
...@@ -21,8 +21,7 @@ save_stack_warning_symbol(void *data, char *msg, unsigned long symbol) ...@@ -21,8 +21,7 @@ save_stack_warning_symbol(void *data, char *msg, unsigned long symbol)
static int save_stack_stack(void *data, char *name) static int save_stack_stack(void *data, char *name)
{ {
struct stack_trace *trace = (struct stack_trace *)data; return -1;
return trace->all_contexts ? 0 : -1;
} }
static void save_stack_address(void *data, unsigned long addr) static void save_stack_address(void *data, unsigned long addr)
...@@ -46,11 +45,10 @@ static struct stacktrace_ops save_stack_ops = { ...@@ -46,11 +45,10 @@ static struct stacktrace_ops save_stack_ops = {
/* /*
* Save stack-backtrace addresses into a stack_trace buffer. * Save stack-backtrace addresses into a stack_trace buffer.
*/ */
void save_stack_trace(struct stack_trace *trace, struct task_struct *task) void save_stack_trace(struct stack_trace *trace)
{ {
dump_trace(task, NULL, NULL, &save_stack_ops, trace); dump_trace(current, NULL, NULL, &save_stack_ops, trace);
if (trace->nr_entries < trace->max_entries) if (trace->nr_entries < trace->max_entries)
trace->entries[trace->nr_entries++] = ULONG_MAX; trace->entries[trace->nr_entries++] = ULONG_MAX;
} }
EXPORT_SYMBOL(save_stack_trace); EXPORT_SYMBOL(save_stack_trace);
...@@ -6,15 +6,13 @@ struct stack_trace { ...@@ -6,15 +6,13 @@ struct stack_trace {
unsigned int nr_entries, max_entries; unsigned int nr_entries, max_entries;
unsigned long *entries; unsigned long *entries;
int skip; /* input argument: How many entries to skip */ int skip; /* input argument: How many entries to skip */
int all_contexts; /* input argument: if true do than one stack */
}; };
extern void save_stack_trace(struct stack_trace *trace, extern void save_stack_trace(struct stack_trace *trace);
struct task_struct *task);
extern void print_stack_trace(struct stack_trace *trace, int spaces); extern void print_stack_trace(struct stack_trace *trace, int spaces);
#else #else
# define save_stack_trace(trace, task) do { } while (0) # define save_stack_trace(trace) do { } while (0)
# define print_stack_trace(trace) do { } while (0) # define print_stack_trace(trace) do { } while (0)
#endif #endif
......
...@@ -257,9 +257,8 @@ static int save_trace(struct stack_trace *trace) ...@@ -257,9 +257,8 @@ static int save_trace(struct stack_trace *trace)
trace->entries = stack_trace + nr_stack_trace_entries; trace->entries = stack_trace + nr_stack_trace_entries;
trace->skip = 3; trace->skip = 3;
trace->all_contexts = 0;
save_stack_trace(trace, NULL); save_stack_trace(trace);
trace->max_entries = trace->nr_entries; trace->max_entries = trace->nr_entries;
......
...@@ -72,9 +72,8 @@ static bool fail_stacktrace(struct fault_attr *attr) ...@@ -72,9 +72,8 @@ static bool fail_stacktrace(struct fault_attr *attr)
trace.entries = entries; trace.entries = entries;
trace.max_entries = depth; trace.max_entries = depth;
trace.skip = 1; trace.skip = 1;
trace.all_contexts = 0;
save_stack_trace(&trace, NULL); save_stack_trace(&trace);
for (n = 0; n < trace.nr_entries; n++) { for (n = 0; n < trace.nr_entries; n++) {
if (attr->reject_start <= entries[n] && if (attr->reject_start <= entries[n] &&
entries[n] < attr->reject_end) entries[n] < attr->reject_end)
......
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