From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 23 09:02:54 2018 Received: (at 30604) by debbugs.gnu.org; 23 Mar 2018 13:02:54 +0000 Received: from localhost ([127.0.0.1]:48813 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ezMLN-0003Ai-IY for submit@debbugs.gnu.org; Fri, 23 Mar 2018 09:02:53 -0400 Received: from dd26836.kasserver.com ([85.13.145.193]:55762) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ezMLG-0003AR-HL for 30604@debbugs.gnu.org; Fri, 23 Mar 2018 09:02:47 -0400 Received: from localhost (178.113.247.207.wireless.dyn.drei.com [178.113.247.207]) by dd26836.kasserver.com (Postfix) with ESMTPSA id 7DB903360156; Fri, 23 Mar 2018 14:02:44 +0100 (CET) Date: Fri, 23 Mar 2018 14:02:31 +0100 From: Danny Milosavljevic To: ludo@gnu.org (Ludovic =?ISO-8859-1?Q?Court=E8s?=) Subject: Re: Keyboard detection before =?utf-8?Q?=E2=80=98cryptsetup?= =?utf-8?Q?=E2=80=99?= runs Message-ID: <20180323140231.1c96615c@scratchpost.org> In-Reply-To: <87o9jlo28l.fsf@inria.fr> References: <87h8plkkkc.fsf@gnu.org> <20180312221541.1886-1-ludo@gnu.org> <20180312221541.1886-5-ludo@gnu.org> <87fu54fjfj.fsf@gnu.org> <87o9jlo28l.fsf@inria.fr> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-unknown-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; boundary="Sig_/AUxA6/_mgeP._IxBi/m+hEl"; protocol="application/pgp-signature" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 30604 Cc: 30604@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --Sig_/AUxA6/_mgeP._IxBi/m+hEl Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Ludo, I thought about it for a bit... On Sun, 18 Mar 2018 16:03:06 +0100 ludo@gnu.org (Ludovic Court=C3=A8s) wrote: > One way to do that would be to have a separate thread that calls > =E2=80=98load-needed-linux-modules=E2=80=99 as appropriate. Ideally it w= ould use > inotify on /sys like udev does, but a poor programmer=E2=80=99s version c= ould > simply call =E2=80=98load-needed-linux-modules=E2=80=99 every half a seco= nd or so. >=20 > Alternately, before passing control to user code (pre-mount actions, > etc.), we could do a =E2=80=9Csettle=E2=80=9D kind of thing: call > =E2=80=98load-linux-modules-from-directory=E2=80=99 every 0.5 seconds unt= il its result > is the same as before. There=E2=80=99s still a risk of missing devices, = and > those devices will never show up later because nobody=E2=80=99s monitorin= g /sys. > But then again, =E2=80=9Cudevadm settle=E2=80=9D must have the same probl= em: it can=E2=80=99t > really know whether things have settled, I guess. Yes, but udevd continues running and monitoring /sys anyway - so I guess they don't really care (if I wrote it, I'd start up the monitoring first and then traverse /sys for modalias - and make sure the modprobe is idempotent). I have to say what we have to do is much more complicated than I thought it would be - and I kinda regret starting this patchset. I didn't want to make it less likely for people to boot than before :-( I suggest we find out how the other distributions do it - if they do it. A small bit of research shows that: - Busybox uses a loop with timeout to try to mount over and over again, depending on bus type [2]. - Alpine coldplugs twice [1]. - Fatdog has a "waitdev" boot parameter that specifies how long it sleeps until it tries to mount the root. - Redhat mkinitrd has an mkinitrd option like "--with=3Dscsi_wait_scan" whi= ch they use after they saw a modalias starting with "scsi:" - or add the kernel option "scsi_mod.scan=3Dsync" to the command line [3] (but they say = that this is unreliable now and one is supposed to use udev inside the initrd). Not sure what they do for USB. The Linux kernel itself has a "rootdelay" parameter which was specifically introduced because of USB devices that took 15 s (!) to show up. All in all, we have alternative ways to continue: (a) Drop this patchset/feature entirely because it's too unreliable. (b) Monitor /sys using inotify in an extra thread/process. (c) Include udev into the initrd and have it do its thing. (d) Monitor the netlink socket in our own thread and play udev ourselves. (e) Find out how to, for each bus type, detect when enumeration is finished. Find out which buses are there. Wait for them to finish enumerating. (f) Always modprobe usb-hid first, no matter what. I think this would become a whack-a-mole thing fast. I'd prefer either (a) or (b) for reliability and simplicity. WDYT? (inotify is Linux-only, but so is /sys/devices :P) [1] https://git.alpinelinux.org/cgit/abuild/tree/initramfs-init?id=3D9154b0= d9b7251cca900f9e834ac9af9ae2ae61d9 (scan_drivers) [2] http://lists.busybox.net/pipermail/busybox/2015-March/082688.html [3] https://bugzilla.redhat.com/show_bug.cgi?id=3D466607 --Sig_/AUxA6/_mgeP._IxBi/m+hEl Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlq0+ucACgkQ5xo1VCww uqWjAwf/ShXF09RtyD6sKDqunwq6f4RVl1YCwD+UXe4YpocIT2o3tmomD4Fo4ZI5 tXARLYRQLOl0K43+kXiwv2X7LHcFwkw8PSWMG6DoP/qoq9caOFUs5dS/XI/i/dUF AUwck47T9kiEblAJi+rFL2Rkm2HSmAYOkG8nfCg9OmMFWOhIyuObA8YPsL1G+Qb7 uI+p+miA0m9l3QWCNS2eIO5EWKl6gWwHOHqWbyO/s+R6PeAC+vpdLkpCE/KlLgV3 P75p0mx+QMkCagcCfZsY3b4nnUOH3A63xEJ3nPqV7o6XrsND1XNVsnhFcot3bEc6 zdQZsljL1SHX4WcTLaFSBp2B3kEyoA== =YjRi -----END PGP SIGNATURE----- --Sig_/AUxA6/_mgeP._IxBi/m+hEl--