All of lore.kernel.org
 help / color / mirror / Atom feed
* Parallel kernel loading and keystroke capture in GRUB2
@ 2008-11-28  5:42 Vlad
       [not found] ` <49300FF9.2000005@linux.intel.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Vlad @ 2008-11-28  5:42 UTC (permalink / raw)
  To: Grub-devel; +Cc: discuss, power

Hi,

In a recent demonstration of how to boot Linux in 5 seconds [1], PowerTOP developers did not use GRUB2, even though GRUB2 is a necessary component of any production and consumer Linux system or multi-boot environment. As I see it, the greatest disadvantage of GRUB2 is that it needlessly wastes the time in which it gives the user the chance to stall the boot sequence in order to make changes to the boot settings. Of course, having this option available is a necesity in case the user's hardware requires tweaking the parameters passed to the kernel. However, GRUB2 should be loading the default kernel during this time, instead of deferring this IO-bound task to after the timeout has elapsed.

I'm not familiar with the internals of GRUB2, but I assume that multi-threading is impossible. Given this limitation, I have devised the following chain of events which should minimize the time needed to boot the default kernel, while still giving the user a chance to change the boot settings:

1. Start accepting and recording user keystrokes (background task)
2. Print a message along the lines of "Press any key to change the boot settings". (background task)
3. Record the start time (ie. start_timestamp=0)
4. Mount the boot partition and read grub.conf
5. If a key has been pressed, display the boot settings. Else, start loading the default kernel into memory.
6. Record the time when the default kernel has finished loading (ie. kernel_loaded_timestamp=3)
7. If a key has been pressed, display the boot settings. Else, if the time expended so far is less than the "timeout" variable set in grub.conf (ie. timeout=10), keep displaying the message and accepting keystrokes for the remainder of the time. Else, execute the default kernel which has previously been loaded to memory. In pseudo-code, this would be:

if (keystroke_detected){
     display_boot_settings();
} else if (kernel_loaded_timestamp - start_timestamp < timeout){
     keep_displaying_intro_message(timeout - (kernel_loaded_timestamp - start_timestamp));
} else {
     execute(default_kernel);
}

8. Once the timeout period has elapsed, if a key has been pressed, display the boot settings. Else boot the default kernel.

The advantage of this scheme is that the time-consuming parts of mounting the boot partition, reading grub.conf and loading the default kernel are done roughly in _parallel_ to the user seeing the intro message. This scheme also ensures that the user's keystrokes do not fall through the cracks, because they are checked before booting the default kernel at steps 5, 7 and 8.

As GRUB2 is currently set up, time is just wasted displaying the "Press any key to change the boot settings" message because GRUB2 is doing nothing beside awaiting user input. Instead, GRUB2 should be doing all the necessary preparations for actually booting the default kernel during this time.

Since popular Linux distros typically display the GRUB2 intro message for 30 seconds, the time being wasted here is astronomical compared to how fast the Linux environment can actually boot. Changing GRUB2 as described above would ensure that no time is wasted while users are given a chance to change their boot settings.

Thanks,
Vlad

[1] http://lwn.net/Articles/299483


      



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

* Re: Parallel kernel loading and keystroke capture in GRUB2
       [not found] ` <49300FF9.2000005@linux.intel.com>
@ 2008-11-29 19:45   ` Arthur Marsh
       [not found]     ` <49342A16.8070505@intel.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Arthur Marsh @ 2008-11-29 19:45 UTC (permalink / raw)
  To: grub-devel; +Cc: discuss, power

Arjan van de Ven wrote, on 2008-11-29 02:06:
> Vlad wrote:
>> Hi,
>> 
>> In a recent demonstration of how to boot Linux in 5 seconds [1],
>> PowerTOP developers did not use GRUB2, even though GRUB2 is a
>> necessary component of any production and consumer Linux system or
>> multi-boot environment. As I see it, the greatest disadvantage of
>> GRUB2 is that it needlessly wastes the time in which it gives the
>> user the chance to stall the boot sequence in order to make changes
>> to the boot settings. Of course, having this option available is a
>> necesity in case the user's hardware requires tweaking the
>> parameters passed to the kernel. However, GRUB2 should be loading
>> the default kernel during this time, instead of deferring this
>> IO-bound task to after the timeout has elapsed.
> 
> we used grub 1.
>> Since popular Linux distros typically display the GRUB2 intro
>> message for 30 seconds,
> 
> I'm not aware of mainstream distributions using grub2 yet. Also, I'm
> not aware of any distro using 30 seconds as timeout, the longest I've
> seen is 5 seconds.

Debian GNU/Linux offers grub2 as an option on installation.

Arthur.




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

* Re: Parallel kernel loading and keystroke capture in GRUB2
       [not found]     ` <49342A16.8070505@intel.com>
@ 2008-12-01 19:23       ` Felipe Sateler
  0 siblings, 0 replies; 3+ messages in thread
From: Felipe Sateler @ 2008-12-01 19:23 UTC (permalink / raw)
  To: grub-devel; +Cc: discuss, power, grub-devel

Kok, Auke wrote:

> Arthur Marsh wrote:
>> Arjan van de Ven wrote, on 2008-11-29 02:06:
>>> Vlad wrote:
>>>> Hi,
>>>>
>>>> In a recent demonstration of how to boot Linux in 5 seconds [1],
>>>> PowerTOP developers did not use GRUB2, even though GRUB2 is a
>>>> necessary component of any production and consumer Linux system or
>>>> multi-boot environment. As I see it, the greatest disadvantage of
>>>> GRUB2 is that it needlessly wastes the time in which it gives the
>>>> user the chance to stall the boot sequence in order to make changes
>>>> to the boot settings. Of course, having this option available is a
>>>> necesity in case the user's hardware requires tweaking the
>>>> parameters passed to the kernel. However, GRUB2 should be loading
>>>> the default kernel during this time, instead of deferring this
>>>> IO-bound task to after the timeout has elapsed.
>>> we used grub 1.
>>>> Since popular Linux distros typically display the GRUB2 intro
>>>> message for 30 seconds,
>>> I'm not aware of mainstream distributions using grub2 yet. Also, I'm
>>> not aware of any distro using 30 seconds as timeout, the longest I've
>>> seen is 5 seconds.
>> 
>> Debian GNU/Linux offers grub2 as an option on installation.
> 
> Debian also offers the kitchen sink, including anvil and builtin laser
> microscope.
> 
> It's fine that they do, but I doubt that debian or any of the other
> distributions will want to offer grub2 as DEFAULT bootloader at installation
> time.
> 
> Until that happens grub2 is an experiment and certainly not interesting for
> fast boot purposes. I would personally stay far away from grub2.

grub2 is enabled in the debian installer by default given some conditions are
met (if I understand correctly, only when installing on some EFI-based
systems). There was a proposal to make grub2 default for lenny, but apparently
it didn't make it.

-- 

  Felipe Sateler




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

end of thread, other threads:[~2008-12-01 19:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-28  5:42 Parallel kernel loading and keystroke capture in GRUB2 Vlad
     [not found] ` <49300FF9.2000005@linux.intel.com>
2008-11-29 19:45   ` Arthur Marsh
     [not found]     ` <49342A16.8070505@intel.com>
2008-12-01 19:23       ` Felipe Sateler

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.