Skip to content

Commit

Permalink
Speed up kernel modules initrd generation if no excludes were specified
Browse files Browse the repository at this point in the history
If no excludes were specified, we can just glob all modules and firmware
without going via modinfo.
  • Loading branch information
DaanDeMeyer committed Mar 6, 2024
1 parent 74c3186 commit 4eac7d0
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions mkosi/kmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,18 @@ def gen_required_kernel_modules(
sandbox: SandboxProtocol = nosandbox,
) -> Iterator[Path]:
modulesd = root / "usr/lib/modules" / kver
modules = filter_kernel_modules(root, kver, include=include, exclude=exclude, host=host)

names = [module_path_to_name(m) for m in modules]
mods, firmware = resolve_module_dependencies(root, kver, names, sandbox=sandbox)
# There is firmware in /usr/lib/firmware that is not depended on by any modules so if any firmware was installed
# we have to take the slow path to make sure we don't copy firmware into the initrd that is not depended on by any
# kernel modules.
if exclude or not (root / "usr/lib/firmware").glob("*"):
modules = filter_kernel_modules(root, kver, include=include, exclude=exclude, host=host)
names = [module_path_to_name(m) for m in modules]
mods, firmware = resolve_module_dependencies(root, kver, names, sandbox=sandbox)
else:
logging.debug("No modules excluded and no firmware installed, using kernel modules generation fast path")
mods = set((modulesd / "kernel").rglob("*.ko*"))
firmware = set(p for p in (root / "usr/lib/firmware").rglob("*") if p.is_file())

yield modulesd.parent
yield modulesd
Expand Down

0 comments on commit 4eac7d0

Please sign in to comment.