From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 12 18:15:13 2018 Received: (at 30604) by debbugs.gnu.org; 12 Mar 2018 22:15:13 +0000 Received: from localhost ([127.0.0.1]:57764 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1evVir-0005Rc-GU for submit@debbugs.gnu.org; Mon, 12 Mar 2018 18:15:13 -0400 Received: from hera.aquilenet.fr ([185.233.100.1]:54978) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1evVio-0005RT-KP for 30604@debbugs.gnu.org; Mon, 12 Mar 2018 18:15:11 -0400 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id B844B12478; Mon, 12 Mar 2018 23:15:09 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PWm2jtYsnegY; Mon, 12 Mar 2018 23:15:08 +0100 (CET) Received: from ribbon (vpn-0-27.aquilenet.fr [IPv6:2a0c:e300:4:27::]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 1F0B212456; Mon, 12 Mar 2018 23:15:08 +0100 (CET) From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) To: Danny Milosavljevic Subject: Re: [bug#30604] [PATCH v10 5/6] linux-initrd: Provide our own 'modprobe' program. References: <87ina1qxic.fsf@gnu.org> <20180312123918.22645-1-ludo@gnu.org> <20180312123918.22645-5-ludo@gnu.org> <20180312210936.7f89a29c@scratchpost.org> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 22 =?utf-8?Q?Vent=C3=B4se?= an 226 de la =?utf-8?Q?R?= =?utf-8?Q?=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Mon, 12 Mar 2018 23:14:59 +0100 In-Reply-To: <20180312210936.7f89a29c@scratchpost.org> (Danny Milosavljevic's message of "Mon, 12 Mar 2018 21:09:36 +0100") Message-ID: <87h8plkkkc.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 1.0 (+) 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: 1.0 (+) Howdy! Danny Milosavljevic skribis: > On Mon, 12 Mar 2018 13:39:17 +0100 > Ludovic Court=C3=A8s wrote: > >> + (when modprobe >> + ;; Tell the kernel to invoke MODPROBE. >> + (call-with-output-file "/proc/sys/kernel/modprobe" >> + (lambda (port) >> + (display modprobe port)))) >> + >> (display "loading kernel modules...\n") > > There's a race because Linux could just start loading modules > immediately before boot-system even starts / executed far enough. > > That was why earlier I kept /sbin/modprobe as the name (it's the > default Linux uses) and made sure that the file /sbin/modprobe is already > in the initrd (as opposed to created by boot-system). > > The race didn't happen to me yet (and I doubt that Linux has modules > fine-grained enough that that's a problem in practise) - but I would pref= er > it not to be possible. > > WDYT? You=E2=80=99re right, I wondered what would happen. I=E2=80=99ve restored = the /sbin/modprobe symlink in v11. >> + (define aliases >> + ;; The list of aliases we are asked to load. >> + (filter-map (match-lambda >> + (('argument . alias) alias) >> + (_ #f)) >> + options)) > > Without "-a", it's not supposed to be a list of aliases. It's supposed t= o be > one alias and the remainder are parameters supposed to be passed to that > kernel module. > > (I didn't know that before). > > When Linux invokes /sbin/modprobe, it doesn't pass "-a" but it doesn't > pass any module parameters either - it just passes one module alias. > > For clarity and in order that we don't have weird problems later (trying = to > load a module named "verbose=3D1" or something :) ), let's just accept on= e alias > for now. Indeed, done in v11. >>+(define* (modprobe-program linux-module-directory #:key >>+ (guile %guile-static-stripped)) > [...] >> + (call-with-output-file "/dev/kmsg" >> + (lambda (port) >> + (format port "modprobe[~a]: aliases ~s; modules ~s; arg= s ~s~%" >> + (getpid) aliases modules (program-arguments)))) > > Hmm, logging is nice! I didn=E2=80=99t mean to leave it, but after all, it=E2=80=99s pretty usefu= l. :-) > But with /dev/kmsg one write(2) syscall needs to pass the entire message. > > What do you think about additionally calling setvbuf with 1024 ? Because: Sure. >> + (write-module-alias-database #$output)))) > > One of the devnames created statically is the one for btrfs, so not writi= ng or > using devnames is not going to end well. We=E2=80=99re fine because btrfs, 9p, overlay, etc. all have an =E2=80=9Cfs= -btrfs=E2=80=9D, =E2=80=9Cfs-9p=E2=80=9D, etc. alias, which shows up in =E2=80=9Cmodules.ali= as=E2=80=9D. No need for =E2=80=9Cmodules.devname=E2=80=9D AFAICS. > (I'd also copy the modules.builtin (from Linux). > Also, what happens if we load a module which has as dependency a builtin? > Will we try to load the builtin as a .ko file and fail the entire thing?) The dependency of a builtin is necessarily a builtin, and the kernel won=E2=80=99t invoke modprobe for a builtin, will it? IOW, I think there= =E2=80=99s no problem here. :-) >> + ;; We may need to lazy-load modules. The initrd installs a > > Nitpick: "kernel modules" (to clarify). Fixed. Thanks for the insightful review! Ludo=E2=80=99.