Skip to content

Commit 8861dd3

Browse files
namhyungrostedt
authored andcommitted
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. 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>
1 parent 613dccd commit 8861dd3

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

Documentation/trace/ftrace.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -858,11 +858,11 @@ x494] <- /root/a.out[+0x4a8] <- /lib/libc-2.7.so[+0x1e1a6]
858858
When enabled, it will account time the task has been
859859
scheduled out as part of the function call.
860860

861-
graph-time - When running function graph tracer, to include the
862-
time to call nested functions. When this is not set,
863-
the time reported for the function will only include
864-
the time the function itself executed for, not the time
865-
for functions that it called.
861+
graph-time - When running function profiler with function graph tracer,
862+
to include the time to call nested functions. When this is
863+
not set, the time reported for the function will only
864+
include the time the function itself executed for, not the
865+
time for functions that it called.
866866

867867
record-cmd - When any event or tracer is enabled, a hook is enabled
868868
in the sched_switch trace point to fill comm cache

include/linux/ftrace.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,9 @@ struct ftrace_ret_stack {
794794
unsigned long ret;
795795
unsigned long func;
796796
unsigned long long calltime;
797+
#ifdef CONFIG_FUNCTION_PROFILER
797798
unsigned long long subtime;
799+
#endif
798800
unsigned long fp;
799801
};
800802

kernel/trace/ftrace.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,13 @@ function_profile_call(unsigned long ip, unsigned long parent_ip,
872872
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
873873
static int profile_graph_entry(struct ftrace_graph_ent *trace)
874874
{
875+
int index = trace->depth;
876+
875877
function_profile_call(trace->func, 0, NULL, NULL);
878+
879+
if (index >= 0 && index < FTRACE_RETFUNC_DEPTH)
880+
current->ret_stack[index].subtime = 0;
881+
876882
return 1;
877883
}
878884

kernel/trace/trace_functions_graph.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ ftrace_push_return_trace(unsigned long ret, unsigned long func, int *depth,
170170
current->ret_stack[index].ret = ret;
171171
current->ret_stack[index].func = func;
172172
current->ret_stack[index].calltime = calltime;
173-
current->ret_stack[index].subtime = 0;
174173
current->ret_stack[index].fp = frame_pointer;
175174
*depth = current->curr_ret_stack;
176175

0 commit comments

Comments
 (0)