Skip to content

Commit

Permalink
perf(drm): group dracut_instmods calls
Browse files Browse the repository at this point in the history
This module loops over many bus devices, and calls `dracut_instmods` for each
one. E.g., on a Lenovo Thinkpad laptop:

```
> for i in /sys/bus/{pci/devices,platform/devices,virtio/devices,soc/devices/soc?,vmbus/devices}/*/modalias; do [[ -e $i ]] && [[ -n $(< "$i") ]]  && echo $i; done | wc -l
79
```

Every call to `dracut_instmods` spawns a `dracut-install` process, which in the
previous example means calling `dracut-install` 79 times using the same
arguments.

If any call to `dracut-install` fails, dracut continues its execution (even the
errors are not shown, because it's called with `--silent`). Therefore, let's
take the contents of all the `modalias` files into an array and call
`dracut-install` only once, adding also the `-o` argument, so if any of the
modules cannot be installed, `dracut-install` does not stop.

(Cherry picked from commit 80f2caf)

Resolves: rhbz#2172269
  • Loading branch information
aafeijoo-suse authored and jannau committed May 20, 2024
1 parent a24e127 commit ceec962
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions modules.d/50drm/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,22 @@ installkernel() {
# as we could e.g. be in the installer; nokmsboot boot parameter will disable
# loading of the driver if needed
if [[ $hostonly ]]; then
local -a _mods
local i modlink modname

for i in /sys/bus/{pci/devices,platform/devices,virtio/devices,soc/devices/soc?,vmbus/devices}/*/modalias; do
[[ -e $i ]] || continue
[[ -n $(< "$i") ]] || continue
# shellcheck disable=SC2046
if hostonly="" dracut_instmods --silent -s "drm_crtc_init|drm_dev_register|drm_encoder_init" -S "iw_handler_get_spy" $(< "$i"); then
if strstr "$(modinfo -F filename $(< "$i") 2> /dev/null)" radeon.ko; then
mapfile -t -O "${#_mods[@]}" _mods < "$i"
done
if ((${#_mods[@]})); then
# shellcheck disable=SC2068
if hostonly="" dracut_instmods --silent -o -s "drm_crtc_init|drm_dev_register|drm_encoder_init" -S "iw_handler_get_spy" ${_mods[@]}; then
if strstr "$(modinfo -F filename "${_mods[@]}" 2> /dev/null)" radeon.ko; then
hostonly='' instmods amdkfd
fi
fi
done
fi
# if there is a privacy screen then its driver must be loaded before the
# kms driver will bind, otherwise its probe() will return -EPROBE_DEFER
# note privacy screens always register, even with e.g. nokmsboot
Expand Down

0 comments on commit ceec962

Please sign in to comment.