Skip to contentSkip to conversation

udev is too slow creating devices

DISCUSSION Ihar 'Philips' Filipau 10 participants 29 messages Sep 18, 2004 – Sep 29, 2004

lore
Share & tools
lore
#0 lore raw
Quoted 6 lines

That will be soon going away with my multi-threaded device discovery work. And I run pci hotplug boxes (and so do all of the PCMCIA/CardBus users), so don't discard PCI from being a async bus type :)

Async is now the norm, and drivers like the microcode module are the exception.

I wanted you to say that.

That's wrong attitude. I'm working on workstation where 95% of
hardware plugged 100% of time. That's not exception. Not eerything is hot-pluggable USB/FireWire/whatever.

Event-based hot-plug scripts are great thing. As an implementation.
But user cares about one thing: 'modprobe usb-storage; mount /whatever' working reliably.

/etc/dev.d probably great thing - but I'm not going to implement FSM
into every shell script which does modprobe for sake being Ok with dynamic /dev/.

You need to change your attitude for first. For second - come up with
a way for user space to block until device is here, and if it is not here/error detected - fail.

As it was said before - /all/ we need, is to be able to tell
discovery phase from idle state of driver. "/All/" is quite much here - but it must be a goal.

I'm absolutely sure, that for PCI devices it is implementable quite
easy - probing is already done outside of modules. And we know precisely are we Ok, or are we not. And we know when we are done. If it is not so for USB yet - then it is bug which must be fixed.

#1 lore raw
Quoted 4 lines · On Sat, 18 Sep 2004 21:44:03 +0200 Ihar 'Philips' Filipau <[email protected]>…

That's wrong attitude. I'm working on workstation where 95% of
hardware plugged 100% of time. That's not exception. Not eerything is hot-pluggable USB/FireWire/whatever.

Even PCI devices are "attached" to the kernel at bootup. From an abstracted POV they are plugged in.

Quoted 4 lines

Event-based hot-plug scripts are great thing. As an implementation.
But user cares about one thing: 'modprobe usb-storage; mount /whatever' working reliably.

That's actually something the user doesn't want to be bothered with. modprobe is done automatically when the device is plugged in. Mounting is done automatically when udev signals the script in dev.d (or your desktop environment via D-BUS). This is what users care about.
Even uber-geeks don't enjoy unnecessary work.

Quoted 4 lines

/etc/dev.d probably great thing - but I'm not going to implement FSM
into every shell script which does modprobe for sake being Ok with dynamic /dev/.

Why not switch completely. Of course, there still is Kernel 2.4, but there is little reason not to use udev on 2.6. We all know that open source is about choice, but his may well mean that more work is needed (ie. two versions of an init script)

Quoted 5 lines

You need to change your attitude for first. For second - come up with

a way for user space to block until device is here, and if it is not here/error detected - fail.

Already done. All userspace nees to do is wait in /etc/dev.d. The only issue is error handling, but after some consideration I have to admit, that this is not different than before.
In a situation where modprobe failed before, it will still do so. In a situation where modprobe succeeded, but later phases failed (like partition detection), the situation isn't any worse with udev. Instead of a non-working device node and an error in dmesg you now get no device node and an error in dmesg. Checking for such a condition is equally hard in both cases.

Quoted 4 lines

As it was said before - /all/ we need, is to be able to tell
discovery phase from idle state of driver. "/All/" is quite much here - but it must be a goal.

Why? You couln't do so from userspace before, and there is little reason to do so. Or am I missing something?

Quoted 4 lines

I'm absolutely sure, that for PCI devices it is implementable quite
easy - probing is already done outside of modules. And we know precisely are we Ok, or are we not. And we know when we are done.

Not really. modprobe may return sucessfully, but the hardware still might fail to work - either silently or with error messages in kernel log. All you really can rely on is that the module has been loaded. Nothin changes with udev.

Regards

#2 lore raw
In reply to Ihar 'Philips' Filipau
Quoted 4 lines · Ihar 'Philips' Filipau
Quoted 4 lines

That will be soon going away with my multi-threaded device discovery work. And I run pci hotplug boxes (and so do all of the PCMCIA/CardBus users), so don't discard PCI from being a async bus type :)

Quoted 8 lines
Quoted 2 lines

Async is now the norm, and drivers like the microcode module are the exception.

I wanted you to say that.

That's wrong attitude. I'm working on workstation where 95% of
hardware plugged 100% of time. That's not exception. Not eerything is hot-pluggable USB/FireWire/whatever.

Do you have PCI devices? pnp-isa devices? Ok, those all are "hotpluggable" as far as the kernel is concerned. They are loaded on demand by userspace when the kernel sees the device.

If not, what kind of devices do you have? The only place the "on-demand" loading of modules doesn't work is for embedded systems that have no way of discovering their devices, and need to be hardcoded in the kernel. But people are working on that :)

Quoted 3 lines

Event-based hot-plug scripts are great thing. As an implementation.
But user cares about one thing: 'modprobe usb-storage; mount /whatever' working reliably.

No, they want to plug in their device and have the proper module automatically loaded, and then the device mounted and the icon show up on their desktop all automatically. With hotplug and its helpers (udev, /etc/dev.d/ and HAL) this all works just fine today.

Quoted 3 lines

/etc/dev.d probably great thing - but I'm not going to implement FSM
into every shell script which does modprobe for sake being Ok with dynamic /dev/.

Fine, I'm not forcing you to do anything you don't want to do. It sounds like you like polling for your device nodes. Great, live with that, it is one way to do this :)

Quoted 1 line

You need to change your attitude for first.

Change it to what? A combative one? Gladly :)

Quoted 2 lines

For second - come up with a way for user space to block until device is here, and if it is not here/error detected - fail.

Please explain (with code) how to do that for something as "simple" as the usb-storage driver. Then we can continue this discussion.

Quoted 3 lines

As it was said before - /all/ we need, is to be able to tell
discovery phase from idle state of driver. "/All/" is quite much here - but it must be a goal.

Wrong. Our goal is to make Linux "just work". And that is what is happening today. This "wait for modprobe" stuff helps no one.

Quoted 4 lines

I'm absolutely sure, that for PCI devices it is implementable quite
easy - probing is already done outside of modules. And we know precisely are we Ok, or are we not. And we know when we are done. If it is not so for USB yet - then it is bug which must be fixed.

PCI and USB both use the same probe core code. So it works the same :)

You think you are grumpy now, just wait till I add threads to the probe code...

thanks,

greg k-h

#3 lore raw

Well, I got your point.
I promise I will not use udev ;-)

For last embedded system where I have had external usb storage used
for firmware upgrade, I used preloading of usb-storage - and everything worked well. Seems it worked better than udev will ever worked - with 0 user space calls and immediate accessibility of /dev/sda ;-)))

I will not try to argue, it is rather pointless for me at moment,
being unemployed and far from any of my systems.

P.S. Funny diversion from OpenBSD thinking. OpenBSD intentionally do not support loadale modules, to prevent _any_ user space attempt to modify running kernel.

P.P.S. Another day, I hope, you will understand that right system need to provide people with two opposite ways of doing things. Sometimes it is advantage to be event-based and asynchronous, sometimes it is very convient to be dumb & synchronous. This two options are not mutually exclusive. I/O subsystem does both ways: you can be dumb and synchronous with read() (as most applications do - regardless of actual I/O being event-driven), or asynchronous with aio_* stuff (sacrificing simplicity of application). Giving a choice is right way to go.

Quoted 66 lines · Greg KH
Quoted 11 lines · Ihar 'Philips' Filipau
Quoted 6 lines

That will be soon going away with my multi-threaded device discovery work. And I run pci hotplug boxes (and so do all of the PCMCIA/CardBus users), so don't discard PCI from being a async bus type :)

Async is now the norm, and drivers like the microcode module are the exception.

I wanted you to say that.

That's wrong attitude. I'm working on workstation where 95% of
hardware plugged 100% of time. That's not exception. Not eerything is hot-pluggable USB/FireWire/whatever.

Do you have PCI devices? pnp-isa devices? Ok, those all are "hotpluggable" as far as the kernel is concerned. They are loaded on demand by userspace when the kernel sees the device.

If not, what kind of devices do you have? The only place the "on-demand" loading of modules doesn't work is for embedded systems that have no way of discovering their devices, and need to be hardcoded in the kernel. But people are working on that :)

Quoted 2 lines

Event-based hot-plug scripts are great thing. As an implementation.
But user cares about one thing: 'modprobe usb-storage; mount /whatever' working reliably.

No, they want to plug in their device and have the proper module automatically loaded, and then the device mounted and the icon show up on their desktop all automatically. With hotplug and its helpers (udev, /etc/dev.d/ and HAL) this all works just fine today.

Quoted 2 lines

/etc/dev.d probably great thing - but I'm not going to implement FSM
into every shell script which does modprobe for sake being Ok with dynamic /dev/.

Fine, I'm not forcing you to do anything you don't want to do. It sounds like you like polling for your device nodes. Great, live with that, it is one way to do this :)

Quoted 1 line

You need to change your attitude for first.

Change it to what? A combative one? Gladly :)

Quoted 2 lines

For second - come up with a way for user space to block until device is here, and if it is not here/error detected - fail.

Please explain (with code) how to do that for something as "simple" as the usb-storage driver. Then we can continue this discussion.

Quoted 2 lines

As it was said before - /all/ we need, is to be able to tell
discovery phase from idle state of driver. "/All/" is quite much here - but it must be a goal.

Wrong. Our goal is to make Linux "just work". And that is what is happening today. This "wait for modprobe" stuff helps no one.

Quoted 9 lines
Quoted 2 lines

I'm absolutely sure, that for PCI devices it is implementable quite
easy - probing is already done outside of modules. And we know precisely are we Ok, or are we not. And we know when we are done. If it is not so for USB yet - then it is bug which must be fixed.

PCI and USB both use the same probe core code. So it works the same :)

You think you are grumpy now, just wait till I add threads to the probe code...

If you are not yet threaded - so that must be done.

#4 lore raw
Quoted 3 lines · Ihar 'Philips' Filipau

Well, I got your point.
I promise I will not use udev ;-)

Heh.

Quoted 4 lines

For last embedded system where I have had external usb storage used
for firmware upgrade, I used preloading of usb-storage - and everything worked well. Seems it worked better than udev will ever worked - with 0 user space calls and immediate accessibility of /dev/sda ;-)))

Great, that works for you. But what about when you have a slow usb hub that the device is plugged into. It will take a while for the USB core to recognize that device and set everything up properly (and who's to say it will be called /dev/sda anyway?).

Quoted 4 lines

P.P.S. Another day, I hope, you will understand that right system need to provide people with two opposite ways of doing things. Sometimes it is advantage to be event-based and asynchronous, sometimes it is very convient to be dumb & synchronous.

My point is we _can not_ be dumb and synchronous in this situation. It just will not work with busses that have devices that can come and go as the system is running. It is pretty much impossible to correctly do what you are proposing. Just think about the different situations that we have to handle properly.

thanks,

greg k-h

#5 lore raw
Quoted 9 lines · Greg KH
Quoted 2 lines

P.P.S. Another day, I hope, you will understand that right system need to provide people with two opposite ways of doing things. Sometimes it is advantage to be event-based and asynchronous, sometimes it is very convient to be dumb & synchronous.

My point is we _can not_ be dumb and synchronous in this situation. It just will not work with busses that have devices that can come and go as the system is running. It is pretty much impossible to correctly do what you are proposing. Just think about the different situations that we have to handle properly.

Example? Your "we can not" sounds like "we not capable enough to
implement."

I thought that discovery deterministic process. What I'm missing?

For now, You haven't gave any example besides "slow USB hub" - but
this is rather example which supports me: you are not going to put /variable/ delays into init scripts? aren't you?

Here we definitely need to hide asynchronousity of process -
handling this volatility in user space will never work reliably.

P.S. You do not need to reply, it seems like case of init scripts is not interesting for you. What is for me about 90% of work I usually do preparing new system. Number-wise, most of devices attached to system, initialized by init scripts - and you just dumbly avoid answering that. You have to modprobe/insmod harddrive & filesystem to be able run your udev, after all. Think about it. And people have had problems with discovery - one of the patches for usb-storage root fs is adding a delay and retries for root fs mounting. Moving problem around is easier than solving it, that's true.

#6 lore raw
Quoted 14 lines · Ihar 'Philips' Filipau
Quoted 6 lines · Greg KH
Quoted 5 lines

P.P.S. Another day, I hope, you will understand that right system need to provide people with two opposite ways of doing things. Sometimes it is advantage to be event-based and asynchronous, sometimes it is very convient to be dumb & synchronous.

Quoted 6 lines

My point is we _can not_ be dumb and synchronous in this situation. It just will not work with busses that have devices that can come and go as the system is running. It is pretty much impossible to correctly do what you are proposing. Just think about the different situations that we have to handle properly.

Quoted 2 lines

Example? Your "we can not" sounds like "we not capable enough to
implement."

Ok, you've found me out. I'm too dumb to solve this problem, sorry. So please send me your patch to implement this and we will take it from there.

Quoted 1 line

I thought that discovery deterministic process. What I'm missing?

Hahaha, no way is it "deterministic"...

Quoted 3 lines

For now, You haven't gave any example besides "slow USB hub" - but
this is rather example which supports me: you are not going to put /variable/ delays into init scripts? aren't you?

Not at all. Again, for the last time, use /etc/dev.d to handle such issues. That will work if the device is found during system init time (when the init scripts are running) or later when the system has been running for 42 days and a new device is plugged in.

Quoted 5 lines

Here we definitely need to hide asynchronousity of process -
handling this volatility in user space will never work reliably.

P.S. You do not need to reply, it seems like case of init scripts is not interesting for you.

It is very interesting for me. Hence my /sbin/hotplug and udev and /etc/dev.d development effort to solve real problems that users have reported needing solved.

Quoted 3 lines

What is for me about 90% of work I usually do
preparing new system. Number-wise, most of devices attached to system, initialized by init scripts - and you just dumbly avoid answering that.

I must be missing some work that I need to do to my systems when I prepare a new one. For some reason I don't spend any time, other than deciding on where to mount a specific device that might possibly be plugged in some time in the future.

Quoted 2 lines

You have to modprobe/insmod harddrive & filesystem to be able run your udev, after all.

Sure, that's what initramfs/initrd is for. See the Gentoo and SuSE boot processes for examples of how to add udev and modprobe together to get a working system for a huge range of different platforms.

Quoted 4 lines

Think about it. And people have had problems with discovery - one of the patches for usb-storage root fs is adding a delay and retries for root fs mounting. Moving problem around is easier than solving it, that's true.

Yes, the usb-storage root issue is a problem. Delaying for it is one simple solution, I don't really have another one at the moment as I haven't spent any time trying to get it to work (much to some people's grumblings at me, but I don't have a box with a BIOS that can boot from a USB device...)

After root is mounted is the real issue, which /etc/dev.d solves.

Good luck,

greg k-h

#7 lore raw
In reply to Ihar 'Philips' Filipau
Quoted 5 lines

You need to change your attitude for first. For second - come up with
a way for user space to block until device is here, and if it is not here/error detected - fail.

Quoted 8 lines

As it was said before - /all/ we need, is to be able to tell
discovery phase from idle state of driver. "/All/" is quite much here - but it must be a goal.

I'm absolutely sure, that for PCI devices it is implementable quite
easy - probing is already done outside of modules. And we know precisely are we Ok, or are we not. And we know when we are done. If it is not so for USB yet - then it is bug which must be fixed.

Nope, Greg is right. Drivers themselves won't necessarily provide you with the device interface in a synchronous way after they are loaded, and some will certainly never. It is all an asynchronous process and there is simply no way to ask for any kind of enforced synchronicity here without major bloatage.

Ben.

#8 lore raw
Quoted 7 lines · Benjamin Herrenschmidt

Nope, Greg is right. Drivers themselves won't necessarily provide you with the device interface in a synchronous way after they are loaded, and some will certainly never. It is all an asynchronous process and there is simply no way to ask for any kind of enforced synchronicity here without major bloatage.

Okay, okay. Let's spread delays and polling all over numerous init
scripts.

You might be ten thousands time right. It is asynchronous process.

But please listen to me: you are not going to handle that in _every_
system application which deals with modules.

If there is problem, it doesn't mean we just pass it over. Probably
we need to solve it?

#9 lore raw
Quoted 10 lines · Ihar 'Philips' Filipau
Quoted 7 lines · Benjamin Herrenschmidt

Nope, Greg is right. Drivers themselves won't necessarily provide you with the device interface in a synchronous way after they are loaded, and some will certainly never. It is all an asynchronous process and there is simply no way to ask for any kind of enforced synchronicity here without major bloatage.

Quoted 2 lines

Okay, okay. Let's spread delays and polling all over numerous init
scripts.

I read it as "Let's bloat initscripts instead of the kernel". We probably have to bloat something, but we don't want to bloat our favourite kernel.

Maybe we should create a bash file with functions that implement it "the right way" and distribute this file with udev as an example?

Quoted 4 lines

You might be ten thousands time right. It is asynchronous process.

But please listen to me: you are not going to handle that in _every_
system application which deals with modules.

We should probably avoid code duplication and put this functionality into a library (maybe even glibc?)

What we currently see is that distros either ignore the race or (like LFS) say something like:

"Because of all those compilcations with Hotplug, Udev and modules, we strongly recommend you to start with a completely non-modular kernel configuration, especially if this is the first time you use Udev."

Signature · 1 line
Alexander E. Patrakov
#10 lore raw
Quoted 3 lines · Alexander E. Patrakov

What we currently see is that distros either ignore the race or (like LFS) say something like:

I don't see distros ignoring the race issues. Look at Gentoo's init scripts, it handles this properly (if not, please let me know.)

Quoted 3 lines

"Because of all those compilcations with Hotplug, Udev and modules, we strongly recommend you to start with a completely non-modular kernel configuration, especially if this is the first time you use Udev."

Heh, no, you'll have the same "issues" with a static kernel and no modules. Your devices will not get found any faster :)

thanks,

greg k-h

#11 lore raw

Hi,

I am fascinated about udev and others, but have some questions.

Quoted 7 lines · Greg KH
Quoted 3 lines · Alexander E. Patrakov

What we currently see is that distros either ignore the race or (like LFS) say something like:

I don't see distros ignoring the race issues. Look at Gentoo's init scripts, it handles this properly (if not, please let me know.)

I have Gentoo with udev (with 100% modular kernel). And I have speedtouch USB ADSL modem. I am using paralell startup scripts feature. And speedtouch tries to initialize itself (load firmware and so on) before USB bus (or how to call it) is discovered. I can imagine moving firmware loader to udev.d scripts but where should I place pppd launching (for example I might have pppd or ifconfig binary on nfs mounted /usr from my LAN...).

I understand that for messages like "xxx was just plugged in" there is (masked) HAL and DBUS. But don't we need something where we can check if particular part of the system (not only device but also removable media or filesystem mount or some daemon) was initialized (or is currently plugged and initialized) or not? And we should be able to locate device file or mount point or controll socket of this part of the system... And don't we need some multi-event script launcher: "Launch this when xxx was plugged and initialized but not before yyy was initialized"? Gentoo has dependency-based startup scripts but dependiencies are resolved statically not dynamically... There should be also some inteligent way to shut down device _and_ all things that depend on it when device is unplugged and then reinitialize _everything_ when device is plugged back... Not only device itself as it is in udev.d. Script in udev.d should not know about services that depend on this device and services that depend on these services...

And how udev, hotlpug and the rest of the system should hadle SATA disk unpluggged in the middle of writing? And what if it will be plugged back?

Thanks,

Grzegorz Kulewski

#12 lore raw
Quoted 4 lines · Grzegorz Kulewski

I have Gentoo with udev (with 100% modular kernel). And I have speedtouch USB ADSL modem. I am using paralell startup scripts feature. And speedtouch tries to initialize itself (load firmware and so on) before USB bus (or how to call it) is discovered.

That's not good.

Quoted 3 lines

I can imagine moving firmware loader to udev.d scripts but where should I place pppd launching (for example I might have pppd or ifconfig binary on nfs mounted /usr from my LAN...).

The firmware downloader should be in the usb hotplug agent notifier location. See the linux-hotplug documentation for how to do this properly (I thought the speedtouch driver package already did this properly for some reason...)

Use the network scripts to start up the connection when it is seen by the system. Gentoo currently does this already today.

Quoted 2 lines

And how udev, hotlpug and the rest of the system should hadle SATA disk unpluggged in the middle of writing? And what if it will be plugged back?

udev will delete the device node. As for your data the user is screwed as they did something very stupid :)

Plug the device back in, and it gets discovered, device node gets created, and then mounted. That is if your SATA kernel driver supports hotpluggable disks.

thanks,

greg k-h

#13 lore raw
Quoted 10 lines · Greg KH
Quoted 3 lines · Grzegorz Kulewski

I can imagine moving firmware loader to udev.d scripts but where should I place pppd launching (for example I might have pppd or ifconfig binary on nfs mounted /usr from my LAN...).

The firmware downloader should be in the usb hotplug agent notifier location. See the linux-hotplug documentation for how to do this properly (I thought the speedtouch driver package already did this properly for some reason...)

I set this up on a Debian box quite a while ago, before the packaged stuff, but it's trivial to implement this in the hotplug scripts and works fine - simply do a "pppd call adsl" after you've had the firmware loader squirt down the firmware. The issue here is "what if I have a weird setup where at init time the device is found but the firmware loader or pppd are not available then" - well in that case I'd argue that the system is broken because you can't expect something to be available at init if you don't help it to be so.

Sticking pppd on an NFS volume in the original example is overly contrived and unlikely - it'd be like me sticking fsck on an unmounted NFS volume and expecting to be able to write some reasonbly generic and portable initscripts. Let's have cool stuff like udev - but let's also have some limits with potential startup headaches by having some utilities fixed.

Cheers,

Jon.

Quoted 24 lines

Use the network scripts to start up the connection when it is seen by the system. Gentoo currently does this already today.

Quoted 2 lines

And how udev, hotlpug and the rest of the system should hadle SATA disk unpluggged in the middle of writing? And what if it will be plugged back?

udev will delete the device node. As for your data the user is screwed as they did something very stupid :)

Plug the device back in, and it gets discovered, device node gets created, and then mounted. That is if your SATA kernel driver supports hotpluggable disks.

thanks,

greg k-h

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#14 lore raw
In reply to Ihar 'Philips' Filipau
Quoted 2 lines · On Sun, 19 Sep 2004 10:27:34 +0200 Ihar 'Philips' Filipau <[email protected]>…

Okay, okay. Let's spread delays and polling all over numerous init
scripts.

Just use /etc/dev.d. No delays, no polling. Everything is event based.

Quoted 5 lines

You might be ten thousands time right. It is asynchronous process.

But please listen to me: you are not going to handle that in _every_
system application which deals with modules.

It would not be necessary if the module provides some pseudo-device without device nodes and loading will *always* succeed.
If this is not the case (ie. always), your script is even unsuitable for a static /dev.
(I know that many scripts make that assumption, including my own. Nevertheless it is wrong, and has always been wrong.)

Quoted 3 lines

If there is problem, it doesn't mean we just pass it over. Probably
we need to solve it?

How do you want to solve it? We cannot look into the future, so how should we know which device nodes "modprobe xyz" will or should create? dev.d is a nice solution. If any device node is created, your script is called. If it is the node you want, you perform your actions.

Regards

#15 lore raw
Quoted 9 lines · Marc Ballarin
Quoted 3 lines

If there is problem, it doesn't mean we just pass it over. Probably
we need to solve it?

How do you want to solve it? We cannot look into the future, so how should we know which device nodes "modprobe xyz" will or should create? dev.d is a nice solution. If any device node is created, your script is called. If it is the node you want, you perform your actions.

Well, can then anyone explain by which mean (black magic?) kernel
mounts root file system? block device might appear any time, file system might take ages to load.

Hu? How is init/do_mounts.c still works then? Or it is needs to be
fixed with messages a-la "root file system will be available shortly, we do hope" and "please plug in again your hard-wired IDE drive"?

People, you must learn doing abstractions carefully. If device is
hard-wired - user *will* expect (as kernel itself does) that it is available all the time after modprobe'ing driver.

#16 lore raw
Quoted 4 lines · On Sun, 19 Sep 2004 16:25:51 +0200 Ihar 'Philips' Filipau <[email protected]>…

Well, can then anyone explain by which mean (black magic?) kernel
mounts root file system? block device might appear any time, file system might take ages to load.

The kernel doesn't use /dev.
Why do you think mounting the root device is such a "frail" process? The kernel blindly ties all known filesystem on the specified device. If the user specifies a wrong root device, or the device is broken or the filesystem corrupted or unknown the kernel will panic.
The reason this is so is, that nothing else can be done. Userspace, however, has more possibilities.

Quoted 4 lines

People, you must learn doing abstractions carefully. If device is
hard-wired - user *will* expect (as kernel itself does) that it is available all the time after modprobe'ing driver.

It is available as long as the device node is present. udev tells you (in dev.d) when this is the case. If the device is hardwired (from a user's point of view) the device node will be created early dring boot-up. If this happens, udev will notify the scripts in dev.d.

Instead of:
modprobe ide-cd && mount /dev/hdc /mnt/cdrom
in /etc/init.d/your-script

you would now do:
if [ ACTION="add" ] && [ DEVNAME="/dev/hdc" ]; then
mount /dev/hdc /mnt/cdrom
fi
in /etc/dev.d/default/your-script.dev

This is even more reliable than the first solution on a static /dev, since loading the driver might fail at any point *after* modprobe returns.
For example, modprobe ide-cd will succeed even when no CD-ROMs are present. The old script would break in this case, the new one wouldn't be called at all.

Error reporting is very difficult. How should the kernel know what the driver is supposed to do?
Obvious errors likes Oopses or I/O errors *could* be reported by hotplug. (ACTION="error", DEVNAME="module-name" ???)
Anything else is impossible.

You just have to adopt your approach to device handling. Currently you *assume* that after a succesfull modprobe the device nodes are available (this was never true, however).
With hotplug/udev you *know* that the device node is available when your script in dev.d is called with the appropriate environment variables.

Regards

#17 lore raw
Quoted 10 lines · Marc Ballarin
Quoted 3 lines · On Sun, 19 Sep 2004 16:25:51 +0200 Ihar 'Philips' Filipau <[email protected]>…

Well, can then anyone explain by which mean (black magic?) kernel
mounts root file system? block device might appear any time, file system might take ages to load.

The kernel doesn't use /dev.

It creates a temporary device node in its rootfs. It does so by looking into sysfs for major and minor numbers. So the question is whether the information is in sysfs at the moment when the kernel requests it.

Quoted 1 line

Why do you think mounting the root device is such a "frail" process?

Because of your own words below that "loading the driver might fail at any point *after* modprobe returns" (read: after module_init() finishes).

Quoted 1 line

The kernel blindly ties all known filesystem on the specified device.

yes, if it exists

Quoted 4 lines

If the user specifies a wrong root device, or the device is broken or the filesystem corrupted or unknown the kernel will panic.
The reason this is so is, that nothing else can be done. Userspace, however, has more possibilities.

OK. The fact is that, when mounting the root filesystem, the kernel can (?) definitely say "there is no such device, and it's useless to wait for it--so I panic". Is it possible to duplicate this logic in the case with udev and modprobe? If so, it should be built into a common place (either the kernel or into modprobe), but not into all apps.

Quoted 16 lines

Instead of:
modprobe ide-cd && mount /dev/hdc /mnt/cdrom
in /etc/init.d/your-script

you would now do:
if [ ACTION="add" ] && [ DEVNAME="/dev/hdc" ]; then
mount /dev/hdc /mnt/cdrom
fi
in /etc/dev.d/default/your-script.dev

This is even more reliable than the first solution on a static /dev, since loading the driver might fail at any point *after* modprobe returns.
For example, modprobe ide-cd will succeed even when no CD-ROMs are present. The old script would break in this case, the new one wouldn't be called at all.

<snip>

Quoted 3 lines

You just have to adopt your approach to device handling. Currently you *assume* that after a succesfull modprobe the device nodes are available (this was never true, however).

Then the "char-major" aliases were always broken, do I understand correctly? Once we realize that, isn't it the time to mark the "Automatic kernel module loading" in the kernel configuration as BROKEN or OBSOLETE?

Quoted 2 lines

With hotplug/udev you *know* that the device node is available when your script in dev.d is called with the appropriate environment variables.

Yes. Now we have a lot of short scriptlets under /etc/dev.d. But I don't yet see how these scriptlets interact with each other.

Signature · 1 line
Alexander E. Patrakov
#18 lore raw
Quoted 6 lines · On Sun, 19 Sep 2004 22:00:52 +0600 "Alexander E. Patrakov"…

OK. The fact is that, when mounting the root filesystem, the kernel can (?) definitely say "there is no such device, and it's useless to wait for it--so I panic". Is it possible to duplicate this logic in the case with udev and modprobe? If so, it should be built into a common place (either the kernel or into modprobe), but not into all apps.

Well, once the system is running, the device might appear any time, so waiting is hardly useless then.

In the past you did modprobe and afterwards tried to access the device. If this succeeded, the device was created successfully, if not, something went wrong, and your script returned an error code.
This approach has some problems.
The device is plugged in later on: "su" to root, re-run script. Not nice. The script doesn't check properly for later errors: something breaks.

Now, the device is either autodetected or - when this is not possible ("legacy" devices) you have to modprobe manually.
If this succeeds, you are informed in dev.d. If it fails you are "informed" by not being called in dev.d.

If I understand correctly, you wish do modprobe for a legacy device and then know if this succeeded completely.
Simply choose a state-file in /var and write something like "not detected" inside. Then do modprobe.
The other part of your script will wait in dev.d for the event. If it arrives, the script will change the state file to "found" and do its work. So, as long as the state is "not detected" you treat the device as not present - just as if your old, synchronous script had returned an error code. The advantage is, that if the device appears later on everything will work automatically.

Quoted 5 lines

Then the "char-major" aliases were always broken, do I understand correctly? Once we realize that, isn't it the time to mark the "Automatic kernel module loading" in the kernel configuration as BROKEN or OBSOLETE?

IIRC this feature is intended primarily for loadable kernel features and pseudo devices, not "real" device drivers.

Quoted 3 lines

Yes. Now we have a lot of short scriptlets under /etc/dev.d. But I don't yet see how these scriptlets interact with each other.

You could use some state file if hotplug messages aren't enough, as described above.

mfg

#19 lore raw
In reply to Alexander E. Patrakov
Quoted 6 lines · Alexander E. Patrakov

OK. The fact is that, when mounting the root filesystem, the kernel can (?) definitely say "there is no such device, and it's useless to wait for it--so I panic". Is it possible to duplicate this logic in the case with udev and modprobe? If so, it should be built into a common place (either the kernel or into modprobe), but not into all apps.

No, we need to just change the kernel to sit and spin for a while if the root partition is not found. This is the main problem right now for booting off of a USB device (or any other "slow" to discover device.) It's a known kernel issue, and there are patches for 2.4 for this, but no one has taken the time to update them for 2.6.

Quoted 2 lines

Then the "char-major" aliases were always broken, do I understand correctly?

Yes, for most drivers they are broken. Like sound, usb, and others.

Quoted 3 lines

Once we realize that, isn't it the time to mark the "Automatic kernel module loading" in the kernel configuration as BROKEN or OBSOLETE?

Fine with me, I've been wanting to do that for years. Are you willing to handle the fallout of such a patch though? :)

Quoted 5 lines
Quoted 2 lines

With hotplug/udev you *know* that the device node is available when your script in dev.d is called with the appropriate environment variables.

Yes. Now we have a lot of short scriptlets under /etc/dev.d. But I don't yet see how these scriptlets interact with each other.

What do you mean? What kind of relationship do you need explained about them?

thanks,

greg k-h

#20 lore raw
Quoted 15 lines · Greg KH
Quoted 1 line · Alexander E. Patrakov

OK. The fact is that, when mounting the root filesystem, the kernel can (?) definitely say "there is no such device, and it's useless to wait for it--so I panic". Is it possible to duplicate this logic in the case with udev and modprobe? If so, it should be built into a common place (either the kernel or into modprobe), but not into all apps.

No, we need to just change the kernel to sit and spin for a while if the root partition is not found. This is the main problem right now for booting off of a USB device (or any other "slow" to discover device.) It's a known kernel issue, and there are patches for 2.4 for this, but no one has taken the time to update them for 2.6.

Quoted 1 line

Then the "char-major" aliases were always broken, do I understand correctly?

Quoted 8 lines

Yes, for most drivers they are broken. Like sound, usb, and others.

Quoted 1 line

Once we realize that, isn't it the time to mark the "Automatic kernel module loading" in the kernel configuration as BROKEN or OBSOLETE?

Fine with me, I've been wanting to do that for years. Are you willing to handle the fallout of such a patch though? :)

Many thanks for detailed explanation. And, since char-major aliases don't work with udev anyway, and net-pf aliases are easy to enumerate and preload by parsing /lib/modules/uname -r/modules.alias, I think that udev users are ready to handle the fallout of this patch.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

With hotplug/udev you *know* that the device node is available when your script in dev.d is called with the appropriate environment variables.

Yes. Now we have a lot of short scriptlets under /etc/dev.d. But I don't yet see how these scriptlets interact with each other.

What do you mean? What kind of relationship do you need explained about them?

Implementation of various logical primitives. E.g., I use GPRS and want to start pppd during the boot process (i.e., an always-on link), but after the following things:

1) /dev/ttyS0 has been created
2) /dev/ppp has been created
3) modules for line disciplines and PPP compression have been preloaded (e.g. by grepping modules.alias for tty-ldisc and ppp-compress) and are ready for use by pppd
4) firewall rules have been applied

How to "AND" these things together in a /etc/dev.d scriptlet?

Signature · 1 line
Alexander E. Patrakov
#21 lore raw
Quoted 9 lines · Alexander E. Patrakov

Implementation of various logical primitives. E.g., I use GPRS and want to start pppd during the boot process (i.e., an always-on link), but after the following things:

1) /dev/ttyS0 has been created
2) /dev/ppp has been created
3) modules for line disciplines and PPP compression have been preloaded (e.g. by grepping modules.alias for tty-ldisc and ppp-compress) and are ready for use by pppd
4) firewall rules have been applied

How to "AND" these things together in a /etc/dev.d scriptlet?

and

5) /tmp is read-write
6) /var is mounted
7) log daemon is already running

but I think they can implemented with a waiting queue or other user-space implementation.
Hmm wait, we will miss the event between udev loaded and /var mounted and dev.d started!

ciao
cate

PS: I hope this discussion will start project of re-thinking the boot/init.d method.

#22 lore raw
In reply to Greg KH

On Sun, 19 Sep 2004 10:30:35 -0700 Greg KH wrote:

| On Sun, Sep 19, 2004 at 10:00:52PM +0600, Alexander E. Patrakov wrote:
| > 
| > OK. The fact is that, when mounting the root filesystem, the kernel can 
| > (?) definitely say "there is no such device, and it's useless to wait 
| > for it--so I panic". Is it possible to duplicate this logic in the case 
| > with udev and modprobe? If so, it should be built into a common place 
| > (either the kernel or into modprobe), but not into all apps.
| 
| No, we need to just change the kernel to sit and spin for a while if the
| root partition is not found.  This is the main problem right now for
| booting off of a USB device (or any other "slow" to discover device.)
| It's a known kernel issue, and there are patches for 2.4 for this, but
| no one has taken the time to update them for 2.6.

(I'm way behind, and I was hoping this thread would die, but:)

I've seen 2.6 patches for booting from USB or IEEE1394. Is there a fair chance of getting something for USB/1394 booting merged? (other than by using initrd)

I'd certainly like to see them merged.

[snip]

--
~Randy
MOTD: Always include version info.
(Again. Sometimes I think ln -s /usr/src/linux/.config .signature)

#23 lore raw
Quoted 16 lines · Randy.Dunlap

On Sun, 19 Sep 2004 10:30:35 -0700 Greg KH wrote:

| On Sun, Sep 19, 2004 at 10:00:52PM +0600, Alexander E. Patrakov wrote:
| > 
| > OK. The fact is that, when mounting the root filesystem, the kernel can 
| > (?) definitely say "there is no such device, and it's useless to wait 
| > for it--so I panic". Is it possible to duplicate this logic in the case 
| > with udev and modprobe? If so, it should be built into a common place 
| > (either the kernel or into modprobe), but not into all apps.
| 
| No, we need to just change the kernel to sit and spin for a while if the
| root partition is not found.  This is the main problem right now for
| booting off of a USB device (or any other "slow" to discover device.)
| It's a known kernel issue, and there are patches for 2.4 for this, but
| no one has taken the time to update them for 2.6.
Quoted 3 lines

(I'm way behind, and I was hoping this thread would die, but:)

I've seen 2.6 patches for booting from USB or IEEE1394.

Where?

Quoted 2 lines

Is there a fair chance of getting something for USB/1394 booting merged? (other than by using initrd)

I want to see this work, as lots of people bug me about this when I meet them with the comment, "Oh, you're the USB maintainer, how come I can't boot off of my USB flash key," which causes me to turn and run away very fast...

thanks,

greg k-h

#24 lore raw
In reply to Marc Ballarin
Quoted 10 lines · Marc Ballarin
Quoted 3 lines · On Sun, 19 Sep 2004 16:25:51 +0200 Ihar 'Philips' Filipau <[email protected]>…

Well, can then anyone explain by which mean (black magic?) kernel
mounts root file system? block device might appear any time, file system might take ages to load.

The kernel doesn't use /dev.

True. But udev together with new loadable modules model was
advertised as a /right/ replacement for devfs,

Quoted 7 lines

Why do you think mounting the root device is such a "frail" process? The kernel blindly ties all known filesystem on the specified device. If the user specifies a wrong root device, or the device is broken or the filesystem corrupted or unknown the kernel will panic.
The reason this is so is, that nothing else can be done. Userspace, however, has more possibilities.

You are right - kernel doesn't know.
It is driver knows, It is user of driver who does know it too.

Quoted 14 lines
Quoted 3 lines

People, you must learn doing abstractions carefully. If device is
hard-wired - user *will* expect (as kernel itself does) that it is available all the time after modprobe'ing driver.

It is available as long as the device node is present. udev tells you (in dev.d) when this is the case. If the device is hardwired (from a user's point of view) the device node will be created early dring boot-up. If this happens, udev will notify the scripts in dev.d.

Instead of:
modprobe ide-cd && mount /dev/hdc /mnt/cdrom
in /etc/init.d/your-script

Quoted 5 lines

you would now do:
if [ ACTION="add" ] && [ DEVNAME="/dev/hdc" ]; then
mount /dev/hdc /mnt/cdrom
fi
in /etc/dev.d/default/your-script.dev

Well, go to /etc/rc.d and try to integrate that with rest of system.
The only right way of handling of such stuff I know - is FSM.
Implementing FSMs in shell scripts - last thing I ever wanted. And I
still cannot get how you are going to safely serialize /etc/dev.d/ callbacks against /etc/rc.d/ without polling.

Quoted 4 lines

This is even more reliable than the first solution on a static /dev, since loading the driver might fail at any point *after* modprobe returns.

Untrue. Driver if something fails have a chance to return error from
module_init() function, which will be passed to modprobe and then to callee.

Quoted 4 lines

For example, modprobe ide-cd will succeed even when no CD-ROMs are present. The old script would break in this case, the new one wouldn't be called at all.

You are wrong. Hardware driver must fail, when hardware is not
present/not detected. Simple as that.
If ide-cd doesn't do that - it needs to be fixed.

Quoted 2 lines

Error reporting is very difficult. How should the kernel know what the driver is supposed to do?

Yes. Driver is not loaded without need. Kernel doesn't need driver -
user need it to accomplish specific task.
User knows what driver is meant for, especially when it loads it
manually.
If user will be told when driver is ready - user can verify that
hardware in question is present.

Quoted 10 lines

Obvious errors likes Oopses or I/O errors *could* be reported by hotplug. (ACTION="error", DEVNAME="module-name" ???)
Anything else is impossible.

You just have to adopt your approach to device handling. Currently you *assume* that after a succesfull modprobe the device nodes are available (this was never true, however).
With hotplug/udev you *know* that the device node is available when your script in dev.d is called with the appropriate environment variables.

What about scripts outside of /etc/dev.d/?

If you ever mantained /etc/rc.d/rc - you will understand what I mean.
Splitting system boot-up procedure will have some funny consequences. Debugging will be left as an execise for end-users. Running once fsck simultaneously on several partitions will cool your temper down.

Again. FSM is no way to go for shell scripts. And shell scripts is
what is used to manage system. Even /etc/dev.d/ scripts - are shell scripts, after all.

P.S. If you will add errors to /etc/dev.d/ scripts - than you will really end up with FSMs in shell scripts. You are welcome to try. I did once and failed.

P.P.S. Well, I will stop trolling. Honestly. Promise.

#25 lore raw
Quoted 3 lines · Ihar 'Philips' Filipau

You are wrong. Hardware driver must fail, when hardware is not
present/not detected. Simple as that.
If ide-cd doesn't do that - it needs to be fixed.

I have a USB CD burner, and during startup I make sure that the USB and SCSI modules are already loaded to speed up the CD recognition. With your procedure I _can't_ do that. First I try to modprobe the USB stuff, which works. Then I try to modprobe the SCSI stuff, which doesn't, because the burner isn't plugged in yet and it sees no SCSI devices.

How does that make sense? Hardware is not serialized nicely the way you seem to want it to be. I expect to be able to plug in my 2 USB disks, my USB burner, and my USB scanner into the USB hub that I just plugged in, either before turning on the computer, halfway through startup, or after I've been working for 2 hours and not have the whole damn mess fail because one of the devices is _only_ initialized in the init scripts. The best way to handle this is /etc/dev.d. If some system is critical for startup, then just add a "touch /var/run/criticalsystem" to the specialized dev.d script and then have the init script poll for said file to become more recent than system startup. It's not like polling will hurt you in that case, if the device really is system-critical then you can't do anything _but_ poll and hope that the hardware isn't fubared.

Cheers,
Kyle Moffett

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCM/CS/IT/U d- s++: a17 C++++>$ UB/L/X/*++++(+)>$ P+++(++++)>$ L++++(+++) E W++(+) N+++(++) o? K? w--- O? M++ V? PS+() PE+(-) Y+ PGP+++ t+(+++) 5 X R? tv-(--) b++++(++) DI+ D+ G e->++++$ h!*()>++$ r !y?(-) ------END GEEK CODE BLOCK------

#26 lore raw
In reply to Ihar 'Philips' Filipau
Quoted 7 lines · Ihar 'Philips' Filipau
Quoted 4 lines

For example, modprobe ide-cd will succeed even when no CD-ROMs are present. The old script would break in this case, the new one wouldn't be called at all.

You are wrong. Hardware driver must fail, when hardware is not
present/not detected. Simple as that.

I'm sorry, but this is not how Linux device drivers work. It's been this way for over 4 years, and hopefully we have fixed up almost all drivers to be able to be loaded even if the hardware they are using isn't currently present. Do you know of any we have missed?

thanks,

greg k-h

#27 lore raw
In reply to Ihar 'Philips' Filipau
Quoted 3 lines · On Sun, 19 Sep 2004 21:40:09 +0200 Ihar 'Philips' Filipau <[email protected]>…

Well, go to /etc/rc.d and try to integrate that with rest of system. The only right way of handling of such stuff I know - is FSM.

Yes. But this is just the nature of this problem. For reliable operation and proper error reporting some state tracking is required even today.

Quoted 1 line

Implementing FSMs in shell scripts - last thing I ever wanted.

In most cases it should boil down to something like

while exists(lockfile)
sleep

Quoted 3 lines

And I
still cannot get how you are going to safely serialize /etc/dev.d/ callbacks against /etc/rc.d/ without polling.

Spinlocking with lock-files could work.

Quoted 2 lines

You are wrong. Hardware driver must fail, when hardware is not
present/not detected. Simple as that.

Why?

Quoted 4 lines

User knows what driver is meant for, especially when it loads it
manually.
If user will be told when driver is ready - user can verify that
hardware in question is present.

This isn't even necessary. If the driver triggers a hotplug event an an apropriate script is in dev.d everything will work automatically. If it doesn't the user can check why.

Quoted 2 lines

What about scripts outside of /etc/dev.d/?

They will have to spin on a lock file. See below.

Quoted 4 lines

Splitting system boot-up procedure will have some funny consequences. Debugging will be left as an execise for end-users. Running once fsck simultaneously on several partitions will cool your temper down.

This is quite easy to solve in dev.d (Python-like pseudo-code):

if not(ACTION==add)
exit
parse(fstab)
if not(DEVNAME in fstab)
exit
if has_parents(mountpoint)
while not(parents in mtab)
if has_failed?(parents)
has_failed!(DEVNAME)
exit
sleep
while is_locked(parent(DEVNAME))
sleep
lock(parent(DEVNAME))
fsck DEVNAME
mount DEVNAME || has_failed!(DEVNAME)
unlock(parent(DEVNAME))

Most likely I missed some fine points, but this way fsck and mounts are serialized when necessary and parallelized when possible (even across different fsck binaries). Dependencies in the filesystem hierarchy are satisfied and errors can be detected.

lock/unlock/has_failed! are simply "touch" and "rm -f" is_locked and has_failed? are simply "test -e". has_parents and parents are derived from fstab.

Of course, the init system needs some "cleverness". If /usr or /var are on separate devices later scripts need to poll mtab and do "has_failed?" checks. This is even needed today with a static /dev (but is not done). As a result current scripts break in undeterministic ways if mounting fails.

Quoted 4 lines

Again. FSM is no way to go for shell scripts. And shell scripts is
what is used to manage system. Even /etc/dev.d/ scripts - are shell scripts, after all.

Well, if bash proves too cumbersome there is still spython...

Regards

#28 lore raw
In reply to Ihar 'Philips' Filipau
Quoted 7 lines · Ihar 'Philips' Filipau

Well, can then anyone explain by which mean (black magic?) kernel
mounts root file system? block device might appear any time, file system might take ages to load.

Hu? How is init/do_mounts.c still works then? Or it is needs to be
fixed with messages a-la "root file system will be available shortly, we do hope" and "please plug in again your hard-wired IDE drive"?

Mounting of the root device is a fragile process that happens to work by chance on current setups, but there is a reason while distributions are now moving to a model where an initrd/initramfs is loaded as the root device first, which then can do the proper selection of a real root device, eventually waiting for one to show up, and then pivot to it. The kernel "built-in" root selection already fails most of the time with usb-storage or sbp2 (ieee1394)

Quoted 3 lines

People, you must learn doing abstractions carefully. If device is
hard-wired - user *will* expect (as kernel itself does) that it is available all the time after modprobe'ing driver.

Arrogance will lead you nowhere here, so step down from your pedestal and try accepting that your view on things might not be the right one.

Ben.