• Peter Zijlstra's avatar
    perf_events: Restore sanity to scaling land · acd1d7c1
    Peter Zijlstra authored
    It is quite possible to call update_event_times() on a context
    that isn't actually running and thereby confuse the thing.
    
    perf stat was reporting !100% scale values for software counters
    (2e2af50b perf_events: Disable events when we detach them,
    solved the worst of that, but there was still some left).
    
    The thing that happens is that because we are not self-reaping
    (we have a caring parent) there is a time between the last
    schedule (out) and having do_exit() called which will detach the
    events.
    
    This period would be accounted as enabled,!running because the
    event->state==INACTIVE, even though !event->ctx->is_active.
    
    Similar issues could have been observed by calling read() on a
    event while the attached task was not scheduled in.
    
    Solve this by teaching update_event_times() about
    ctx->is_active.
    Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
    Cc: Paul Mackerras <paulus@samba.org>
    Cc: Mike Galbraith <efault@gmx.de>
    Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Frederic Weisbecker <fweisbec@gmail.com>
    LKML-Reference: <1258984836.4531.480.camel@laptop>
    Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
    acd1d7c1
perf_event.c 120 KB