From 97ec3f19c1f74ede6569acfceb5b6ab62f20db66 Mon Sep 17 00:00:00 2001 From: Lichen Liu Date: Mon, 14 Apr 2025 10:36:15 +0800 Subject: [PATCH] kdump-lib.sh: rounded up the total_mem to 128M in get_system_size Resolves: RHEL-83645 Upstream: kdump-utils commit 18fc5b7e7b89ee3caba04ce18bf32036aa19da6e Author: Lichen Liu Date: Fri Mar 7 12:22:05 2025 +0800 kdump-lib.sh: rounded up the total_mem to 128M in get_system_size The kernel code to calculate reserving size rounded up the total_mem because usually the memblock usable mem size is smaller than the physical dimm memory size: total_mem = roundup(total_mem, SZ_128M); This patch is aimed to align with the kernel's behavior. A machine showing 4000MB of total memory will be treated as having 4G instead of 3G memory. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2306493 Signed-off-by: Lichen Liu Signed-off-by: Lichen Liu --- kdump-lib.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 813c580..8a51722 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -949,8 +949,11 @@ PROC_IOMEM=/proc/iomem #get system memory size i.e. memblock.memory.total_size in the unit of GB get_system_size() { - sum=$(sed -n "s/\s*\([0-9a-fA-F]\+\)-\([0-9a-fA-F]\+\) : System RAM$/+ 0x\2 - 0x\1 + 1/p" $PROC_IOMEM) - echo $(( (sum) / 1024 / 1024 / 1024)) + local _mem_size_mb _sum + _sum=$(sed -n "s/\s*\([0-9a-fA-F]\+\)-\([0-9a-fA-F]\+\) : System RAM$/+ 0x\2 - 0x\1 + 1/p" $PROC_IOMEM) + _mem_size_mb=$(( (_sum) / 1024 / 1024 )) + # rounding up the total_size to 128M to align with kernel code kernel/crash_reserve.c + echo $(((_mem_size_mb + 127) / 128 * 128 / 1024 )) } # Return the recommended size for the reserved crashkernel memory