• James Clark's avatar
    perf: Always wake the parent event · 961c3912
    James Clark authored
    
    
    When using per-process mode and event inheritance is set to true,
    forked processes will create a new perf events via inherit_event() ->
    perf_event_alloc(). But these events will not have ring buffers
    assigned to them. Any call to wakeup will be dropped if it's called on
    an event with no ring buffer assigned because that's the object that
    holds the wakeup list.
    
    If the child event is disabled due to a call to
    perf_aux_output_begin() or perf_aux_output_end(), the wakeup is
    dropped leaving userspace hanging forever on the poll.
    
    Normally the event is explicitly re-enabled by userspace after it
    wakes up to read the aux data, but in this case it does not get woken
    up so the event remains disabled.
    
    This can be reproduced when using Arm SPE and 'stress' which forks once
    before running the workload. By looking at the list of aux buffers read,
    it's apparent that they stop after the fork:
    
      perf record -e arm_spe// -vvv -- stress -c 1
    
    With this patch applied they continue to be printed. This behaviour
    doesn't happen when using systemwide or per-cpu mode.
    Reported-by: default avatarRuben Ayrapetyan <Ruben.Ayrapetyan@arm.com>
    Signed-off-by: default avatarJames Clark <james.clark@arm.com>
    Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Link: https://lkml.kernel.org/r/20211206113840.130802-2-james.clark@arm.com
    961c3912
core.c 323 KB