perf: Simplify child event tear-down
authorPeter Zijlstra <peterz@infradead.org>
Fri, 17 Jan 2025 14:25:23 +0000 (15:25 +0100)
committerPeter Zijlstra <peterz@infradead.org>
Tue, 8 Apr 2025 18:55:46 +0000 (20:55 +0200)
commit0a00a43b8c200df5b9ca2b3e1726479b5916264b
treee3869a52423886755646c64d13a45886fa63c7ca
parent7ed9138a72829d2035ecbd8dbd35b1bc3c137c40
perf: Simplify child event tear-down

Currently perf_event_release_kernel() will iterate the child events and attempt
tear-down. However, it removes them from the child_list using list_move(),
notably skipping the state management done by perf_child_detach().

Crucially, it fails to clear PERF_ATTACH_CHILD, which opens the door for a
concurrent perf_remove_from_context() to race.

This way child_list management stays fully serialized using child_mutex.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Ravi Bangoria <ravi.bangoria@amd.com>
Link: https://lkml.kernel.org/r/20250307193305.486326750@infradead.org
kernel/events/core.c