]> git.baikalelectronics.ru Git - kernel.git/commit
function_graph: Use new curr_ret_depth to manage depth instead of curr_ret_stack
authorSteven Rostedt (VMware) <rostedt@goodmis.org>
Mon, 19 Nov 2018 13:07:12 +0000 (08:07 -0500)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Wed, 28 Nov 2018 01:31:54 +0000 (20:31 -0500)
commitf69beb1d3a80f95d89f7e78eb714116075cbc3b8
tree790493fbeb31636acf0149ea92b146dc03f7c90d
parent05b58556c1d7c711a861beea7d8ad925a9b163cb
function_graph: Use new curr_ret_depth to manage depth instead of curr_ret_stack

Currently, the depth of the ret_stack is determined by curr_ret_stack index.
The issue is that there's a race between setting of the curr_ret_stack and
calling of the callback attached to the return of the function.

Commit 29022851af1b ("tracing/fgraph: Adjust fgraph depth before calling
trace return callback") moved the calling of the callback to after the
setting of the curr_ret_stack, even stating that it was safe to do so, when
in fact, it was the reason there was a barrier() there (yes, I should have
commented that barrier()).

Not only does the curr_ret_stack keep track of the current call graph depth,
it also keeps the ret_stack content from being overwritten by new data.

The function profiler, uses the "subtime" variable of ret_stack structure
and by moving the curr_ret_stack, it allows for interrupts to use the same
structure it was using, corrupting the data, and breaking the profiler.

To fix this, there needs to be two variables to handle the call stack depth
and the pointer to where the ret_stack is being used, as they need to change
at two different locations.

Cc: stable@kernel.org
Fixes: 29022851af1b0 ("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>
include/linux/sched.h
kernel/trace/ftrace.c
kernel/trace/trace_functions_graph.c