From 817f53312678153037928344823e2a1f11fd3a69 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Dec 05 2019 12:53:31 +0000 Subject: [PATCH 1/2] kmod.prov: fix and speed it up For kernel builds, /usr/lib/rpm/kmod.prov is fork+execed by rpmbuild in "Processing files:" step about 8000 times, single-threaded, with cumulative run time of ~2 minutes. Speed up this script, by avoiding additional fork+execing. Tested to work, observed speedup: almost exactly 2 times faster. While verifying correctness, noticed that old script was buggy - it was generating a bogus "Provides:" item - kmod(modules.builtin.modinfo), because the logic in script was filtering for */*.ko files and for */modules.builtin* files, and wasn't prepared for the existence of */modules.builtin.modinfo file. Signed-off-by: Denys Vlasenko --- diff --git a/kmod.prov b/kmod.prov index f02d8a0..bbe5aa0 100644 --- a/kmod.prov +++ b/kmod.prov @@ -1,17 +1,28 @@ #!/bin/sh +x +# Kernel build can have many thousands of modules. +# kmod.prov is run for every one of them. +# Try to make this script run as fast as we can. +# For example, use shell string ops instead of external programs +# where possible. IFS=$'\n' -for i in $(grep -E '(/lib/modules/.*\.ko|/lib/modules/.*/modules.builtin)'); -do - kmod=$(basename $i | sed -e 's/.[xg]z//'); +read -r fname || exit - if [ $kmod == "modules.builtin" ]; then - for j in $(cat $i); do - j=$(basename $j); - echo "kmod($j)" - done - else - echo "kmod($kmod)" - fi -done +# Only process files from .../lib/modules/... subtree +[ "${fname#*/lib/modules/*}" != "$fname" ] || exit 0 + +kmod=${fname##*/} # like basename, but faster + +if [ "$kmod" = "modules.builtin" ]; then + for j in $(cat -- "$fname"); do + echo "kmod(${j##*/})" + done + exit 0 +fi + +kmod=${kmod%.gz} +kmod=${kmod%.xz} +if [ "${kmod%.ko}" != "$kmod" ]; then + echo "kmod($kmod)" +fi From 40a9e696d6eb5be97e426bd3bfa334f2bdf15afe Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Dec 05 2019 12:56:00 +0000 Subject: [PATCH 2/2] Bump version Signed-off-by: Denys Vlasenko --- diff --git a/redhat-rpm-config.spec b/redhat-rpm-config.spec index be131d7..c052047 100644 --- a/redhat-rpm-config.spec +++ b/redhat-rpm-config.spec @@ -6,7 +6,7 @@ Summary: Red Hat specific rpm configuration files Name: redhat-rpm-config -Version: 145 +Version: 146 Release: 1%{?dist} # No version specified. License: GPL+ @@ -207,6 +207,9 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora/srpm forge.lua %{_rpmconfigdir}/macros.d/macros.kmp %changelog +* Thu Dec 05 2019 Denys Vlasenko - 146-1 +- kmod.prov: fix and speed it up + * Tue Dec 03 15:48:18 CET 2019 Igor Gnatenko - 145-1 - %%set_build_flags: define LT_SYS_LIBRARY_PATH