Bug#508834: grub-pc: grub_init_all() appears to be the culprit

Kevin Mitchell kevmitch at math.sfu.ca
Sat Jul 4 09:56:18 UTC 2009


Package: grub-pc
Version: 1.96+20090702-1
Severity: normal


I also find grub-probe rather slow, but I'm talking more like 3 or 4
seconds not 10 minutes. I agree that the initial reporter may have other
problems that compound the issue, but the issue is nevertheless still
real.

An additional disturbing observation is that while grub-probe is busy
consuming 100% cpu on one core, it appears to cause Xorg to consume up
to 100% cpu on my second core! This is reported by top, gkrellm and
htop. I also find that my mouse pointer tends to lag during this
time. 

After some poking around in the source, I find that most of the time
(and most of the BLKFLSBUF calls) occur at

util/grub-probe.c:368 grub_init_all ()

I traced the grub_init_all funciton to grub_probe_init.c which does
nothing but call a bunch of functions to initialize the various modules
for all supported filesystems. Unfortunately, my detective work was
stopped at this point because none of these functions appear to exist
anywhere. Instead it looks like they are somehow defined in a
round-about way through .lst files which I don't understand at all.

The efficiency of grub-probe aside, I believe the real problem is the
number of times that it is called during the update-grub process. 
In chronological order:


/usr/sbin/grub-mkconfig:117-127                                   5 calls to grub-probe

/etc/grub.d/00_header:75                                          1 call to grub-probe


/etc/grub.d/00_header:75 prepare_grub_to_access_device 
    /usr/lib/grub/grub-mkconfig_lib: 138-146                      3 calls to grub-probe 

/etc/grub.d/05_debian_theme: 42 prepare_grub_to_access_device
    /usr/lib/grub/grub-mkconfig_lib: 138-146                      3 calls to grub-probe 

/etc/grub.d/10_linux:40                                           1 call to upate-grub

for every kernel!
/etc/grub.d/10_linux:140 linux_entry
    /etc/grub.d/10_linux: 96 prepare_grub_to_access_device
        /usr/lib/grub/grub-mkconfig_lib: 138-146                  3 calls to grub-probe   

again for every kernel if  GRUB_DISABLE_LINUX_RECOVERY is not set!
/etc/grub.d/10_linux:140 linux_entry
    /etc/grub.d/10_linux: 96 prepare_grub_to_access_device
        /usr/lib/grub/grub-mkconfig_lib: 138-146                  3 calls to grub-probe   


/etc/grub.d/30_os-prober: 50                                      1 call to grub-probe

for every other os!
/etc/grub.d/30_os-prober: 55,81,100 prepare_grub_to_access_device
    /usr/lib/grub/grub-mkconfig_lib: 138-146                      3 calls to grub-probe 

Which is 23 calls in total meaning that update-grub takes over a
minute in the highly optimistic case that you have only one kernel and
one other os. For me who typicaly has 3 or 4 kernels this starts to push 
2 minutes.

Is it really necessary to be calling it this may times. Could it not
just be called once or twice at the beginning and have the resulting
query information reused?

Kevin

-- Package-specific info:

*********************** BEGIN /proc/mounts
/dev/root / xfs rw,noatime,noquota 0 0
/dev/sda7 /home xfs rw,noatime,noquota 0 0
/dev/sda7 /i386/home xfs rw,noatime,noquota 0 0
/dev/root /i386/tmp xfs rw,noatime,noquota 0 0
/dev/root /i386/etc/apt xfs rw,noatime,noquota 0 0
/dev/sda2 /boot ext3 rw,noatime,errors=continue,commit=5,data=writeback 0 0
*********************** END /proc/mounts

*********************** BEGIN /boot/grub/device.map
(hd0)	/dev/sda
*********************** END /boot/grub/device.map

*********************** BEGIN /boot/grub/grub.cfg
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
set default=0
set timeout=5
set root=(hd0,5)
search --no-floppy --fs-uuid --set 27b1b881-6a39-47e9-8929-25b97eecae2f
if loadfont /usr/share/grub/ascii.pf2 ; then
  set gfxmode=640x480
  insmod gfxterm
  insmod vbe
  if terminal_output gfxterm ; then true ; else
    # For backward compatibility with versions of terminal.mod that don't
    # understand terminal_output
    terminal gfxterm
  fi
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
menuentry "Debian GNU/Linux, Linux 2.6.30.014" {
	set root=(hd0,2)
	search --no-floppy --fs-uuid --set 234cc6d9-e0ef-4105-b817-f1c83edbc1a2
	linux	/vmlinuz-2.6.30.014 root=/dev/sda5 ro vga=792 selinux=0 enforcing=0 resume=/dev/sda3  clocksource=hpet quiet 
}
menuentry "Debian GNU/Linux, Linux 2.6.30.014 (recovery mode)" {
	set root=(hd0,2)
	search --no-floppy --fs-uuid --set 234cc6d9-e0ef-4105-b817-f1c83edbc1a2
	linux	/vmlinuz-2.6.30.014 root=/dev/sda5 ro single vga=792 selinux=0 enforcing=0 resume=/dev/sda3  clocksource=hpet quiet
}
menuentry "Debian GNU/Linux, Linux 2.6.30.013" {
	set root=(hd0,2)
	search --no-floppy --fs-uuid --set 234cc6d9-e0ef-4105-b817-f1c83edbc1a2
	linux	/vmlinuz-2.6.30.013 root=/dev/sda5 ro vga=792 selinux=0 enforcing=0 resume=/dev/sda3  clocksource=hpet quiet 
}
menuentry "Debian GNU/Linux, Linux 2.6.30.013 (recovery mode)" {
	set root=(hd0,2)
	search --no-floppy --fs-uuid --set 234cc6d9-e0ef-4105-b817-f1c83edbc1a2
	linux	/vmlinuz-2.6.30.013 root=/dev/sda5 ro single vga=792 selinux=0 enforcing=0 resume=/dev/sda3  clocksource=hpet quiet
}
menuentry "Debian GNU/Linux, Linux 2.6.30.012" {
	set root=(hd0,2)
	search --no-floppy --fs-uuid --set 234cc6d9-e0ef-4105-b817-f1c83edbc1a2
	linux	/vmlinuz-2.6.30.012 root=/dev/sda5 ro vga=792 selinux=0 enforcing=0 resume=/dev/sda3  clocksource=hpet quiet 
}
menuentry "Debian GNU/Linux, Linux 2.6.30.012 (recovery mode)" {
	set root=(hd0,2)
	search --no-floppy --fs-uuid --set 234cc6d9-e0ef-4105-b817-f1c83edbc1a2
	linux	/vmlinuz-2.6.30.012 root=/dev/sda5 ro single vga=792 selinux=0 enforcing=0 resume=/dev/sda3  clocksource=hpet quiet
}
menuentry "Debian GNU/Linux, Linux 2.6.30-1-amd64" {
	set root=(hd0,2)
	search --no-floppy --fs-uuid --set 234cc6d9-e0ef-4105-b817-f1c83edbc1a2
	linux	/vmlinuz-2.6.30-1-amd64 root=UUID=27b1b881-6a39-47e9-8929-25b97eecae2f ro vga=792 selinux=0 enforcing=0 resume=/dev/sda3  clocksource=hpet quiet 
	initrd	/initrd.img-2.6.30-1-amd64
}
menuentry "Debian GNU/Linux, Linux 2.6.30-1-amd64 (recovery mode)" {
	set root=(hd0,2)
	search --no-floppy --fs-uuid --set 234cc6d9-e0ef-4105-b817-f1c83edbc1a2
	linux	/vmlinuz-2.6.30-1-amd64 root=UUID=27b1b881-6a39-47e9-8929-25b97eecae2f ro single vga=792 selinux=0 enforcing=0 resume=/dev/sda3  clocksource=hpet quiet
	initrd	/initrd.img-2.6.30-1-amd64
}
menuentry "Debian GNU/Linux, Linux 2.6.26-2-amd64" {
	set root=(hd0,2)
	search --no-floppy --fs-uuid --set 234cc6d9-e0ef-4105-b817-f1c83edbc1a2
	linux	/vmlinuz-2.6.26-2-amd64 root=UUID=27b1b881-6a39-47e9-8929-25b97eecae2f ro vga=792 selinux=0 enforcing=0 resume=/dev/sda3  clocksource=hpet quiet 
	initrd	/initrd.img-2.6.26-2-amd64
}
menuentry "Debian GNU/Linux, Linux 2.6.26-2-amd64 (recovery mode)" {
	set root=(hd0,2)
	search --no-floppy --fs-uuid --set 234cc6d9-e0ef-4105-b817-f1c83edbc1a2
	linux	/vmlinuz-2.6.26-2-amd64 root=UUID=27b1b881-6a39-47e9-8929-25b97eecae2f ro single vga=792 selinux=0 enforcing=0 resume=/dev/sda3  clocksource=hpet quiet
	initrd	/initrd.img-2.6.26-2-amd64
}
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" {
	linux	/memtest86+.bin
}
menuentry "Memory test (memtest86+, serial console 115200)" {
	linux	/memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Microsoft Windows XP Professional (on /dev/sda1)" {
	set root=(hd0,1)
	search --no-floppy --fs-uuid --set 086c417b6c416492
	drivemap -s (hd0) ${root}
	chainloader +1
}
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
### END /etc/grub.d/40_custom ###
*********************** END /boot/grub/grub.cfg

-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (600, 'unstable'), (500, 'transitional-i386'), (500, 'transitional'), (500, 'testing'), (400, 'stable'), (300, 'experimental'), (204, 'unstable-i386'), (203, 'testing-i386'), (202, 'stable-i386'), (201, 'experimental-i386')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.30.014 (SMP w/2 CPU cores; PREEMPT)
Locale: LANG=en_GB, LC_CTYPE=en_GB (charmap=ISO-8859-1)
Shell: /bin/sh linked to /bin/dash

Versions of packages grub-pc depends on:
ii  debconf [debconf-2.0]    1.5.27          Debian configuration management sy
ii  grub-common              1.96+20090702-1 GRand Unified Bootloader, version 
ii  libc6                    2.9-18          GNU C Library: Shared libraries
ii  ucf                      3.0018          Update Configuration File: preserv

grub-pc recommends no packages.

Versions of packages grub-pc suggests:
pn  desktop-base                  <none>     (no description available)
ii  genisoimage                   9:1.1.9-1  Creates ISO-9660 CD-ROM filesystem
ii  os-prober                     1.29       utility to detect other OSes on a 

-- debconf information:
  grub-pc/linux_cmdline:
  grub-pc/chainload_from_menu.lst: true
  grub-pc/install_devices:





More information about the Pkg-grub-devel mailing list