From patchwork Thu Sep 6 13:39:24 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: 11211 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 1451123E02 for ; Thu, 6 Sep 2012 13:41:27 +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 60FCBA18C32 for ; Thu, 6 Sep 2012 13:40:30 +0000 (UTC) Received: by ieak11 with SMTP id k11so2775988iea.11 for ; Thu, 06 Sep 2012 06:41:26 -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=avVnnhV6DW4RCVA/CnIGCY/CU5xbTOvuxixTgkYpzls=; b=iafFllItim5tbdPa4sl2S0U5aeNGeCZuZV12HecghaXchw+gqAqi8eneljC9vuvv2L HRrytm7qKkIKoaB5IHakDTZtmR/zwG7RSb7AR4kShzcCrFy5xr5YKG1STRghjcpPbd4T ULFC2S58TU9k1LVL+bo/Pm4kzrXPc5ETO/ibIJk7Mrz30SkTDE+JyLR+YaKhTwpyQM9o +It7LfzMYGMIvRhfY67dND/WLiiWH6yPAfwbIrs3Mgf60q7gY+hs+BK3UqGOdYo4vBvu z0Y9y8k33CUAPU8wYc2STIeExqwa01MZogkMyOA7Q8bCZKh23eFi7t+FeE/mxCAzD3IJ I5Jg== Received: by 10.50.237.41 with SMTP id uz9mr2949337igc.43.1346938885977; Thu, 06 Sep 2012 06:41:25 -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 ex8csp319795igc; Thu, 6 Sep 2012 06:41:25 -0700 (PDT) Received: by 10.68.234.73 with SMTP id uc9mr4559853pbc.158.1346938885168; Thu, 06 Sep 2012 06:41:25 -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 pv1si3843445pbb.149.2012.09.06.06.41.24 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 06 Sep 2012 06:41:25 -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 md12so2769774pbc.37 for ; Thu, 06 Sep 2012 06:41:24 -0700 (PDT) Received: by 10.68.225.199 with SMTP id rm7mr4692215pbc.150.1346938884806; Thu, 06 Sep 2012 06:41:24 -0700 (PDT) Received: from localhost.localdomain ([115.242.202.147]) by mx.google.com with ESMTPS id rm9sm1353658pbc.72.2012.09.06.06.41.21 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 06 Sep 2012 06:41:23 -0700 (PDT) From: Rajagopal Venkat To: powertop@lists.01.org Cc: patches@linaro.org, linaro-dev@lists.linaro.org, Rajagopal Venkat Subject: [Powertop][PATCH v1] Fix timer and work perf events timestamp tracing Date: Thu, 6 Sep 2012 19:09:24 +0530 Message-Id: <1346938764-31141-1-git-send-email-rajagopal.venkat@linaro.org> X-Mailer: git-send-email 1.7.11.3 X-Gm-Message-State: ALoCoQkiCH7PfmCj7e9EmJFIBQ0iUxLjT0yrudo5JaunkXFz/DGFuy7bEuHo1wAICMEIdGxBW+RC Fix timer and work perf events timestamp tracing by - considering event exit timestamp relative to measurement first timestamp for events which entry timestamp is not recorded. Currently these events exit timestamp itself is considered as usage period resulting in false usage report. - clearing event timestamps from global map at the end of each measurement to avoid collision with earlier recorded timestamps. Signed-off-by: Rajagopal Venkat --- src/process/do_process.cpp | 12 ++++++++++++ src/process/timer.cpp | 4 ++++ src/process/work.cpp | 4 ++++ 3 files changed, 20 insertions(+) diff --git a/src/process/do_process.cpp b/src/process/do_process.cpp index cb7c672..eaef7f1 100644 --- a/src/process/do_process.cpp +++ b/src/process/do_process.cpp @@ -490,6 +490,10 @@ void perf_process_bundle::handle_trace_point(void *trace, int cpu, uint64_t time } pop_consumer(cpu); t = timer->done(time, tmr); + if (t == ~0ULL) { + timer->fire(first_stamp, tmr); + t = timer->done(time, tmr); + } consumer_child_time(cpu, t); } else if (strcmp(event->name, "hrtimer_expire_entry") == 0) { @@ -532,6 +536,10 @@ void perf_process_bundle::handle_trace_point(void *trace, int cpu, uint64_t time pop_consumer(cpu); t = timer->done(time, tmr); + if (t == ~0ULL) { + timer->fire(first_stamp, tmr); + t = timer->done(time, tmr); + } consumer_child_time(cpu, t); } else if (strcmp(event->name, "workqueue_execute_start") == 0) { @@ -575,6 +583,10 @@ void perf_process_bundle::handle_trace_point(void *trace, int cpu, uint64_t time } pop_consumer(cpu); t = work->done(time, wk); + if (t == ~0ULL) { + work->fire(first_stamp, wk); + t = work->done(time, wk); + } consumer_child_time(cpu, t); } else if (strcmp(event->name, "cpu_idle") == 0) { diff --git a/src/process/timer.cpp b/src/process/timer.cpp index 8917490..1ca8c25 100644 --- a/src/process/timer.cpp +++ b/src/process/timer.cpp @@ -79,6 +79,9 @@ uint64_t timer::done(uint64_t time, uint64_t timer_struct) { int64_t delta; + if (running_since.find(timer_struct) == running_since.end()) + return ~0ULL; + if (running_since[timer_struct] > time) return 0; @@ -147,6 +150,7 @@ 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..e62e5d3 100644 --- a/src/process/work.cpp +++ b/src/process/work.cpp @@ -56,6 +56,9 @@ uint64_t work::done(uint64_t time, uint64_t work_struct) { int64_t delta; + if (running_since.find(work_struct) == running_since.end()) + return ~0ULL; + if (running_since[work_struct] > time) return 0; @@ -102,6 +105,7 @@ void clear_work(void) all_work.erase(it); it = all_work.begin(); } + running_since.clear(); }