linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] skip initramfs check
@ 2005-11-17 14:14 Marcelo Tosatti
  2005-11-17 22:56 ` Andrew Morton
  2005-11-21  7:30 ` Rob Landley
  0 siblings, 2 replies; 7+ messages in thread
From: Marcelo Tosatti @ 2005-11-17 14:14 UTC (permalink / raw)
  To: akpm, linux-kernel; +Cc: Matt Mackall, Al Viro


Hi, 

The initramfs check at populate_rootfs() can consume significant time
(several seconds) on slow/embedded platforms, since it has to decompress
the image.

Add an option to skip it under CONFIG_EMBEDDED.

Is there a nicer way to achieve the same result?

diff --git a/init/Kconfig b/init/Kconfig
index ea097e0..a9d709e 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -398,6 +398,16 @@ config CC_ALIGN_JUMPS
 	  no dummy operations need be executed.
 	  Zero means use compiler's default.
 
+config INITRAMFS_SKIP
+	bool "Skip initramfs verification of initrd" if EMBEDDED
+	default n
+	help
+	  By default the initialization code uncompresses the initrd image to 
+	  verify if it is a initramfs image. 
+
+	  Say Y here if you are sure not to be using initramfs and want to
+	  skip that test.
+
 endmenu		# General setup
 
 config TINY_SHMEM
diff --git a/init/initramfs.c b/init/initramfs.c
index 0c5d9a3..92628b0 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -486,6 +486,7 @@ void __init populate_rootfs(void)
 	if (initrd_start) {
 		int fd;
 		printk(KERN_INFO "checking if image is initramfs...");
+#ifndef CONFIG_INITRAMFS_SKIP
 		err = unpack_to_rootfs((char *)initrd_start,
 			initrd_end - initrd_start, 1);
 		if (!err) {
@@ -495,6 +496,7 @@ void __init populate_rootfs(void)
 			free_initrd();
 			return;
 		}
+#endif
 		printk("it isn't (%s); looks like an initrd\n", err);
 		fd = sys_open("/initrd.image", O_WRONLY|O_CREAT, 700);
 		if (fd >= 0) {

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] skip initramfs check
  2005-11-17 14:14 [PATCH] skip initramfs check Marcelo Tosatti
@ 2005-11-17 22:56 ` Andrew Morton
  2005-11-21  7:30 ` Rob Landley
  1 sibling, 0 replies; 7+ messages in thread
From: Andrew Morton @ 2005-11-17 22:56 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: linux-kernel, mpm, viro

Marcelo Tosatti <marcelo.tosatti@cyclades.com> wrote:
>
> The initramfs check at populate_rootfs() can consume significant time
> (several seconds) on slow/embedded platforms, since it has to decompress
> the image.
> 
> Add an option to skip it under CONFIG_EMBEDDED.
> 
> Is there a nicer way to achieve the same result?

I'd have thought that a __setup option would be preferable?  Remove an
ifdef, more flexible, and it's all __init code anyway.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] skip initramfs check
  2005-11-21  7:30 ` Rob Landley
@ 2005-11-21  6:23   ` Marcelo Tosatti
  2005-11-21 15:04     ` Rob Landley
  0 siblings, 1 reply; 7+ messages in thread
From: Marcelo Tosatti @ 2005-11-21  6:23 UTC (permalink / raw)
  To: Rob Landley; +Cc: akpm, linux-kernel, Matt Mackall, Al Viro


Hi Rob,

On Mon, Nov 21, 2005 at 01:30:55AM -0600, Rob Landley wrote:
> On Thursday 17 November 2005 08:14, Marcelo Tosatti wrote:
> > Hi,
> >
> > The initramfs check at populate_rootfs() can consume significant time
> > (several seconds) on slow/embedded platforms, since it has to decompress
> > the image.
> 
> Query: is the problem that a big initramfs image is being unpacked more than 
> once, or is unpacking an empty initramfs image (134 bytes) causing a 
> significant delay?

The problem is a big non-initramfs RAMDISK image (used for root mountpoint on this 
particular embedded platform), that is decompressed more than once:

- during the initramfs check, which fails because it is not initramfs.
- during the real RAMDISK decompression to memory.

> I'm fairly certain that back in 1990 I could unzip 134 bytes on my 33 mhz 386 
> running dos in a fraction of a second.  What's the use case here?

So the issue is not the empty initramfs image (which BTW could probably
be made unecessary?), but a 10Mb RAMDISK image being decompressed by a
48Mhz PPC, which takes quite a few seconds.

Need to rework the patch to use a __setup option as Andrew suggested.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] skip initramfs check
  2005-11-17 14:14 [PATCH] skip initramfs check Marcelo Tosatti
  2005-11-17 22:56 ` Andrew Morton
@ 2005-11-21  7:30 ` Rob Landley
  2005-11-21  6:23   ` Marcelo Tosatti
  1 sibling, 1 reply; 7+ messages in thread
From: Rob Landley @ 2005-11-21  7:30 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: akpm, linux-kernel, Matt Mackall, Al Viro

On Thursday 17 November 2005 08:14, Marcelo Tosatti wrote:
> Hi,
>
> The initramfs check at populate_rootfs() can consume significant time
> (several seconds) on slow/embedded platforms, since it has to decompress
> the image.

Query: is the problem that a big initramfs image is being unpacked more than 
once, or is unpacking an empty initramfs image (134 bytes) causing a 
significant delay?

I'm fairly certain that back in 1990 I could unzip 134 bytes on my 33 mhz 386 
running dos in a fraction of a second.  What's the use case here?

Rob

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] skip initramfs check
  2005-11-21 15:50       ` Matt Mackall
@ 2005-11-21 10:49         ` Marcelo Tosatti
  0 siblings, 0 replies; 7+ messages in thread
From: Marcelo Tosatti @ 2005-11-21 10:49 UTC (permalink / raw)
  To: Matt Mackall; +Cc: Rob Landley, akpm, linux-kernel

On Mon, Nov 21, 2005 at 07:50:50AM -0800, Matt Mackall wrote:
> On Mon, Nov 21, 2005 at 09:04:46AM -0600, Rob Landley wrote:
> > On Monday 21 November 2005 00:23, Marcelo Tosatti wrote:
> > > Hi Rob,
> > > > Query: is the problem that a big initramfs image is being unpacked more
> > > > than once, or is unpacking an empty initramfs image (134 bytes) causing a
> > > > significant delay?
> > >
> > > The problem is a big non-initramfs RAMDISK image (used for root mountpoint
> > > on this particular embedded platform), that is decompressed more than once:
> > >
> > > - during the initramfs check, which fails because it is not initramfs.
> > > - during the real RAMDISK decompression to memory.
> > >
> > > > I'm fairly certain that back in 1990 I could unzip 134 bytes on my 33 mhz
> > > > 386 running dos in a fraction of a second.  What's the use case here?
> > >
> > > So the issue is not the empty initramfs image (which BTW could probably
> > > be made unecessary?), but a 10Mb RAMDISK image being decompressed by a
> > > 48Mhz PPC, which takes quite a few seconds.
> > >
> > > Need to rework the patch to use a __setup option as Andrew suggested.
> > 
> > It sounds to me like is the initial check (which is just giving a thumbs 
> > up/thumbs down "is this an initramfs", correct?) only needs to decompress the 
> > first page or so of data to make this determination.  A quick glance at the 
> > code seems to imply it's just checking the header and the first entry, so 4k 
> > should be plenty for that.
> > 
> > Some variant of lib/zlib_inflate...  Ouch, bit of a mess there.  Hey Matt: you 
> > know this area.  Is it feasible to do some kind of:
> > 
> > deflate_init(whatever)
> > deflate_next_x_bytes(source *, dest *, length)
> > 
> > To grab a the first X bytes from the initramfs image?
> 
> Not at the moment. But I think it is feasible to simply move the ramdisk
> detection and unpacking inside the ramfs state machine. In other
> words, add two new states:
> 
> - detecting type
> - unpacking ramdisk
> 
> When the first few bytes are fed from the decompressor to the state
> machine, we either transition to the normal ramfs unpacking or we
> treat it as a ramdisk.

Yes that would be ideal. 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] skip initramfs check
  2005-11-21  6:23   ` Marcelo Tosatti
@ 2005-11-21 15:04     ` Rob Landley
  2005-11-21 15:50       ` Matt Mackall
  0 siblings, 1 reply; 7+ messages in thread
From: Rob Landley @ 2005-11-21 15:04 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: akpm, linux-kernel, Matt Mackall, Al Viro

On Monday 21 November 2005 00:23, Marcelo Tosatti wrote:
> Hi Rob,
> > Query: is the problem that a big initramfs image is being unpacked more
> > than once, or is unpacking an empty initramfs image (134 bytes) causing a
> > significant delay?
>
> The problem is a big non-initramfs RAMDISK image (used for root mountpoint
> on this particular embedded platform), that is decompressed more than once:
>
> - during the initramfs check, which fails because it is not initramfs.
> - during the real RAMDISK decompression to memory.
>
> > I'm fairly certain that back in 1990 I could unzip 134 bytes on my 33 mhz
> > 386 running dos in a fraction of a second.  What's the use case here?
>
> So the issue is not the empty initramfs image (which BTW could probably
> be made unecessary?), but a 10Mb RAMDISK image being decompressed by a
> 48Mhz PPC, which takes quite a few seconds.
>
> Need to rework the patch to use a __setup option as Andrew suggested.

It sounds to me like is the initial check (which is just giving a thumbs 
up/thumbs down "is this an initramfs", correct?) only needs to decompress the 
first page or so of data to make this determination.  A quick glance at the 
code seems to imply it's just checking the header and the first entry, so 4k 
should be plenty for that.

Some variant of lib/zlib_inflate...  Ouch, bit of a mess there.  Hey Matt: you 
know this area.  Is it feasible to do some kind of:

deflate_init(whatever)
deflate_next_x_bytes(source *, dest *, length)

To grab a the first X bytes from the initramfs image?

Rob

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] skip initramfs check
  2005-11-21 15:04     ` Rob Landley
@ 2005-11-21 15:50       ` Matt Mackall
  2005-11-21 10:49         ` Marcelo Tosatti
  0 siblings, 1 reply; 7+ messages in thread
From: Matt Mackall @ 2005-11-21 15:50 UTC (permalink / raw)
  To: Rob Landley; +Cc: Marcelo Tosatti, akpm, linux-kernel, Al Viro

On Mon, Nov 21, 2005 at 09:04:46AM -0600, Rob Landley wrote:
> On Monday 21 November 2005 00:23, Marcelo Tosatti wrote:
> > Hi Rob,
> > > Query: is the problem that a big initramfs image is being unpacked more
> > > than once, or is unpacking an empty initramfs image (134 bytes) causing a
> > > significant delay?
> >
> > The problem is a big non-initramfs RAMDISK image (used for root mountpoint
> > on this particular embedded platform), that is decompressed more than once:
> >
> > - during the initramfs check, which fails because it is not initramfs.
> > - during the real RAMDISK decompression to memory.
> >
> > > I'm fairly certain that back in 1990 I could unzip 134 bytes on my 33 mhz
> > > 386 running dos in a fraction of a second.  What's the use case here?
> >
> > So the issue is not the empty initramfs image (which BTW could probably
> > be made unecessary?), but a 10Mb RAMDISK image being decompressed by a
> > 48Mhz PPC, which takes quite a few seconds.
> >
> > Need to rework the patch to use a __setup option as Andrew suggested.
> 
> It sounds to me like is the initial check (which is just giving a thumbs 
> up/thumbs down "is this an initramfs", correct?) only needs to decompress the 
> first page or so of data to make this determination.  A quick glance at the 
> code seems to imply it's just checking the header and the first entry, so 4k 
> should be plenty for that.
> 
> Some variant of lib/zlib_inflate...  Ouch, bit of a mess there.  Hey Matt: you 
> know this area.  Is it feasible to do some kind of:
> 
> deflate_init(whatever)
> deflate_next_x_bytes(source *, dest *, length)
> 
> To grab a the first X bytes from the initramfs image?

Not at the moment. But I think it is feasible to simply move the ramdisk
detection and unpacking inside the ramfs state machine. In other
words, add two new states:

- detecting type
- unpacking ramdisk

When the first few bytes are fed from the decompressor to the state
machine, we either transition to the normal ramfs unpacking or we
treat it as a ramdisk.

-- 
Mathematics is the supreme nostalgia of our time.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-11-21 16:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-17 14:14 [PATCH] skip initramfs check Marcelo Tosatti
2005-11-17 22:56 ` Andrew Morton
2005-11-21  7:30 ` Rob Landley
2005-11-21  6:23   ` Marcelo Tosatti
2005-11-21 15:04     ` Rob Landley
2005-11-21 15:50       ` Matt Mackall
2005-11-21 10:49         ` Marcelo Tosatti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).