Skip to content

Commit

Permalink
perf: Ensure we call add_event_to_ctx() with the right locks held
Browse files Browse the repository at this point in the history
Even though we call it from the inherit path, where the child is
not yet accessible, we need to hold ctx->lock, add_event_to_ctx()
assumes IRQs are disabled.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Sep 10, 2010
1 parent 3b8fad3 commit cee010e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions kernel/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -5913,6 +5913,7 @@ inherit_event(struct perf_event *parent_event,
struct perf_event_context *child_ctx)
{
struct perf_event *child_event;
unsigned long flags;

/*
* Instead of creating recursive hierarchies of events,
Expand Down Expand Up @@ -5957,7 +5958,9 @@ inherit_event(struct perf_event *parent_event,
/*
* Link it up in the child's context:
*/
raw_spin_lock_irqsave(&child_ctx->lock, flags);
add_event_to_ctx(child_event, child_ctx);
raw_spin_unlock_irqrestore(&child_ctx->lock, flags);

/*
* Get a reference to the parent filp - we will fput it
Expand Down

0 comments on commit cee010e

Please sign in to comment.