From: Peter Zijlstra Date: Wed, 26 Jan 2011 14:38:35 +0000 (+0100) Subject: perf: Fix reading in perf_event_read() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=542e72fc90f5ed9eecb574f80f70868c7f296093;p=GitHub%2Fmt8127%2Fandroid_kernel_alcatel_ttab.git perf: Fix reading in perf_event_read() 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 Signed-off-by: Peter Zijlstra LKML-Reference: Signed-off-by: Ingo Molnar --- diff --git a/kernel/perf_event.c b/kernel/perf_event.c index 852ae8c66502..999835b6112b 100644 --- a/kernel/perf_event.c +++ b/kernel/perf_event.c @@ -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)