Recently, it's found 'kdumpctl estimate' returns 512M while the system
reserves 1024M kdump memory in a case. This happens because the ranges
in /proc/iomem are inclusively. For example, "0-1: System RAM" means 2
bytes of system memory other than 1 byte. Fix this error by adding one
more byte.
Note some documentations are added as well.
Reported-by: Ruowen Qin <ruqin(a)redhat.com>
Fixes: 1813189 ("kdump-lib.sh: introduce functions to return recommened mem
size")
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
---
kdump-lib.sh | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 557eff6..f34f477 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -788,19 +788,26 @@ prepare_cmdline()
echo "$cmdline"
}
-#get system memory size in the unit of GB
+#get system memory size i.e. memblock.memory.total_size in the unit of GB
get_system_size()
{
result=$(grep "System RAM" /proc/iomem | awk -F ":" '{ print $1
}' | tr "[:lower:]" "[:upper:]" | paste -sd+)
result="+$result"
# replace '-' with '+0x' and '+' with '-0x'
- sum=$(echo "$result" | sed -e 's/-/K0x/g' -e 's/+/-0x/g' -e
's/K/+/g')
+ sum=$(echo "$result" | sed -e 's/-/K0x/g' -e 's/+/-0x/g' -e
's/K/+01+/g')
size=$(printf "%d\n" $((sum)))
size=$((size / 1024 / 1024 / 1024))
echo "$size"
}
+# Return the memory size given the system memory size and
+# crashkernel=range1:size1[,range2:size2,…].
+#
+# This functions is expected to be consisteng with the reserve_crashkernel() in
+# kernel.
+#
+# Note the ranges of crashkernel should be in increasing order.
get_recommend_size()
{
local mem_size=$1
--
2.35.1
Show replies by date