[3.16.y-ckt stable] Patch "ftrace: Fix ftrace enable ordering of sysctl ftrace_enabled" has been added to staging queue

Luis Henriques luis.henriques at canonical.com
Tue Mar 24 15:34:29 UTC 2015

This is a note to let you know that I have just added a patch titled

    ftrace: Fix ftrace enable ordering of sysctl ftrace_enabled

to the linux-3.16.y-queue branch of the 3.16.y-ckt extended stable tree 
which can be found at:


This patch is scheduled to be released in version 3.16.7-ckt9.

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.16.y-ckt tree, see



>From 297c23116216700d782172a261692617a5cd6ec3 Mon Sep 17 00:00:00 2001
From: "Steven Rostedt (Red Hat)" <rostedt at goodmis.org>
Date: Fri, 6 Mar 2015 19:55:13 -0500
Subject: ftrace: Fix ftrace enable ordering of sysctl ftrace_enabled

commit 524a38682573b2e15ab6317ccfe50280441514be upstream.

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.

Signed-off-by: Steven Rostedt <rostedt at goodmis.org>
Signed-off-by: Luis Henriques <luis.henriques at canonical.com>
 kernel/trace/ftrace.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 054f9bbe5f12..6cf0ed87edbc 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -2229,7 +2229,7 @@ static void ftrace_startup_sysctl(void)
 		if (ftrace_graph_active)
 			command |= FTRACE_START_FUNC_RET;
-		ftrace_run_update_code(command);
+		ftrace_startup_enable(command);

@@ -4914,12 +4914,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)

+		ftrace_startup_sysctl();
 	} else {
 		/* stopping ftrace calls (just send to ftrace_stub) */
 		ftrace_trace_function = ftrace_stub;

More information about the kernel-team mailing list