linux and initrd load very slowly on UEFI system

Bug #944347 reported by Kamal Mostafa
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
grub2 (Ubuntu)
Fix Released
Critical
Adam Conrad

Bug Description

On a Intel Tunnel Mountain system, grub2 loads from disk very slowly when booting with UEFI: about 53 seconds to execute a pair of "linux" and "initrd" commands.

Expected behavior:
    Load time for linux and initrd should be on order of 1 second.

Problem observed with:
    grub2 (oneiric) 1.99-12ubuntu5
    grub2 (precise) 1.99-14ubuntu2
    Intel Tunnel Mountain UEFI BIOS version SDV.TM.B8 or SDV.TM.B9

Tags: patch

Related branches

Revision history for this message
Kamal Mostafa (kamalmostafa) wrote :

The performance problem appears to be due to overhead of the individual disk read calls...

grub2's disk I/O layer buffers 8 disk sectors per read, hard-coded in include/grub/disk.h as GRUB_DISK_CACHE_SIZE.

Increasing GRUB_DISK_CACHE_SIZE to 1024 (patch attached) dramatically improves the load performance for my Intel Tunnel Mountain system booting with UEFI: total load time for linux and initrd is reduced from about 53 seconds to about 1 second.

Revision history for this message
Kamal Mostafa (kamalmostafa) wrote :

PPA grub2 package with the above patch (kamal0~1024sectors.patch) applied:
https://launchpad.net/~kamalmostafa/+archive/grub2-lp944347

Revision history for this message
Manoj Iyer (manjo) wrote :

GRUB_DISK_CACHE_SIZE seems to be size of disk cache size in 512byte units, so it could be as large as supported sector read size. I think currently we can do 4K sector reads on some disks, ( I hope my math is right) so you could only have:

#define GRUB_DISK_CACHE_BITS 8
instead of
#define GRUB_DISK_CACHE_BITS 10

Revision history for this message
Kamal Mostafa (kamalmostafa) wrote :

FWIW, it turns out that the idea of cranking up GRUG_DISK_CACHE_SIZE to help EFI has been discovered previously: http://blog.fpmurphy.com/2010/03/grub2-efi-support.html

Revision history for this message
Manoj Iyer (manjo) wrote :

The patch kamal posted greatly improves boot speed on UEFI systems, mine went from "for ever" to under 5secs. Could we have this patch in 12.04 if it does not hurt other systems on legacy bios?

Changed in grub2 (Ubuntu):
importance: Undecided → High
status: New → Confirmed
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "kamal0~1024sectors.patch" of this bug report has been identified as being a patch. The ubuntu-reviewers team has been subscribed to the bug report so that they can review the patch. In the event that this is in fact not a patch you can resolve this situation by removing the tag 'patch' from the bug report and editing the attachment so that it is not flagged as a patch. Additionally, if you are member of the ubuntu-reviewers team please also unsubscribe the team from this bug report.

[This is an automated message performed by a Launchpad user owned by Brian Murray. Please contact him regarding any issues with the action taken in this bug report.]

tags: added: patch
Changed in grub2 (Ubuntu):
assignee: Kamal Mostafa (kamalmostafa) → nobody
Revision history for this message
Adam Conrad (adconrad) wrote :

Fix committed in bzr

Changed in grub2 (Ubuntu):
assignee: nobody → Adam Conrad (adconrad)
status: Confirmed → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :
Download full text (4.0 KiB)

This bug was fixed in the package grub2 - 1.99-16ubuntu1

---------------
grub2 (1.99-16ubuntu1) precise; urgency=low

  * Resynchronise with Debian. Remaining changes:
    - Adjust for default Ubuntu boot options ("quiet splash").
    - Default to hiding the menu; holding down Shift at boot will show it.
    - Set a monochromatic theme and an appropriate background for Ubuntu.
    - Apply Ubuntu GRUB Legacy changes to legacy update-grub script.
    - Fix backslash-escaping in merge_debconf_into_conf.
    - Remove "GNU/Linux" from default distributor string.
    - Add crashkernel option.
    - Bypass menu unless other OSes are installed or Shift is pressed.
    - Allow Shift to interrupt 'sleep --interruptible'.
    - Reduce visual clutter in normal mode.
    - Remove verbose messages printed before reading configuration.
    - Suppress kernel/initrd progress messages, except in recovery mode.
    - Show the boot menu if the previous boot failed.
    - Don't generate device.map during grub-install or grub-mkconfig.
    - Adjust upgrade version checks for Ubuntu.
    - Suppress "GRUB loading" message unless Shift is held down.
    - Adjust versions of grub-doc and grub-legacy-doc conflicts.
    - Fix LVM/RAID probing in the absence of /boot/grub/device.map.
    - Look for .mo files in /usr/share/locale-langpack first.
    - Build-depend on qemu-kvm rather than qemu-system for grub-pc tests.
    - Check hardware support before using gfxpayload=keep.
    - Put second and subsequent Linux menu entries in a submenu.
    - Preferred resolution detection for VBE.
    - Set vt.handoff=7 for smooth handoff to kernel graphical mode.
    - Update default/grub.md5sum to include maverick's default md5sum.
    - In recovery mode, add nomodeset to the Linux kernel arguments, and
      remove the 'set gfxpayload=keep' command.
    - Skip Windows os-prober entries on Wubi systems, and suppress the menu
      by default if those are the only other-OS entries.
    - Handle probing striped DM-RAID devices.
    - Replace 'single' by 'recovery' when friendly-recovery is installed.
  * Use qemu -no-kvm in tests for now to work around LP #947597.
  * Disable cursor as early as possible in grub_main (LP: #861048).

grub2 (1.99-16) unstable; urgency=low

  * Backport from upstream:
    - Build with -fno-asynchronous-unwind-tables to save space (closes:
      #662787).

grub2 (1.99-15) unstable; urgency=low

  [ Adam Conrad ]
  * grub.cfg_400.patch: Redirect grep stdout to /dev/null since
    grub-mkconfig is "exec > grub.cfg.new", which causes grep's input
    and output to be the same FD (LP: #934269) (closes: #652972)
  * efi_disk_cache.patch: Bump the disk cache on EFI systems to
    dramatically reduce load times for vmlinux/initrd (LP: #944347)

  [ Colin Watson ]
  * no_libzfs.patch: Use xasprintf rather than asprintf.
  * Backport from upstream:
    - Rewrite XFS btree parsing; fixes invalid BMAP (closes: #657776).
    - Handle newer autotools, and add some missing quotes in the process.
      (Note that this moves grub-mkconfig_lib and update-grub_lib to
      /usr/share/grub; I added links in /usr/lib/grub for compatibility.)
    - Fix incorrect identifiers ...

Read more...

Changed in grub2 (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
Kamal Mostafa (kamalmostafa) wrote :

Adam, there's a bug in your version of the patch "efi_disk_cache.patch":

  +#define GRUB_DISK_CACHE_SIZE 1024
  +#define GRUB_DISK_CACHE_BITS 8 <---- SHOULD BE "10"

You may have been misled by Manoj's suggestion of trying BITS==8... But note that 2^BITS must be kept == SIZE which isn't the case in your version of the patch.

Anyway, I have determined that BITS==10, SIZE==1024 is a good value performance-wise (and the blog poster suggests even higher: BITS==13). I recommend that we stick with BITS==10, SIZE==1024.

Changed in grub2 (Ubuntu):
status: Fix Released → Confirmed
Revision history for this message
Manoj Iyer (manjo) wrote :

Grub update broke booting on UEFI systems, I get a message saying "null in the ring. Aborted. Press any key to exit." I think this is the result of the BITS=8 vs BITS=10, as Kamal mentioned SIZE==2^BITS, setting BITS=8 SIZE should be set to 2^8. The reason I suggested using BITS=8 is that will correspond to the largest supported sector size on the disk, which is 4K sector size. Kamals settings of BITS=10 will read more than one sector at a time, it might consume more memory but might not cause any harm. Since we have already tested BITS=10, I suggested we do what Kamal suggested and what we have tested. Unless someone else has an opposition to reading more than one largest supported disk sector at a time.

Changed in grub2 (Ubuntu):
importance: High → Critical
Revision history for this message
Colin Watson (cjwatson) wrote :

Just a mistake, I think. I'll get that fixed.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package grub2 - 1.99-17ubuntu1

---------------
grub2 (1.99-17ubuntu1) precise; urgency=low

  * Resynchronise with Debian. Remaining changes:
    - Adjust for default Ubuntu boot options ("quiet splash").
    - Default to hiding the menu; holding down Shift at boot will show it.
    - Set a monochromatic theme and an appropriate background for Ubuntu.
    - Apply Ubuntu GRUB Legacy changes to legacy update-grub script.
    - Fix backslash-escaping in merge_debconf_into_conf.
    - Remove "GNU/Linux" from default distributor string.
    - Add crashkernel option.
    - Bypass menu unless other OSes are installed or Shift is pressed.
    - Allow Shift to interrupt 'sleep --interruptible'.
    - Reduce visual clutter in normal mode.
    - Remove verbose messages printed before reading configuration.
    - Suppress kernel/initrd progress messages, except in recovery mode.
    - Show the boot menu if the previous boot failed.
    - Don't generate device.map during grub-install or grub-mkconfig.
    - Adjust upgrade version checks for Ubuntu.
    - Suppress "GRUB loading" message unless Shift is held down.
    - Adjust versions of grub-doc and grub-legacy-doc conflicts.
    - Fix LVM/RAID probing in the absence of /boot/grub/device.map.
    - Look for .mo files in /usr/share/locale-langpack first.
    - Build-depend on qemu-kvm rather than qemu-system for grub-pc tests.
    - Check hardware support before using gfxpayload=keep.
    - Put second and subsequent Linux menu entries in a submenu.
    - Preferred resolution detection for VBE.
    - Set vt.handoff=7 for smooth handoff to kernel graphical mode.
    - Update default/grub.md5sum to include maverick's default md5sum.
    - In recovery mode, add nomodeset to the Linux kernel arguments, and
      remove the 'set gfxpayload=keep' command.
    - Skip Windows os-prober entries on Wubi systems, and suppress the menu
      by default if those are the only other-OS entries.
    - Handle probing striped DM-RAID devices.
    - Replace 'single' by 'recovery' when friendly-recovery is installed.
    - Use qemu -no-kvm in tests for now to work around LP #947597.
    - Disable cursor as early as possible in grub_main.

grub2 (1.99-17) unstable; urgency=low

  * efi_disk_cache.patch: Fix incorrect GRUB_DISK_CACHE_BITS (LP: #944347).
 -- Colin Watson <email address hidden> Tue, 06 Mar 2012 18:42:33 +0000

Changed in grub2 (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
Kamal Mostafa (kamalmostafa) wrote :

I confirm grub2 (1.99-17ubuntu1) fixes the problem: UEFI grub loads linux and initrd quickly now.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.