Skip to content

Commit b36fca0

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 3c2f7ec commit b36fca0

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
# read the value of an environ variable from given environ file path
2122
#
@@ -65,7 +66,7 @@ is_aws_aarch64()
6566

6667
is_sme_or_sev_active()
6768
{
68-
journalctl -q --dmesg --grep "^Memory Encryption Features active: AMD (SME|SEV)$" > /dev/null 2>&1
69+
$maximize_crashkernel || journalctl -q --dmesg --grep "^Memory Encryption Features active: AMD (SME|SEV)$" > /dev/null 2>&1
6970
}
7071

7172
has_command()
@@ -873,12 +874,19 @@ get_recommend_size()
873874
874875
has_mlx5()
875876
{
876-
[[ -d /sys/bus/pci/drivers/mlx5_core ]]
877+
$maximize_crashkernel || [[ -d /sys/bus/pci/drivers/mlx5_core ]]
877878
}
878879
879880
has_aarch64_smmu()
880881
{
881-
ls /sys/devices/platform/arm-smmu-* 1> /dev/null 2>&1
882+
$maximize_crashkernel || ls /sys/devices/platform/arm-smmu-* 1> /dev/null 2>&1
883+
}
884+
885+
is_aarch64_64k_kernel()
886+
{
887+
local _kernel="$1"
888+
# the naming convention of 64k variant suffixes with +64k, e.g. "vmlinuz-5.14.0-312.el9.aarch64+64k"
889+
$maximize_crashkernel || echo "$_kernel" | grep -q 64k
882890
}
883891
884892
is_memsize()
@@ -1033,6 +1041,9 @@ kdump_get_arch_recommend_crashkernel()
10331041
local _delta=0
10341042
local _skip=0
10351043
1044+
# osbuild deploys rpm on isolated environment. kdump-utils has no opportunity
1045+
# to deduce the exact memory cost on the real target.
1046+
_is_osbuild && maximize_crashkernel=true
10361047
if [[ -z $1 ]]; then
10371048
if is_fadump_capable; then
10381049
_dump_mode=fadump
@@ -1061,8 +1072,7 @@ kdump_get_arch_recommend_crashkernel()
10611072
# skip adding additional memory for small-memory machine
10621073
_skip=1
10631074
1064-
# the naming convention of 64k variant suffixes with +64k, e.g. "vmlinuz-5.14.0-312.el9.aarch64+64k"
1065-
if echo "$_running_kernel" | grep -q 64k; then
1075+
if is_aarch64_64k_kernel "$_running_kernel"; then
10661076
# Without smmu, the diff of MemFree between 4K and 64K measured on a high end aarch64 machine is 82M.
10671077
# Picking up 100M to cover this diff. And finally, we have "2G-4G:356M;4G-64G:420M;64G-:676M"
10681078
((_delta += 100))

0 commit comments

Comments
 (0)