Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755536Ab3IYMvS (ORCPT ); Wed, 25 Sep 2013 08:51:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57336 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755394Ab3IYMvN (ORCPT ); Wed, 25 Sep 2013 08:51:13 -0400 From: Jiri Olsa To: linux-kernel@vger.kernel.org Cc: Jiri Olsa , Arnaldo Carvalho de Melo , Corey Ashford , Frederic Weisbecker , Ingo Molnar , Paul Mackerras , Peter Zijlstra Subject: [PATCH 03/21] perf x86: Update event count properly for read syscall Date: Wed, 25 Sep 2013 14:50:29 +0200 Message-Id: <1380113447-17144-4-git-send-email-jolsa@redhat.com> In-Reply-To: <1380113447-17144-1-git-send-email-jolsa@redhat.com> References: <1380113447-17144-1-git-send-email-jolsa@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1685 Lines: 49 Within the read syscall we update the event count via pmu->read callback if the event is in ACTIVE state. This triggers event update (x86_perf_event_update) for x86 pmu and leads to wrong event count in case the event hasn't been started yet -> the event base is not adjusted to new cpu and new count computation is based on previous CPU prev_count. Fixing this to update the counter only if it has been started, so the event base is properly adjusted. Signed-off-by: Jiri Olsa Cc: Arnaldo Carvalho de Melo Cc: Corey Ashford Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Arnaldo Carvalho de Melo --- arch/x86/kernel/cpu/perf_event.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c index 8355c84..e89c773 100644 --- a/arch/x86/kernel/cpu/perf_event.c +++ b/arch/x86/kernel/cpu/perf_event.c @@ -1570,7 +1570,11 @@ early_initcall(init_hw_perf_events); static inline void x86_pmu_read(struct perf_event *event) { - x86_perf_event_update(event); + struct hw_perf_event *hwc = &event->hw; + + /* Update only if the event has already been started. */ + if (!(hwc->state & PERF_HES_ARCH)) + x86_perf_event_update(event); } /* -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/