testing optimizations for labsconf 2021 talk - #47
Open
mwilck wants to merge 18 commits into
Open
Conversation
mwilck
commented
Oct 1, 2021
Contributor
- labsconf 2021 debugging / profiling
- weak-modules2: remove pointless debug statements in add_kmp_modules
- weak-modules2: skip "test" call to has_unresolved_symbols
- weak-modules2: try incremental depmod in has_unresolved_symbols
- weak-modules2: remove_kmp(): drop inconsistency test
- weak-modules2: sanitize "kernel" logic
- weak-modules2: split run_depmod() and build_initrd()
- weak-modules2: incremental depmod in run_depmod with WM2_DEPMOD_INC
- weak-modules2: use needs_initrd for kernel subpackages
- weak-modules2: factor out get_image_name()
- weak-modules2: honor INITRD_IN_POSTTRANS for kernel packages
mwilck
force-pushed
the
labsconf
branch
3 times, most recently
from
October 4, 2021 20:30
8d58308 to
7d53d44
Compare
mwilck
force-pushed
the
master
branch
3 times, most recently
from
June 2, 2022 07:56
5a09721 to
37cfee6
Compare
... and remove_kmp_modules
The first call is supposed to check whether the kernel at hand is in an inconsistent state before adding the KMP. But this is a very rare situation; has_unresolved_symbols() is a slow operation (calling depmod) and should thus not be called without good reason. If adding the kmp failed and OPT_DEBUG=1, we carry out this operation to provide a clue to users.
Fall back to full depmod if this fails
This test is bogus because remove_kmp() is called after the actual package removal. The symlinks may still be present, but either point to a different KMP, or be stale.
Rather than reading "_kernel_" from stdin, use a function argument.
With initrd in posttrans and incremental depmod, the logic for depmod and initrd rebuilding will become different.
This requires copying modules.* to the temporary dir, too.
Like for KMPs, the information whether modules are present in the initrd is also valuable for deciding if the intird must be rebuilt for kernel subpackages. For the time being, we always set the _kernel_ flag, forcing the initrd to be rebuilt for these packages, too.
With this patch, if the $INITRD_IN_POSTTRANS environment variable is set in weak-modules2's environment, it will postpone the rebuilding of the initramfs to the %posttrans stage if possible. Also, for kernel subpackages like -extra or -optional, the initrd rebuild will only be triggered if it's necessary (i.e. if the current initrd contains at least one of the modules in the package).
We are removing modules here which might be in the initrd. We can derive kernel-modules and kernel-basenames like we do in add_kmp_modules. Why don't we do it? The common case by far is that kernel subpackages are removed or updated together with the base package. In that case, rebuilding the initrd in %postun of the subpackage is just a waste, as the kernel will be uninstalled anyway. In %postun we can't figure out whether or not the base package will also be uninstalled. If it's not, in the worst case, some modules will be kept in initramfs that are no longer installed on the system itself. That shouldn't hurt. By not rebuilding the initrd here, we speed up the common case. We have to call depmod though, in order to make sure that the module dependency database doesn't hold stale references to uninstalled modules.
depmod ignores modules that are not in the search path of the kernel being worked on (which holds for the symlink targets in case of weak modules). We must pass the full path of the symlink. Using bash namerefs for this purpose. https://stackoverflow.com/questions/10582763/how-to-return-an-array-in-bash-without-using-globals
Iterate over all installed kernels explicitly instead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.