• Peter Zijlstra's avatar
    perf: Fix contexted inheritance · c5ed5145
    Peter Zijlstra authored
    Linus reported that the RCU lockdep annotation bits triggered for this
    rcu_dereference() because we're not holding rcu_read_lock().
    
    Going over the code I cannot convince myself its correct:
    
     - holding a ref on the parent_ctx, doesn't avoid it being uncloned
       concurrently (as the comment says), so we can race with a free.
    
     - holding parent_ctx->mutex doesn't avoid the above free from taking
       place either, it would at best avoid parent_ctx from being freed.
    
    I.e. the warning is correct. To fix the bug, serialize against the
    unclone_ctx() call by extending the reach of the parent_ctx->lock.
    Reported-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
    Cc: Paul Mackerras <paulus@samba.org>
    Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
    LKML-Reference: <new-submission>
    Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
    c5ed5145
perf_event.c 152 KB