Skip to content

Commit

Permalink
tracing: fix deadlock when setting set_ftrace_pid
Browse files Browse the repository at this point in the history
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 e6ea44e 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>
  • Loading branch information
KOSAKI Motohiro authored and Ingo Molnar committed Mar 6, 2009
1 parent 422d3c7 commit 10dd3eb
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions kernel/trace/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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 */
Expand Down

0 comments on commit 10dd3eb

Please sign in to comment.