• Peter Zijlstra's avatar
    perf: Fix perf_enable_on_exec() event scheduling · 3e349507
    Peter Zijlstra authored
    There are two problems with the current perf_enable_on_exec() event
    scheduling:
    
      - the newly enabled events will be immediately scheduled
        irrespective of their ctx event list order.
    
      - there's a hole in the ctx->lock between scheduling the events
        out and putting them back on.
    
    Esp. the latter issue is a real problem because a hole in event
    scheduling leaves the thing in an observable inconsistent state,
    confusing things.
    
    Fix both issues by first doing the enable iteration and at the end,
    when there are newly enabled events, reschedule the ctx in one go.
    Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
    Cc: David Ahern <dsahern@gmail.com>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Stephane Eranian <eranian@google.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Vince Weaver <vincent.weaver@maine.edu>
    Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
    3e349507
core.c 219 KB