From: Brad Hards <bhards@bigpond.net.au>
To: Brian Craft <bcboy@thecraftstudio.com>, linux-kernel@vger.kernel.org
Subject: Re: delay before open() works
Date: Sun, 15 Sep 2002 15:25:01 +1000 [thread overview]
Message-ID: <200209151525.01920.bhards@bigpond.net.au> (raw)
In-Reply-To: <20020914094225.A1267@porky.localdomain>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Sun, 15 Sep 2002 02:42, Brian Craft wrote:
<snip>
> This is pretty gross, since I have to determine the "15" by playing with
> it, and I'm sure it will fail some of the time unless I make it reeeeeally
> long. I suspected this was some hardware issue -- USB latencies on device
> discovery, or boot time for the scanner -- but a friend who isn't
> attempting to power-up his devices says he sees the same behavior when just
> scripting "modprobe". So it appears there's some fairly long delay in the
> kernel itself.
>
> Anyone know off-hand what causes this delay, or if there's some way to get
> the open() to block?
There is a fundamental problem with the way hotplugging works in this case.
The underlying hardware (in this case USB) detects a status change. It calls
call_usermode_helper(), and hands off the task to keventd. Then things wait.
Eventually keventd gets around to calling /sbin/hotplug, which loads modules,
runs scripts, writes config files, exec code - whatever. The problem is that
if module initialisation isn't complete, then clearly its interfaces may not
be established (or in some badly-coded cases, may contain races where the
interface is registered but isn't valid).
After discussions with Oliver Neukem at Linux Kongress, the idea of a second
hotplug event emerges. This is signalled by the driver that actually
registers the interface after the interface is properly established (so in
your example, USB core does one call_usermode_helper(), which probably does
something like "modprobe scanner"; and the scanner driver does a second
call_usermode_helper(), which loads xsane).
BTW: I'm not sure who actually came up with the idea - it was in the hotplug
BoF, but I missed this part of it.
Solves this race. Unfortunately requires some janitorial work. Patch away...
Brad
- --
http://conf.linux.org.au. 22-25Jan2003. Perth, Australia. Birds in Black.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE9hBmtW6pHgIdAuOMRAsblAKCKoiHGDnKnCU3kORyTJKEy8sjPKwCfSwDj
QGrrS/elmJ/YbBwmpksI+WU=
=yclZ
-----END PGP SIGNATURE-----
next prev parent reply other threads:[~2002-09-15 5:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-09-14 16:42 Brian Craft
2002-09-15 5:25 ` Brad Hards [this message]
2002-09-15 6:10 ` Greg KH
2002-09-15 6:38 ` Brad Hards
2002-09-15 6:49 ` Greg KH
2002-09-15 6:20 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200209151525.01920.bhards@bigpond.net.au \
--to=bhards@bigpond.net.au \
--cc=bcboy@thecraftstudio.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®