function_graph: Move return callback before update of curr_ret_stack
authorSteven Rostedt (VMware) <rostedt@goodmis.org>
Mon, 19 Nov 2018 20:18:40 +0000 (15:18 -0500)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Wed, 28 Nov 2018 01:31:54 +0000 (20:31 -0500)
commit552701dd0fa7c3d448142e87210590ba424694a0
tree3090655780506b181aeef9125d6377d6166349a8
parent39eb456dacb543de90d3bc6a8e0ac5cf51ac475e
function_graph: Move return callback before update of curr_ret_stack

In the past, curr_ret_stack had two functions. One was to denote the depth
of the call graph, the other is to keep track of where on the ret_stack the
data is used. Although they may be slightly related, there are two cases
where they need to be used differently.

The one case is that it keeps the ret_stack data from being corrupted by an
interrupt coming in and overwriting the data still in use. The other is just
to know where the depth of the stack currently is.

The function profiler uses the ret_stack to save a "subtime" variable that
is part of the data on the ret_stack. If curr_ret_stack is modified too
early, then this variable can be corrupted.

The "max_depth" option, when set to 1, will record the first functions going
into the kernel. To see all top functions (when dealing with timings), the
depth variable needs to be lowered before calling the return hook. But by
lowering the curr_ret_stack, it makes the data on the ret_stack still being
used by the return hook susceptible to being overwritten.

Now that there's two variables to handle both cases (curr_ret_depth), we can
move them to the locations where they can handle both cases.

Cc: stable@kernel.org
Fixes: 03274a3ffb449 ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
kernel/trace/trace_functions_graph.c