ftrace: Fix ftrace enable ordering of sysctl ftrace_enabled
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>
Sat, 7 Mar 2015 00:55:13 +0000 (19:55 -0500)
committerSteven Rostedt <rostedt@goodmis.org>
Mon, 9 Mar 2015 14:55:34 +0000 (10:55 -0400)
Some archs (specifically PowerPC), are sensitive with the ordering of
the enabling of the calls to function tracing and setting of the
function to use to be traced.

That is, update_ftrace_function() sets what function the ftrace_caller
trampoline should call. Some archs require this to be set before
calling ftrace_run_update_code().

Another bug was discovered, that ftrace_startup_sysctl() called
ftrace_run_update_code() directly. If the function the ftrace_caller
trampoline changes, then it will not be updated. Instead a call
to ftrace_startup_enable() should be called because it tests to see
if the callback changed since the code was disabled, and will
tell the arch to update appropriately. Most archs do not need this
notification, but PowerPC does.

The problem could be seen by the following commands:

 # echo 0 > /proc/sys/kernel/ftrace_enabled
 # echo function > /sys/kernel/debug/tracing/current_tracer
 # echo 1 > /proc/sys/kernel/ftrace_enabled
 # cat /sys/kernel/debug/tracing/trace

The trace will show that function tracing was not active.

Cc: stable@vger.kernel.org # 2.6.27+
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
kernel/trace/ftrace.c

index ea520bb54d44acb1b83bd6b707a470f1256e0dfe..4f228024055b119d93279705ec4c42d7475c72f7 100644 (file)
@@ -2710,7 +2710,7 @@ static void ftrace_startup_sysctl(void)
                command = FTRACE_UPDATE_CALLS;
                if (ftrace_graph_active)
                        command |= FTRACE_START_FUNC_RET;
-               ftrace_run_update_code(command);
+               ftrace_startup_enable(command);
        }
 }
 
@@ -5580,12 +5580,12 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
 
        if (ftrace_enabled) {
 
-               ftrace_startup_sysctl();
-
                /* we are starting ftrace again */
                if (ftrace_ops_list != &ftrace_list_end)
                        update_ftrace_function();
 
+               ftrace_startup_sysctl();
+
        } else {
                /* stopping ftrace calls (just send to ftrace_stub) */
                ftrace_trace_function = ftrace_stub;
This page took 0.028595 seconds and 5 git commands to generate.