Skip to content

Commit

Permalink
perf: Fix reading in perf_event_read()
Browse files Browse the repository at this point in the history
It is quite possible for the event to have been disabled between
perf_event_read() sending the IPI and the CPU servicing the IPI and
calling __perf_event_read(), hence revalidate the state.

Reported-by: Stephane Eranian <eranian@google.com>
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 Feb 3, 2011
1 parent 9ffdc6c commit 542e72f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions kernel/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -1901,11 +1901,12 @@ static void __perf_event_read(void *info)
return;

raw_spin_lock(&ctx->lock);
update_context_time(ctx);
if (ctx->is_active)
update_context_time(ctx);
update_event_times(event);
if (event->state == PERF_EVENT_STATE_ACTIVE)
event->pmu->read(event);
raw_spin_unlock(&ctx->lock);

event->pmu->read(event);
}

static inline u64 perf_event_count(struct perf_event *event)
Expand Down

0 comments on commit 542e72f

Please sign in to comment.