mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arjan van de Ven <arjan@infradead.org>
To: rusty@rustcorp.com.au
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org
Subject: [PATCH] modules: extend initcall_debug functionality to the module loader
Date: Thu, 17 Jul 2008 16:21:38 -0700	[thread overview]
Message-ID: <20080717162138.50a57cb1@infradead.org> (raw)



From: Arjan van de Ven <arjan@linux.intel.com>
Subject: [PATCH] modules: extend initcall_debug functionality to the module loader

The kernel has this really nice facility where if you put "initcall_debug"
on the kernel commandline, it'll print which function it's going to execute
just before calling an initcall, and then after the call completes it will
1) print if it had an error code
2) checks for a few simple bugs (like leaving irqs off)
and
3) print how long the init call took in milliseconds.

While trying to optimize the boot speed of my laptop, I have been loving
number 3 to figure out what to optimize...
... and then I wished that the same thing was done for module loading.

This patch makes the module loader use this exact same functionality;
it's a logical extension in my view (since modules are just sort of
late binding initcalls anyway) and so far I've found it quite useful
in finding where things are too slow in my boot.

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
---
 include/linux/init.h |    2 ++
 init/main.c          |    6 ++++--
 kernel/module.c      |    2 +-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/include/linux/init.h b/include/linux/init.h
index 21d658c..e875fcc 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -142,6 +142,8 @@ extern initcall_t __security_initcall_start[], __security_initcall_end[];
 extern char __initdata boot_command_line[];
 extern char *saved_command_line;
 extern unsigned int reset_devices;
+extern int do_one_initcall(initcall_t fn);
+
 
 /* used by init/main.c */
 void setup_arch(char **);
diff --git a/init/main.c b/init/main.c
index edeace0..4480ca7 100644
--- a/init/main.c
+++ b/init/main.c
@@ -685,7 +685,7 @@ asmlinkage void __init start_kernel(void)
 	rest_init();
 }
 
-static int __initdata initcall_debug;
+static int initcall_debug;
 
 static int __init initcall_debug_setup(char *str)
 {
@@ -694,7 +694,7 @@ static int __init initcall_debug_setup(char *str)
 }
 __setup("initcall_debug", initcall_debug_setup);
 
-static void __init do_one_initcall(initcall_t fn)
+int do_one_initcall(initcall_t fn)
 {
 	int count = preempt_count();
 	ktime_t t0, t1, delta;
@@ -734,6 +734,8 @@ static void __init do_one_initcall(initcall_t fn)
 		print_fn_descriptor_symbol(KERN_WARNING "initcall %s", fn);
 		printk(" returned with %s\n", msgbuf);
 	}
+
+	return result;
 }
 
 
diff --git a/kernel/module.c b/kernel/module.c
index 5f80478..b69ac29 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2220,7 +2220,7 @@ sys_init_module(void __user *umod,
 
 	/* Start the module */
 	if (mod->init != NULL)
-		ret = mod->init();
+		ret = do_one_initcall(mod->init);
 	if (ret < 0) {
 		/* Init routine failed: abort.  Try to protect us from
                    buggy refcounters. */
-- 
1.5.5.1


                 reply	other threads:[~2008-07-17 23:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20080717162138.50a57cb1@infradead.org \
    --to=arjan@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®