Skip to contentSkip to conversation

cold plugging

DISCUSSION Treeve Jelbert 12 participants 23 messages Jan 13, 2006 – Jan 16, 2006

lore
Share & tools
lore
#0 lore raw

I am running kernel-2.6.15 and udev-80 in a build everything from source environment.

the kernel has lots of modules.

when the system is fully up, new hardware is detected and processed correctly by udev.

my problem concerns hardware which is present before udevd starts, eg usb, pcmcia, 1394, ....

udev does not seem to process any UEVENTS for these things. I tried udevstart, but this seems to have no effect.

Which program should be run to detect entries in /sys , trigger a UEVENT and hence the execution of the udev rules, in order to load modules and create device nodes?

I assume that somebody has a script or program that does this.

With previous kernels, I used udevsend as a hotplug driver and the relevant modules did get loaded.

Signature · 12 lines
Regards, Treeve


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#1 lore raw
Quoted 5 lines · Treeve Jelbert

I am running kernel-2.6.15 and udev-80 in a build everything from source environment.

the kernel has lots of modules.

Quoted 8 lines

when the system is fully up, new hardware is detected and processed correctly by udev.

my problem concerns hardware which is present before udevd starts, eg usb, pcmcia, 1394, ....

udev does not seem to process any UEVENTS for these things. I tried udevstart, but this seems to have no effect.

Don't use udev, udevsend and udevstart anymore, if you don't really need to. The 2.6.15 kernel and udevd is all you need.

Quoted 8 lines

Which program should be run to detect entries in /sys , trigger a UEVENT and hence the execution of the udev rules, in order to load modules and create device nodes?

I assume that somebody has a script or program that does this.

With previous kernels, I used udevsend as a hotplug driver and the relevant modules did get loaded.

No, this never worked with udevsend. At the time udevsend is executed and the modules too, all early events are already lost unless you have recorded them in initramfs.

You need to retrigger all events after you have started udevd, just write "add" to all "uevent" files in /sys and the events will be sent to the udev daemon, which will create the device nodes and run modprobe and other tools to setup the devices.

I'm using this:

	list=$(echo /sys/bus/*/devices/*/uevent)
	list="$list $(echo /sys/class/*/*/uevent)"
	list="$list $(echo /sys/block/*/uevent /sys/block/*/*/uevent)"
	for i in $list; do
	    case "$i" in
		*/device/uevent|*\**)
		    continue
		    ;;
		*/class/mem/*|*/class/tty/*)
		    first="$first $i"
		    ;;
		*/block/md*)
		    last="$last $i"
		    ;;
		*/*)
		    default="$default $i"
		    ;;
	    esac
	done

	# trigger the sorted events
	for i in $first $default $last; do
	    echo "add" > "$i"
	done

To wait for the events to finish (if you need to), I do:

	loop00
	while test -d /dev/.udev/queue; do
	    sleep 0.1;
	    test "$loop" -gt 0 || break
	    loop=$(($loop - 1))
	done

Kay

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
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 Treeve Jelbert
Quoted 17 lines · Kay Sievers

I'm using this:

	list=$(echo /sys/bus/*/devices/*/uevent)
	list="$list $(echo /sys/class/*/*/uevent)"
	list="$list $(echo /sys/block/*/uevent /sys/block/*/*/uevent)"
	for i in $list; do
	    case "$i" in
		*/device/uevent|*\**)
		    continue
		    ;;
		*/class/mem/*|*/class/tty/*)
		    first="$first $i"
		    ;;
		*/block/md*)
		    last="$last $i"
		    ;;
		*/*)
		    default="$default $i"
Quoted 10 lines
		    ;;
	    esac
	done

	# trigger the sorted events
	for i in $first $default $last; do
	    echo "add" > "$i"
	done

Why sort the events? They arrive at udevd in random order anyway.

Quoted 9 lines

To wait for the events to finish (if you need to), I do:

	loop00
	while test -d /dev/.udev/queue; do
	    sleep 0.1;
	    test "$loop" -gt 0 || break
	    loop=$(($loop - 1))
	done

USB uevents easily get past this loop. I have a check in my script that sleeps 2 seconds after that and reports all new uevents in those 2 seconds as possible bugs.

Signature · 12 lines
Alexander E. Patrakov


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
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 Treeve Jelbert

I demand that Alexander E. Patrakov may or may not have written...

Quoted 1 line

Kay Sievers wrote:

[snip]

Quoted 9 lines
Quoted 7 lines

To wait for the events to finish (if you need to), I do:

	loop00
	while test -d /dev/.udev/queue; do
	    sleep 0.1;
	    test "$loop" -gt 0 || break
	    loop=$(($loop - 1))
	done

USB uevents easily get past this loop.

Also slower machines. I have a machine (PII 366) here which has randomly failed to create /dev/hda* in time, causing problems for fsck; doubling the timeout avoids the problem.

[snip]

Signature · 17 lines
| Darren Salt | nr. Ashington, | d youmustbejoking,demon,co,uk
| Debian,     | Northumberland | s zap,tartarus,org
| RISC OS     | Toon Army      | @
|   Kill all extremists!

G No room for line, 0:1


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#4 lore raw
In reply to Treeve Jelbert
Quoted 23 lines · Alexander E. Patrakov
Quoted 21 lines · Kay Sievers

I'm using this:

	list=$(echo /sys/bus/*/devices/*/uevent)
	list="$list $(echo /sys/class/*/*/uevent)"
	list="$list $(echo /sys/block/*/uevent /sys/block/*/*/uevent)"
	for i in $list; do
	    case "$i" in
		*/device/uevent|*\**)
		    continue
		    ;;
		*/class/mem/*|*/class/tty/*)
		    first="$first $i"
		    ;;
		*/block/md*)
		    last="$last $i"
		    ;;
		*/*)
		    default="$default $i"
		    ;;
	    esac
	done
Quoted 7 lines
Quoted 6 lines
	# trigger the sorted events
	for i in $first $default $last; do
	    echo "add" > "$i"
	done

Why sort the events? They arrive at udevd in random order anyway.

Because many things need /dev/null and the tty device nodes in their handlers and scripts, so they need to be created first.

Try it and see if you don't believe us :)

Quoted 9 lines
Quoted 9 lines

To wait for the events to finish (if you need to), I do:

	loop00
	while test -d /dev/.udev/queue; do
	    sleep 0.1;
	    test "$loop" -gt 0 || break
	    loop=$(($loop - 1))
	done
Quoted 3 lines

USB uevents easily get past this loop. I have a check in my script that sleeps 2 seconds after that and reports all new uevents in those 2 seconds as possible bugs.

Why does USB take longer for you? What is taking such a long time?

thanks,

greg k-h

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#5 lore raw
In reply to Treeve Jelbert
Quoted 12 lines · Darren Salt

I demand that Alexander E. Patrakov may or may not have written...

Quoted 1 line

Kay Sievers wrote:

[snip]

Quoted 7 lines
Quoted 7 lines

To wait for the events to finish (if you need to), I do:

	loop=300
	while test -d /dev/.udev/queue; do
	    sleep 0.1;
	    test "$loop" -gt 0 || break
	    loop=$(($loop - 1))
	done
Quoted 6 lines
Quoted 1 line

USB uevents easily get past this loop.

Also slower machines. I have a machine (PII 366) here which has randomly failed to create /dev/hda* in time, causing problems for fsck; doubling the timeout avoids the problem.

This is almost certainly due to the buggy IDE subsystem patch in Debian's kernel.

Scott

Signature · 2 lines
Have you ever, ever felt like this?
Had strange things happen?  Are you going round the twist?
#6 lore raw
In reply to Treeve Jelbert
Quoted 2 lines · Scott James Remnant

This is almost certainly due to the buggy IDE subsystem patch in Debian's kernel.

I understand that it has been removed.

Signature · 2 lines
ciao,
Marco
#7 lore raw
In reply to Treeve Jelbert

[context restored]

I demand that Marco d'Itri may or may not have written...

Quoted 3 lines · Scott James Remnant
Quoted 2 lines · Darren Salt
Quoted 1 line

I demand that Alexander E. Patrakov may or may not have written...

[snip; udev initial population delay timeout]

Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

USB uevents easily get past this loop.

Also slower machines. I have a machine (PII 366) here which has randomly failed to create /dev/hda* in time, causing problems for fsck; doubling the timeout avoids the problem.

This is almost certainly due to the buggy IDE subsystem patch in Debian's kernel.

I understand that it has been removed.

It's a long time since I used a Debian kernel for anything other than installation. (I do use make-kpkg, though.) I might be missing out on a patch here and there, but I can live with that :-)

My kernels are somewhat monolithic, the intent being to be able to mount filesystems from init=/bin/sh (given root=/dev/hda*) without needing to load any modules.

FWIW, the machine in question is currently running 2.6.15+dyntick and udev 0.079-1.

Signature · 17 lines
| Darren Salt | nr. Ashington, | d youmustbejoking,demon,co,uk
| Debian,     | Northumberland | s zap,tartarus,org
| RISC OS     | Toon Army      | @
|   We've got Souness, we don't want him

You are taking advantage of the good nature of a friend. Be careful.


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#8 lore raw
In reply to Treeve Jelbert
Quoted 30 lines · Greg KH
Quoted 29 lines · Alexander E. Patrakov
Quoted 27 lines · Kay Sievers

I'm using this:

	list=$(echo /sys/bus/*/devices/*/uevent)
	list="$list $(echo /sys/class/*/*/uevent)"
	list="$list $(echo /sys/block/*/uevent /sys/block/*/*/uevent)"
	for i in $list; do
	    case "$i" in
		*/device/uevent|*\**)
		    continue
		    ;;
		*/class/mem/*|*/class/tty/*)
		    first="$first $i"
		    ;;
		*/block/md*)
		    last="$last $i"
		    ;;
		*/*)
		    default="$default $i"
		    ;;
	    esac
	done

	# trigger the sorted events
	for i in $first $default $last; do
	    echo "add" > "$i"
	done
Quoted 4 lines
Quoted 1 line

Why sort the events? They arrive at udevd in random order anyway.

Because many things need /dev/null and the tty device nodes in their handlers and scripts, so they need to be created first.

But the above script does not guarantee that /dev/null will be created first. It only orders the events, but as events are processed in parallel, it may well happen that a later event gets processed earlier.

Signature · 12 lines
pozsy


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#9 lore raw
In reply to Treeve Jelbert
Quoted 31 lines · Pozsar Balazs
Quoted 30 lines · Greg KH
Quoted 29 lines · Alexander E. Patrakov
Quoted 27 lines · Kay Sievers

I'm using this:

	list=$(echo /sys/bus/*/devices/*/uevent)
	list="$list $(echo /sys/class/*/*/uevent)"
	list="$list $(echo /sys/block/*/uevent /sys/block/*/*/uevent)"
	for i in $list; do
	    case "$i" in
		*/device/uevent|*\**)
		    continue
		    ;;
		*/class/mem/*|*/class/tty/*)
		    first="$first $i"
		    ;;
		*/block/md*)
		    last="$last $i"
		    ;;
		*/*)
		    default="$default $i"
		    ;;
	    esac
	done

	# trigger the sorted events
	for i in $first $default $last; do
	    echo "add" > "$i"
	done
Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Why sort the events? They arrive at udevd in random order anyway.

Because many things need /dev/null and the tty device nodes in their handlers and scripts, so they need to be created first.

But the above script does not guarantee that /dev/null will be created first. It only orders the events, but as events are processed in parallel, it may well happen that a later event gets processed earlier.

Have you seen this happen?

thanks,

greg k-h

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#10 lore raw
In reply to Treeve Jelbert
Quoted 3 lines · Greg KH

Why does USB take longer for you? What is taking such a long time?

The /dev/bus/usb/... node for my Mustek Plug-N-Scan 1200 UB Plus scanner.

Signature · 13 lines
Alexander E. Patrakov



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#11 lore raw
In reply to Treeve Jelbert
Quoted 12 lines · Greg KH
Quoted 5 lines · Pozsar Balazs

But the above script does not guarantee that /dev/null will be created first. It only orders the events, but as events are processed in parallel, it may well happen that a later event gets processed earlier.

Have you seen this happen?

Yes, /dev/null is never created first even if echoing to uevent files is ordered by Kay's script. There are always three or four messages on boot about /dev/null not being found. I solved this by creating /lib/udev/devices/null.

Signature · 12 lines
Alexander E. Patrakov


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#12 lore raw
In reply to Treeve Jelbert
Quoted 10 lines · Greg KH
Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Why sort the events? They arrive at udevd in random order anyway.

Because many things need /dev/null and the tty device nodes in their handlers and scripts, so they need to be created first.

But the above script does not guarantee that /dev/null will be created first. It only orders the events, but as events are processed in parallel, it may well happen that a later event gets processed earlier.

Have you seen this happen?

To be honest: no, I just wanted to make a point about theoretical incorrectness.
One solution could be to wait after each pass for udev to finish processing events just like after sending all the events in the above script.

Signature · 12 lines
pozsy


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#13 lore raw
In reply to Treeve Jelbert
Quoted 6 lines · Alexander E. Patrakov
Quoted 3 lines · Greg KH

Why does USB take longer for you? What is taking such a long time?

The /dev/bus/usb/... node for my Mustek Plug-N-Scan 1200 UB Plus scanner.

It's the simplest way to wait for all events. Depending how you handle dependencies/checkoints on bootup, it may be sudfficient if all localfs devices have appeared and you can let the other events finish asynchronously.

Kay

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#14 lore raw
In reply to Treeve Jelbert
Quoted 9 lines · Alexander E. Patrakov
Quoted 7 lines · Greg KH
Quoted 3 lines · Pozsar Balazs

But the above script does not guarantee that /dev/null will be created first. It only orders the events, but as events are processed in parallel, it may well happen that a later event gets processed earlier.

Quoted 6 lines
Quoted 2 lines

Have you seen this happen?

Yes, /dev/null is never created first even if echoing to uevent files is ordered by Kay's script. There are always three or four messages on boot about /dev/null not being found. I solved this by creating /lib/udev/devices/null.

Sure, /dev/null is usually created/copied by the first init script itself, but that's not what Greg meant, you may want to run pretty complex software for bringing up all kinds of block devices and similar, so it's just safer to have the random, zero, mem, ... and the tty's around, before the block devices are running. The order is mainly a copy of what udevstart was doing in the past.

With the async events, you can wait at any point during coldplug event triggering for the events to finish. We need to find out, what's the best approch to do this, that's the reason none of the current alternatives is in the udev tree itself today. I wanted to start simple and this stupid shell script snippet, works fine for me. We'll see with what we'll end with and if we can agree on some default, we all can use, which would be nice.

Thanks,
Kay

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#15 lore raw
In reply to Treeve Jelbert
Quoted 10 lines · Kay Sievers
Quoted 7 lines · Alexander E. Patrakov
Quoted 3 lines · Greg KH

Why does USB take longer for you? What is taking such a long time?

Quoted 9 lines
Quoted 3 lines

The /dev/bus/usb/... node for my Mustek Plug-N-Scan 1200 UB Plus scanner.

It's the simplest way to wait for all events. Depending how you handle dependencies/checkoints on bootup, it may be sudfficient if all localfs devices have appeared and you can let the other events finish asynchronously.

Thanks, but you probably missed the point. Your loop does NOT wait for all events. I think that in my case the following happens:

1) The script creates an empty /dev/.udev/queue directory
2) The script causes the kernel to emit uevents
3) udevd gets those uevents, and reacts upon them. This reaction involves, among other things, making device nodes and calling /sbin/modprobe to load new drivers.
4) Those drivers are bound to devices by the kernel, this produces new uevents, go to (3).
5) When the internal queue of udevd becomes empty, it removes the /dev/.udev/queue directory and the loop exits.

The problem is that some modules take longer than 0.1s to detect their hardware, so there is a period of time longer than 0.1s with the empty udevd queue, after which new uevents arrive.

6) such late uevents reach udevd after the loop ends, and then it may be too late (but it is OK for me to ignore this for my scanner).

A "solution" is to rewrite the script so that it repeatedly checks that the queue stays empty for some period of time (i.e., retests the existence of /dev/.udev/queue several times with delays between them) instead of exiting immediately when the queue becomes empty for a moment.

Signature · 12 lines
Alexander E. Patrakov


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#16 lore raw
In reply to Treeve Jelbert
Quoted 27 lines · Alexander E. Patrakov
Quoted 13 lines · Kay Sievers
Quoted 5 lines · Alexander E. Patrakov
Quoted 2 lines · Greg KH

Why does USB take longer for you? What is taking such a long time?

The /dev/bus/usb/... node for my Mustek Plug-N-Scan 1200 UB Plus scanner.

It's the simplest way to wait for all events. Depending how you handle dependencies/checkoints on bootup, it may be sudfficient if all localfs devices have appeared and you can let the other events finish asynchronously.

Thanks, but you probably missed the point. Your loop does NOT wait for all events. I think that in my case the following happens:

1) The script creates an empty /dev/.udev/queue directory
2) The script causes the kernel to emit uevents
3) udevd gets those uevents, and reacts upon them. This reaction involves, among other things, making device nodes and calling /sbin/modprobe to load new drivers.
4) Those drivers are bound to devices by the kernel, this produces new uevents, go to (3).
5) When the internal queue of udevd becomes empty, it removes the /dev/.udev/queue directory and the loop exits.

Quoted 3 lines

The problem is that some modules take longer than 0.1s to detect their hardware, so there is a period of time longer than 0.1s with the empty udevd queue, after which new uevents arrive.

Which modprobe for which module is it, that returns before events for the devices are generated?

Kay

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#17 lore raw
In reply to Treeve Jelbert

(reposting from a different address, since SpamCop blacklisted the SMTP server and the message sent from [email protected] didn't reach the list. Sorry if you get this twice.)

Quoted 41 lines · Kay Sievers
Quoted 38 lines · Alexander E. Patrakov
Quoted 11 lines · Kay Sievers
Quoted 8 lines · Alexander E. Patrakov
Quoted 4 lines · Greg KH

Why does USB take longer for you? What is taking such a long time?

Quoted 11 lines
Quoted 3 lines

The /dev/bus/usb/... node for my Mustek Plug-N-Scan 1200 UB Plus scanner.

It's the simplest way to wait for all events. Depending how you handle dependencies/checkoints on bootup, it may be sudfficient if all localfs devices have appeared and you can let the other events finish asynchronously.

Thanks, but you probably missed the point. Your loop does NOT wait for all events. I think that in my case the following happens:

1) The script creates an empty /dev/.udev/queue directory
2) The script causes the kernel to emit uevents
3) udevd gets those uevents, and reacts upon them. This reaction involves, among other things, making device nodes and calling /sbin/modprobe to load new drivers.
4) Those drivers are bound to devices by the kernel, this produces new uevents, go to (3).
5) When the internal queue of udevd becomes empty, it removes the /dev/.udev/queue directory and the loop exits.

Quoted 11 lines
Quoted 5 lines

The problem is that some modules take longer than 0.1s to detect their hardware, so there is a period of time longer than 0.1s with the empty udevd queue, after which new uevents arrive.

Which modprobe for which module is it, that returns before events for the devices are generated?

Sorry, after playing with udev versions and changing rules, I lost my ability to reproduce this with my scanner alone. But this does happen when I boot with both my scanner and my MP3 player plugged in. Leaked events (i.e.: those that happen within 2 seconds after the end of the loop) are pasted at the end of this mail, so I assume that it is related with usb_storage for this report. Note that if I boot with only one of those devices, nothing leaks.

UDEV_LOG=0
ACTION­d DEVPATH=/devices/pci0000:00/0000:00:07.2/usb1/1-2 SUBSYSTEM=usb
SEQNUM18
PHYSDEVBUS=usb
PHYSDEVDRIVER=usb
- -------------------------------------
UDEV_LOG=0
ACTION­d DEVPATH=/devices/pci0000:00/0000:00:07.2/usb1/1-2/1-2:1.0 SUBSYSTEM=usb
SEQNUM19
PHYSDEVBUS=usb
DEVICE=/proc/bus/usb/001/003
PRODUCTA9/a002/100
TYPE=0/0/0
INTERFACE=8/6/80 MODALIAS=usb:v0419pA002d0100dc00dsc00dp00ic08isc06ip50 UDEVD_EVENT=1
- -------------------------------------
UDEV_LOG=0
ACTION­d
DEVPATH=/class/usb_device/usbdev1.3
SUBSYSTEM=usb_device
SEQNUM20 PHYSDEVPATH=/devices/pci0000:00/0000:00:07.2/usb1/1-2 PHYSDEVBUS=usb
PHYSDEVDRIVER=usb
MAJOR9
MINOR=2
UDEVD_EVENT=1
DEVNAME=/dev/bus/usb/001/003
- -------------------------------------
UDEV_LOG=0
ACTION­d
DEVPATH=/class/scsi_host/host0
SUBSYSTEM=scsi_host
SEQNUM26 PHYSDEVPATH=/devices/pci0000:00/0000:00:07.2/usb1/1-2/1-2:1.0/host0 UDEVD_EVENT=1

Signature · 12 lines
Alexander E. Patrakov


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#18 lore raw
In reply to Treeve Jelbert
Quoted 4 lines · Kay Sievers

Which modprobe for which module is it, that returns before events for the devices are generated?

Everything that has to do with serio - i8042, atkbd, psmouse, etc. Device creation and driver binding/unbinding is offloaded to kseriod thread so it is quite likely that module init function returns early.

Signature · 12 lines
Dmitry


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#19 lore raw
In reply to Treeve Jelbert
Quoted 13 lines · Alexander E. Patrakov

Thanks, but you probably missed the point. Your loop does NOT wait for all events. I think that in my case the following happens:

1) The script creates an empty /dev/.udev/queue directory
2) The script causes the kernel to emit uevents
3) udevd gets those uevents, and reacts upon them. This reaction involves, among other things, making device nodes and calling /sbin/modprobe to load new drivers.
4) Those drivers are bound to devices by the kernel, this produces new uevents, go to (3).
5) When the internal queue of udevd becomes empty, it removes the /dev/.udev/queue directory and the loop exits.

Quoted 6 lines

The problem is that some modules take longer than 0.1s to detect their hardware, so there is a period of time longer than 0.1s with the empty udevd queue, after which new uevents arrive.

6) such late uevents reach udevd after the loop ends, and then it may be too late (but it is OK for me to ignore this for my scanner).

I had a similar problem with a USB Flash drive that had a delay in the driver for it to "warm up". I just had a larger delay (and less cycles) in my queue polling script and it works OK. The worst case scenario is that this loop delays the boot for 1 second, which I can live with.

mkdir -p /dev/.udev/queue
udevsynthesize
udevd_timeout
while [ -d /dev/.udev/queue/ ]; do
/usr/bin/sleep 1
udevd_timeout=$(($udevd_timeout - 1))
if [ $udevd_timeout -eq 0 ]; then
echo "timeout"
break
fi
done
echo "coldplug complete"

regards,

Aras Vaichas

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#20 lore raw
In reply to Treeve Jelbert
Quoted 18 lines · Aras Vaichas
Quoted 17 lines · Alexander E. Patrakov

Thanks, but you probably missed the point. Your loop does NOT wait for all events. I think that in my case the following happens:

1) The script creates an empty /dev/.udev/queue directory
2) The script causes the kernel to emit uevents
3) udevd gets those uevents, and reacts upon them. This reaction involves, among other things, making device nodes and calling /sbin/modprobe to load new drivers.
4) Those drivers are bound to devices by the kernel, this produces new uevents, go to (3).
5) When the internal queue of udevd becomes empty, it removes the /dev/.udev/queue directory and the loop exits.

The problem is that some modules take longer than 0.1s to detect their hardware, so there is a period of time longer than 0.1s with the empty udevd queue, after which new uevents arrive.

Quoted 6 lines
Quoted 2 lines

6) such late uevents reach udevd after the loop ends, and then it may be too late (but it is OK for me to ignore this for my scanner).

I had a similar problem with a USB Flash drive that had a delay in the driver for it to "warm up". I just had a larger delay (and less cycles) in my queue polling script and it works OK.

Sure, this can happen with usb_storage. Secondary events, that arrive after a module has scheduled device creation and return immediately, have never been handled and there is no sane way to do it for udev.

I'm sure we don't want to introduce another round of sleep 1 to the device management, like the nightmare we had in the past. The right way to solve that - if you really depend on these devices at all - is to have certain checkpoint during boot that have the dependency on these devices recorded.

Ususal setups don't depend on scanners and such stuff to be fully initialized before you can continue with booting, you can perfectly do this asynchronously. If you depend on a usb-storage volume, you better put that in fstab and let your "localfs" boot script wait until all reuqirements are fulfilled, instead of guessing how long it could take that "all" events have finished.

Thanks,
Kay

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#21 lore raw
In reply to Treeve Jelbert
Quoted 8 lines · Dmitry Torokhov
Quoted 3 lines · Kay Sievers

Which modprobe for which module is it, that returns before events for the devices are generated?

Everything that has to do with serio - i8042, atkbd, psmouse, etc. Device creation and driver binding/unbinding is offloaded to kseriod thread so it is quite likely that module init function returns early.

Ah, good to know that "input" does that too. usb-storage does that for long, it has a default internal timeout of 5 seconds to let the device "settle down". The modprobe returns before the devices are created.

Thanks,
Kay

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#22 lore raw
In reply to Treeve Jelbert
Quoted 11 lines · Kay Sievers
Quoted 6 lines
Quoted 2 lines

6) such late uevents reach udevd after the loop ends, and then it may be too late (but it is OK for me to ignore this for my scanner).

I had a similar problem with a USB Flash drive that had a delay in the driver for it to "warm up". I just had a larger delay (and less cycles) in my queue polling script and it works OK.

Sure, this can happen with usb_storage. Secondary events, that arrive after a module has scheduled device creation and return immediately, have never been handled and there is no sane way to do it for udev.

Quoted 5 lines

I'm sure we don't want to introduce another round of sleep 1 to the device management, like the nightmare we had in the past. The right way to solve that - if you really depend on these devices at all - is to have certain checkpoint during boot that have the dependency on these devices recorded.

We've added some workarounds in Mandriva's rc.sysinit to wait for usb/firewire devices if needed:

# wait for usb and firewire storage scanning processes to finish
[ -n "$needusbstorage" ] && while ps -eocomm | grep -q usb-stor-scan; do sleep 1; done
[ -n "$needfirewirestorage" ] && while ps -eocomm | grep -q kfwrescan; do sleep 1; done
Signature · 13 lines
Olivier Blin - Mandriva



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel