aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/power/sysfs.c
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@linux.intel.com>2010-07-18 20:01:06 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2010-07-18 20:01:06 -0400
commit8d4b9d1bfef117862a2889dec4dac227068544c9 (patch)
treea17f69a64b97759452988047058666ae51f70304 /drivers/base/power/sysfs.c
parent0fcb4eef8294492c8f1de8236b1ed81f09e42922 (diff)
PM / Runtime: Add runtime PM statistics (v3)
In order for PowerTOP to be able to report how well the new runtime PM is working for the various drivers, the kernel needs to export some basic statistics in sysfs. This patch adds two sysfs files in the runtime PM domain that expose the total time a device has been active, and the time a device has been suspended. With this PowerTOP can compute the activity percentage Active %age = 100 * (delta active) / (delta active + delta suspended) and present the information to the user. I've written the PowerTOP code (slated for version 1.12) already, and the output looks like this: Runtime Device Power Management statistics Active Device name 10.0% 06:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8101E/RTL8102E PCI Express Fast Ethernet controller [version 2: fix stat update bugs noticed by Alan Stern] [version 3: rebase to -next and move the sysfs declaration] Signed-off-by: Arjan van de Ven <arjan@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'drivers/base/power/sysfs.c')
-rw-r--r--drivers/base/power/sysfs.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
index 1eca50c8e7ca..e56b4388fe61 100644
--- a/drivers/base/power/sysfs.c
+++ b/drivers/base/power/sysfs.c
@@ -6,6 +6,7 @@
6#include <linux/string.h> 6#include <linux/string.h>
7#include <linux/pm_runtime.h> 7#include <linux/pm_runtime.h>
8#include <asm/atomic.h> 8#include <asm/atomic.h>
9#include <linux/jiffies.h>
9#include "power.h" 10#include "power.h"
10 11
11/* 12/*
@@ -111,6 +112,33 @@ static ssize_t control_store(struct device * dev, struct device_attribute *attr,
111 112
112static DEVICE_ATTR(control, 0644, control_show, control_store); 113static DEVICE_ATTR(control, 0644, control_show, control_store);
113 114
115static ssize_t rtpm_active_time_show(struct device *dev,
116 struct device_attribute *attr, char *buf)
117{
118 int ret;
119 spin_lock_irq(&dev->power.lock);
120 update_pm_runtime_accounting(dev);
121 ret = sprintf(buf, "%i\n", jiffies_to_msecs(dev->power.active_jiffies));
122 spin_unlock_irq(&dev->power.lock);
123 return ret;
124}
125
126static DEVICE_ATTR(runtime_active_time, 0444, rtpm_active_time_show, NULL);
127
128static ssize_t rtpm_suspended_time_show(struct device *dev,
129 struct device_attribute *attr, char *buf)
130{
131 int ret;
132 spin_lock_irq(&dev->power.lock);
133 update_pm_runtime_accounting(dev);
134 ret = sprintf(buf, "%i\n",
135 jiffies_to_msecs(dev->power.suspended_jiffies));
136 spin_unlock_irq(&dev->power.lock);
137 return ret;
138}
139
140static DEVICE_ATTR(runtime_suspended_time, 0444, rtpm_suspended_time_show, NULL);
141
114static ssize_t rtpm_status_show(struct device *dev, 142static ssize_t rtpm_status_show(struct device *dev,
115 struct device_attribute *attr, char *buf) 143 struct device_attribute *attr, char *buf)
116{ 144{
@@ -254,6 +282,8 @@ static struct attribute * power_attrs[] = {
254#ifdef CONFIG_PM_RUNTIME 282#ifdef CONFIG_PM_RUNTIME
255 &dev_attr_control.attr, 283 &dev_attr_control.attr,
256 &dev_attr_runtime_status.attr, 284 &dev_attr_runtime_status.attr,
285 &dev_attr_runtime_suspended_time.attr,
286 &dev_attr_runtime_active_time.attr,
257#endif 287#endif
258 &dev_attr_wakeup.attr, 288 &dev_attr_wakeup.attr,
259#ifdef CONFIG_PM_SLEEP 289#ifdef CONFIG_PM_SLEEP