Skip to contentSkip to conversation

ftrace: Access ret_stack->subtime only in the function profiler

PATCH Applied Namhyung Kim 2 participants 2 messages Aug 31, 2016 – Sep 1, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ftrace: Access ret_stack->subtime only in the function profiler

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.

Cc Josh Poimboeuf <[email protected]>
---
 Documentation/trace/ftrace.txt       | 10 +++++-----
 include/linux/ftrace.h               |  2 ++
 kernel/trace/ftrace.c                |  6 ++++++
 kernel/trace/trace_functions_graph.c |  1 -
 4 files changed, 13 insertions(+), 6 deletions(-)
Documentation/trace/ftrace.txt +5 -5
index a6b3705e62a6..185c39fea2a0 100644
@@ -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
include/linux/ftrace.h +2 -0
index 6f93ac46e7f0..b3d34d3e0e7e 100644
@@ -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
 #ifdef HAVE_FUNCTION_GRAPH_FP_TEST
 	unsigned long fp;
 #endif
kernel/trace/ftrace.c +6 -0
index 84752c8e28b5..2050a7652a86 100644
@@ -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;
 }
 
kernel/trace/trace_functions_graph.c +0 -1
index 0cbe38a844fa..9c7ffa4df5a8 100644
@@ -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;
 #ifdef HAVE_FUNCTION_GRAPH_FP_TEST
 	current->ret_stack[index].fp = frame_pointer;
 #endif
Signature · 1 line
2.9.3
maintainer Applied
#1 lore raw
Quoted 7 lines · On Wed, 31 Aug 2016 11:55:29 +0900 Namhyung Kim <[email protected]> wrote:

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.

Cc Josh Poimboeuf <[email protected]>

Applied, thanks Namhyung!

-- Steve