Skip to content

Commit 524a386

Browse files
committed
ftrace: Fix ftrace enable ordering of sysctl ftrace_enabled
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>
1 parent 1619dc3 commit 524a386

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

kernel/trace/ftrace.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2710,7 +2710,7 @@ static void ftrace_startup_sysctl(void)
27102710
command = FTRACE_UPDATE_CALLS;
27112711
if (ftrace_graph_active)
27122712
command |= FTRACE_START_FUNC_RET;
2713-
ftrace_run_update_code(command);
2713+
ftrace_startup_enable(command);
27142714
}
27152715
}
27162716

@@ -5580,12 +5580,12 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
55805580

55815581
if (ftrace_enabled) {
55825582

5583-
ftrace_startup_sysctl();
5584-
55855583
/* we are starting ftrace again */
55865584
if (ftrace_ops_list != &ftrace_list_end)
55875585
update_ftrace_function();
55885586

5587+
ftrace_startup_sysctl();
5588+
55895589
} else {
55905590
/* stopping ftrace calls (just send to ftrace_stub) */
55915591
ftrace_trace_function = ftrace_stub;

0 commit comments

Comments
 (0)