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 <dvlasenk@redhat.com>
This commit is contained in:
parent
2721f1c528
commit
817f533126
35
kmod.prov
35
kmod.prov
@ -1,17 +1,28 @@
|
|||||||
#!/bin/sh +x
|
#!/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'
|
IFS=$'\n'
|
||||||
|
|
||||||
for i in $(grep -E '(/lib/modules/.*\.ko|/lib/modules/.*/modules.builtin)');
|
read -r fname || exit
|
||||||
do
|
|
||||||
kmod=$(basename $i | sed -e 's/.[xg]z//');
|
|
||||||
|
|
||||||
if [ $kmod == "modules.builtin" ]; then
|
# Only process files from .../lib/modules/... subtree
|
||||||
for j in $(cat $i); do
|
[ "${fname#*/lib/modules/*}" != "$fname" ] || exit 0
|
||||||
j=$(basename $j);
|
|
||||||
echo "kmod($j)"
|
kmod=${fname##*/} # like basename, but faster
|
||||||
done
|
|
||||||
else
|
if [ "$kmod" = "modules.builtin" ]; then
|
||||||
echo "kmod($kmod)"
|
for j in $(cat -- "$fname"); do
|
||||||
fi
|
echo "kmod(${j##*/})"
|
||||||
done
|
done
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
kmod=${kmod%.gz}
|
||||||
|
kmod=${kmod%.xz}
|
||||||
|
if [ "${kmod%.ko}" != "$kmod" ]; then
|
||||||
|
echo "kmod($kmod)"
|
||||||
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user