Skip to content

Commit 10dd3eb

Browse files
kosakiIngo Molnar
authored andcommitted
tracing: fix deadlock when setting set_ftrace_pid
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 <[email protected]> Reviewed-by: Lai Jiangshan <[email protected]> Cc: Steven Rostedt <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
1 parent 422d3c7 commit 10dd3eb

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

kernel/trace/ftrace.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,8 @@ static void ftrace_update_pid_func(void)
218218
{
219219
ftrace_func_t func;
220220

221-
mutex_lock(&ftrace_lock);
222-
223221
if (ftrace_trace_function == ftrace_stub)
224-
goto out;
222+
return;
225223

226224
func = ftrace_trace_function;
227225

@@ -238,9 +236,6 @@ static void ftrace_update_pid_func(void)
238236
#else
239237
__ftrace_trace_function = func;
240238
#endif
241-
242-
out:
243-
mutex_unlock(&ftrace_lock);
244239
}
245240

246241
/* set when tracing only a pid */

0 commit comments

Comments
 (0)