Commit da01e18a authored by Linus Torvalds's avatar Linus Torvalds

x86: avoid avoid passing around 'thread_info' in stack dumping code

None of the code actually wants a thread_info, it all wants a
task_struct, and it's just converting to a thread_info pointer much too
early.

No semantic change.
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 6720a305
...@@ -14,7 +14,7 @@ extern int kstack_depth_to_print; ...@@ -14,7 +14,7 @@ extern int kstack_depth_to_print;
struct thread_info; struct thread_info;
struct stacktrace_ops; struct stacktrace_ops;
typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo, typedef unsigned long (*walk_stack_t)(struct task_struct *task,
unsigned long *stack, unsigned long *stack,
unsigned long bp, unsigned long bp,
const struct stacktrace_ops *ops, const struct stacktrace_ops *ops,
...@@ -23,13 +23,13 @@ typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo, ...@@ -23,13 +23,13 @@ typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
int *graph); int *graph);
extern unsigned long extern unsigned long
print_context_stack(struct thread_info *tinfo, print_context_stack(struct task_struct *task,
unsigned long *stack, unsigned long bp, unsigned long *stack, unsigned long bp,
const struct stacktrace_ops *ops, void *data, const struct stacktrace_ops *ops, void *data,
unsigned long *end, int *graph); unsigned long *end, int *graph);
extern unsigned long extern unsigned long
print_context_stack_bp(struct thread_info *tinfo, print_context_stack_bp(struct task_struct *task,
unsigned long *stack, unsigned long bp, unsigned long *stack, unsigned long bp,
const struct stacktrace_ops *ops, void *data, const struct stacktrace_ops *ops, void *data,
unsigned long *end, int *graph); unsigned long *end, int *graph);
......
...@@ -42,16 +42,14 @@ void printk_address(unsigned long address) ...@@ -42,16 +42,14 @@ void printk_address(unsigned long address)
static void static void
print_ftrace_graph_addr(unsigned long addr, void *data, print_ftrace_graph_addr(unsigned long addr, void *data,
const struct stacktrace_ops *ops, const struct stacktrace_ops *ops,
struct thread_info *tinfo, int *graph) struct task_struct *task, int *graph)
{ {
struct task_struct *task;
unsigned long ret_addr; unsigned long ret_addr;
int index; int index;
if (addr != (unsigned long)return_to_handler) if (addr != (unsigned long)return_to_handler)
return; return;
task = tinfo->task;
index = task->curr_ret_stack; index = task->curr_ret_stack;
if (!task->ret_stack || index < *graph) if (!task->ret_stack || index < *graph)
...@@ -68,7 +66,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data, ...@@ -68,7 +66,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
static inline void static inline void
print_ftrace_graph_addr(unsigned long addr, void *data, print_ftrace_graph_addr(unsigned long addr, void *data,
const struct stacktrace_ops *ops, const struct stacktrace_ops *ops,
struct thread_info *tinfo, int *graph) struct task_struct *task, int *graph)
{ } { }
#endif #endif
...@@ -79,10 +77,10 @@ print_ftrace_graph_addr(unsigned long addr, void *data, ...@@ -79,10 +77,10 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
* severe exception (double fault, nmi, stack fault, debug, mce) hardware stack * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
*/ */
static inline int valid_stack_ptr(struct thread_info *tinfo, static inline int valid_stack_ptr(struct task_struct *task,
void *p, unsigned int size, void *end) void *p, unsigned int size, void *end)
{ {
void *t = tinfo; void *t = task_thread_info(task);
if (end) { if (end) {
if (p < end && p >= (end-THREAD_SIZE)) if (p < end && p >= (end-THREAD_SIZE))
return 1; return 1;
...@@ -93,14 +91,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo, ...@@ -93,14 +91,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
} }
unsigned long unsigned long
print_context_stack(struct thread_info *tinfo, print_context_stack(struct task_struct *task,
unsigned long *stack, unsigned long bp, unsigned long *stack, unsigned long bp,
const struct stacktrace_ops *ops, void *data, const struct stacktrace_ops *ops, void *data,
unsigned long *end, int *graph) unsigned long *end, int *graph)
{ {
struct stack_frame *frame = (struct stack_frame *)bp; struct stack_frame *frame = (struct stack_frame *)bp;
while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) { while (valid_stack_ptr(task, stack, sizeof(*stack), end)) {
unsigned long addr; unsigned long addr;
addr = *stack; addr = *stack;
...@@ -112,7 +110,7 @@ print_context_stack(struct thread_info *tinfo, ...@@ -112,7 +110,7 @@ print_context_stack(struct thread_info *tinfo,
} else { } else {
ops->address(data, addr, 0); ops->address(data, addr, 0);
} }
print_ftrace_graph_addr(addr, data, ops, tinfo, graph); print_ftrace_graph_addr(addr, data, ops, task, graph);
} }
stack++; stack++;
} }
...@@ -121,7 +119,7 @@ print_context_stack(struct thread_info *tinfo, ...@@ -121,7 +119,7 @@ print_context_stack(struct thread_info *tinfo,
EXPORT_SYMBOL_GPL(print_context_stack); EXPORT_SYMBOL_GPL(print_context_stack);
unsigned long unsigned long
print_context_stack_bp(struct thread_info *tinfo, print_context_stack_bp(struct task_struct *task,
unsigned long *stack, unsigned long bp, unsigned long *stack, unsigned long bp,
const struct stacktrace_ops *ops, void *data, const struct stacktrace_ops *ops, void *data,
unsigned long *end, int *graph) unsigned long *end, int *graph)
...@@ -129,7 +127,7 @@ print_context_stack_bp(struct thread_info *tinfo, ...@@ -129,7 +127,7 @@ print_context_stack_bp(struct thread_info *tinfo,
struct stack_frame *frame = (struct stack_frame *)bp; struct stack_frame *frame = (struct stack_frame *)bp;
unsigned long *ret_addr = &frame->return_address; unsigned long *ret_addr = &frame->return_address;
while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) { while (valid_stack_ptr(task, ret_addr, sizeof(*ret_addr), end)) {
unsigned long addr = *ret_addr; unsigned long addr = *ret_addr;
if (!__kernel_text_address(addr)) if (!__kernel_text_address(addr))
...@@ -139,7 +137,7 @@ print_context_stack_bp(struct thread_info *tinfo, ...@@ -139,7 +137,7 @@ print_context_stack_bp(struct thread_info *tinfo,
break; break;
frame = frame->next_frame; frame = frame->next_frame;
ret_addr = &frame->return_address; ret_addr = &frame->return_address;
print_ftrace_graph_addr(addr, data, ops, tinfo, graph); print_ftrace_graph_addr(addr, data, ops, task, graph);
} }
return (unsigned long)frame; return (unsigned long)frame;
......
...@@ -61,15 +61,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs, ...@@ -61,15 +61,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
bp = stack_frame(task, regs); bp = stack_frame(task, regs);
for (;;) { for (;;) {
struct thread_info *context;
void *end_stack; void *end_stack;
end_stack = is_hardirq_stack(stack, cpu); end_stack = is_hardirq_stack(stack, cpu);
if (!end_stack) if (!end_stack)
end_stack = is_softirq_stack(stack, cpu); end_stack = is_softirq_stack(stack, cpu);
context = task_thread_info(task); bp = ops->walk_stack(task, stack, bp, ops, data,
bp = ops->walk_stack(context, stack, bp, ops, data,
end_stack, &graph); end_stack, &graph);
/* Stop if not on irq stack */ /* Stop if not on irq stack */
......
...@@ -153,7 +153,6 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs, ...@@ -153,7 +153,6 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
const struct stacktrace_ops *ops, void *data) const struct stacktrace_ops *ops, void *data)
{ {
const unsigned cpu = get_cpu(); const unsigned cpu = get_cpu();
struct thread_info *tinfo;
unsigned long *irq_stack = (unsigned long *)per_cpu(irq_stack_ptr, cpu); unsigned long *irq_stack = (unsigned long *)per_cpu(irq_stack_ptr, cpu);
unsigned long dummy; unsigned long dummy;
unsigned used = 0; unsigned used = 0;
...@@ -179,7 +178,6 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs, ...@@ -179,7 +178,6 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
* current stack address. If the stacks consist of nested * current stack address. If the stacks consist of nested
* exceptions * exceptions
*/ */
tinfo = task_thread_info(task);
while (!done) { while (!done) {
unsigned long *stack_end; unsigned long *stack_end;
enum stack_type stype; enum stack_type stype;
...@@ -202,7 +200,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs, ...@@ -202,7 +200,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
if (ops->stack(data, id) < 0) if (ops->stack(data, id) < 0)
break; break;
bp = ops->walk_stack(tinfo, stack, bp, ops, bp = ops->walk_stack(task, stack, bp, ops,
data, stack_end, &graph); data, stack_end, &graph);
ops->stack(data, "<EOE>"); ops->stack(data, "<EOE>");
/* /*
...@@ -218,7 +216,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs, ...@@ -218,7 +216,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
if (ops->stack(data, "IRQ") < 0) if (ops->stack(data, "IRQ") < 0)
break; break;
bp = ops->walk_stack(tinfo, stack, bp, bp = ops->walk_stack(task, stack, bp,
ops, data, stack_end, &graph); ops, data, stack_end, &graph);
/* /*
* We link to the next stack (which would be * We link to the next stack (which would be
...@@ -240,7 +238,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs, ...@@ -240,7 +238,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
/* /*
* This handles the process stack: * This handles the process stack:
*/ */
bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph); bp = ops->walk_stack(task, stack, bp, ops, data, NULL, &graph);
put_cpu(); put_cpu();
} }
EXPORT_SYMBOL(dump_trace); EXPORT_SYMBOL(dump_trace);
......
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