mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arjan van de Ven <arjan@infradead.org>
To: Corrado Zoccolo <czoccolo@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: How to debug kernel startup time?
Date: Sun, 29 Mar 2009 09:59:17 -0700	[thread overview]
Message-ID: <20090329095917.20948680@infradead.org> (raw)
In-Reply-To: <4e5e476b0903290945u19572af6ub366001596a7fd3f@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 971 bytes --]

On Sun, 29 Mar 2009 18:45:36 +0200
Corrado Zoccolo <czoccolo@gmail.com> wrote:

> On Sun, Mar 29, 2009 at 5:51 PM, Arjan van de Ven
> <arjan@infradead.org> wrote:
> > On Sun, 29 Mar 2009 17:40:10 +0200
> > Corrado Zoccolo <czoccolo@gmail.com> wrote:
> >
> >> Hi,
> >> I'm seeing around 2 s "lost" during kernel boot, that are not
> >> accounted for any init call (excerpt of dmesg with initcall_debug
> >> follows, kernel is 2.6.29).
> >> What's the suggested way to investigate such problems?
> >
> > I take it you don't have an initrd ?
> 
> You guessed right.
> 
> >
> > If so I know what you are hitting; I have a patch to solve it but
> > it's a bit convoluted and not ready for mainline.... let me know if
> > you want to try it, I suspect it'll solve your issue ;)
> >
> 
> Sure. I'd like to test it.
> 

attached...

-- 
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org

[-- Attachment #2: linux-2.6.29-dont-wait-for-mouse.patch --]
[-- Type: text/x-patch, Size: 1359 bytes --]

Subject: [PATCH] fastboot: remove "wait for all devices before mounting root" delay

In the non-initrd case, we wait for all devices to finish their
probing before we try to mount the rootfs.
In practice, this means that we end up waiting 2 extra seconds for
the PS/2 mouse probing even though the root holding device has been
ready since a long time.

The previous two patches in this series made the RAID autodetect code
do it's own "wait for probing to be done" code, and added
"wait and retry" functionality in case the root device isn't actually
available.

These two changes should make it safe to remove the delay itself,
and this patch does this. On my test laptop, this reduces the boot time
by 2 seconds (kernel time goes from 3.9 to 1.9 seconds).

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
---
--- a/init/do_mounts.c	2009-01-07 18:42:10.000000000 -0800
+++ b/init/do_mounts.c	2009-01-07 18:43:02.000000000 -0800
@@ -370,14 +370,17 @@ void __init prepare_namespace(void)
 		ssleep(root_delay);
 	}
 
+#if 0
 	/*
 	 * wait for the known devices to complete their probing
 	 *
 	 * Note: this is a potential source of long boot delays.
 	 * For example, it is not atypical to wait 5 seconds here
 	 * for the touchpad of a laptop to initialize.
 	 */
 	wait_for_device_probe();
+#endif
+	async_synchronize_full();
 
 	md_run_setup();
 


[-- Attachment #3: linux-2.6.29-retry-root-mount.patch --]
[-- Type: text/x-patch, Size: 1923 bytes --]

Subject: [PATCH] fastboot: retry mounting the root fs if we can't find init

currently we wait until all device init is done before trying to mount
the root fs, and to consequently execute init.

In preparation for relaxing the first delay, this patch adds a retry
attempt in case /sbin/init is not found. Before retrying, the code
will wait for all device init to complete.

While this patch by itself doesn't gain boot time yet (it needs follow on
patches), the alternative already is to panic()...

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
---
--- a/init/main.c	2009-01-07 18:29:11.000000000 -0800
+++ b/init/main.c	2009-01-07 18:32:08.000000000 -0800
@@ -837,6 +837,7 @@ static void run_init_process(char *init_
  */
 static noinline int init_post(void)
 {
+	int retry_count = 1;
 	/* need to finish all async __init code before freeing the memory */
 	async_synchronize_full();
 	free_initmem();
@@ -859,6 +860,8 @@ static noinline int init_post(void)
 				ramdisk_execute_command);
 	}
 
+retry:
+
 	/*
 	 * We try each of these until one succeeds.
 	 *
@@ -871,6 +874,23 @@ static noinline int init_post(void)
 					"defaults...\n", execute_command);
 	}
 	run_init_process("/sbin/init");
+
+        if (retry_count > 0) {
+               retry_count--;
+               /* 
+                * We haven't found init yet... potentially because the device
+                * is still being probed. We need to
+                * - flush keventd and friends
+                * - wait for the known devices to complete their probing
+                * - try to mount the root fs again
+                */
+               flush_scheduled_work();
+               while (driver_probe_done() != 0)
+                       msleep(100);
+               prepare_namespace();
+               goto retry;
+        }
+
 	run_init_process("/etc/init");
 	run_init_process("/bin/init");
 	run_init_process("/bin/sh");


  reply	other threads:[~2009-03-29 16:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-29 15:40 Corrado Zoccolo
2009-03-29 15:51 ` Arjan van de Ven
2009-03-29 16:45   ` Corrado Zoccolo
2009-03-29 16:59     ` Arjan van de Ven [this message]
2009-03-31  6:06       ` Corrado Zoccolo

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=20090329095917.20948680@infradead.org \
    --to=arjan@infradead.org \
    --cc=czoccolo@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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®