From patchwork Fri Mar 7 04:14:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 25860 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f72.google.com (mail-pb0-f72.google.com [209.85.160.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D557A203C3 for ; Fri, 7 Mar 2014 04:14:22 +0000 (UTC) Received: by mail-pb0-f72.google.com with SMTP id jt11sf8797209pbb.11 for ; Thu, 06 Mar 2014 20:14:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=nzErs13mlbDMv75sCVzI5vJ/LA2tdmxFzkFFAKZ0ffk=; b=EKh91wQBagJ0Oha28Uk/ra4dZXI5QmTVqt5PEeIG8vv7Woo+/saR1FHQK5tXqau03B 3vN3fs++4CShXMNfSV6ykgCf+xwqMNNZ1w3U5eX58n5uljZzyIwYKrGLIMZ2VFrwhfBs V+KWX5ZjxJqWAoVtBjgi8D0e76aoYDoucVIodAzYX/g6jb/EZQfMKarbMTVymrseKD2F jxrnqwMfKSYv42oRKgXEE8IDk5xP7GnZNlEpu2W82cgEoB7EoYXY2VdgrvCDf3AQbYMc 1VSDHE+JlhQKGXYjha7aYktbDj1cfiMCQbpnxUL+RBjfiLfMBDd4/TF9uM3yG2rHwVjf k6SA== X-Gm-Message-State: ALoCoQm7pIsmAX9FhNXae/QbAyJYQ9LD7dF9fq9cCzYcQ0iofB2hMORTp170MmpvJo8I4OcHFQRp X-Received: by 10.66.222.105 with SMTP id ql9mr7730041pac.9.1394165661920; Thu, 06 Mar 2014 20:14:21 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.25.212 with SMTP id 78ls1023093qgt.30.gmail; Thu, 06 Mar 2014 20:14:21 -0800 (PST) X-Received: by 10.52.142.10 with SMTP id rs10mr10463173vdb.3.1394165661773; Thu, 06 Mar 2014 20:14:21 -0800 (PST) Received: from mail-ve0-f179.google.com (mail-ve0-f179.google.com [209.85.128.179]) by mx.google.com with ESMTPS id tr5si2470782vdc.143.2014.03.06.20.14.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 06 Mar 2014 20:14:21 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.179; Received: by mail-ve0-f179.google.com with SMTP id db12so3722709veb.10 for ; Thu, 06 Mar 2014 20:14:21 -0800 (PST) X-Received: by 10.220.99.72 with SMTP id t8mr8226380vcn.10.1394165661689; Thu, 06 Mar 2014 20:14:21 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.78.9 with SMTP id i9csp86924vck; Thu, 6 Mar 2014 20:14:21 -0800 (PST) X-Received: by 10.67.14.69 with SMTP id fe5mr19384002pad.120.1394165658719; Thu, 06 Mar 2014 20:14:18 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id yn4si6911913pab.168.2014.03.06.20.14.18; Thu, 06 Mar 2014 20:14:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751669AbaCGEOR (ORCPT + 11 others); Thu, 6 Mar 2014 23:14:17 -0500 Received: from mail-pd0-f170.google.com ([209.85.192.170]:38338 "EHLO mail-pd0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751033AbaCGEOQ (ORCPT ); Thu, 6 Mar 2014 23:14:16 -0500 Received: by mail-pd0-f170.google.com with SMTP id v10so3513556pde.1 for ; Thu, 06 Mar 2014 20:14:16 -0800 (PST) X-Received: by 10.66.149.231 with SMTP id ud7mr19513061pab.8.1394165656083; Thu, 06 Mar 2014 20:14:16 -0800 (PST) Received: from localhost.localdomain (z88l218.static.ctm.net. [202.175.88.218]) by mx.google.com with ESMTPSA id np9sm16160570pbc.31.2014.03.06.20.14.13 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 06 Mar 2014 20:14:15 -0800 (PST) From: Daniel Lezcano To: rjw@rjwysocki.net Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] cpuidle: add 'failed' statistic Date: Fri, 7 Mar 2014 05:14:10 +0100 Message-Id: <1394165650-6927-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: daniel.lezcano@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The actual statistics give some informations about the different idle states a cpu entered but unfortunately it does not show if the state is resulting from good selections or not. This simple patch adds the 'failed' statistic for each state, so we can easily do a ratio between the 'usage' and the 'failed' to deduce how efficient the state selections have been. Is considered 'failed' when a state duration is lesser than the target residency which means the state consumed more power than the expected power saving. Signed-off-by: Daniel Lezcano --- drivers/cpuidle/cpuidle.c | 4 ++++ drivers/cpuidle/sysfs.c | 3 +++ include/linux/cpuidle.h | 1 + 3 files changed, 8 insertions(+) diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 09d05ab..c2323e7 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -100,6 +100,10 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv, */ dev->states_usage[entered_state].time += dev->last_residency; dev->states_usage[entered_state].usage++; + + /* We stayed less than the target residency */ + if (diff < drv->states[entered_state].target_residency) + dev->states_usage[entered_state].failed++; } else { dev->last_residency = 0; } diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c index e918b6d..1c7eb90 100644 --- a/drivers/cpuidle/sysfs.c +++ b/drivers/cpuidle/sysfs.c @@ -296,6 +296,7 @@ define_show_state_function(exit_latency) define_show_state_function(power_usage) define_show_state_ull_function(usage) define_show_state_ull_function(time) +define_show_state_ull_function(failed) define_show_state_str_function(name) define_show_state_str_function(desc) define_show_state_ull_function(disable) @@ -307,6 +308,7 @@ define_one_state_ro(latency, show_state_exit_latency); define_one_state_ro(power, show_state_power_usage); define_one_state_ro(usage, show_state_usage); define_one_state_ro(time, show_state_time); +define_one_state_ro(failed, show_state_failed); define_one_state_rw(disable, show_state_disable, store_state_disable); static struct attribute *cpuidle_state_default_attrs[] = { @@ -316,6 +318,7 @@ static struct attribute *cpuidle_state_default_attrs[] = { &attr_power.attr, &attr_usage.attr, &attr_time.attr, + &attr_failed.attr, &attr_disable.attr, NULL }; diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index 50fcbb0..bdad544 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h @@ -32,6 +32,7 @@ struct cpuidle_driver; struct cpuidle_state_usage { unsigned long long disable; unsigned long long usage; + unsigned long long failed; unsigned long long time; /* in US */ };