ftrace: Access ret_stack->subtime only in the function profiler
authorNamhyung Kim <namhyung@kernel.org>
Wed, 31 Aug 2016 02:55:29 +0000 (11:55 +0900)
committerSteven Rostedt <rostedt@goodmis.org>
Thu, 1 Sep 2016 16:19:40 +0000 (12:19 -0400)
The subtime is used only for function profiler with function graph
tracer enabled.  Move the definition of subtime under
CONFIG_FUNCTION_PROFILER to reduce the memory usage.  Also move the
initialization of subtime into the graph entry callback.

Link: http://lkml.kernel.org/r/20160831025529.24018-1-namhyung@kernel.org
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Documentation/trace/ftrace.txt
include/linux/ftrace.h
kernel/trace/ftrace.c
kernel/trace/trace_functions_graph.c

index a6b3705e62a692667524e97b4a6a8ff36a328371..185c39fea2a022b6c6a7910e07a925d9688f542f 100644 (file)
@@ -858,11 +858,11 @@ x494] <- /root/a.out[+0x4a8] <- /lib/libc-2.7.so[+0x1e1a6]
               When enabled, it will account time the task has been
               scheduled out as part of the function call.
 
-  graph-time - When running function graph tracer, to include the
-              time to call nested functions. When this is not set,
-              the time reported for the function will only include
-              the time the function itself executed for, not the time
-              for functions that it called.
+  graph-time - When running function profiler with function graph tracer,
+              to include the time to call nested functions. When this is
+              not set, the time reported for the function will only
+              include the time the function itself executed for, not the
+              time for functions that it called.
 
   record-cmd - When any event or tracer is enabled, a hook is enabled
               in the sched_switch trace point to fill comm cache
index 7d565afe35d2fa9ba25359c9bf879d8bde9893e7..1e2b316d669306d3614381a3157c4fc5e10c1fd5 100644 (file)
@@ -794,7 +794,9 @@ struct ftrace_ret_stack {
        unsigned long ret;
        unsigned long func;
        unsigned long long calltime;
+#ifdef CONFIG_FUNCTION_PROFILER
        unsigned long long subtime;
+#endif
        unsigned long fp;
 };
 
index 84752c8e28b5286b03d9422a79a92429427681cb..2050a7652a86afa140ac94c3eb4de604aea80449 100644 (file)
@@ -872,7 +872,13 @@ function_profile_call(unsigned long ip, unsigned long parent_ip,
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
 static int profile_graph_entry(struct ftrace_graph_ent *trace)
 {
+       int index = trace->depth;
+
        function_profile_call(trace->func, 0, NULL, NULL);
+
+       if (index >= 0 && index < FTRACE_RETFUNC_DEPTH)
+               current->ret_stack[index].subtime = 0;
+
        return 1;
 }
 
index e14017c361709ad66ec4380c8c74d603c80faec7..148c90f1e49b29d970977ac53bcef2ed789a072a 100644 (file)
@@ -170,7 +170,6 @@ ftrace_push_return_trace(unsigned long ret, unsigned long func, int *depth,
        current->ret_stack[index].ret = ret;
        current->ret_stack[index].func = func;
        current->ret_stack[index].calltime = calltime;
-       current->ret_stack[index].subtime = 0;
        current->ret_stack[index].fp = frame_pointer;
        *depth = current->curr_ret_stack;