Skip to content

Commit 7eea4fc

Browse files
Jiaxing Wangrostedt
authored andcommitted
tracing/stack_trace: Skip 4 instead of 3 when using ftrace_ops_list_func
When using ftrace_ops_list_func, we should skip 4 instead of 3, to avoid ftrace_call+0x5/0xb appearing in the stack trace: Depth Size Location (110 entries) ----- ---- -------- 0) 2956 0 update_curr+0xe/0x1e0 1) 2956 68 ftrace_call+0x5/0xb 2) 2888 92 enqueue_entity+0x53/0xe80 3) 2796 80 enqueue_task_fair+0x47/0x7e0 4) 2716 28 enqueue_task+0x45/0x70 5) 2688 12 activate_task+0x22/0x30 Add a function using_ftrace_ops_list_func() to test for this while keeping ftrace_ops_list_func to remain static. Link: http://lkml.kernel.org/p/[email protected] Signed-off-by: Jiaxing Wang <[email protected]> Signed-off-by: Steven Rostedt <[email protected]>
1 parent ad1438a commit 7eea4fc

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

kernel/trace/ftrace.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,11 @@ static void update_ftrace_function(void)
313313
ftrace_trace_function = func;
314314
}
315315

316+
int using_ftrace_ops_list_func(void)
317+
{
318+
return ftrace_trace_function == ftrace_ops_list_func;
319+
}
320+
316321
static void add_ftrace_ops(struct ftrace_ops **list, struct ftrace_ops *ops)
317322
{
318323
ops->next = *list;

kernel/trace/trace.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,7 @@ void ftrace_destroy_function_files(struct trace_array *tr);
830830
void ftrace_init_global_array_ops(struct trace_array *tr);
831831
void ftrace_init_array_ops(struct trace_array *tr, ftrace_func_t func);
832832
void ftrace_reset_array_ops(struct trace_array *tr);
833+
int using_ftrace_ops_list_func(void);
833834
#else
834835
static inline int ftrace_trace_task(struct task_struct *task)
835836
{

kernel/trace/trace_stack.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,12 @@ check_stack(unsigned long ip, unsigned long *stack)
8585

8686
max_stack_size = this_size;
8787

88-
max_stack_trace.nr_entries = 0;
89-
max_stack_trace.skip = 3;
88+
max_stack_trace.nr_entries = 0;
89+
90+
if (using_ftrace_ops_list_func())
91+
max_stack_trace.skip = 4;
92+
else
93+
max_stack_trace.skip = 3;
9094

9195
save_stack_trace(&max_stack_trace);
9296

0 commit comments

Comments
 (0)