tracing/stack_trace: Skip 4 instead of 3 when using ftrace_ops_list_func
authorJiaxing Wang <wangjiaxing@insigma.com.cn>
Sun, 20 Apr 2014 15:10:43 +0000 (23:10 +0800)
committerSteven Rostedt <rostedt@goodmis.org>
Thu, 24 Apr 2014 17:36:03 +0000 (13:36 -0400)
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/1398006644-5935-2-git-send-email-wangjiaxing@insigma.com.cn
Signed-off-by: Jiaxing Wang <wangjiaxing@insigma.com.cn>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
kernel/trace/ftrace.c
kernel/trace/trace.h
kernel/trace/trace_stack.c

index 846888ea2ba4cd9ffd37c5b4d8836c46c59d7dec..3cfeb66bda6703a22dd78c6def2d4685344b7c76 100644 (file)
@@ -313,6 +313,11 @@ static void update_ftrace_function(void)
        ftrace_trace_function = func;
 }
 
+int using_ftrace_ops_list_func(void)
+{
+       return ftrace_trace_function == ftrace_ops_list_func;
+}
+
 static void add_ftrace_ops(struct ftrace_ops **list, struct ftrace_ops *ops)
 {
        ops->next = *list;
index 5d2f07d6746c0a5a49b2e12a152f830c9611046f..8624b50414660cc2f43f1f83f0afdb699c8f5c9a 100644 (file)
@@ -830,6 +830,7 @@ void ftrace_destroy_function_files(struct trace_array *tr);
 void ftrace_init_global_array_ops(struct trace_array *tr);
 void ftrace_init_array_ops(struct trace_array *tr, ftrace_func_t func);
 void ftrace_reset_array_ops(struct trace_array *tr);
+int using_ftrace_ops_list_func(void);
 #else
 static inline int ftrace_trace_task(struct task_struct *task)
 {
index 21b320e5d163c6c1958d5fbddc4528a533f4a6ff..5aa9a5b9b6e2b197e56fa272cf7b0777a682df33 100644 (file)
@@ -85,8 +85,12 @@ check_stack(unsigned long ip, unsigned long *stack)
 
        max_stack_size = this_size;
 
-       max_stack_trace.nr_entries      = 0;
-       max_stack_trace.skip            = 3;
+       max_stack_trace.nr_entries = 0;
+
+       if (using_ftrace_ops_list_func())
+               max_stack_trace.skip = 4;
+       else
+               max_stack_trace.skip = 3;
 
        save_stack_trace(&max_stack_trace);