simplify the stacktrace code
authorChristoph Hellwig <hch@lst.de>
Tue, 8 May 2007 07:23:29 +0000 (00:23 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Tue, 8 May 2007 18:14:58 +0000 (11:14 -0700)
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: Christoph 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: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/mips/kernel/stacktrace.c
arch/s390/kernel/stacktrace.c
arch/sh/kernel/stacktrace.c
arch/sparc64/kernel/stacktrace.c
arch/x86_64/kernel/stacktrace.c
include/linux/stacktrace.h
kernel/lockdep.c
lib/fault-inject.c

index a586aba337a7afcbd0f93f50c36c59167face762..ebd9db8d1ecebfe7a065145df4d2c204a24ed313 100644 (file)
@@ -31,8 +31,7 @@ static void save_raw_context_stack(struct stack_trace *trace,
        }
 }
 
-static void save_context_stack(struct stack_trace *trace,
-       struct task_struct *task, struct pt_regs *regs)
+static void save_context_stack(struct stack_trace *trace, struct pt_regs *regs)
 {
        unsigned long sp = regs->regs[29];
 #ifdef CONFIG_KALLSYMS
@@ -41,7 +40,7 @@ static void save_context_stack(struct stack_trace *trace,
 
        if (raw_show_trace || !__kernel_text_address(pc)) {
                unsigned long stack_page =
-                       (unsigned long)task_stack_page(task);
+                       (unsigned long)task_stack_page(current);
                if (stack_page && sp >= stack_page &&
                    sp <= stack_page + THREAD_SIZE - 32)
                        save_raw_context_stack(trace, sp);
@@ -54,7 +53,7 @@ static void save_context_stack(struct stack_trace *trace,
                        trace->entries[trace->nr_entries++] = pc;
                if (trace->nr_entries >= trace->max_entries)
                        break;
-               pc = unwind_stack(task, &sp, pc, &ra);
+               pc = unwind_stack(current, &sp, pc, &ra);
        } while (pc);
 #else
        save_raw_context_stack(trace, sp);
@@ -64,22 +63,13 @@ static void save_context_stack(struct stack_trace *trace,
 /*
  * 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 *regs = &dummyregs;
 
        WARN_ON(trace->nr_entries || !trace->max_entries);
 
-       if (task && task != current) {
-               regs->regs[29] = task->thread.reg29;
-               regs->regs[31] = 0;
-               regs->cp0_epc = task->thread.reg31;
-       } else {
-               if (!task)
-                       task = current;
-               prepare_frametrace(regs);
-       }
-
-       save_context_stack(trace, task, regs);
+       prepare_frametrace(regs);
+       save_context_stack(trace, regs);
 }
index 2e5c65a1863eaada4750a1c36ed0baa3ff3be5ea..515ff9011dd742e33a5bfb54c4d55d99818937d9 100644 (file)
@@ -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");
        unsigned long orig_sp, new_sp;
@@ -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,
                                S390_lowcore.panic_stack - PAGE_SIZE,
                                S390_lowcore.panic_stack);
-       if ((new_sp != orig_sp) && !trace->all_contexts)
+       if (new_sp != orig_sp)
                return;
        new_sp = save_context_stack(trace, &trace->skip, new_sp,
                                S390_lowcore.async_stack - ASYNC_SIZE,
                                S390_lowcore.async_stack);
-       if ((new_sp != orig_sp) && !trace->all_contexts)
+       if (new_sp != orig_sp)
                return;
-       if (task)
-               save_context_stack(trace, &trace->skip, new_sp,
-                                  (unsigned long) task_stack_page(task),
-                                  (unsigned long) task_stack_page(task) + THREAD_SIZE);
-       else
-               save_context_stack(trace, &trace->skip, new_sp,
-                                  S390_lowcore.thread_info,
-                                  S390_lowcore.thread_info + THREAD_SIZE);
+
+       save_context_stack(trace, &trace->skip, new_sp,
+                          S390_lowcore.thread_info,
+                          S390_lowcore.thread_info + THREAD_SIZE);
        return;
 }
index 0d5268afe80f35fff78b48cd2c559225c4fedb4a..4bdd2f83535da137635e7507b19f608592f0fd7a 100644 (file)
  */
 void save_stack_trace(struct stack_trace *trace, struct task_struct *task)
 {
-       unsigned long *sp;
-
-       if (!task)
-               task = current;
-       if (task == current)
-               sp = (unsigned long *)current_stack_pointer;
-       else
-               sp = (unsigned long *)task->thread.sp;
+       unsigned long *sp = (unsigned long *)current_stack_pointer;
 
        while (!kstack_end(sp)) {
                unsigned long addr = *sp++;
index c4d15f2762b9e37579b73bc3e11e6219682b65b8..47f92a59be18ad41904891f3888974a9df9b08b1 100644 (file)
@@ -3,22 +3,16 @@
 #include <linux/thread_info.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;
-       struct thread_info *tp;
+       struct thread_info *tp = task_thread_info(current);
 
-       if (!task)
-               task = current;
-       tp = task_thread_info(task);
-       if (task == current) {
-               flushw_all();
-               __asm__ __volatile__(
-                       "mov    %%fp, %0"
-                       : "=r" (ksp)
-               );
-       } else
-               ksp = tp->ksp;
+       flushw_all();
+       __asm__ __volatile__(
+               "mov    %%fp, %0"
+               : "=r" (ksp)
+       );
 
        fp = ksp + STACK_BIAS;
        thread_base = (unsigned long) tp;
index 65ac2c6b34a6a1f80c9be549572e1d2f2e1d102e..cb910911358407583ae5d2babf847f743f4a0882 100644 (file)
@@ -21,8 +21,7 @@ save_stack_warning_symbol(void *data, char *msg, unsigned long symbol)
 
 static int save_stack_stack(void *data, char *name)
 {
-       struct stack_trace *trace = (struct stack_trace *)data;
-       return trace->all_contexts ? 0 : -1;
+       return -1;
 }
 
 static void save_stack_address(void *data, unsigned long addr)
@@ -46,11 +45,10 @@ static struct stacktrace_ops save_stack_ops = {
 /*
  * 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)
                trace->entries[trace->nr_entries++] = ULONG_MAX;
 }
 EXPORT_SYMBOL(save_stack_trace);
-
index 50e2b01e517cc3c9bdf3af4b328c4afb8d3aab21..1d2b084c01859a3b4ebb4f1657129e8451110b5e 100644 (file)
@@ -6,15 +6,13 @@ struct stack_trace {
        unsigned int nr_entries, max_entries;
        unsigned long *entries;
        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,
-                            struct task_struct *task);
+extern void save_stack_trace(struct stack_trace *trace);
 
 extern void print_stack_trace(struct stack_trace *trace, int spaces);
 #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)
 #endif
 
index 7065a687ac546020de4d53883f188f9702e036fd..c1e308a080b87eed578d0ef7f85cd197c8a141b6 100644 (file)
@@ -257,9 +257,8 @@ static int save_trace(struct stack_trace *trace)
        trace->entries = stack_trace + nr_stack_trace_entries;
 
        trace->skip = 3;
-       trace->all_contexts = 0;
 
-       save_stack_trace(trace, NULL);
+       save_stack_trace(trace);
 
        trace->max_entries = trace->nr_entries;
 
index 0fabd12c39d79786e3bcf0ce1fa3bb68c48d01d9..b18fc2ff9ffea5df3d3377fc092bb8306d556fd2 100644 (file)
@@ -72,9 +72,8 @@ static bool fail_stacktrace(struct fault_attr *attr)
        trace.entries = entries;
        trace.max_entries = depth;
        trace.skip = 1;
-       trace.all_contexts = 0;
 
-       save_stack_trace(&trace, NULL);
+       save_stack_trace(&trace);
        for (n = 0; n < trace.nr_entries; n++) {
                if (attr->reject_start <= entries[n] &&
                               entries[n] < attr->reject_end)