Skip to content

Commit 2d34ae4

Browse files
author
Pingfan Liu
committed
crashkernel: Maximize the reserved size in osbuild case
At present, the deduction of the proper crashkernel value depends on detecting platform details. However, more and more platforms are now deployed using OSTree images, which means kdump-utils cannot retrieve complete platform information. This often leads to an underestimation of the memory required by the kdump kernel, increasing the risk of out-of-memory (OOM) issues. To mitigate this situation, we choose to maximize the reserved crashkernel size in the osbuild case, and recommend users to update the kernel command line and release the excess reserved memory after reboot (addressed in the next patch). Signed-off-by: Pingfan Liu <[email protected]>
1 parent c3e6ee8 commit 2d34ae4

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

kdump-lib.sh

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ FADUMP_REGISTER_SYS_NODE="/sys/kernel/fadump/registered"
1616
FADUMP_APPEND_ARGS_SYS_NODE="/sys/kernel/fadump/bootargs_append"
1717
# shellcheck disable=SC2034
1818
FENCE_KDUMP_CONFIG_FILE="/etc/sysconfig/fence_kdump"
19+
maximize_crashkernel=false
1920

2021
is_fadump_capable()
2122
{
@@ -35,7 +36,7 @@ is_aws_aarch64()
3536

3637
is_sme_or_sev_active()
3738
{
38-
journalctl -q --dmesg --grep "^Memory Encryption Features active: AMD (SME|SEV)$" > /dev/null 2>&1
39+
$maximize_crashkernel || journalctl -q --dmesg --grep "^Memory Encryption Features active: AMD (SME|SEV)$" > /dev/null 2>&1
3940
}
4041

4142
# read the value of an environ variable from given environ file path
@@ -850,12 +851,19 @@ get_recommend_size()
850851
851852
has_mlx5()
852853
{
853-
[[ -d /sys/bus/pci/drivers/mlx5_core ]]
854+
$maximize_crashkernel || [[ -d /sys/bus/pci/drivers/mlx5_core ]]
854855
}
855856
856857
has_aarch64_smmu()
857858
{
858-
ls /sys/devices/platform/arm-smmu-* 1> /dev/null 2>&1
859+
$maximize_crashkernel || ls /sys/devices/platform/arm-smmu-* 1> /dev/null 2>&1
860+
}
861+
862+
is_aarch64_64k_kernel()
863+
{
864+
local _kernel="$1"
865+
# the naming convention of 64k variant suffixes with +64k, e.g. "vmlinuz-5.14.0-312.el9.aarch64+64k"
866+
$maximize_crashkernel || echo "$_kernel" | grep -q 64k
859867
}
860868
861869
is_memsize()
@@ -1010,6 +1018,9 @@ kdump_get_arch_recommend_crashkernel()
10101018
local _delta=0
10111019
local _skip=0
10121020
1021+
# osbuild deploys rpm on isolated environment. kdump-utils has no opportunity
1022+
# to deduce the exact memory cost on the real target.
1023+
_is_osbuild && maximize_crashkernel=true
10131024
if [[ -z $1 ]]; then
10141025
if is_fadump_capable; then
10151026
_dump_mode=fadump
@@ -1038,8 +1049,7 @@ kdump_get_arch_recommend_crashkernel()
10381049
# skip adding additional memory for small-memory machine
10391050
_skip=1
10401051
1041-
# the naming convention of 64k variant suffixes with +64k, e.g. "vmlinuz-5.14.0-312.el9.aarch64+64k"
1042-
if echo "$_running_kernel" | grep -q 64k; then
1052+
if is_aarch64_64k_kernel "$_running_kernel"; then
10431053
# Without smmu, the diff of MemFree between 4K and 64K measured on a high end aarch64 machine is 82M.
10441054
# Picking up 100M to cover this diff. And finally, we have "2G-4G:356M;4G-64G:420M;64G-:676M"
10451055
((_delta += 100))

0 commit comments

Comments
 (0)