Skip to content

Commit 7bb677b

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 78c790e commit 7bb677b

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

kdump-lib.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ fi
1111
FADUMP_ENABLED_SYS_NODE="/sys/kernel/fadump/enabled"
1212
FADUMP_REGISTER_SYS_NODE="/sys/kernel/fadump/registered"
1313
FADUMP_APPEND_ARGS_SYS_NODE="/sys/kernel/fadump/bootargs_append"
14+
maximize_crashkernel=0
1415

1516
is_uki()
1617
{
@@ -41,7 +42,7 @@ is_aws_aarch64()
4142

4243
is_sme_or_sev_active()
4344
{
44-
journalctl -q --dmesg --grep "^Memory Encryption Features active: AMD (SME|SEV)$" >/dev/null 2>&1
45+
$maximize_crashkernel || journalctl -q --dmesg --grep "^Memory Encryption Features active: AMD (SME|SEV)$" >/dev/null 2>&1
4546
}
4647

4748
has_command()
@@ -846,12 +847,18 @@ get_recommend_size()
846847
847848
has_mlx5()
848849
{
849-
[[ -d /sys/bus/pci/drivers/mlx5_core ]]
850+
$maximize_crashkernel || [[ -d /sys/bus/pci/drivers/mlx5_core ]]
850851
}
851852
852853
has_aarch64_smmu()
853854
{
854-
ls /sys/devices/platform/arm-smmu-* 1> /dev/null 2>&1
855+
$maximize_crashkernel || ls /sys/devices/platform/arm-smmu-* 1> /dev/null 2>&1
856+
}
857+
858+
is_aarch64_64k_kernel()
859+
{
860+
local _kernel="$1"
861+
$maximize_crashkernel || echo "$_kernel" | grep -q 64k
855862
}
856863
857864
is_memsize() { [[ "$1" =~ ^[+-]?[0-9]+[KkMmGgTtPbEe]?$ ]]; }
@@ -995,6 +1002,9 @@ kdump_get_arch_recommend_crashkernel()
9951002
local _arch _ck_cmdline _dump_mode
9961003
local _delta=0
9971004
1005+
# osbuild deploys rpm on chroot environment. kdump-utils has no opportunity
1006+
# to deduce the exact memory cost on the real target.
1007+
maximize_crashkernel=$(is_ostree)
9981008
if [[ -z "$1" ]]; then
9991009
if is_fadump_capable; then
10001010
_dump_mode=fadump
@@ -1022,7 +1032,7 @@ kdump_get_arch_recommend_crashkernel()
10221032
fi
10231033
10241034
# the naming convention of 64k variant suffixes with +64k, e.g. "vmlinuz-5.14.0-312.el9.aarch64+64k"
1025-
if echo "$_running_kernel" | grep -q 64k; then
1035+
if is_aarch64_64k_kernel "$_running_kernel"; then
10261036
# Without smmu, the diff of MemFree between 4K and 64K measured on a high end aarch64 machine is 82M.
10271037
# Picking up 100M to cover this diff. And finally, we have "2G-4G:356M;4G-64G:420M;64G-:676M"
10281038
((_delta += 100))

0 commit comments

Comments
 (0)