]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
tracing: fix deadlock when setting set_ftrace_pid
authorKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Fri, 6 Mar 2009 06:29:04 +0000 (15:29 +0900)
committerIngo Molnar <mingo@elte.hu>
Fri, 6 Mar 2009 11:07:38 +0000 (12:07 +0100)
Impact: fix deadlock while using set_ftrace_pid

Reproducer:

# cd /sys/kernel/debug/tracing
# echo $$ > set_ftrace_pid

then, console becomes hung.

Details:

when writing set_ftracepid, kernel callstack is following

ftrace_pid_write()
mutex_lock(&ftrace_lock);
ftrace_update_pid_func()
mutex_lock(&ftrace_lock);
mutex_unlock(&ftrace_lock);
mutex_unlock(&ftrace_lock);

then, system always deadlocks when ftrace_pid_write() is called.

In past days, ftrace_pid_write() used ftrace_start_lock, but
commit e6ea44e9b4c12325337cd1c06103cd515a1c02b2 consolidated
ftrace_start_lock to ftrace_lock.

Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Reviewed-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Steven Rostedt <srostedt@redhat.com>
LKML-Reference: <20090306151155.0778.A69D9226@jp.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
kernel/trace/ftrace.c

index d7a06a0d9447d77f4c9ec6fb469b1d88da0f55da..d33d306bdcf4648ab9daabeabb803828c4864cb1 100644 (file)
@@ -218,10 +218,8 @@ static void ftrace_update_pid_func(void)
 {
        ftrace_func_t func;
 
-       mutex_lock(&ftrace_lock);
-
        if (ftrace_trace_function == ftrace_stub)
-               goto out;
+               return;
 
        func = ftrace_trace_function;
 
@@ -238,9 +236,6 @@ static void ftrace_update_pid_func(void)
 #else
        __ftrace_trace_function = func;
 #endif
-
- out:
-       mutex_unlock(&ftrace_lock);
 }
 
 /* set when tracing only a pid */