[PATCH 0/2] Fix failure to dump vmcore to nfs target for s390x RHEL9
by Coiby Xu
On s390x RHEL9, vmcore can't be dumped to a nfs target for the following
reasons,
1. ifcfg is retired and we can't get znet config info from
/etc/sysconfig/network-scripts any more.
2. ipcalc is not installed by default, thus static route info can't
be generated correctly.
3. rpc-statd.service can't be started because of a bug in dracut
This two patches address the first two issues and the third issue has
been addressed by Kairui [1].
[1] https://github.com/dracutdevs/dracut/pull/1063
Coiby Xu (2):
read znet config from nmcli directly
add dependency on ipcalc
dracut-module-setup.sh | 31 +++++++++++++++++++++++++++----
kexec-tools.spec | 1 +
2 files changed, 28 insertions(+), 4 deletions(-)
--
2.30.0
3 years, 2 months
[PATCH v2] Make generated initrd location configurable
by Kelvin Fan
In the latest releases of Fedora CoreOS, the /boot
directory is mounted read-only. Instead of always placing the
generated kdump initrd next to the default initrd (which is
usually under /boot), make the generated initrd's location
configurable in `/etc/sysconfig/kdump`.
Signed-off by: Kelvin Fan <kfan(a)redhat.com>
---
Changes v1 -> v2:
- Fixed typo `ARGET_INITRD=` -> `TARGET_INITRD`
kdump.sysconfig | 3 +++
kdumpctl | 12 +++++++++---
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/kdump.sysconfig b/kdump.sysconfig
index 30f0c63..952d5c7 100644
--- a/kdump.sysconfig
+++ b/kdump.sysconfig
@@ -30,6 +30,9 @@ KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 reset_devices novmcoredd"
# KEXEC_ARGS="--elf32-core-headers"
KEXEC_ARGS=""
+# Where to store the generated kdump initrd
+TARGET_INITRD_DIR=""
+
#Where to find the boot image
#KDUMP_BOOTDIR="/boot"
diff --git a/kdumpctl b/kdumpctl
index 24f5cf7..4df41b2 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -151,8 +151,9 @@ rebuild_kdump_initrd()
rebuild_initrd()
{
- if [[ ! -w "$KDUMP_BOOTDIR" ]];then
- derror "$KDUMP_BOOTDIR does not have write permission. Can not rebuild $TARGET_INITRD"
+ TARGET_INITRD_DIR=$(dirname $TARGET_INITRD)
+ if [[ ! -w "$TARGET_INITRD_DIR" ]];then
+ derror "$TARGET_INITRD_DIR does not have write permission. Can not rebuild $TARGET_INITRD"
return 1
fi
@@ -335,7 +336,12 @@ setup_initrd()
# with fadump aware initrd
backup_default_initrd
else
- TARGET_INITRD="$KDUMP_INITRD"
+ if [ -z $TARGET_INITRD_DIR ]; then
+ TARGET_INITRD="$KDUMP_INITRD"
+ else
+ KDUMP_INITRD_BASE=$(basename "$KDUMP_INITRD")
+ TARGET_INITRD="$TARGET_INITRD_DIR"/"$KDUMP_INITRD_BASE"
+ fi
# check if a backup of default initrd exists. If yes,
# it signifies a switch from fadump mode. So, restore
--
2.29.2
3 years, 2 months
Re: [PATCH] Remove trace_buf_size and trace_event from the kernel
boot parameters of the kdump kernel
by Kairui Song
On Tue, Jan 26, 2021 at 2:38 PM fj1508ic(a)fujitsu.com
<fj1508ic(a)fujitsu.com> wrote:
>
> The kdump kernel uses resources for ftrace because trace_buf_size, which
> specifies the ring buffer size for ftrace, and trace_event, which specifies
> a valid trace event, are not removed, but the kdump kernel does not require
> ftrace.
>
> trace_buf_size is ignored if the specified size is 0, so specify 1.
>
> Signed-off-by: Hisashi Nagaoka <fj1508ic(a)fujitsu.com>
> ---
> kdump-lib.sh | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/kdump-lib.sh b/kdump-lib.sh
> index 0e38580..a54a650 100755
> --- a/kdump-lib.sh
> +++ b/kdump-lib.sh
> @@ -827,5 +827,9 @@ prepare_cmdline()
> fi
> done
>
> + # Remove trace_buf_size, trace_event
> + cmdline=$(remove_cmdline_param "$cmdline" trace_buf_size trace_event)
> + cmdline="${cmdline} trace_buf_size=1"
> +
> echo ${cmdline}
> }
> --
> 2.26.2
> _______________________________________________
> kexec mailing list -- kexec(a)lists.fedoraproject.org
> To unsubscribe send an email to kexec-leave(a)lists.fedoraproject.org
> Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
> List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
> List Archives: https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.org
Looks good
Acked-by: Kairui Song <kasong(a)redhat.com>
--
Best Regards,
Kairui Song
3 years, 2 months
[PATCH] kdumpctl: Add kdumpctl estimate
by Kairui Song
Add a rough esitimation support, currently, following memory usage are
checked by this sub command:
- System RAM
- Kdump Initramfs size
- Kdump Kernel image size
- Kdump Kernel module size
- Kdump userspace user and other runtime allocated memory (currently
simply using a fixed value: 64M)
This will provide user three values as reference,
The output of kdumpctl estimate looks like this:
# kdumpctl estimate
Reserved crashkernel: 128M
Baseline crashkernel: 160M
Estimated crashkernel: 143M
Recommanded crashkernel: 160M
Kenrel image size: 47M
Kernel modules size: 9M
Initramfs size: 22M
Runtime reservation: 64M
Large modules:
nouveau: 2281472
xfs: 1515520
WARNING: Current crashkernel size is lower than recommanded size 160M.
"Reserved crashkernel" is currently reserved crashkernel value.
"Baseline crashkernel" is the crashkernel size when `crashkernel=auto`
is used, based on crashkernel auto rules from RHEL.
"Estimated crashkernel" is the estimate value based on the memory usage
items listed above.
"Recommanded crashkernel" will use the largest value of estimated
crashkernel and the baseline crashkernel.
All values are rounded up and converted to MB.
All modules with static size larger than 1M will be listed as large
module.
Signed-off-by: Kairui Song <kasong(a)redhat.com>
---
kdump-lib.sh | 69 ++++++++++++++++++++++++++++++++++++++++
kdumpctl | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 156 insertions(+), 2 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh
index e87b9f1..9d89598 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -891,3 +891,72 @@ kdump_get_arch_recommend_size()
echo $result
return 0
}
+
+check_vmlinux()
+{
+ # Use readelf to check if it's a valid ELF
+ # TODO: find a better to way to check that it's really vmlinux
+ # and not just an elf
+ readelf -h $1 &>/dev/null || return 1
+}
+
+get_vmlinux_size()
+{
+ local size=0
+
+ while read _type _offset _virtaddr _physaddr _fsize _msize _flg _aln; do
+ size=$(( $size + $_msize ))
+ done <<< $(readelf -l -W $1 | grep "^ LOAD" 2>/dev/stderr)
+
+ echo $size
+}
+
+try_decompress()
+{
+ # The obscure use of the "tr" filter is to work around older versions of
+ # "grep" that report the byte offset of the line instead of the pattern.
+
+ # Try to find the header ($1) and decompress from here
+ for pos in `tr "$1\n$2" "\n$2=" < "$4" | grep -abo "^$2"`
+ do
+ if ! type -P $3 > /dev/null; then
+ ddebug "Signiature detected but '$3' is missing, skip this decompressor"
+ break
+ fi
+
+ pos=${pos%%:*}
+ tail -c+$pos "$img" | $3 > $5 2> /dev/null
+ if check_vmlinux $5; then
+ ddebug "Kernel is extracted with '$3'"
+ return 0
+ fi
+ done
+
+ return 1
+}
+
+# Borrowed from linux/scripts/extract-vmlinux
+get_kernel_size()
+{
+ # Prepare temp files:
+ local img=$1 tmp=$(mktemp /tmp/vmlinux-XXX)
+ trap "rm -f $tmp" 0
+
+ # Try to check if it's a vmlinux already
+ check_vmlinux $img && get_vmlinux_size $img && return 0
+
+ # That didn't work, so retry after decompression.
+ try_decompress '\037\213\010' xy gunzip $img $tmp || \
+ try_decompress '\3757zXZ\000' abcde unxz $img $tmp || \
+ try_decompress 'BZh' xy bunzip2 $img $tmp || \
+ try_decompress '\135\0\0\0' xxx unlzma $img $tmp || \
+ try_decompress '\211\114\132' xy 'lzop -d' $img $tmp || \
+ try_decompress '\002!L\030' xxx 'lz4 -d' $img $tmp || \
+ try_decompress '(\265/\375' xxx unzstd $img $tmp
+
+ # Finally check for uncompressed images or objects:
+ get_vmlinux_size $tmp && return 0
+
+ derror "Failed to get kernel image size"
+ return 1
+}
diff --git a/kdumpctl b/kdumpctl
index 24f5cf7..04b38d1 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -1214,6 +1214,88 @@ rebuild() {
return $?
}
+do_estimate() {
+ local kdump_mods
+ local -A large_mods
+ local baseline
+ local kernel_size mod_size initrd_size baseline_size runtime_size reserved_size estimated_size recommanded_size
+ local size_mb=$(( 1024 * 1024 ))
+
+ setup_initrd
+
+ if [ ! -f $TARGET_INITRD ]; then
+ derror "kdumpctl estimate: kdump initramfs is not built yet."
+ exit 1
+ fi
+
+ kdump_mods="$(lsinitrd $TARGET_INITRD -f /usr/lib/dracut/hostonly-kernel-modules.txt | tr '\n' ' ')"
+
+ baseline=$(kdump_get_arch_recommend_size)
+ if [[ "${baseline: -1}" == "M" ]]; then
+ baseline=${baseline%M}
+ elif [[ "${baseline: -1}" == "G" ]]; then
+ baseline=$(( ${baseline%G} * 1024 ))
+ elif [[ "${baseline: -1}" == "T" ]]; then
+ baseline=$(( ${baseline%Y} * 1048576 ))
+ fi
+
+ # The default value when using crashkernel=auto
+ baseline_size=$(( $baseline * $size_mb ))
+ # Current reserved crashkernel size
+ reserved_size=$(cat /sys/kernel/kexec_crash_size)
+ # A pre-estimated value for userspace usage and kernel
+ # runtime allocation, 64M should good for most cases
+ runtime_size=$(( 64 * $size_mb ))
+ # Kernel image size
+ kernel_size=$(get_kernel_size $KDUMP_KERNEL)
+ # Kdump initramfs size
+ initrd_size=$(du -b $TARGET_INITRD | awk '{print $1}')
+ # Kernel modules size after loaded
+ mod_size=0
+ while read _name _size _; do
+ if [[ ! " $kdump_mods " == *" $_name "* ]]; then
+ continue
+ fi
+ mod_size=$(( $mod_size + $_size ))
+
+ # Mark module with static size larger than 2M as large module
+ if [[ $(( $_size / $size_mb )) -ge 1 ]]; then
+ large_mods[$_name]=$_size
+ fi
+ done <<< $(< /proc/modules)
+
+ estimated_size=$(( $kernel_size + $mod_size + $initrd_size + $runtime_size ))
+
+ if [[ $baseline_size -gt $estimated_size ]]; then
+ recommanded_size=$baseline_size
+ else
+ recommanded_size=$estimated_size
+ fi
+
+ echo "Reserved crashkernel: $(( ( $reserved_size + $size_mb - 1 ) / $size_mb ))M"
+ echo "Baseline crashkernel: $(( ( $baseline_size + $size_mb - 1 ) / $size_mb ))M"
+ echo "Estimated crashkernel: $(( ( $estimated_size + $size_mb - 1 ) / $size_mb ))M"
+ echo "Recommanded crashkernel: $(( ( $recommanded_size + $size_mb - 1 ) / $size_mb ))M"
+ echo
+ echo "Kenrel image size: $(( ( $kernel_size + $size_mb - 1 ) / $size_mb ))M"
+ echo "Kernel modules size: $(( ( $mod_size + $size_mb - 1 ) / $size_mb ))M"
+ echo "Initramfs size: $(( ( $initrd_size + $size_mb - 1 ) / $size_mb ))M"
+ echo "Runtime reservation: $(( ( $runtime_size + $size_mb - 1 ) / $size_mb ))M"
+ echo -n "Large modules:"
+ if [[ "${#large_mods[@]}" -eq 0 ]]; then
+ echo " <none>"
+ else
+ echo ""
+ for _mod in ${!large_mods[@]}; do
+ echo " $_mod: ${large_mods[$_mod]}"
+ done
+ fi
+
+ if [[ $reserved_size -le $recommanded_size ]]; then
+ echo "WARNING: Current crashkernel size is lower than recommanded size $(( ( $recommanded_size + 1023 ) / $size_mb ))M."
+ fi
+}
+
if [ ! -f "$KDUMP_CONFIG_FILE" ]; then
derror "Error: No kdump config file found!"
exit 1
@@ -1269,8 +1351,11 @@ main ()
showmem)
show_reserved_mem
;;
+ estimate)
+ do_estimate $2
+ ;;
*)
- dinfo $"Usage: $0 {start|stop|status|restart|reload|rebuild|propagate|showmem}"
+ dinfo $"Usage: $0 {start|stop|status|restart|reload|rebuild|propagate|showmem|estimate}"
exit 1
esac
}
@@ -1280,6 +1365,6 @@ single_instance_lock
# To avoid fd 9 leaking, we invoke a subshell, close fd 9 and call main.
# So that fd isn't leaking when main is invoking a subshell.
-(exec 9<&-; main $1)
+(exec 9<&-; main $@)
exit $?
--
2.29.2
3 years, 2 months
[PATCH] kdump-lib.sh: introduce functions to return recommened mem size
by Pingfan Liu
There is requirement to decide the recommended memory size for the current
system. Ant the algorithm is based on /proc/iomem, so it can align with the
algorithm used by reserve_crashkernel() in kernel.
Signed-off-by: Pingfan Liu <piliu(a)redhat.com>
---
V1 -> V2:
embeded in kdump-lib.sh
add check against /proc/iomem
kdump-lib.sh | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 68 insertions(+)
diff --git a/kdump-lib.sh b/kdump-lib.sh
index d2801da..6bb285d 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -823,3 +823,71 @@ prepare_cmdline()
echo ${cmdline}
}
+
+#get system memory size in the unit of GB
+get_system_size()
+{
+ result=$( cat /proc/iomem | grep "System RAM" | 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' | sed -e 's/+/-0x/g' | sed -e 's/K/+/g' )
+ size=$(printf "%d\n" $(($sum)))
+ let size=$size/1024/1024/1024
+
+ echo $size
+}
+
+get_recommend_size()
+{
+ local mem_size=$1
+ local _ck_cmdline=$2
+
+ last_sz=""
+ last_unit=""
+
+ IFS=','
+ for i in $_ck_cmdline
+ do
+ end=$( echo $i | awk -F "-" {' print $2 '} | awk -F ":" {' print $1 '} )
+ recommend=$( echo $i | awk -F "-" {' print $2 '} | awk -F ":" {' print $2 '} )
+ size=${end: : -1}
+ unit=${end: -1}
+ if [ $unit == 'T' ]; then
+ let size=$size*1024
+ fi
+ if [ $mem_size -lt $size ]; then
+ echo $recommend
+ unset IFS
+ return
+ fi
+ done
+ unset IFS
+}
+
+# return recommended size based on current system RAM size
+kdump_api_get_arch_recommend_size()
+{
+ 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 == "S390" ]; then
+ ck_cmdline="1G-4G:160M,4G-64G:192M,64G-1T:256M,1T-:512M"
+ elif [ $arch == "ARM64" ]; 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
+
+ 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
+}
--
2.29.2
3 years, 2 months
[PATCH] Make generated initrd location configurable
by Kelvin Fan
In the latest releases of Fedora CoreOS, the /boot
directory is mounted read-only. Instead of always placing the
generated kdump initrd next to the default initrd (which is
usually under /boot), make the generated initrd's location
configurable in `/etc/sysconfig/kdump`.
Signed-off by: Kelvin Fan <kfan(a)redhat.com>
---
kdump.sysconfig | 3 +++
kdumpctl | 12 +++++++++---
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/kdump.sysconfig b/kdump.sysconfig
index 30f0c63..952d5c7 100644
--- a/kdump.sysconfig
+++ b/kdump.sysconfig
@@ -30,6 +30,9 @@ KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 reset_devices novmcoredd"
# KEXEC_ARGS="--elf32-core-headers"
KEXEC_ARGS=""
+# Where to store the generated kdump initrd
+TARGET_INITRD_DIR=""
+
#Where to find the boot image
#KDUMP_BOOTDIR="/boot"
diff --git a/kdumpctl b/kdumpctl
index 24f5cf7..a4e8763 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -151,8 +151,9 @@ rebuild_kdump_initrd()
rebuild_initrd()
{
- if [[ ! -w "$KDUMP_BOOTDIR" ]];then
- derror "$KDUMP_BOOTDIR does not have write permission. Can not rebuild $TARGET_INITRD"
+ TARGET_INITRD_DIR=$(dirname $TARGET_INITRD)
+ if [[ ! -w "$TARGET_INITRD_DIR" ]];then
+ derror "$TARGET_INITRD_DIR does not have write permission. Can not rebuild $TARGET_INITRD"
return 1
fi
@@ -335,7 +336,12 @@ setup_initrd()
# with fadump aware initrd
backup_default_initrd
else
- TARGET_INITRD="$KDUMP_INITRD"
+ if [ -z $TARGET_INITRD_DIR ]; then
+ TARGET_INITRD="$KDUMP_INITRD"
+ else
+ KDUMP_INITRD_BASE=$(basename "$KDUMP_INITRD")
+ ARGET_INITRD="$TARGET_INITRD_DIR"/"$KDUMP_INITRD_BASE"
+ fi
# check if a backup of default initrd exists. If yes,
# it signifies a switch from fadump mode. So, restore
--
2.29.2
3 years, 2 months
[PATCH] Revert "Append both nofail and x-systemd.before to kdump mount target"
by Kairui Song
That commit is trying to workaround a kernel VFS bug. Now,
the VFS issue should have been fixed in all recent releases, so
remove this workaround.
This reverts commit 539bff40830e961d7ef85248e39bff0e40b23c91.
Signed-off-by: Kairui Song <kasong(a)redhat.com>
---
mkdumprd | 3 ---
1 file changed, 3 deletions(-)
diff --git a/mkdumprd b/mkdumprd
index 0623940..8ba8e2a 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -86,9 +86,6 @@ to_mount() {
# drop nofail or nobootwait
_options=$(echo $_options | sed 's/\(^\|,\)nofail\($\|,\)/\1/g')
_options=$(echo $_options | sed 's/\(^\|,\)nobootwait\($\|,\)/\1/g')
- # use both nofail and x-systemd.before to ensure systemd will try best to
- # mount it before kdump starts, this is an attempt to improve robustness
- _options="$_options,nofail,x-systemd.before=initrd-fs.target"
echo "$_pdev $_new_mntpoint $_fstype $_options"
}
--
2.29.2
3 years, 2 months