tracing: Use trace_sched_process_free() instead of exit() for pid tracing
authorSteven Rostedt (VMware) <rostedt@goodmis.org>
Wed, 5 Aug 2020 00:00:02 +0000 (20:00 -0400)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Wed, 5 Aug 2020 00:15:07 +0000 (20:15 -0400)
commitafcab636657421f7ebfa0783a91f90256bba0091
treed8cb175e8c00ecfd6e6dc9a92ef13cfd6bcc1cd3
parent477d08478170469d10b533624342d13701e24b34
tracing: Use trace_sched_process_free() instead of exit() for pid tracing

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: 1e10486ffee0a ("ftrace: Add 'function-fork' trace option")
Fixes: c37775d57830a ("tracing: Add infrastructure to allow set_event_pid to follow children"
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
kernel/trace/ftrace.c
kernel/trace/trace_events.c