Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] package/eudev: tweak initscript
@ 2014-10-20 17:45 Gustavo Zacarias
  2014-10-20 17:54 ` Yann E. MORIN
  0 siblings, 1 reply; 5+ messages in thread
From: Gustavo Zacarias @ 2014-10-20 17:45 UTC (permalink / raw)
  To: buildroot

Make the udev initscript trigger in a coherent way, i.e. first set
subsystems, then device and then let the whole thing settle.
Otherwise for usb_modeswitch udev rules they never kick in since the
storage aspect (device) gets claimed first and the switch ignored.

Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
---
 package/eudev/S10udev | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/package/eudev/S10udev b/package/eudev/S10udev
index 107dfd5..c3eafce 100755
--- a/package/eudev/S10udev
+++ b/package/eudev/S10udev
@@ -30,8 +30,9 @@ case "$1" in
         printf "Populating ${udev_root:-/dev} using udev: "
         printf '\000\000\000\000' > /proc/sys/kernel/hotplug
         $UDEV_BIN -d || (echo "FAIL" && exit 1)
-        udevadm trigger --action=add
-        udevadm settle
+        udevadm trigger --type=subsystems --action=add
+        udevadm trigger --type=devices --action=add
+        udevadm settle --timeout=10
         echo "done"
         ;;
     stop)
-- 
2.0.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Buildroot] [PATCH] package/eudev: tweak initscript
  2014-10-20 17:45 [Buildroot] [PATCH] package/eudev: tweak initscript Gustavo Zacarias
@ 2014-10-20 17:54 ` Yann E. MORIN
  2014-10-20 17:57   ` Gustavo Zacarias
  0 siblings, 1 reply; 5+ messages in thread
From: Yann E. MORIN @ 2014-10-20 17:54 UTC (permalink / raw)
  To: buildroot

Gustavo, All,

On 2014-10-20 14:45 -0300, Gustavo Zacarias spake thusly:
> Make the udev initscript trigger in a coherent way, i.e. first set
> subsystems, then device and then let the whole thing settle.
> Otherwise for usb_modeswitch udev rules they never kick in since the
> storage aspect (device) gets claimed first and the switch ignored.
> 
> Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
> ---
>  package/eudev/S10udev | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/package/eudev/S10udev b/package/eudev/S10udev
> index 107dfd5..c3eafce 100755
> --- a/package/eudev/S10udev
> +++ b/package/eudev/S10udev
> @@ -30,8 +30,9 @@ case "$1" in
>          printf "Populating ${udev_root:-/dev} using udev: "
>          printf '\000\000\000\000' > /proc/sys/kernel/hotplug
>          $UDEV_BIN -d || (echo "FAIL" && exit 1)

Hmmm... This exit won't do much: it exits a sub-shell, so the initscript
will still continue...

> -        udevadm trigger --action=add
> -        udevadm settle
> +        udevadm trigger --type=subsystems --action=add
> +        udevadm trigger --type=devices --action=add
> +        udevadm settle --timeout=10

Why did you add a timeout, and not explain it?

Also, are 10 seconds really enough? What happens if a device takes
longer than 10s to initialise (and it is needed to boot, like a slow
USB mass-storage) ?

Regards,
Yann E. MORIN.

>          echo "done"
>          ;;
>      stop)
> -- 
> 2.0.4
> 
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Buildroot] [PATCH] package/eudev: tweak initscript
  2014-10-20 17:54 ` Yann E. MORIN
@ 2014-10-20 17:57   ` Gustavo Zacarias
  2014-10-20 18:10     ` Yann E. MORIN
  0 siblings, 1 reply; 5+ messages in thread
From: Gustavo Zacarias @ 2014-10-20 17:57 UTC (permalink / raw)
  To: buildroot

On 10/20/2014 02:54 PM, Yann E. MORIN wrote:

> Hmmm... This exit won't do much: it exits a sub-shell, so the initscript
> will still continue...

I've focused on fixing the one problem, i didn't audit the whole script.

>> -        udevadm trigger --action=add
>> -        udevadm settle
>> +        udevadm trigger --type=subsystems --action=add
>> +        udevadm trigger --type=devices --action=add
>> +        udevadm settle --timeout=10
> 
> Why did you add a timeout, and not explain it?
> 
> Also, are 10 seconds really enough? What happens if a device takes
> longer than 10s to initialise (and it is needed to boot, like a slow
> USB mass-storage) ?

It just seems prudent to avoid a stall, but yeah forgot to mention it,
it's the usual practice in many distros.
You've got rootwait & friends for that, remember this is post mount-root
so it doesn't matter there. And if you're doing initramfs then
switching/pivoting to some other root, well, you're scripting it, you
should take care of it there since you're doing the mount.
Regards.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Buildroot] [PATCH] package/eudev: tweak initscript
  2014-10-20 17:57   ` Gustavo Zacarias
@ 2014-10-20 18:10     ` Yann E. MORIN
  2014-10-20 18:17       ` Gustavo Zacarias
  0 siblings, 1 reply; 5+ messages in thread
From: Yann E. MORIN @ 2014-10-20 18:10 UTC (permalink / raw)
  To: buildroot

Gustavo, All,

On 2014-10-20 14:57 -0300, Gustavo Zacarias spake thusly:
> On 10/20/2014 02:54 PM, Yann E. MORIN wrote:
> 
> > Hmmm... This exit won't do much: it exits a sub-shell, so the initscript
> > will still continue...
> 
> I've focused on fixing the one problem, i didn't audit the whole script.

Sorry, that was not a critcism of your patch. I just noticed it by
chance...

> >> -        udevadm trigger --action=add
> >> -        udevadm settle
> >> +        udevadm trigger --type=subsystems --action=add
> >> +        udevadm trigger --type=devices --action=add
> >> +        udevadm settle --timeout=10
> > 
> > Why did you add a timeout, and not explain it?
> > 
> > Also, are 10 seconds really enough? What happens if a device takes
> > longer than 10s to initialise (and it is needed to boot, like a slow
> > USB mass-storage) ?
> 
> It just seems prudent to avoid a stall, but yeah forgot to mention it,
> it's the usual practice in many distros.

Mine has no timeout, but from man udevadm, the default is 120s:

   udevadm settle [options]
       Watches the udev event queue, and exits if all current events are
       handled.

       --timeout=seconds
           Maximum number of seconds to wait for the event queue to
           become empty. The default value is 120 seconds. A value of
           0 will check if the queue is empty and always return
           immediately.

So, I think 10s are a bit too short, but can not really suggest a better
default. Maybe we could just keep the default timeout, even though it is
a bit long?

Whether we wait 10 or 120 seconds, if something's stuck, there's not
much we can do about it. My distro, however, does this:

    # wait for the udevd childs to finish
    log_action_begin_msg "Waiting for /dev to be fully populated"
    if udevadm settle; then
        log_action_end_msg 0
    else
        log_action_end_msg 0 'timeout'
    fi
 
Which we could actually do (except in a simpler way, like log the
issue).

> You've got rootwait & friends for that, remember this is post mount-root
> so it doesn't matter there.

Not only USB mass-storage for root, but eth over USB, too. I've seen a
USB bus take about 8s to properly initialise and enumerate all the
devices, and a few seconds more for the USB-eth device to show up, and
there was an NFS resource to be mounted from /etc/fstab.

Anyway, this is a corner case.

Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>

Regards,
Yann E. MORIN.

> And if you're doing initramfs then
> switching/pivoting to some other root, well, you're scripting it, you
> should take care of it there since you're doing the mount.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Buildroot] [PATCH] package/eudev: tweak initscript
  2014-10-20 18:10     ` Yann E. MORIN
@ 2014-10-20 18:17       ` Gustavo Zacarias
  0 siblings, 0 replies; 5+ messages in thread
From: Gustavo Zacarias @ 2014-10-20 18:17 UTC (permalink / raw)
  To: buildroot

On 10/20/2014 03:10 PM, Yann E. MORIN wrote:

> Mine has no timeout, but from man udevadm, the default is 120s:
> 
>    udevadm settle [options]
>        Watches the udev event queue, and exits if all current events are
>        handled.
> 
>        --timeout=seconds
>            Maximum number of seconds to wait for the event queue to
>            become empty. The default value is 120 seconds. A value of
>            0 will check if the queue is empty and always return
>            immediately.
> 
> So, I think 10s are a bit too short, but can not really suggest a better
> default. Maybe we could just keep the default timeout, even though it is
> a bit long?

120s sounds brutal IMHO, you'll have to wait 2 full minutes to see
anything. But yeah we could argue 10s is a bit short, maybe 30s is a
good compromise?

> Whether we wait 10 or 120 seconds, if something's stuck, there's not
> much we can do about it. My distro, however, does this:
> 
>     # wait for the udevd childs to finish
>     log_action_begin_msg "Waiting for /dev to be fully populated"
>     if udevadm settle; then
>         log_action_end_msg 0
>     else
>         log_action_end_msg 0 'timeout'
>     fi
>  
> Which we could actually do (except in a simpler way, like log the
> issue).

Probably something like...
udevadm settle --timeout=30 || echo "udevadm settle timed out!"

> Not only USB mass-storage for root, but eth over USB, too. I've seen a
> USB bus take about 8s to properly initialise and enumerate all the
> devices, and a few seconds more for the USB-eth device to show up, and
> there was an NFS resource to be mounted from /etc/fstab.
> 
> Anyway, this is a corner case.

One would hope you don't switch root to nfs until you get the proper
mount too which would mean a valid ip address as well (this without
using the kernel nfsroot/dhcp client).
Using the kernel subsystem i never tried using ethernet over usb but
presumably rootwait would wait until ip negotiation is done? (again
dunno what happens with the internal dhcp client if eth* isn't ready yet).
Regards.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-10-20 18:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-20 17:45 [Buildroot] [PATCH] package/eudev: tweak initscript Gustavo Zacarias
2014-10-20 17:54 ` Yann E. MORIN
2014-10-20 17:57   ` Gustavo Zacarias
2014-10-20 18:10     ` Yann E. MORIN
2014-10-20 18:17       ` Gustavo Zacarias

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox