• Peter Zijlstra's avatar
    perf: Rework perf_event_exit_event() · ef54c1a4
    Peter Zijlstra authored
    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: default avatarMarco Elver <elver@google.com>
    Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Link: https://lkml.kernel.org/r/20210408103605.1676875-2-elver@google.com
    ef54c1a4
core.c 316 KB