Skip to content

Commit aedfe61

Browse files
rostedtgregkh
authored andcommitted
tracing: Use trace_sched_process_free() instead of exit() for pid tracing
commit afcab63 upstream. On exit, if a process is preempted after the trace_sched_process_exit() tracepoint but before the process is done exiting, then when it gets scheduled in, the function tracers will not filter it properly against the function tracing pid filters. That is because the function tracing pid filters hooks to the sched_process_exit() tracepoint to remove the exiting task's pid from the filter list. Because the filtering happens at the sched_switch tracepoint, when the exiting task schedules back in to finish up the exit, it will no longer be in the function pid filtering tables. This was noticeable in the notrace self tests on a preemptable kernel, as the tests would fail as it exits and preempted after being taken off the notrace filter table and on scheduling back in it would not be in the notrace list, and then the ending of the exit function would trace. The test detected this and would fail. Cc: stable@vger.kernel.org Cc: Namhyung Kim <namhyung@kernel.org> Fixes: 1e10486 ("ftrace: Add 'function-fork' trace option") Fixes: c37775d ("tracing: Add infrastructure to allow set_event_pid to follow children" Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e8b292a commit aedfe61

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎kernel/trace/ftrace.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6969,12 +6969,12 @@ void ftrace_pid_follow_fork(struct trace_array *tr, bool enable)
69696969
if (enable) {
69706970
register_trace_sched_process_fork(ftrace_pid_follow_sched_process_fork,
69716971
tr);
6972-
register_trace_sched_process_exit(ftrace_pid_follow_sched_process_exit,
6972+
register_trace_sched_process_free(ftrace_pid_follow_sched_process_exit,
69736973
tr);
69746974
} else {
69756975
unregister_trace_sched_process_fork(ftrace_pid_follow_sched_process_fork,
69766976
tr);
6977-
unregister_trace_sched_process_exit(ftrace_pid_follow_sched_process_exit,
6977+
unregister_trace_sched_process_free(ftrace_pid_follow_sched_process_exit,
69786978
tr);
69796979
}
69806980
}

‎kernel/trace/trace_events.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,12 +538,12 @@ void trace_event_follow_fork(struct trace_array *tr, bool enable)
538538
if (enable) {
539539
register_trace_prio_sched_process_fork(event_filter_pid_sched_process_fork,
540540
tr, INT_MIN);
541-
register_trace_prio_sched_process_exit(event_filter_pid_sched_process_exit,
541+
register_trace_prio_sched_process_free(event_filter_pid_sched_process_exit,
542542
tr, INT_MAX);
543543
} else {
544544
unregister_trace_sched_process_fork(event_filter_pid_sched_process_fork,
545545
tr);
546-
unregister_trace_sched_process_exit(event_filter_pid_sched_process_exit,
546+
unregister_trace_sched_process_free(event_filter_pid_sched_process_exit,
547547
tr);
548548
}
549549
}

0 commit comments

Comments
 (0)