kdump-lib.sh: kdump_get_arch_recommend_size uses crashkernel.default

Resolves: bz1986281
Conflict: None
Upstream: Fedora

commit 7b7ddaba88
Author: Kairui Song <kasong@redhat.com>
Date:   Fri Jul 2 01:31:26 2021 +0800

    kdump-lib.sh: kdump_get_arch_recommend_size uses crashkernel.default

    The new `crashkernel.default` file in kernel package can be used as the
    ck_cmdline source.

    Also keep the legacy code so old kernel packages will still work.

    Signed-off-by: Kairui Song <kasong@redhat.com>
    Acked-by: Pingfan Liu <piliu@redhat.com>

Signed-off-by: Kairui Song <kasong@redhat.com>
This commit is contained in:
Kairui Song 2021-07-02 01:31:26 +08:00
parent 0ef6c1aa27
commit abb0c38b7f

View File

@ -943,31 +943,40 @@ get_recommend_size()
}
# return recommended size based on current system RAM size
# $1: kernel version, if not set, will defaults to `uname -r`
kdump_get_arch_recommend_size()
{
if ! [[ -r "/proc/iomem" ]] ; then
local kernel=$1 arch
if ! [ -r "/proc/iomem" ] ; then
echo "Error, can not access /proc/iomem."
return 1
fi
arch=$(lscpu | grep Architecture | awk -F ":" '{ print $2 }' | tr [:lower:] [:upper:])
if [ $arch == "X86_64" ] || [ $arch == "S390X" ]; then
ck_cmdline="1G-4G:160M,4G-64G:192M,64G-1T:256M,1T-:512M"
elif [ $arch == "AARCH64" ]; then
ck_cmdline="2G-:448M"
elif [ $arch == "PPC64LE" ]; then
if is_fadump_capable; then
ck_cmdline="4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-:180G"
else
ck_cmdline="2G-4G:384M,4G-16G:512M,16G-64G:1G,64G-128G:2G,128G-:4G"
[ -z "$kernel" ] && kernel=$(uname -r)
ck_cmdline=$(cat "/usr/lib/modules/$kernel/crashkernel.default" 2>/dev/null)
if [ -n "$ck_cmdline" ]; then
ck_cmdline=${ck_cmdline#crashkernel=}
else
arch=$(lscpu | grep Architecture | awk -F ":" '{ print $2 }' | tr '[:lower:]' '[:upper:]')
if [ "$arch" = "X86_64" ] || [ "$arch" = "S390X" ]; then
ck_cmdline="1G-4G:160M,4G-64G:192M,64G-1T:256M,1T-:512M"
elif [ "$arch" = "AARCH64" ]; then
ck_cmdline="2G-:448M"
elif [ "$arch" = "PPC64LE" ]; then
if is_fadump_capable; then
ck_cmdline="4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-:180G"
else
ck_cmdline="2G-4G:384M,4G-16G:512M,16G-64G:1G,64G-128G:2G,128G-:4G"
fi
fi
fi
ck_cmdline=$(echo $ck_cmdline | sed -e 's/-:/-102400T:/g')
sys_mem=$(get_system_size)
result=$(get_recommend_size $sys_mem "$ck_cmdline")
echo $result
return 0
get_recommend_size "$sys_mem" "$ck_cmdline"
}
# Print all underlying crypt devices of a block device