function trace: fix a bug of single thread function trace
authorLiming Wang <liming.wang@windriver.com>
Tue, 2 Dec 2008 02:33:08 +0000 (10:33 +0800)
committerIngo Molnar <mingo@elte.hu>
Tue, 2 Dec 2008 08:23:24 +0000 (09:23 +0100)
Impact: fix "no output from tracer" bug caused by ftrace_update_pid_func()

When disabling single thread function trace using
"echo -1 > set_ftrace_pid", the normal function trace
has to restore to original function, otherwise the normal
function trace will not work well.

Without this commit, something like below:

$ ps |grep 850
  850 root      2556 S    -/bin/sh
$ echo 850 > /debug/tracing/set_ftrace_pid
$ echo function > /debug/tracing/current_tracer
$ echo 1 > /debug/tracing/tracing_enabled
$ sleep 1
$ echo 0 > /debug/tracing/tracing_enabled
$ cat /debug/tracing/trace_pipe |wc -l
59704
$ echo -1 > /debug/tracing/set_ftrace_pid
$ echo 1 > /debug/tracing/tracing_enabled
$ sleep 1
$ echo 0 > /debug/tracing/tracing_enabled
$ more /debug/tracing/trace_pipe
<====== nothing output now!
it should output trace record.

Signed-off-by: Liming Wang <liming.wang@windriver.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
kernel/trace/ftrace.c

index 08b536a2614ed62faa562be542f1b3bb67232a00..6d89ab46c6e3777b3c4f57cc1650cace5ac8daa4 100644 (file)
@@ -243,10 +243,8 @@ static void ftrace_update_pid_func(void)
                set_ftrace_pid_function(func);
                func = ftrace_pid_func;
        } else {
-               if (func != ftrace_pid_func)
-                       goto out;
-
-               set_ftrace_pid_function(func);
+               if (func == ftrace_pid_func)
+                       func = ftrace_pid_function;
        }
 
 #ifdef CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST