]> git.baikalelectronics.ru Git - kernel.git/commit
ftrace/graph: Trace function entry before updating index
authorSteven Rostedt <srostedt@redhat.com>
Sat, 12 Feb 2011 01:36:02 +0000 (20:36 -0500)
committerSteven Rostedt <rostedt@goodmis.org>
Thu, 10 Mar 2011 15:34:43 +0000 (10:34 -0500)
commit5173812b78254d6e98b59e2a015ac84f82c2b223
treebcaaca178d547618e50cda43544096863d955a92
parentfa11506844542b97b19edfc2e5f2408444300d82
ftrace/graph: Trace function entry before updating index

Currently the index to the ret_stack is updated and the real return address
is saved in the ret_stack. Then we call the trace function. The trace
function could decide that it doesn't want to trace this function
(ex. set_graph_function does not match) and it will return 0 which means
not to trace this call.

The normal function graph tracer has this code:

if (!(trace->depth || ftrace_graph_addr(trace->func)) ||
      ftrace_graph_ignore_irqs())
return 0;

What this states is, if the trace depth (which is curr_ret_stack)
is zero (top of nested functions) then test if we want to trace this
function. If this function is not to be traced, then return  0 and
the rest of the function graph tracer logic will not trace this function.

The problem arises when an interrupt comes in after we updated the
curr_ret_stack. The next function that gets called will have a trace->depth
of 1. Which fools this trace code into thinking that we are in a nested
function, and that we should trace. This causes interrupts to be traced
when they should not be.

The solution is to trace the function first and then update the ret_stack.

Reported-by: zhiping zhong <xzhong86@163.com>
Reported-by: wu zhangjin <wuzhangjin@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
arch/x86/kernel/ftrace.c