• Peter Zijlstra's avatar
    perf: Fix races in computing the header sizes · f73e22ab
    Peter Zijlstra authored
    There are two races with the current code:
    
     - Another event can join the group and compute a larger header_size
       concurrently, if the smaller store wins we'll have an incorrect
       header_size set.
    
     - We compute the header_size after the event becomes active,
       therefore its possible to use the size before its computed.
    
    Remedy the first by moving the computation inside the ctx::mutex lock,
    and the second by placing it _before_ perf_install_in_context().
    Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
    f73e22ab
core.c 218 KB