-
Notifications
You must be signed in to change notification settings - Fork 21
sysconfig: use initramfs_options to reduce memory usage #130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Starting with Linux 6.18, Fedora 42, RHEL 10.2, and RHEL 9.8, the kernel supports the `initramfs_options` boot parameter. Sets `initramfs_options=size=90%` can increase the size of the tmpfs used for initramfs decompression from the default 50% to 90% of memory. This change greatly reduces memory pressure during decompression, allowing for a reduction in the memory reserved for the crashkernel. Signed-off-by: Lichen Liu <lichliu@redhat.com>
Summary of ChangesHello @licliu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request optimizes system memory usage during the boot process by leveraging the new Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds the initramfs_options=size=90% kernel parameter to reduce memory pressure during kdump initramfs decompression. This is a good improvement for systems with newer kernels.
However, there are a couple of issues to consider:
-
Incorrect Memory Estimation: The
do_estimatefunction inkdumpctlcalculates the recommendedcrashkernelmemory. It contains logic based on the default 50% tmpfs size for initramfs. With your change to 90%, this estimation is no longer accurate and will recommend a much larger memory size than necessary, which counteracts the goal of this PR. The calculation inkdumpctl(line 1610) should be updated to reflect the new tmpfs size. Based on the existing formulas in the code, the multiplier forinitrd_sizeshould probably change from3to approximately2.11(which is1 + 1/0.9). -
Unconditional Parameter: The
initramfs_optionsparameter is added unconditionally. According to the PR description, this is only supported on kernels 6.18 and newer. While older kernels will likely ignore this parameter, it would be cleaner to add it conditionally inkdumpctlbased on the kernel version. This would also allow thedo_estimatefunction to adjust its calculation based on whether the option is actually being used.
Addressing these points would make the change more robust and fully achieve the goal of optimizing memory usage.
| [default]="irqpoll maxcpus=1 reset_devices novmcoredd cma=0 hugetlb_cma=0 initramfs_options=size=90%" | ||
| [aarch64]="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory udev.children-max=2 panic=10 swiotlb=noforce novmcoredd cma=0 hugetlb_cma=0 kfence.sample_interval=0 initramfs_options=size=90%" | ||
| [i386]="irqpoll nr_cpus=1 reset_devices numa=off udev.children-max=2 panic=10 transparent_hugepage=never novmcoredd cma=0 hugetlb_cma=0 kfence.sample_interval=0 initramfs_options=size=90%" | ||
| [ppc64]="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd hugetlb_cma=0 kfence.sample_interval=0 initramfs_options=size=90%" | ||
| [ppc64le]="irqpoll nr_cpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd hugetlb_cma=0 kfence.sample_interval=0 initramfs_options=size=90%" | ||
| [s390x]="nr_cpus=1 cgroup_disable=memory numa=off udev.children-max=2 panic=10 transparent_hugepage=never novmcoredd vmcp_cma=0 cma=0 hugetlb_cma=0 kfence.sample_interval=0 initramfs_options=size=90%" | ||
| [x86_64]="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 acpi_no_memhotplug transparent_hugepage=never nokaslr hest_disable novmcoredd cma=0 hugetlb_cma=0 pcie_ports=compat kfence.sample_interval=0 initramfs_options=size=90%" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The option initramfs_options=size=90% is repeated for every architecture. This creates code duplication and makes future maintenance harder. If this value needs to be changed, it will have to be updated in 7 different places, which is error-prone.
To improve maintainability, you could define this option in a variable and append it programmatically to all entries. For example, you could add a loop after the array definition:
INITRAMFS_OPTS=" initramfs_options=size=90%"
for arch in "${!KDUMP_COMMANDLINE_APPEND[@]}"; do
KDUMP_COMMANDLINE_APPEND[$arch]+=$INITRAMFS_OPTS
doneThis would centralize the option and make the code cleaner and easier to manage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @licliu, to further extend Gemini's idea, how about extracting all values shared by all architectures (something like this commit)? If you think it's a good idea, I will create a PR and address this feedback in that PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @coiby, I think that's great.
|
The older kernels will ignore this option so I think it will not be a big problem. |
Starting with Linux 6.18, Fedora 42, RHEL 10.2, and RHEL 9.8, the kernel supports the
initramfs_optionsboot parameter.Sets
initramfs_options=size=90%can increase the size of the tmpfs used for initramfs decompression from the default 50% to 90% of memory.This change greatly reduces memory pressure during decompression, allowing for a reduction in the memory reserved for the crashkernel.