Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

modules: add CONFIG_MODPROBE_PATH

Allow the developer to specifiy the initial value of the modprobe_path[]
string. This can be used to set it to the empty string initially, thus
effectively disabling request_module() during early boot until userspace
writes a new value via the /proc/sys/kernel/modprobe interface. [1]

When building a custom kernel (often for an embedded target), it's normal
to build everything into the kernel that is needed for booting, and indeed
the initramfs often contains no modules at all, so every such
request_module() done before userspace init has mounted the real rootfs is
a waste of time.

This is particularly useful when combined with the previous patch, which
made the initramfs unpacking asynchronous - for that to work, it had to
make any usermodehelper call wait for the unpacking to finish before
attempting to invoke the userspace helper. By eliminating all such
(known-to-be-futile) calls of usermodehelper, the initramfs unpacking and
the {device,late}_initcalls can proceed in parallel for much longer.

For a relatively slow ppc board I'm working on, the two patches combined
lead to 0.2s faster boot - but more importantly, the fact that the
initramfs unpacking proceeds completely in the background while devices
get probed means I get to handle the gpio watchdog in time without getting
reset.

[1] __request_module() already has an early -ENOENT return when
modprobe_path is the empty string.

Link: https://lkml.kernel.org/r/20210313212528.2956377-3-linux@rasmusvillemoes.dk
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Jessica Yu <jeyu@kernel.org>
Acked-by: Luis Chamberlain <mcgrof@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Rasmus Villemoes and committed by
Linus Torvalds
17652f42 e7cb072e

+13 -1
+12
init/Kconfig
··· 2299 2299 2300 2300 If unsure, say N. 2301 2301 2302 + config MODPROBE_PATH 2303 + string "Path to modprobe binary" 2304 + default "/sbin/modprobe" 2305 + help 2306 + When kernel code requests a module, it does so by calling 2307 + the "modprobe" userspace utility. This option allows you to 2308 + set the path where that binary is found. This can be changed 2309 + at runtime via the sysctl file 2310 + /proc/sys/kernel/modprobe. Setting this to the empty string 2311 + removes the kernel's ability to request modules (but 2312 + userspace can still load modules explicitly). 2313 + 2302 2314 config TRIM_UNUSED_KSYMS 2303 2315 bool "Trim unused exported kernel symbols" if EXPERT 2304 2316 depends on !COMPILE_TEST
+1 -1
kernel/kmod.c
··· 58 58 /* 59 59 modprobe_path is set via /proc/sys. 60 60 */ 61 - char modprobe_path[KMOD_PATH_LEN] = "/sbin/modprobe"; 61 + char modprobe_path[KMOD_PATH_LEN] = CONFIG_MODPROBE_PATH; 62 62 63 63 static void free_modprobe_argv(struct subprocess_info *info) 64 64 {