Skip to content

Commit

Permalink
PM: Add initcall_debug style timing for suspend/resume
Browse files Browse the repository at this point in the history
In order to diagnose overall suspend/resume times, we need
basic instrumentation to break down the total time into per
device timing, similar to initcall_debug.

This patch adds the basic timing instrumentation, needed
for a scritps/bootgraph.pl equivalent or humans.
The bootgraph.pl program is still a work in progress, but
is far enough along to know that this patch is sufficient.

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
  • Loading branch information
Arjan van de Ven authored and Rafael J. Wysocki committed Dec 15, 2009
1 parent 1d531c1 commit f251177
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
31 changes: 31 additions & 0 deletions drivers/base/power/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <linux/resume-trace.h>
#include <linux/rwsem.h>
#include <linux/interrupt.h>
#include <linux/sched.h>

#include "../base.h"
#include "power.h"
Expand Down Expand Up @@ -172,6 +173,13 @@ static int pm_op(struct device *dev,
pm_message_t state)
{
int error = 0;
ktime_t calltime, delta, rettime;

if (initcall_debug) {
pr_info("calling %s+ @ %i\n",
dev_name(dev), task_pid_nr(current));
calltime = ktime_get();
}

switch (state.event) {
#ifdef CONFIG_SUSPEND
Expand Down Expand Up @@ -219,6 +227,14 @@ static int pm_op(struct device *dev,
default:
error = -EINVAL;
}

if (initcall_debug) {
rettime = ktime_get();
delta = ktime_sub(rettime, calltime);
pr_info("call %s+ returned %d after %Ld usecs\n", dev_name(dev),
error, (unsigned long long)ktime_to_ns(delta) >> 10);
}

return error;
}

Expand All @@ -236,6 +252,13 @@ static int pm_noirq_op(struct device *dev,
pm_message_t state)
{
int error = 0;
ktime_t calltime, delta, rettime;

if (initcall_debug) {
pr_info("calling %s_i+ @ %i\n",
dev_name(dev), task_pid_nr(current));
calltime = ktime_get();
}

switch (state.event) {
#ifdef CONFIG_SUSPEND
Expand Down Expand Up @@ -283,6 +306,14 @@ static int pm_noirq_op(struct device *dev,
default:
error = -EINVAL;
}

if (initcall_debug) {
rettime = ktime_get();
delta = ktime_sub(rettime, calltime);
printk("initcall %s_i+ returned %d after %Ld usecs\n", dev_name(dev),
error, (unsigned long long)ktime_to_ns(delta) >> 10);
}

return error;
}

Expand Down
2 changes: 2 additions & 0 deletions include/linux/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ void prepare_namespace(void);

extern void (*late_time_init)(void);

extern int initcall_debug;

#endif

#ifndef MODULE
Expand Down

0 comments on commit f251177

Please sign in to comment.