aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace
diff options
context:
space:
mode:
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>2013-03-13 20:43:57 -0400
committerSteven Rostedt <rostedt@goodmis.org>2013-03-15 00:36:06 -0400
commit87889501d0adfae10e3b0f0e6f2d7536eed9ae84 (patch)
treec103cc8bf1687f5ffe54ff7f17c7672bda20cad1 /kernel/trace
parentdd42cd3ea96d687f15525c4f14fa582702db223f (diff)
tracing: Use stack of calling function for stack tracer
Use the stack of stack_trace_call() instead of check_stack() as the test pointer for max stack size. It makes it a bit cleaner and a little more accurate. Adding stable, as a later fix depends on this patch. Cc: stable@vger.kernel.org Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace')
-rw-r--r--kernel/trace/trace_stack.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
index 42ca822fc701..dc02e29d8255 100644
--- a/kernel/trace/trace_stack.c
+++ b/kernel/trace/trace_stack.c
@@ -39,20 +39,21 @@ static DEFINE_MUTEX(stack_sysctl_mutex);
39int stack_tracer_enabled; 39int stack_tracer_enabled;
40static int last_stack_tracer_enabled; 40static int last_stack_tracer_enabled;
41 41
42static inline void check_stack(void) 42static inline void
43check_stack(unsigned long *stack)
43{ 44{
44 unsigned long this_size, flags; 45 unsigned long this_size, flags;
45 unsigned long *p, *top, *start; 46 unsigned long *p, *top, *start;
46 int i; 47 int i;
47 48
48 this_size = ((unsigned long)&this_size) & (THREAD_SIZE-1); 49 this_size = ((unsigned long)stack) & (THREAD_SIZE-1);
49 this_size = THREAD_SIZE - this_size; 50 this_size = THREAD_SIZE - this_size;
50 51
51 if (this_size <= max_stack_size) 52 if (this_size <= max_stack_size)
52 return; 53 return;
53 54
54 /* we do not handle interrupt stacks yet */ 55 /* we do not handle interrupt stacks yet */
55 if (!object_is_on_stack(&this_size)) 56 if (!object_is_on_stack(stack))
56 return; 57 return;
57 58
58 local_irq_save(flags); 59 local_irq_save(flags);
@@ -73,7 +74,7 @@ static inline void check_stack(void)
73 * Now find where in the stack these are. 74 * Now find where in the stack these are.
74 */ 75 */
75 i = 0; 76 i = 0;
76 start = &this_size; 77 start = stack;
77 top = (unsigned long *) 78 top = (unsigned long *)
78 (((unsigned long)start & ~(THREAD_SIZE-1)) + THREAD_SIZE); 79 (((unsigned long)start & ~(THREAD_SIZE-1)) + THREAD_SIZE);
79 80
@@ -113,6 +114,7 @@ static void
113stack_trace_call(unsigned long ip, unsigned long parent_ip, 114stack_trace_call(unsigned long ip, unsigned long parent_ip,
114 struct ftrace_ops *op, struct pt_regs *pt_regs) 115 struct ftrace_ops *op, struct pt_regs *pt_regs)
115{ 116{
117 unsigned long stack;
116 int cpu; 118 int cpu;
117 119
118 preempt_disable_notrace(); 120 preempt_disable_notrace();
@@ -122,7 +124,7 @@ stack_trace_call(unsigned long ip, unsigned long parent_ip,
122 if (per_cpu(trace_active, cpu)++ != 0) 124 if (per_cpu(trace_active, cpu)++ != 0)
123 goto out; 125 goto out;
124 126
125 check_stack(); 127 check_stack(&stack);
126 128
127 out: 129 out:
128 per_cpu(trace_active, cpu)--; 130 per_cpu(trace_active, cpu)--;