From patchwork Wed Sep 5 10:22:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: rajagopal.venkat@linaro.org X-Patchwork-Id: 11192 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 794D823EFE for ; Wed, 5 Sep 2012 10:24:59 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 458EDA188B4 for ; Wed, 5 Sep 2012 10:24:06 +0000 (UTC) Received: by ieak11 with SMTP id k11so706992iea.11 for ; Wed, 05 Sep 2012 03:24:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:x-gm-message-state; bh=H3DQhefTQOBK5KI4nWOqO8H7Qe1jSdcR6oMLNrqYDNA=; b=Cdb5hZKRwwXuJJvy0+ZvNXe3i/J/fCrNKE9asF2n8O1e8ChnLiKre7UrfrCgYpMOQg kmla+7gTZMkFds7nVnOZ4N4qrQwbFYwXtKYoDJgF/zlgCADB8lyDb21OS9k2+qaV7suE l1DaBmc0dTlq/XR9UkxoJyxxpmiUbAD5U2Ca4RhWKqqWuw7LK5FxNaV7sXzFiaAuWwdV lvUWMdmZ5lpFpg0jne2P0kM2fKzVShsuFDuFeFw0oNpvCLSQRy5OUvok6TNWG3oElQu2 co1/qJWt5/uf7q+pwYm1NOvfaV07AbLV9yOAB9BV62putFGrjiallALlXiyES9xdCEfJ AFAg== Received: by 10.50.207.106 with SMTP id lv10mr17408090igc.0.1346840698019; Wed, 05 Sep 2012 03:24:58 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp245360igc; Wed, 5 Sep 2012 03:24:57 -0700 (PDT) Received: by 10.68.221.70 with SMTP id qc6mr54152859pbc.92.1346840696978; Wed, 05 Sep 2012 03:24:56 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id hf6si1903528pbc.253.2012.09.05.03.24.56 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 05 Sep 2012 03:24:56 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of rajagopal.venkat@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of rajagopal.venkat@linaro.org) smtp.mail=rajagopal.venkat@linaro.org Received: by pbcmd12 with SMTP id md12so787033pbc.37 for ; Wed, 05 Sep 2012 03:24:56 -0700 (PDT) Received: by 10.66.79.36 with SMTP id g4mr31860896pax.67.1346840696475; Wed, 05 Sep 2012 03:24:56 -0700 (PDT) Received: from localhost.localdomain ([115.241.106.174]) by mx.google.com with ESMTPS id gv1sm1131848pbc.38.2012.09.05.03.24.53 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 05 Sep 2012 03:24:55 -0700 (PDT) From: Rajagopal Venkat To: powertop@lists.01.org Cc: patches@linaro.org, linaro-dev@lists.linaro.org, Rajagopal Venkat Subject: [Powertop][PATCH] Fix timer and work perf events timestamp tracing Date: Wed, 5 Sep 2012 15:52:34 +0530 Message-Id: <1346840555-18457-1-git-send-email-rajagopal.venkat@linaro.org> X-Mailer: git-send-email 1.7.11.3 X-Gm-Message-State: ALoCoQkw0jcC0S7WP8/djWBvd9FC4zV5cMQrXOMK9lxfryP9xWn0ieaATq4VQSMCM3Bha9+e43vY Incorrect timer and work perf events timestamp tracing is one of the reason for reporting usage over 100%. This patch will resolve the issue by - rejecting the events for which entry timestamp is not recorded. Currently these events exit timestamp itself is considered as usage period resulting in over 100% usage. - clearing event timestamps from global map at the end of each measurement to avoid collision with earlier recorded timestamps. Signed-off-by: Rajagopal Venkat Tested-by: Viresh Kumar --- src/process/timer.cpp | 5 ++++- src/process/work.cpp | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/process/timer.cpp b/src/process/timer.cpp index 8917490..db074c4 100644 --- a/src/process/timer.cpp +++ b/src/process/timer.cpp @@ -79,7 +79,8 @@ uint64_t timer::done(uint64_t time, uint64_t timer_struct) { int64_t delta; - if (running_since[timer_struct] > time) + if (running_since.find(timer_struct) == running_since.end() || + running_since[timer_struct] > time) return 0; delta = time - running_since[timer_struct]; @@ -147,6 +148,8 @@ void clear_timers(void) all_timers.erase(it); it = all_timers.begin(); } + + running_since.clear(); } bool timer::is_deferred(void) diff --git a/src/process/work.cpp b/src/process/work.cpp index 82f13a2..e436643 100644 --- a/src/process/work.cpp +++ b/src/process/work.cpp @@ -56,7 +56,8 @@ uint64_t work::done(uint64_t time, uint64_t work_struct) { int64_t delta; - if (running_since[work_struct] > time) + if (running_since.find(work_struct) == running_since.end() || + running_since[work_struct] > time) return 0; delta = time - running_since[work_struct]; @@ -102,6 +103,8 @@ void clear_work(void) all_work.erase(it); it = all_work.begin(); } + + running_since.clear(); }