Skip to contentSkip to conversation

Enable all events for initramfs

PATCH In review Hannes Reinecke 3 participants 4 messages Jul 13, 2004 – Jul 15, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Enable all events for initramfs

Hi all,

currently most driver events are not sent out when using initramfs as driver_init() (which triggers the events) is called before init_workqueues.

This patch rearranges the init calls so that the hotplug event queue is enabled prior to calling driver_init(), hence we're getting all hotplug events again.

Patch is relative to 2.6.7-mm6, but should apply to 2.6.8-rc1 also.

Please apply.

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke			[email protected]
SuSE Linux AG				S390 & zSeries
Maxfeldstraße 5				+49 911 74053 688
90409 Nürnberg				http://www.suse.de
init/main.c renamed from init/main.c.orig +5 -1
@@ -93,6 +93,7 @@
 extern void populate_rootfs(void);
 extern void driver_init(void);
 extern void prepare_namespace(void);
+extern void usermodehelper_init(void);
 
 #ifdef CONFIG_TC
 extern void tc_init(void);
@@ -599,6 +600,10 @@
  */
 static void __init do_basic_setup(void)
 {
+	/* drivers will send hotplug events */
+	init_workqueues();
+	usermodehelper_init();
+
 	driver_init();
 
 #ifdef CONFIG_SYSCTL
@@ -608,7 +613,6 @@
 	/* Networking initialization needs a process context */ 
 	sock_init();
 
-	init_workqueues();
 	do_initcalls();
 }
 
kernel/kmod.c renamed from kernel/kmod.c.orig +1 -3
@@ -272,10 +272,8 @@
 }
 EXPORT_SYMBOL(call_usermodehelper);
 
-static __init int usermodehelper_init(void)
+void __init usermodehelper_init(void)
 {
 	khelper_wq = create_singlethread_workqueue("khelper");
 	BUG_ON(!khelper_wq);
-	return 0;
 }
-core_initcall(usermodehelper_init);
#1 lore raw
Quoted 5 lines · Hannes Reinecke

Hi all,

currently most driver events are not sent out when using initramfs as driver_init() (which triggers the events) is called before init_workqueues.

Quoted 7 lines

This patch rearranges the init calls so that the hotplug event queue is enabled prior to calling driver_init(), hence we're getting all hotplug events again.

Patch is relative to 2.6.7-mm6, but should apply to 2.6.8-rc1 also.

Please apply.

This is probably a very good news.

I see the following application of it. Since no hotplug events are dropped any more, the initramfs could save their type and environment in files on a ramfs, and then remount that ramfs to some location accessible by the main system. The information accumulated in these files can be used for re-synthesis of events not handled because e.g. /usr was not mounted.

This means that we can drop the udevstart program and *.rc files that come with the hotplug package and replace them by playback of such recorded events. This looks much cleaner, since right now the reconstruction is imperfect.

I will try to implement this approach (i.e, create initramfs and modify the hotplug and udev packages) during this week on a copy of Linux From Scratch 20040702, and report the results here.

Signature · 13 lines
Alexander E. Patrakov



-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#2 lore raw
In reply to Hannes Reinecke
Quoted 6 lines · Alexander E. Patrakov

I see the following application of it. Since no hotplug events are dropped any more, the initramfs could save their type and environment in files on a ramfs, and then remount that ramfs to some location accessible by the main system. The information accumulated in these files can be used for re-synthesis of events not handled because e.g. /usr was not mounted.

The info as already in sysfs. See how udevstart regenerates each relevant event.
The whole point of handling these events on the fly is speed. No need to run udevstart anymore. But you better not drop udevstart. It will rebuild /dev/ if you toasted its content.
And a hotplug package is really broken if it relies on stuff in /usr

Signature · 14 lines
USB is for mice, FireWire is for men!

sUse lINUX ag, nÜRNBERG


-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#3 lore raw
In reply to Hannes Reinecke
Quoted 8 lines · Alexander E. Patrakov
Quoted 6 lines · Hannes Reinecke

Hi all,

currently most driver events are not sent out when using initramfs as driver_init() (which triggers the events) is called before init_workqueues.

Quoted 8 lines
Quoted 7 lines

This patch rearranges the init calls so that the hotplug event queue is enabled prior to calling driver_init(), hence we're getting all hotplug events again.

Patch is relative to 2.6.7-mm6, but should apply to 2.6.8-rc1 also.

Please apply.

LFS-ers: get it from http://lkml.org/lkml/diff/2004/7/13/74/1

Quoted 9 lines

This is probably a very good news.

I see the following application of it. Since no hotplug events are dropped any more, the initramfs could save their type and environment in files on a ramfs, and then remount that ramfs to some location accessible by the main system. The information accumulated in these files can be used for re-synthesis of events not handled because e.g. /usr was not mounted.

It appeared to be easier to just make /sbin/hotplug processes in initramfs sleep until they can call /sbin/hotplug on the real root.

Quoted 9 lines

This means that we can drop the udevstart program and *.rc files that come with the hotplug package and replace them by playback of such recorded events. This looks much cleaner, since right now the reconstruction is imperfect.

I will try to implement this approach (i.e, create initramfs and modify the hotplug and udev packages) during this week on a copy of Linux From Scratch 20040702, and report the results here.

Done.

The initramfs image (busybox-based) is available at:

http://ums.physics.usu.ru/~patrakov/initramfs_data.cpio.gz

md5sum: 69f5b834526b4ce918887c2f7a4067a6

This has been tested on my computer with LFS SVN-20040702 and LFS-bootscripts 20040704 with the following changes:

1) The mountkernfs, udev, checkfs and hotplug initscripts should be disabled or removed. Removal of checkfs is because of (3) below, other initscripts are not needed because my initramfs does their jobs. For those not familiar with LFS, the "mountkernfs" initscript mounts /proc and /sys, the "udev" initscript mounts ramfs on /dev and then runs udevstart and creates some extra nodes, "checkfs" runs fsck, "hotplug" is a pretty much original initscript that comes with the hotplug package that should be well-known here :)

2) The LFS-specific change of the kmod.c file should be dropped

3) The use of a journaled filesystem (e.g. ext3) mounted rw at boot is a must. /sbin/hotplug may mishandle hotplug events on read-only root.

4) The /proc, /sys and /proc/bus/usb entries in /etc/fstab should be marked as "noauto"

5) The following line should be added to /etc/modprobe.conf:

install usbcore /sbin/modprobe -i usbcore ; mount /proc/bus/usb

(usbcore must be a module, or a modification of /init is needed)

Results: all my devices are in /dev, all modules for my hardware are loaded due to early hotplug events delivered to /sbin/hotplug without any loss.

Caveats:

1) a kernel bogusly complains about runaway modprobe loop net-pf-1. This is really not a loop, just imagine that 200 "udevd" behemots simultaneously try to create a socket :( Don't compile af-unix as a module.

2) The loop that waits for all hotplug processes to go away doesn't seem to work. As a result, a bug involving a race between hotplug and e.g.
swapon is likely to exist.

Signature · 12 lines
Alexander E. Patrakov


-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_idG21&alloc_id040&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel