Skip to content

Commit 7af341e

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 3a5ab86 commit 7af341e

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
has_command()
@@ -832,12 +833,19 @@ get_recommend_size()
832833
833834
has_mlx5()
834835
{
835-
[[ -d /sys/bus/pci/drivers/mlx5_core ]]
836+
$maximize_crashkernel || [[ -d /sys/bus/pci/drivers/mlx5_core ]]
836837
}
837838
838839
has_aarch64_smmu()
839840
{
840-
ls /sys/devices/platform/arm-smmu-* 1> /dev/null 2>&1
841+
$maximize_crashkernel || ls /sys/devices/platform/arm-smmu-* 1> /dev/null 2>&1
842+
}
843+
844+
is_aarch64_64k_kernel()
845+
{
846+
local _kernel="$1"
847+
# the naming convention of 64k variant suffixes with +64k, e.g. "vmlinuz-5.14.0-312.el9.aarch64+64k"
848+
$maximize_crashkernel || echo "$_kernel" | grep -q 64k
841849
}
842850
843851
is_memsize()
@@ -992,6 +1000,9 @@ kdump_get_arch_recommend_crashkernel()
9921000
local _delta=0
9931001
local _skip=0
9941002
1003+
# osbuild deploys rpm on isolated environment. kdump-utils has no opportunity
1004+
# to deduce the exact memory cost on the real target.
1005+
_is_osbuild && maximize_crashkernel=true
9951006
if [[ -z $1 ]]; then
9961007
if is_fadump_capable; then
9971008
_dump_mode=fadump
@@ -1020,8 +1031,7 @@ kdump_get_arch_recommend_crashkernel()
10201031
# skip adding additional memory for small-memory machine
10211032
_skip=1
10221033
1023-
# the naming convention of 64k variant suffixes with +64k, e.g. "vmlinuz-5.14.0-312.el9.aarch64+64k"
1024-
if echo "$_running_kernel" | grep -q 64k; then
1034+
if is_aarch64_64k_kernel "$_running_kernel"; then
10251035
# Without smmu, the diff of MemFree between 4K and 64K measured on a high end aarch64 machine is 82M.
10261036
# Picking up 100M to cover this diff. And finally, we have "2G-4G:356M;4G-64G:420M;64G-:676M"
10271037
((_delta += 100))

0 commit comments

Comments
 (0)