Forums

Linux Kernel speculation

Started by Nobby Anderson May 21, 2009
On May 21, 9:36=A0pm, Nobody <nob...@nowhere.com> wrote:

> Then you shouldn't need an initrd. The rationale behind initrd is so that > you can load modules which are needed for mounting the root filesystem > (e.g. IDE/SCSI/RAID/USB drivers, filesystem modules).
On a full-blow desktop system, no, you shouldn't. But embedded systems may use basically the same mechanisms for their ultimate run-time environment. Or maybe it's better to say that the whole initrd scheme is basically about booting your desktop up in an embedded-system type of miniature configuration, that then bootstraps the full system.
On May 21, 1:36=A0pm, Nobby Anderson <no...@invalid.invalid> wrote:

> The total boot time is of the order of 35 seconds - that's from a cold st=
art
> to the application running with tcp sockets open to receive stuff from th=
e
> LAN. =A0I'd like to explore ways of making that faster.
I have a blackfin uClinux system that I just clocked at 12 seconds from A/C power to user-mode application starting up, including 2 second u-boot delay. I'm not noticing any delay during kernel or ramfs decompression, but the size of the uImage as compared to the filesystem confirms that it's compressed.
> It seems that the biggest pauses in the boot process are to do with the > initrd loading, then the flash RAM being decompressed into RAM for the > ramdisk, and then there's a long pause while the Etherent hardware > initialises.
I wonder if u-boot might be running the processor in some severely sub- optimal (but safe) way? You may be able to try a newer u-boot without changing kernel versions and thus not really having to make changes to your application itself. Also make sure the ethernet pause is just the hardware drivers, not something like a vestigial attempt to contact a DHCP server or something like that.
On May 21, 5:41=A0pm, Nobby Anderson <no...@invalid.invalid> wrote:

> None of the existing time is taken in init, the init script here just > configures the Etherent and starts the application. =A0It's all in the > kernel/ramdisk loading. =A0I'm not sure how I could speed up the loading > process - I suspect the ARM stuff in the links above doesn't use > compressed disk and kernel images for a start, which would help, but I on=
ly
> have 4MB flash so I need to do that.
Another idea... could you have a severely bottlenecked interface to flash, either due to hardware limitations or more likely "safe" settings used during this early phase of operating? I'm thinking something like very conservative bus timing, using byte-wide access, an SPI device run at a pathetically low clock rate or one byte at a time, or some really running-around-in-circles block translation mapping... etc.
cs_posting@hotmail.com wrote:
> Nobby Anderson <no...@invalid.invalid> wrote: > >> The total boot time is of the order of 35 seconds - that's from >> a cold start to the application running with tcp sockets open >> to receive stuff from the LAN. I'd like to explore ways of >> making that faster. > > I have a blackfin uClinux system that I just clocked at 12 > seconds from A/C power to user-mode application starting up, > including 2 second u-boot delay. I'm not noticing any delay > during kernel or ramfs decompression, but the size of the uImage > as compared to the filesystem confirms that it's compressed.
The use of compressed kernal code can easily speed up booting on a reasonably fast processor, because the sum of file read time + decompression time is less than a file read of uncompressed material. -- [mail]: Chuck F (cbfalconer at maineline dot net) [page]: <http://cbfalconer.home.att.net> Try the download section.
On Thu, 11 Jun 2009 12:09:31 -0700, cs_posting wrote:

>> Then you shouldn't need an initrd. The rationale behind initrd is so that >> you can load modules which are needed for mounting the root filesystem >> (e.g. IDE/SCSI/RAID/USB drivers, filesystem modules). > > On a full-blow desktop system, no, you shouldn't. > > But embedded systems may use basically the same mechanisms for their > ultimate run-time environment. > > Or maybe it's better to say that the whole initrd scheme is basically > about booting your desktop up in an embedded-system type of miniature > configuration, that then bootstraps the full system.
It isn't about size, but portability. initrd was created so that you can create a kernel and filesystem image which will boot on a wide range of hardware. Before initrd, Linux distributions needed to provide kernels which had dozens of different IDE/SCSI drivers built in (this is before SATA). You couldn't provide the drivers as modules because you need to be able to access the disk before you can load modules. initrd lets you mount an initial RAM filesystem containing IDE, SCSI and SATA drivers, plus the tools required to probe the hardware and load the appropriate driver. Once you've loaded the driver, you can get everything else from the hard disk. If you're building a kernel for specific hardware, you don't need to use modules for the core hardware, or maybe at all. You just build what you need directly into the kernel. No modules means no need for initrd.
On Jun 13, 11:15=A0pm, Nobody <nob...@nowhere.com> wrote:

> > Or maybe it's better to say that the whole initrd scheme is basically > > about booting your desktop up in an embedded-system type of miniature > > configuration, that then bootstraps the full system. > > It isn't about size, but portability.
I didn't actually say it is about size... but the argument you are going to make below actually does come down largely to size and ease of changing.
> initrd was created so that you can create a kernel and filesystem image > which will boot on a wide range of hardware. Before initrd, Linux > distributions needed to provide kernels which had dozens of different > IDE/SCSI drivers built in (this is before SATA). You couldn't provide the > drivers as modules because you need to be able to access the disk before > you can load modules.
You still have to provide drivers for all the hardware you want to boot on in the image. The difference is that you can then discard the size of the modules that you don't use (for the hardware you don't have) when you free the initrd; with a monolithic kernel you can't free up the space of unused compiled in drivers (or do we do kernel paging? I must admit I don't know). Also it's arguably easier to issue the cpio incantation to make a new image than it is to recompile the kernel to include different drivers.
> If you're building a kernel for specific hardware, you don't need to use > modules for the core hardware, or maybe at all. You just build what you > need directly into the kernel. No modules means no need for initrd.
Not exactly, because initrd is not confined to making modules available. Initrd also lets you run scripts to setup your root filesystem - you might need to bring up a network and mount it over a network filesystem. Or setup unionfs... Or re-image the machine from some internal or external archive... etc. You have all the functionality you choose to include - and as I started out by saying, many embedded systems just stop here and run out of the initrd or similar-idea ramfs or whatever permanently.
On Mon, 15 Jun 2009 09:17:06 -0700, cs_posting wrote:

>> initrd was created so that you can create a kernel and filesystem image >> which will boot on a wide range of hardware. Before initrd, Linux >> distributions needed to provide kernels which had dozens of different >> IDE/SCSI drivers built in (this is before SATA). You couldn't provide the >> drivers as modules because you need to be able to access the disk before >> you can load modules. > > You still have to provide drivers for all the hardware you want to > boot on in the image. The difference is that you can then discard the > size of the modules that you don't use (for the hardware you don't > have) when you free the initrd; with a monolithic kernel you can't > free up the space of unused compiled in drivers (or do we do kernel > paging? I must admit I don't know).
No, kernel memory is physical memory.
> Also it's arguably easier to issue the cpio incantation to make a new > image than it is to recompile the kernel to include different drivers.
Right. But still, it comes down to portability. If you're targeting a specific piece of hardware, you know which drivers you need, and you don't compile in anything else.
>> If you're building a kernel for specific hardware, you don't need to use >> modules for the core hardware, or maybe at all. You just build what you >> need directly into the kernel. No modules means no need for initrd. > > Not exactly, because initrd is not confined to making modules > available. Initrd also lets you run scripts to setup your root > filesystem - you might need to bring up a network and mount it over a > network filesystem. Or setup unionfs... Or re-image the machine > from some internal or external archive... etc. You have all the > functionality you choose to include - and as I started out by saying, > many embedded systems just stop here and run out of the initrd or > similar-idea ramfs or whatever permanently.
The kernel can mount an NFS root filesystem directly, provided that you can get the network up using only what's built into the kernel; if you need to log into a VPN, that would require user-space support. Probably the most common non-module use of initrd on desktop and server systems is if the root filesystem is on a RAID array, as these typically can't be initialised without user-space support. But that's atypical for an embedded system.
On Jun 19, 4:54=A0am, Nobody <nob...@nowhere.com> wrote:
> > Also it's arguably easier to issue the cpio incantation to make a new > > image than it is to recompile the kernel to include different drivers. > > Right. But still, it comes down to portability. If you're targeting a > specific piece of hardware, you know which drivers you need, and you don'=
t
> compile in anything else.
You still have to "include" all of the drivers for the hardware you might need to be portable enough to boot from, the question is if you are compiling them into the kernel (where you can't ordinarily free the unused ones) or if you are cpio'ing them into the initrd.
> > Not exactly, because initrd is not confined to making modules > > available. =A0 Initrd also lets you run scripts to setup your root > > filesystem - you might need to bring up a network and mount it over a > > network filesystem. =A0Or setup unionfs... =A0 Or re-image the machine > > from some internal or external archive... etc. =A0
> Probably the most common non-module use of initrd on desktop and server > systems is if the root filesystem is on a RAID array, as these typically > can't be initialised without user-space support. But that's atypical for > an embedded system.
Most common? Hmm, I wonder how many linux eeepc's (unionfs setup script in initrd) have shipped compared to servers with RAID arrays ;-) Note that I was not describing this as typical for an embedded system, instead I was pointing out that more complicated systems may initially boot to a temporary ram root filesystem using similar or identical mechanism to what embedded systems use as their ultimate root filesystem. In other words, many complicated systems behave like embedded systems in order to bootstrap their full complexity.