Skip to content

Commit 66eafeb

Browse files
Liming WangIngo Molnar
authored andcommitted
function trace: fix a bug of single thread function trace
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 <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
1 parent 222658e commit 66eafeb

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

kernel/trace/ftrace.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,8 @@ static void ftrace_update_pid_func(void)
243243
set_ftrace_pid_function(func);
244244
func = ftrace_pid_func;
245245
} else {
246-
if (func != ftrace_pid_func)
247-
goto out;
248-
249-
set_ftrace_pid_function(func);
246+
if (func == ftrace_pid_func)
247+
func = ftrace_pid_function;
250248
}
251249

252250
#ifdef CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST

0 commit comments

Comments
 (0)