Commit ab1b6f03a10ba1f5638188ab06bf46e33ac3a160

Authored by Christoph Hellwig
Committed by Linus Torvalds
1 parent 7e4c3690b0

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: 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>

Showing 8 changed files with 28 additions and 61 deletions Side-by-side Diff

arch/mips/kernel/stacktrace.c
... ... @@ -31,8 +31,7 @@
31 31 }
32 32 }
33 33  
34   -static void save_context_stack(struct stack_trace *trace,
35   - struct task_struct *task, struct pt_regs *regs)
  34 +static void save_context_stack(struct stack_trace *trace, struct pt_regs *regs)
36 35 {
37 36 unsigned long sp = regs->regs[29];
38 37 #ifdef CONFIG_KALLSYMS
... ... @@ -41,7 +40,7 @@
41 40  
42 41 if (raw_show_trace || !__kernel_text_address(pc)) {
43 42 unsigned long stack_page =
44   - (unsigned long)task_stack_page(task);
  43 + (unsigned long)task_stack_page(current);
45 44 if (stack_page && sp >= stack_page &&
46 45 sp <= stack_page + THREAD_SIZE - 32)
47 46 save_raw_context_stack(trace, sp);
... ... @@ -54,7 +53,7 @@
54 53 trace->entries[trace->nr_entries++] = pc;
55 54 if (trace->nr_entries >= trace->max_entries)
56 55 break;
57   - pc = unwind_stack(task, &sp, pc, &ra);
  56 + pc = unwind_stack(current, &sp, pc, &ra);
58 57 } while (pc);
59 58 #else
60 59 save_raw_context_stack(trace, sp);
61 60  
... ... @@ -64,23 +63,14 @@
64 63 /*
65 64 * Save stack-backtrace addresses into a stack_trace buffer.
66 65 */
67   -void save_stack_trace(struct stack_trace *trace, struct task_struct *task)
  66 +void save_stack_trace(struct stack_trace *trace)
68 67 {
69 68 struct pt_regs dummyregs;
70 69 struct pt_regs *regs = &dummyregs;
71 70  
72 71 WARN_ON(trace->nr_entries || !trace->max_entries);
73 72  
74   - if (task && task != current) {
75   - regs->regs[29] = task->thread.reg29;
76   - regs->regs[31] = 0;
77   - regs->cp0_epc = task->thread.reg31;
78   - } else {
79   - if (!task)
80   - task = current;
81   - prepare_frametrace(regs);
82   - }
83   -
84   - save_context_stack(trace, task, regs);
  73 + prepare_frametrace(regs);
  74 + save_context_stack(trace, regs);
85 75 }
arch/s390/kernel/stacktrace.c
... ... @@ -59,7 +59,7 @@
59 59 }
60 60 }
61 61  
62   -void save_stack_trace(struct stack_trace *trace, struct task_struct *task)
  62 +void save_stack_trace(struct stack_trace *trace)
63 63 {
64 64 register unsigned long sp asm ("15");
65 65 unsigned long orig_sp, new_sp;
66 66  
67 67  
... ... @@ -69,21 +69,17 @@
69 69 new_sp = save_context_stack(trace, &trace->skip, orig_sp,
70 70 S390_lowcore.panic_stack - PAGE_SIZE,
71 71 S390_lowcore.panic_stack);
72   - if ((new_sp != orig_sp) && !trace->all_contexts)
  72 + if (new_sp != orig_sp)
73 73 return;
74 74 new_sp = save_context_stack(trace, &trace->skip, new_sp,
75 75 S390_lowcore.async_stack - ASYNC_SIZE,
76 76 S390_lowcore.async_stack);
77   - if ((new_sp != orig_sp) && !trace->all_contexts)
  77 + if (new_sp != orig_sp)
78 78 return;
79   - if (task)
80   - save_context_stack(trace, &trace->skip, new_sp,
81   - (unsigned long) task_stack_page(task),
82   - (unsigned long) task_stack_page(task) + THREAD_SIZE);
83   - else
84   - save_context_stack(trace, &trace->skip, new_sp,
85   - S390_lowcore.thread_info,
86   - S390_lowcore.thread_info + THREAD_SIZE);
  79 +
  80 + save_context_stack(trace, &trace->skip, new_sp,
  81 + S390_lowcore.thread_info,
  82 + S390_lowcore.thread_info + THREAD_SIZE);
87 83 return;
88 84 }
arch/sh/kernel/stacktrace.c
... ... @@ -19,14 +19,7 @@
19 19 */
20 20 void save_stack_trace(struct stack_trace *trace, struct task_struct *task)
21 21 {
22   - unsigned long *sp;
23   -
24   - if (!task)
25   - task = current;
26   - if (task == current)
27   - sp = (unsigned long *)current_stack_pointer;
28   - else
29   - sp = (unsigned long *)task->thread.sp;
  22 + unsigned long *sp = (unsigned long *)current_stack_pointer;
30 23  
31 24 while (!kstack_end(sp)) {
32 25 unsigned long addr = *sp++;
arch/sparc64/kernel/stacktrace.c
... ... @@ -3,22 +3,16 @@
3 3 #include <linux/thread_info.h>
4 4 #include <asm/ptrace.h>
5 5  
6   -void save_stack_trace(struct stack_trace *trace, struct task_struct *task)
  6 +void save_stack_trace(struct stack_trace *trace)
7 7 {
8 8 unsigned long ksp, fp, thread_base;
9   - struct thread_info *tp;
  9 + struct thread_info *tp = task_thread_info(current);
10 10  
11   - if (!task)
12   - task = current;
13   - tp = task_thread_info(task);
14   - if (task == current) {
15   - flushw_all();
16   - __asm__ __volatile__(
17   - "mov %%fp, %0"
18   - : "=r" (ksp)
19   - );
20   - } else
21   - ksp = tp->ksp;
  11 + flushw_all();
  12 + __asm__ __volatile__(
  13 + "mov %%fp, %0"
  14 + : "=r" (ksp)
  15 + );
22 16  
23 17 fp = ksp + STACK_BIAS;
24 18 thread_base = (unsigned long) tp;
arch/x86_64/kernel/stacktrace.c
... ... @@ -21,8 +21,7 @@
21 21  
22 22 static int save_stack_stack(void *data, char *name)
23 23 {
24   - struct stack_trace *trace = (struct stack_trace *)data;
25   - return trace->all_contexts ? 0 : -1;
  24 + return -1;
26 25 }
27 26  
28 27 static void save_stack_address(void *data, unsigned long addr)
29 28  
... ... @@ -46,9 +45,9 @@
46 45 /*
47 46 * Save stack-backtrace addresses into a stack_trace buffer.
48 47 */
49   -void save_stack_trace(struct stack_trace *trace, struct task_struct *task)
  48 +void save_stack_trace(struct stack_trace *trace)
50 49 {
51   - dump_trace(task, NULL, NULL, &save_stack_ops, trace);
  50 + dump_trace(current, NULL, NULL, &save_stack_ops, trace);
52 51 if (trace->nr_entries < trace->max_entries)
53 52 trace->entries[trace->nr_entries++] = ULONG_MAX;
54 53 }
include/linux/stacktrace.h
... ... @@ -6,15 +6,13 @@
6 6 unsigned int nr_entries, max_entries;
7 7 unsigned long *entries;
8 8 int skip; /* input argument: How many entries to skip */
9   - int all_contexts; /* input argument: if true do than one stack */
10 9 };
11 10  
12   -extern void save_stack_trace(struct stack_trace *trace,
13   - struct task_struct *task);
  11 +extern void save_stack_trace(struct stack_trace *trace);
14 12  
15 13 extern void print_stack_trace(struct stack_trace *trace, int spaces);
16 14 #else
17   -# define save_stack_trace(trace, task) do { } while (0)
  15 +# define save_stack_trace(trace) do { } while (0)
18 16 # define print_stack_trace(trace) do { } while (0)
19 17 #endif
20 18  
... ... @@ -257,9 +257,8 @@
257 257 trace->entries = stack_trace + nr_stack_trace_entries;
258 258  
259 259 trace->skip = 3;
260   - trace->all_contexts = 0;
261 260  
262   - save_stack_trace(trace, NULL);
  261 + save_stack_trace(trace);
263 262  
264 263 trace->max_entries = trace->nr_entries;
265 264  
... ... @@ -72,9 +72,8 @@
72 72 trace.entries = entries;
73 73 trace.max_entries = depth;
74 74 trace.skip = 1;
75   - trace.all_contexts = 0;
76 75  
77   - save_stack_trace(&trace, NULL);
  76 + save_stack_trace(&trace);
78 77 for (n = 0; n < trace.nr_entries; n++) {
79 78 if (attr->reject_start <= entries[n] &&
80 79 entries[n] < attr->reject_end)