Skip to content

Commit 2494f96

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 063548f commit 2494f96

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

kdump-lib.sh

Lines changed: 28 additions & 4 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_uki()
2122
{
@@ -46,7 +47,7 @@ is_aws_aarch64()
4647

4748
is_sme_or_sev_active()
4849
{
49-
journalctl -q --dmesg --grep "^Memory Encryption Features active: AMD (SME|SEV)$" > /dev/null 2>&1
50+
$maximize_crashkernel || journalctl -q --dmesg --grep "^Memory Encryption Features active: AMD (SME|SEV)$" > /dev/null 2>&1
5051
}
5152

5253
has_command()
@@ -273,6 +274,20 @@ is_ostree()
273274
test -f /run/ostree-booted
274275
}
275276

277+
# Decide whether it runs in sandbox or not
278+
is_osbuild()
279+
{
280+
local _init_comm
281+
282+
_init_comm=$(ps -p 1 -o comm= 2>/dev/null || echo "unknown")
283+
# no real init in isolated env
284+
if [[ "$init_comm" != "systemd" ]]; then
285+
return 0
286+
fi
287+
288+
return 1
289+
}
290+
276291
# get ip address or hostname from nfs/ssh config value
277292
get_remote_host()
278293
{
@@ -854,12 +869,18 @@ get_recommend_size()
854869
855870
has_mlx5()
856871
{
857-
[[ -d /sys/bus/pci/drivers/mlx5_core ]]
872+
$maximize_crashkernel || [[ -d /sys/bus/pci/drivers/mlx5_core ]]
858873
}
859874
860875
has_aarch64_smmu()
861876
{
862-
ls /sys/devices/platform/arm-smmu-* 1> /dev/null 2>&1
877+
$maximize_crashkernel || ls /sys/devices/platform/arm-smmu-* 1> /dev/null 2>&1
878+
}
879+
880+
is_aarch64_64k_kernel()
881+
{
882+
local _kernel="$1"
883+
$maximize_crashkernel || echo "$_kernel" | grep -q 64k
863884
}
864885
865886
is_memsize()
@@ -1006,6 +1027,9 @@ kdump_get_arch_recommend_crashkernel()
10061027
local _arch _ck_cmdline _dump_mode
10071028
local _delta=0
10081029
1030+
# osbuild deploys rpm on isolated environment. kdump-utils has no opportunity
1031+
# to deduce the exact memory cost on the real target.
1032+
is_osbuild && maximize_crashkernel=true
10091033
if [[ -z $1 ]]; then
10101034
if is_fadump_capable; then
10111035
_dump_mode=fadump
@@ -1033,7 +1057,7 @@ kdump_get_arch_recommend_crashkernel()
10331057
fi
10341058
10351059
# the naming convention of 64k variant suffixes with +64k, e.g. "vmlinuz-5.14.0-312.el9.aarch64+64k"
1036-
if echo "$_running_kernel" | grep -q 64k; then
1060+
if is_aarch64_64k_kernel "$_running_kernel"; then
10371061
# Without smmu, the diff of MemFree between 4K and 64K measured on a high end aarch64 machine is 82M.
10381062
# Picking up 100M to cover this diff. And finally, we have "2G-4G:356M;4G-64G:420M;64G-:676M"
10391063
((_delta += 100))

0 commit comments

Comments
 (0)