Skip to content

Commit 4a13a00

Browse files
rostedtgregkh
authored andcommitted
tracing: Use stack of calling function for stack tracer
commit 8788950 upstream. 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. Signed-off-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0e16fac commit 4a13a00

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

‎kernel/trace/trace_stack.c‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,21 @@ static DEFINE_MUTEX(stack_sysctl_mutex);
3939
int stack_tracer_enabled;
4040
static int last_stack_tracer_enabled;
4141

42-
static inline void check_stack(void)
42+
static inline void
43+
check_stack(unsigned long *stack)
4344
{
4445
unsigned long this_size, flags;
4546
unsigned long *p, *top, *start;
4647
int i;
4748

48-
this_size = ((unsigned long)&this_size) & (THREAD_SIZE-1);
49+
this_size = ((unsigned long)stack) & (THREAD_SIZE-1);
4950
this_size = THREAD_SIZE - this_size;
5051

5152
if (this_size <= max_stack_size)
5253
return;
5354

5455
/* we do not handle interrupt stacks yet */
55-
if (!object_is_on_stack(&this_size))
56+
if (!object_is_on_stack(stack))
5657
return;
5758

5859
local_irq_save(flags);
@@ -73,7 +74,7 @@ static inline void check_stack(void)
7374
* Now find where in the stack these are.
7475
*/
7576
i = 0;
76-
start = &this_size;
77+
start = stack;
7778
top = (unsigned long *)
7879
(((unsigned long)start & ~(THREAD_SIZE-1)) + THREAD_SIZE);
7980

@@ -113,6 +114,7 @@ static void
113114
stack_trace_call(unsigned long ip, unsigned long parent_ip,
114115
struct ftrace_ops *op, struct pt_regs *pt_regs)
115116
{
117+
unsigned long stack;
116118
int cpu;
117119

118120
preempt_disable_notrace();
@@ -122,7 +124,7 @@ stack_trace_call(unsigned long ip, unsigned long parent_ip,
122124
if (per_cpu(trace_active, cpu)++ != 0)
123125
goto out;
124126

125-
check_stack();
127+
check_stack(&stack);
126128

127129
out:
128130
per_cpu(trace_active, cpu)--;

0 commit comments

Comments
 (0)