From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kay Sievers Date: Mon, 03 Oct 2005 12:21:30 +0000 Subject: Re: [RFC] coldplug - emit hotplug events from sysfs Message-Id: <20051003122130.GA10321@vrfy.org> List-Id: References: <20051001124943.GA26076@vrfy.org> In-Reply-To: <20051001124943.GA26076@vrfy.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-hotplug@vger.kernel.org On Mon, Oct 03, 2005 at 12:29:03PM +0200, Olivier Blin wrote: > Kay Sievers writes: > > > Here is another approach to address the coldplug problem. After playing > > around with "udevsythesize" it felt stupid to try to compose all the events > > from sysfs values which will never be exactly the same as the kernel > > event. > > This patch adds a "uevent" file to all class/block/bus-devices. Writing to > > this file, will just emit the hotplug event from the kernel again. udevstart > > and all the coldplug logic can be 3 lines of shell-script now. Boots fine > > and is _very_ fast on my box. > > > > What do you think? > > It looks really nice, but will we still be able to differientate > coldplug events in udev rules? > For example, in Mandriva, we do PCI coldplug for USB controllers only, > because we handle other stuff (sound, network, ...) later in > services. We used to rely on UDEV_START in udev rules. Not with this simple patch. It would be possible by adding an additional parameter to kobject_hotplug() to add an aditional key. Or we could use a different ACTION value and map it with udev... But unlike udevstart/udevsynthesize, you have complete control which events are generated, cause you will do it from a shell script and not with a binary. Wouldn't it work, to just trigger the events for the usb controllers and and leave the others alone? To play with it, I use this stupid hack in an early init-script and it works without udevstart or any other coldplug logic. After mounting tmpfs, creating /dev/null, disabling /sbin/hotplug and starting udevd, it creates the tty devices, waits for the events to finish, then sends out all remaining events to finish asynchronously: ... # regenerate events by triggering sysfs for i in /sys/class/t*/*/uevent; do echo 1 > $i; done # wait for async tty events to finish while [ $(cat /proc/*/status 2> /dev/null | grep -c -E '^Name:.udevd?$') -gt 1 ]; do sleep 0.1 done for i in /sys/class/[!t]*/*/uevent; do echo 1 > $i; done for i in /sys/block/*/uevent; do echo 1 > $i; done for i in /sys/block/*/*[1-9]/uevent; do echo 1 > $i; done for i in /sys/bus/*/devices/*/uevent; do echo 1 > $i; done ... To make this reliable, we would need to trigger some events in a defined order, like the device mapper events after the block device events and similar, and may need some checkpoints to make sure that certain devices are available at a specific point... Anyway, it works on two of my boxes and is the fastest udev/coldplug bootup, I've ever seen. :) Thanks, Kay ------------------------------------------------------- This SF.Net email is sponsored by: Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel