]> git.itanic.dy.fi Git - linux-stable/commit
perf: Rework perf_event_exit_event()
authorPeter Zijlstra <peterz@infradead.org>
Thu, 8 Apr 2021 10:35:56 +0000 (12:35 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 16 Apr 2021 14:32:40 +0000 (16:32 +0200)
commitef54c1a476aef7eef26fe13ea10dc090952c00f8
tree1ac3881ba3f8f3027cc2817f894be12c1c9d8327
parent874fc35cdd55e2d46161901de43ec58ca2efc5fe
perf: Rework perf_event_exit_event()

Make perf_event_exit_event() more robust, such that we can use it from
other contexts. Specifically the up and coming remove_on_exec.

For this to work we need to address a few issues. Remove_on_exec will
not destroy the entire context, so we cannot rely on TASK_TOMBSTONE to
disable event_function_call() and we thus have to use
perf_remove_from_context().

When using perf_remove_from_context(), there's two races to consider.
The first is against close(), where we can have concurrent tear-down
of the event. The second is against child_list iteration, which should
not find a half baked event.

To address this, teach perf_remove_from_context() to special case
!ctx->is_active and about DETACH_CHILD.

[ elver@google.com: fix racing parent/child exit in sync_child_event(). ]
Signed-off-by: Marco Elver <elver@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20210408103605.1676875-2-elver@google.com
include/linux/perf_event.h
kernel/events/core.c