From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: linux-pm <linux-pm@lists.linux-foundation.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Linux PCI <linux-pci@vger.kernel.org>,
ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
Len Brown <lenb@kernel.org>, Zhang Rui <rui.zhang@intel.com>,
Pavel Machek <pavel@ucw.cz>,
Alan Stern <stern@rowland.harvard.edu>,
Arjan van de Ven <arjan@infradead.org>,
Ingo Molnar <mingo@elte.hu>
Subject: [PATCH 9/9] PM: Measure suspend and resume times for individual devices
Date: Thu, 10 Sep 2009 01:40:52 +0200 [thread overview]
Message-ID: <200909100140.52270.rjw@sisk.pl> (raw)
In-Reply-To: <200909100127.11252.rjw@sisk.pl>
From: Rafael J. Wysocki <rjw@sisk.pl>
If verbose PM debugging is enabled, measure and print the time of
suspending and resuming of individual devices.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
drivers/base/power/main.c | 50 +++++++++++++++++++++++++++++++++++++++++-----
kernel/power/swsusp.c | 2 -
2 files changed, 46 insertions(+), 6 deletions(-)
Index: linux-2.6/drivers/base/power/main.c
===================================================================
--- linux-2.6.orig/drivers/base/power/main.c
+++ linux-2.6/drivers/base/power/main.c
@@ -442,11 +442,11 @@ static bool pm_op_started(struct device
*/
int pm_time_elapsed(struct timeval *start, struct timeval *stop)
{
- s64 elapsed_centisecs64;
+ s64 elapsed_msecs64;
- elapsed_centisecs64 = timeval_to_ns(stop) - timeval_to_ns(start);
- do_div(elapsed_centisecs64, NSEC_PER_SEC / 100);
- return elapsed_centisecs64;
+ elapsed_msecs64 = timeval_to_ns(stop) - timeval_to_ns(start);
+ do_div(elapsed_msecs64, NSEC_PER_SEC / MSEC_PER_SEC);
+ return elapsed_msecs64;
}
static char *pm_verb(int event)
@@ -476,7 +476,7 @@ static char *pm_verb(int event)
static void dpm_show_time(struct timeval *start, struct timeval *stop,
pm_message_t state, const char *info)
{
- int centisecs = pm_time_elapsed(start, stop);
+ int centisecs = pm_time_elapsed(start, stop) / 10;
printk(KERN_INFO "PM: %s%s%s of devices complete in %d.%02d seconds\n",
info ? info : "", info ? " " : "", pm_verb(state.event),
@@ -497,6 +497,32 @@ static void pm_dev_err(struct device *de
kobject_name(&dev->kobj), pm_verb(state.event), info, error);
}
+#ifdef DEBUG
+static inline void dbg_get_time(struct timeval *start)
+{
+ do_gettimeofday(start);
+}
+
+static void dbg_show_time(struct timeval *start, struct device *dev,
+ pm_message_t state, char *info)
+{
+ struct timeval stop;
+ int msecs;
+
+ do_gettimeofday(&stop);
+ msecs = pm_time_elapsed(start, &stop);
+ dev_dbg(dev, "PID %d: %s%s%s complete in %d.%03d seconds\n",
+ task_pid_nr(current), info ? info : "", info ? " " : "",
+ pm_verb(state.event), msecs / 1000, msecs % 1000);
+}
+
+#else /* !DEBUG */
+static void dbg_get_time(struct timeval *start) {}
+static void dbg_show_time(struct timeval *start, struct device *dev,
+ pm_message_t state, char *info) {}
+
+#endif /* !DEBUG */
+
/*------------------------- Resume routines -------------------------*/
/**
@@ -510,7 +536,9 @@ static void pm_dev_err(struct device *de
static int __device_resume_noirq(struct device *dev, pm_message_t state)
{
int error = 0;
+ struct timeval start;
+ dbg_get_time(&start);
TRACE_DEVICE(dev);
TRACE_RESUME(0);
@@ -523,6 +551,7 @@ static int __device_resume_noirq(struct
wake_up_all(&dev->power.wait_queue);
TRACE_RESUME(error);
+ dbg_show_time(&start, dev, state, "EARLY");
return error;
}
@@ -639,7 +668,9 @@ EXPORT_SYMBOL_GPL(dpm_resume_noirq);
static int __device_resume(struct device *dev, pm_message_t state)
{
int error = 0;
+ struct timeval start;
+ dbg_get_time(&start);
TRACE_DEVICE(dev);
TRACE_RESUME(0);
@@ -681,6 +712,7 @@ static int __device_resume(struct device
wake_up_all(&dev->power.wait_queue);
TRACE_RESUME(error);
+ dbg_show_time(&start, dev, state, NULL);
return error;
}
@@ -923,6 +955,9 @@ static pm_message_t resume_event(pm_mess
static int __device_suspend_noirq(struct device *dev, pm_message_t state)
{
int error = 0;
+ struct timeval start;
+
+ dbg_get_time(&start);
if (dev->bus && dev->bus->pm) {
pm_dev_dbg(dev, state, "LATE ");
@@ -932,6 +967,7 @@ static int __device_suspend_noirq(struct
dev->power.op_complete = true;
wake_up_all(&dev->power.wait_queue);
+ dbg_show_time(&start, dev, state, "LATE");
return error;
}
@@ -1063,6 +1099,9 @@ EXPORT_SYMBOL_GPL(dpm_suspend_noirq);
static int __device_suspend(struct device *dev, pm_message_t state)
{
int error = 0;
+ struct timeval start;
+
+ dbg_get_time(&start);
down(&dev->sem);
@@ -1103,6 +1142,7 @@ static int __device_suspend(struct devic
dev->power.op_complete = true;
wake_up_all(&dev->power.wait_queue);
+ dbg_show_time(&start, dev, state, NULL);
return error;
}
Index: linux-2.6/kernel/power/swsusp.c
===================================================================
--- linux-2.6.orig/kernel/power/swsusp.c
+++ linux-2.6/kernel/power/swsusp.c
@@ -169,7 +169,7 @@ int swsusp_swap_in_use(void)
void swsusp_show_speed(struct timeval *start, struct timeval *stop,
unsigned nr_pages, char *msg)
{
- int centisecs = pm_time_elapsed(start, stop);
+ int centisecs = pm_time_elapsed(start, stop) / 10;
int k;
int kps;
next prev parent reply other threads:[~2009-09-09 23:42 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-09 23:27 [PATCH 0/9] PM: Asynchronous suspend of devices Rafael J. Wysocki
2009-09-09 23:32 ` [PATCH 1/9] PM: Introduce PM links framework Rafael J. Wysocki
2010-01-30 5:11 ` Mahalingam, Nithish
2009-09-09 23:32 ` Rafael J. Wysocki
2009-09-09 23:35 ` [PATCH 2/9] PM: Asynchronous resume of devices Rafael J. Wysocki
2009-09-09 23:35 ` Rafael J. Wysocki
2009-09-09 23:36 ` [PATCH 3/9] PM: Asynchronous suspend " Rafael J. Wysocki
2009-09-09 23:36 ` Rafael J. Wysocki
2009-09-09 23:36 ` [PATCH 4/9] PM: Allow PCI devices to suspend/resume asynchronously Rafael J. Wysocki
2009-09-09 23:36 ` Rafael J. Wysocki
2009-09-09 23:37 ` [PATCH 5/9] PM: Allow ACPI " Rafael J. Wysocki
2009-09-09 23:37 ` Rafael J. Wysocki
2009-09-09 23:38 ` [PATCH 6/9] PM: Add a switch for disabling/enabling asynchronous suspend/resume Rafael J. Wysocki
2009-09-09 23:38 ` Rafael J. Wysocki
2009-09-10 10:26 ` Pavel Machek
2009-09-10 10:26 ` Pavel Machek
2009-09-10 18:56 ` Rafael J. Wysocki
2009-09-10 18:56 ` Rafael J. Wysocki
2009-09-10 18:59 ` Pavel Machek
2009-09-10 18:59 ` Pavel Machek
2009-09-10 20:15 ` Rafael J. Wysocki
2009-09-10 20:15 ` Rafael J. Wysocki
2009-09-09 23:39 ` [PATCH 7/9] PM: Measure device suspend and resume times Rafael J. Wysocki
2009-09-11 17:48 ` Ben Gamari
2009-09-11 22:18 ` Rafael J. Wysocki
2009-09-09 23:39 ` Rafael J. Wysocki
2009-09-09 23:40 ` [PATCH 8/9] PM: Add facility for advanced testing of async suspend/resume Rafael J. Wysocki
2009-09-09 23:40 ` Rafael J. Wysocki
2009-09-09 23:40 ` [PATCH 9/9] PM: Measure suspend and resume times for individual devices Rafael J. Wysocki
2009-09-09 23:40 ` Rafael J. Wysocki [this message]
2009-09-10 18:37 ` [PATCH 0/9] PM: Asynchronous suspend of devices Pavel Machek
2009-09-10 18:43 ` Rafael J. Wysocki
2009-09-10 18:43 ` Rafael J. Wysocki
2009-09-10 18:37 ` Pavel Machek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200909100140.52270.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=arjan@infradead.org \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
--cc=mingo@elte.hu \
--cc=pavel@ucw.cz \
--cc=rui.zhang@intel.com \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.