Commit 8f0c45cd authored by Ingo Molnar's avatar Ingo Molnar Committed by Linus Torvalds

enhance initcall_debug, measure latency

enhance the initcall_debug boot option:

 - measure the time the initcall took to execute and report
   it in units of milliseconds.

 - show the return code of initcalls (useful to see failures and
   to make sure that an initcall hung)

[akpm@linux-foundation.org: fix printk warning]
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent b73a7e76
...@@ -648,6 +648,7 @@ static void __init do_initcalls(void) ...@@ -648,6 +648,7 @@ static void __init do_initcalls(void)
int count = preempt_count(); int count = preempt_count();
for (call = __initcall_start; call < __initcall_end; call++) { for (call = __initcall_start; call < __initcall_end; call++) {
ktime_t t0, t1, delta;
char *msg = NULL; char *msg = NULL;
char msgbuf[40]; char msgbuf[40];
int result; int result;
...@@ -657,10 +658,26 @@ static void __init do_initcalls(void) ...@@ -657,10 +658,26 @@ static void __init do_initcalls(void)
print_fn_descriptor_symbol(": %s()", print_fn_descriptor_symbol(": %s()",
(unsigned long) *call); (unsigned long) *call);
printk("\n"); printk("\n");
t0 = ktime_get();
} }
result = (*call)(); result = (*call)();
if (initcall_debug) {
t1 = ktime_get();
delta = ktime_sub(t1, t0);
printk("initcall 0x%p", *call);
print_fn_descriptor_symbol(": %s()",
(unsigned long) *call);
printk(" returned %d.\n", result);
printk("initcall 0x%p ran for %Ld msecs: ",
*call, (unsigned long long)delta.tv64 >> 20);
print_fn_descriptor_symbol("%s()\n",
(unsigned long) *call);
}
if (result && result != -ENODEV && initcall_debug) { if (result && result != -ENODEV && initcall_debug) {
sprintf(msgbuf, "error code %d", result); sprintf(msgbuf, "error code %d", result);
msg = msgbuf; msg = msgbuf;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment