tracing: Fix stack tracer sysctl handling
authorLi Zefan <lizf@cn.fujitsu.com>
Fri, 26 Jun 2009 08:55:51 +0000 (16:55 +0800)
committerIngo Molnar <mingo@elte.hu>
Fri, 26 Jun 2009 18:48:39 +0000 (20:48 +0200)
This made my machine completely frozen:

  # echo 1 > /proc/sys/kernel/stack_tracer_enabled
  # echo 2 > /proc/sys/kernel/stack_tracer_enabled

The cause is register_ftrace_function() was called twice.

Also fix ftrace_enabled sysctl, though seems nothing bad happened
as I tested it.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <4A448D17.9010305@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
kernel/trace/ftrace.c
kernel/trace/trace_stack.c

index f3716bf04df648418b5f8dc246d54c958097baaf..bce9e01a29c8402301635e4d70ed810bb78eb303 100644 (file)
@@ -3160,10 +3160,10 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
 
        ret  = proc_dointvec(table, write, file, buffer, lenp, ppos);
 
-       if (ret || !write || (last_ftrace_enabled == ftrace_enabled))
+       if (ret || !write || (last_ftrace_enabled == !!ftrace_enabled))
                goto out;
 
-       last_ftrace_enabled = ftrace_enabled;
+       last_ftrace_enabled = !!ftrace_enabled;
 
        if (ftrace_enabled) {
 
index 2d7aebd71dbd4e3489b8bf59fd29585b422be8e9..e644af91012468d2e8771a885d6298e0de93e66c 100644 (file)
@@ -326,10 +326,10 @@ stack_trace_sysctl(struct ctl_table *table, int write,
        ret = proc_dointvec(table, write, file, buffer, lenp, ppos);
 
        if (ret || !write ||
-           (last_stack_tracer_enabled == stack_tracer_enabled))
+           (last_stack_tracer_enabled == !!stack_tracer_enabled))
                goto out;
 
-       last_stack_tracer_enabled = stack_tracer_enabled;
+       last_stack_tracer_enabled = !!stack_tracer_enabled;
 
        if (stack_tracer_enabled)
                register_ftrace_function(&trace_ops);