Bug 1794491

Summary: Fix and speed up /usr/lib/rpm/kmod.prov
Product: Red Hat Enterprise Linux 8 Reporter: Denys Vlasenko <dvlasenk>
Component: redhat-rpm-configAssignee: Florian Festi <ffesti>
Status: CLOSED ERRATA QA Contact: Luca Berton <lberton>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.0CC: ffesti, fweimer, lberton, mdomonko, packaging-team-maint, rbiba
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: 8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: redhat-rpm-config-123-1.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-04 04:10:37 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Denys Vlasenko 2020-01-23 17:25:42 UTC
Please backport the fix from Fedora BZ 1775790:

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.

Ideally rpmbuild should be changed to parallelize this, but it's not trivial to implement.

The fix in Fedora, meanwhile, speeds up the script, by avoiding additional fork+execing. The new kmod.prov is:

#!/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'

read -r fname || exit

# 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

Comment 9 errata-xmlrpc 2020-11-04 04:10:37 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (redhat-rpm-config bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2020:4825