On Fri, May 26, 2023 at 11:41 PM Philipp Rudo <prudo(a)redhat.com> wrote:
Hi Pinfang,
On Wed, 24 May 2023 23:40:41 +0800
Pingfan Liu <piliu(a)redhat.com> wrote:
> From: Pingfan Liu <piliu at redhat.com>
>
> On aarch64, both 4K and 64K kernel can be installed, while they demand
> different size reserved memory for kdump kernel.
>
> 'get_conf PAGE_SIZE' can not work if installing a 64K kernel when
> running a 4K kernel. Hence resorting to the kernel release naming rules.
> At present, the 64K kernel has the keyword '64k' in its suffix.
>
> The base line for 64K is decided based on 4K. The diff 100M is picked up
> since on a high end machine without smmu enabled, the diff of MemFree is
> 82M.
>
> As for the smmu case, a huge difference in the memory consumption lies
> between 64k and 4k driver. And it should be calculated separatedly.
>
> Signed-off-by: Pingfan Liu <piliu(a)redhat.com>
> ---
> kdump-lib.sh | 21 ++++++++++++++++++++-
> kdumpctl | 3 ++-
> 2 files changed, 22 insertions(+), 2 deletions(-)
>
> diff --git a/kdump-lib.sh b/kdump-lib.sh
> index 992e8d9..a496b75 100755
> --- a/kdump-lib.sh
> +++ b/kdump-lib.sh
> @@ -846,6 +846,7 @@ _crashkernel_add()
>
> # get default crashkernel
> # $1 dump mode, if not specified, dump_mode will be judged by is_fadump_capable
> +# $2 kernel-release, if not specified, got by _get_kdump_kernel_version
^^^^^^^^^^^^^^
see comment below
> kdump_get_arch_recommend_crashkernel()
> {
> local _arch _ck_cmdline _dump_mode
> @@ -865,8 +866,26 @@ kdump_get_arch_recommend_crashkernel()
> if [[ $_arch == "x86_64" ]] || [[ $_arch == "s390x" ]];
then
> _ck_cmdline="1G-4G:192M,4G-64G:256M,64G-:512M"
> elif [[ $_arch == "aarch64" ]]; then
> - # For 4KB page size, the formula is based on x86 plus extra = 64M
> + local _running_kernel
> + local _delta=0
> +
> + # Base line for 4K variant kernel. The formula is based on x86 plus
extra = 64M
> _ck_cmdline="1G-4G:256M,4G-64G:320M,64G-:576M"
> + if [[ -z "$2" ]]; then
> + _running_kernel=$(_get_kdump_kernel_version)
> + else
> + _running_kernel=$2
> + fi
> +
> + # the naming convention of 64k variant suffixes with +64k, e.g.
"vmlinuz-5.14.0-312.el9.aarch64+64k"
> + if echo "$_running_kernel" | grep -q 64k; then
> + # Without smmu, the diff of MemFree between 4K and 64K
measured on a high end aarch64 machine is 82M.
> + # Picking up 100M to cover this diff. And finally, we have
"1G-4G:356M;4G-64G:420M;64G-:676M"
> + ((_delta += 100))
> + else
> + ((_delta += 0))
> + fi
> + _ck_cmdline=$(_crashkernel_add "$_ck_cmdline"
"$_delta")
> elif [[ $_arch == "ppc64le" ]]; then
> if [[ $_dump_mode == "fadump" ]]; 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"
> diff --git a/kdumpctl b/kdumpctl
> index bfd170a..5c55a6a 100755
> --- a/kdumpctl
> +++ b/kdumpctl
> @@ -1682,7 +1682,8 @@ _update_crashkernel()
> _kernel=$1
> _dump_mode=$(get_dump_mode_by_kernel "$_kernel")
> _old_default_crashkernel=$(get_grub_kernel_boot_parameter "$_kernel"
crashkernel)
> - _new_default_crashkernel=$(kdump_get_arch_recommend_crashkernel
"$_dump_mode")
> + # The second argument is for the case of aarch64, where installing a 64k
variant on a 4k kernel, or vice versa
> + _new_default_crashkernel=$(kdump_get_arch_recommend_crashkernel
"$_dump_mode" "$_kernel")
in _update_crashkernel _kernel is the path to the image, not the kernel
version as requested in kdump_get_arch_recommend_size. This shouldn't
cause a problem at the moment as the image name contains the version.
But I'm afraid this will cause confusion in the future.
It is rigorous. I tend to do this way.
AFAIK there is no easy way to parse the version from a kernel image
yet. But I have the function below on one of my local branches. If you
like you can use it.
Thanks and I will use it.
Pingfan
Thanks
Philipp
_is_valid_kver()
{
[[ -f /usr/lib/modules/$1/modules.dep ]]
}
_parse_kver()
{
local _img _kver
[[ -z "$1" ]] && return
_img=$1
BLS_ENTRY_TOKEN=$(</etc/machine-id)
# Fedora standard installation, i.e. $BOOT/vmlinuz-<version>
_kver=${_img##*/vmlinuz-}
_kver=${_kver%$KDUMP_IMG_EXT}
if _is_valid_kver $_kver; then
echo $_kver
return
fi
# BLS recommended image names, i.e. $BOOT/<token>/<version>/linux
_kver=${_img##*/$BLS_ENTRY_TOKEN/}
_kver=${_kver%%/*}
if _is_valid_kver $_kver; then
echo $_kver
return
fi
# Fedora UKI installation, i.e.
$BOOT/efi/EFI/Linux/<token>-<version>.efi
_kver=${_img##*/$BLS_ENTRY_TOKEN-}
_kver=${_kver%.efi}
if _is_valid_kver $_kver; then
echo $_kver
return
fi
ddebug "Could not parse version from $_img"
}
> if [[ $_old_default_crashkernel != "$_new_default_crashkernel" ]];
then
> _fadump_val=$(get_grub_kernel_boot_parameter "$_kernel"
fadump)
> if _update_kernel_cmdline "$_kernel"
"$_new_default_crashkernel" "$_dump_mode" "$_fadump_val";
then