]> git.baikalelectronics.ru Git - kernel.git/commit
function_graph: Reverse the order of pushing the ret_stack and the callback
authorSteven Rostedt (VMware) <rostedt@goodmis.org>
Tue, 20 Nov 2018 17:40:25 +0000 (12:40 -0500)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Wed, 28 Nov 2018 01:31:54 +0000 (20:31 -0500)
commitb71166985ca333365461cd5c09f7447e6cf4e422
tree9fc799fd26232ec5a9018d33d965bb048947aab8
parent98d51a76b9b000cebca1634fd3db6f77274077f3
function_graph: Reverse the order of pushing the ret_stack and the callback

The function graph profiler uses the ret_stack to store the "subtime" and
reuse it by nested functions and also on the return. But the current logic
has the profiler callback called before the ret_stack is updated, and it is
just modifying the ret_stack that will later be allocated (it's just lucky
that the "subtime" is not touched when it is allocated).

This could also cause a crash if we are at the end of the ret_stack when
this happens.

By reversing the order of the allocating the ret_stack and then calling the
callbacks attached to a function being traced, the ret_stack entry is no
longer used before it is allocated.

Cc: stable@kernel.org
Fixes: 7e2f56662a145 ("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