Patchwork [LUCID] UBUNTU: SAUCE: PM: report resume time of each device

login
register
mail settings
Submitter Manoj Iyer
Date Jan. 26, 2010, 3:52 p.m.
Message ID <alpine.DEB.2.00.1001260948060.7545@hungry>
Download mbox | patch
Permalink /patch/43708/
State Changes Requested
Delegated to: Andy Whitcroft
Headers show

Comments

Manoj Iyer - Jan. 26, 2010, 3:52 p.m.
The following patch reports the resume time of each device. Not sure if we 
want to submit this upstream because it will populate dmesg with lot of PM 
messages. Probably need to filter all the PM messages to kern_resume.log 
or some such file in /var/log.

The following changes since commit 
5d4092811713de51759a9d194eb78e4eb1c48822:
   Manoj Iyer (1):
         UBUNTU: SAUCE: PM: report resume time of each device

are available in the git repository at:


ssh://zinc.canonical.com/srv/kernel.ubuntu.com/git/manjo/ubuntu-lucid.git 
suspendresume2


From 5d4092811713de51759a9d194eb78e4eb1c48822 Mon Sep 17 00:00:00 2001
From: Manoj Iyer <manoj.iyer@canonical.com>
Date: Tue, 26 Jan 2010 09:44:20 -0600
Subject: [PATCH] UBUNTU: SAUCE: PM: report resume time of each device

Report the resume time of each device.

Signed-off-by: Manoj Iyer <manoj.iyer@canonical.com>
---
  drivers/base/power/main.c |   23 +++++++++++++++++++++++
  1 files changed, 23 insertions(+), 0 deletions(-)
Manoj Iyer - Jan. 27, 2010, 6:39 a.m.
Jermey/Colin,

I have been using the patch below to print resume times of device.

--- manjo

On Tue, 26 Jan 2010, Manoj Iyer wrote:

>
> The following patch reports the resume time of each device. Not sure if we
> want to submit this upstream because it will populate dmesg with lot of PM
> messages. Probably need to filter all the PM messages to kern_resume.log
> or some such file in /var/log.
>
> The following changes since commit
> 5d4092811713de51759a9d194eb78e4eb1c48822:
>   Manoj Iyer (1):
>         UBUNTU: SAUCE: PM: report resume time of each device
>
> are available in the git repository at:
>
>
> ssh://zinc.canonical.com/srv/kernel.ubuntu.com/git/manjo/ubuntu-lucid.git
> suspendresume2
>
>
> From 5d4092811713de51759a9d194eb78e4eb1c48822 Mon Sep 17 00:00:00 2001
> From: Manoj Iyer <manoj.iyer@canonical.com>
> Date: Tue, 26 Jan 2010 09:44:20 -0600
> Subject: [PATCH] UBUNTU: SAUCE: PM: report resume time of each device
>
> Report the resume time of each device.
>
> Signed-off-by: Manoj Iyer <manoj.iyer@canonical.com>
> ---
>  drivers/base/power/main.c |   23 +++++++++++++++++++++++
>  1 files changed, 23 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
> index d72d4b3..b4833d5 100644
> --- a/drivers/base/power/main.c
> +++ b/drivers/base/power/main.c
> @@ -341,6 +341,25 @@ static void dpm_show_time(ktime_t starttime, pm_message_t state, char *info)
>  		usecs / USEC_PER_MSEC, usecs % USEC_PER_MSEC);
>  }
>
> +
> +static void device_show_time(struct device *dev, ktime_t starttime, pm_message_t state, char *info)
> +{
> +	ktime_t calltime;
> +	s64 usecs64;
> +	int usecs;
> +
> +	calltime = ktime_get();
> +	usecs64 = ktime_to_ns(ktime_sub(calltime, starttime));
> +	do_div(usecs64, NSEC_PER_USEC);
> +	usecs = usecs64;
> +	if (usecs == 0)
> +		usecs = 1;
> +	pr_info("PM: %s%s%s of drv:%s dev:%s complete after %ld.%03ld msecs\n",
> +		info ?: "", info ? " " : "", pm_verb(state.event),
> +		dev_driver_string(dev), dev_name(dev), usecs / USEC_PER_MSEC,
> +		usecs % USEC_PER_MSEC);
> +}
> +
>  /*------------------------- Resume routines -------------------------*/
>
>  /**
> @@ -354,6 +373,7 @@ static void dpm_show_time(ktime_t starttime, pm_message_t state, char *info)
>  static int device_resume_noirq(struct device *dev, pm_message_t state)
>  {
>  	int error = 0;
> +	ktime_t starttime = ktime_get();
>
>  	TRACE_DEVICE(dev);
>  	TRACE_RESUME(0);
> @@ -364,6 +384,7 @@ static int device_resume_noirq(struct device *dev, pm_message_t state)
>  	if (dev->bus->pm) {
>  		pm_dev_dbg(dev, state, "EARLY ");
>  		error = pm_noirq_op(dev, dev->bus->pm, state);
> +		device_show_time(dev, starttime, state, "early");
>  	}
>   End:
>  	TRACE_RESUME(error);
> @@ -407,6 +428,7 @@ EXPORT_SYMBOL_GPL(dpm_resume_noirq);
>  static int device_resume(struct device *dev, pm_message_t state)
>  {
>  	int error = 0;
> +	ktime_t starttime = ktime_get();
>
>  	TRACE_DEVICE(dev);
>  	TRACE_RESUME(0);
> @@ -443,6 +465,7 @@ static int device_resume(struct device *dev, pm_message_t state)
>  			error = dev->class->resume(dev);
>  		}
>  	}
> +	device_show_time(dev, starttime, state, NULL);
>   End:
>  	up(&dev->sem);
>
> -- 
> 1.6.3.3
>
>
>
> Cheers
> --- manjo
>
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
>

Patch

diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index d72d4b3..b4833d5 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -341,6 +341,25 @@  static void dpm_show_time(ktime_t starttime, pm_message_t state, char *info)
  		usecs / USEC_PER_MSEC, usecs % USEC_PER_MSEC);
  }

+
+static void device_show_time(struct device *dev, ktime_t starttime, pm_message_t state, char *info)
+{
+	ktime_t calltime;
+	s64 usecs64;
+	int usecs;
+
+	calltime = ktime_get();
+	usecs64 = ktime_to_ns(ktime_sub(calltime, starttime));
+	do_div(usecs64, NSEC_PER_USEC);
+	usecs = usecs64;
+	if (usecs == 0)
+		usecs = 1;
+	pr_info("PM: %s%s%s of drv:%s dev:%s complete after %ld.%03ld msecs\n", 
+		info ?: "", info ? " " : "", pm_verb(state.event),
+		dev_driver_string(dev), dev_name(dev), usecs / USEC_PER_MSEC, 
+		usecs % USEC_PER_MSEC);
+}
+
  /*------------------------- Resume routines -------------------------*/

  /**
@@ -354,6 +373,7 @@  static void dpm_show_time(ktime_t starttime, pm_message_t state, char *info)
  static int device_resume_noirq(struct device *dev, pm_message_t state)
  {
  	int error = 0;
+	ktime_t starttime = ktime_get();

  	TRACE_DEVICE(dev);
  	TRACE_RESUME(0);
@@ -364,6 +384,7 @@  static int device_resume_noirq(struct device *dev, pm_message_t state)
  	if (dev->bus->pm) {
  		pm_dev_dbg(dev, state, "EARLY ");
  		error = pm_noirq_op(dev, dev->bus->pm, state);
+		device_show_time(dev, starttime, state, "early");
  	}
   End:
  	TRACE_RESUME(error);
@@ -407,6 +428,7 @@  EXPORT_SYMBOL_GPL(dpm_resume_noirq);
  static int device_resume(struct device *dev, pm_message_t state)
  {
  	int error = 0;
+	ktime_t starttime = ktime_get();

  	TRACE_DEVICE(dev);
  	TRACE_RESUME(0);
@@ -443,6 +465,7 @@  static int device_resume(struct device *dev, pm_message_t state)
  			error = dev->class->resume(dev);
  		}
  	}
+	device_show_time(dev, starttime, state, NULL);
   End:
  	up(&dev->sem);