[RFC 00/13] reuse NetworkManager connection profiles to set up kdump network
by Coiby Xu
Currently, kexec-tools parses legacy ifcfg-* configuration files or
NetworkManager .nmconnection connection profiles to build up dracut
command line parameters like ip=. Then dracut parses these parameters and
runs nm-initrd-generator to generate NetworkManager connection profiles.
Taking a bonding network as an example, nm-initrd-generator generates two
connections as follows,
$ /usr/libexec/nm-initrd-generator -s -- bootdev=mybond0 rd.neednet kdumpnic=mybond0 bond=mybond0:kdump-eth0
*** Connection 'mybond0' ***
[connection]
id=mybond0
uuid=ed87d02b-dd44-4f0e-8b11-37db7e89bb48
type=bond
autoconnect-retries=1
interface-name=mybond0
multi-connect=1
permissions=
[bond]
mode=balance-rr
[ipv4]
dhcp-timeout=90
dns-search=
method=auto
[ipv6]
addr-gen-mode=eui64
dhcp-timeout=90
dns-search=
method=auto
[proxy]
*** Connection 'kdump-eth0' ***
[connection]
id=kdump-eth0
uuid=ed6a7448-b5f8-4f8a-b718-3e24ea1c924b
type=ethernet
autoconnect-retries=1
interface-name=kdump-eth0
master=ed87d02b-dd44-4f0e-8b11-37db7e89bb48
multi-connect=1
permissions=
slave-type=bond
wait-device-timeout=60000
[ethernet]
mac-address-blacklist=
Later dracut starts NetworkManager to activate these profiles to bring up
the network connections. This way of seting up kdump network is tedious,
error-prone and unncessary. A better way is to directly copy the needed
connection profiles to initrd. A potential benefit of this approach for
the users is they can simply edit the connection profile directly like
changing ipv4.dhcp-timeout instead of being forced to use the hard-coded
value enforced by nm-initrd-generator.
This patch set reuses NetworkManager connection profiles to set up kdump
network. It also reduces the memory consumption of network drivers and
fix other issues at the same time. Here are the bug list that addressed by
this patch set on bugzilla,
- Bug 1962421 - [RHEL-9]"eth0: Failed to rename network interface 3 from 'eth0' to 'kdump-eth0': File exists"
- Bug 2064708 - kdump: mkdumprd: failed to make kdump initrd for bridge network on z15 z/vm
- bugs related to OOM caused by network driver
- Bug 1950282 - shutdown those unneeded network interfaces to save memory for kdump
- Bug 1958587 - the kdump initramfs includes unnecessary NIC drivers for SSH/NFS dumping target
- Bug 1890021 - be2net is using too much memory during kdump
- Bug 1662202 - [RHEL-8.1] aarch64: hpe-apache crashkernel OOM when dump to network targe
Coiby Xu (13):
add function to copy NetworkManage connection profile to the initramfs
support legacy ifcfg
ask NM to wait the network device to be available
don't let NetworkManager manage unneeded network interfaces
stop dracut 35network-manager from running nm-initrd-generator
set up kdump network bridge by directly copying NM connection profile
to initrd
set up kdump bonding network by directly copying NM connection profile
to initrd
fix error for vlan over team network interface
set up kdump vlan network by directly copying NM connection profile to
initrd
set up kdump teaming network by directly copying NM connection profile
to initrd
clean up unneeded code after copying .nmconnection to initrd
address the cases where a NIC has a different name in kdump kernel
simplify setup_znet by copying connection profile to initrd
dracut-kdump.sh | 18 +-
dracut-module-setup.sh | 385 ++++++++++++++---------------------------
2 files changed, 133 insertions(+), 270 deletions(-)
--
2.34.1
1 year, 3 months
[PATCH 00/11] crashkernel=auto: support fadump, reserve extra SWIOTLB memory and remove crashkernel.default
by Coiby Xu
The crashkernel=auto implementation in kernel space has been rejected
upstream [1]. The current user space implementation [2] [3] ships a
crashkernel.default but hasn't supported the swiotlb memory requirement,
custom crashkernel value from user and fadump.
The crashkernel.default implementation seems to be overly
complex,
- the default crashkernel value rarely changes. This is no need to ship
the same crashkernel.default default for every kernel package of a
architecture;
- when deciding the value of crashkernel for a new kernel, the
crashkernel.default of existing kernel is took into consideration
We can simply let the kexec-tools maintain the default crashkernel
values and provide an API for kdump-anacon-addon to query it. And for
a newly installed kernel, we can simply call "kdumpctl reset-crashkernel
KERNELPATH" to set its crashkernel value.
For the unfulfilled requirements,
- crashkernel is introduced to /etc/kdump.conf for the user can set
custom crashkernel value to tell kexec-tools to manage crashkernel
value automatically.
- "kdumpctl reset-crashkernel" has been written for the above
purpose.
- "kdumpctl fadump on/off" is added for supporting fadump.
[1] https://lore.kernel.org/linux-mm/20210507010432.IN24PudKT%25akpm@linux-fo...
[2] https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1171
[3] https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.o...
Coiby Xu (11):
update default crashkernel value
factor out kdump_get_arch_recommend_crashkernel
provide get_default_crashkernel for kdump_anaconda_addon
introduce crashkernel option to kdump.conf
add a helper function to write a config value to kdump.conf
add a helper function to read kernel cmdline parameter from grubby
--info
rewrite reset_crashkernel to provide more features for the user and to
be called by kernel installation hook
allow to add extra memory to crashkernel string
Reserve extra memory when SME or SEV is active
provide kdumpctl fadump on/off
use "kdumpctl reset-crashkernel KERNELIMAGE" in kernel installation
hook
92-crashkernel.install | 135 +----------------------------
kdump-lib-initramfs.sh | 9 ++
kdump-lib.sh | 95 +++++++++++++++------
kdump.conf | 6 ++
kdump.conf.5 | 7 ++
kdumpctl | 188 ++++++++++++++++++++++++++++++++++++-----
kdumpctl.8 | 16 ++--
7 files changed, 271 insertions(+), 185 deletions(-)
--
2.31.1
1 year, 3 months
[PATCH] mkdumprd: allow spaces after 'path' config phrase when network dump
by Kazuhito Hagio
Without this patch, when there are two or more spaces after 'path'
configuration phrase with ssh or nfs setting, SAVE_PATH is set to
'/var/crash' in mkdumprd, and in most cases kdump service fails to
start.
ssh kdump(a)192.168.122.1
path /kdump
^^
This behavior would be too sensitive and different from the other
configurations. With this patch, mkdumprd allows such spaces.
Signed-off-by: Kazuhito Hagio <k-hagio(a)ab.jp.nec.com>
---
mkdumprd | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mkdumprd b/mkdumprd
index a6f7fe8..aa0abfd 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -13,7 +13,7 @@ export IN_KDUMP=1
conf_file="/etc/kdump.conf"
SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
-SAVE_PATH=$(grep ^path $conf_file| cut -d' ' -f2)
+SAVE_PATH=$(awk '/^path/ {print $2}' $conf_file)
[ -z "$SAVE_PATH" ] && SAVE_PATH=$DEFAULT_PATH
# strip the duplicated "/"
SAVE_PATH=$(echo $SAVE_PATH | tr -s /)
--
2.18.0
1 year, 4 months
[PATCH] sysconfig: use a simple template to maintain
by Kairui Song
From: Kairui Song <kasong(a)tencent.com>
These kdump.sysconfig.* files are almost identical with a bit different
in several parameters, just use a simple script to generate them upon
packaging. This should make it easier to maintain, updating a comment or
param for certain arch can be done in one place.
There are some minor differences with the generated version due to some
arch's sysconfig is not up-to-dated, this actually fixed the issues,
to check these differences:
# for arch in aarch64 i386 ppc64 ppc64le s390x x86_64; do
./kdump-gen-sysconfig.sh kdump.sysconfig.template $arch > kdump.sysconfig.$arch.new
git checkout HEAD^ kdump.sysconfig.$arch &>/dev/null
echo "Diff of arch $arch:"
diff kdump.sysconfig.$arch kdump.sysconfig.$arch.new; echo ""
done; git reset;
Diff of arch aarch64:
> #What is the images extension. Relocatable kernels don't have one
> KDUMP_IMG_EXT=""
Diff of arch i386:
Diff of arch ppc64:
42,43d41
< #Specify the action after failure
<
Diff of arch ppc64le:
42,43d41
< #Specify the action after failure
<
Diff of arch s390x:
26,28d25
< # Any additional /sbin/mkdumprd arguments required.
< MKDUMPRD_ARGS=""
<
Diff of arch x86_64:
Signed-off-by: Kairui Song <kasong(a)tencent.com>
---
kdump-gen-sysconfig.sh | 51 ++++++++++++++++++
kdump.sysconfig.aarch64 | 53 ------------------
kdump.sysconfig.i386 | 56 -------------------
kdump.sysconfig.ppc64 | 58 --------------------
kdump.sysconfig.ppc64le | 58 --------------------
kdump.sysconfig.s390x | 59 ---------------------
kdump.sysconfig => kdump.sysconfig.template | 3 ++
kdump.sysconfig.x86_64 | 56 -------------------
kexec-tools.spec | 18 +++----
9 files changed, 60 insertions(+), 352 deletions(-)
create mode 100755 kdump-gen-sysconfig.sh
delete mode 100644 kdump.sysconfig.aarch64
delete mode 100644 kdump.sysconfig.i386
delete mode 100644 kdump.sysconfig.ppc64
delete mode 100644 kdump.sysconfig.ppc64le
delete mode 100644 kdump.sysconfig.s390x
rename kdump.sysconfig => kdump.sysconfig.template (96%)
delete mode 100644 kdump.sysconfig.x86_64
diff --git a/kdump-gen-sysconfig.sh b/kdump-gen-sysconfig.sh
new file mode 100755
index 0000000..1eac80d
--- /dev/null
+++ b/kdump-gen-sysconfig.sh
@@ -0,0 +1,51 @@
+#!/bin/bash
+
+TEMPLATE=$1
+ARCH=$2
+SED_EXP=""
+
+update_param()
+{
+ SED_EXP="${SED_EXP}s/^$1=.*$/$1=\"$2\"/;"
+}
+
+case "$ARCH" in
+aarch64)
+ update_param KEXEC_ARGS "-s"
+ update_param KDUMP_COMMANDLINE_APPEND \
+ "irqpoll nr_cpus=1 reset_devices cgroup_disable=memory udev.children-max=2 panic=10 swiotlb=noforce novmcoredd cma=0 hugetlb_cma=0"
+ ;;
+i386)
+ update_param KDUMP_COMMANDLINE_APPEND \
+ "irqpoll nr_cpus=1 reset_devices numa=off udev.children-max=2 panic=10 transparent_hugepage=never novmcoredd cma=0 hugetlb_cma=0"
+ ;;
+ppc64)
+ update_param KDUMP_COMMANDLINE_REMOVE \
+ "hugepages hugepagesz slub_debug quiet log_buf_len swiotlb hugetlb_cma"
+ update_param KDUMP_COMMANDLINE_APPEND \
+ "irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd hugetlb_cma=0"
+ update_param KEXEC_ARGS "--dt-no-old-root"
+ ;;
+ppc64le)
+ update_param KDUMP_COMMANDLINE_REMOVE \
+ "hugepages hugepagesz slub_debug quiet log_buf_len swiotlb hugetlb_cma"
+ update_param KDUMP_COMMANDLINE_APPEND \
+ "irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd hugetlb_cma=0"
+ update_param KEXEC_ARGS "--dt-no-old-root -s"
+ ;;
+s390x)
+ update_param KDUMP_COMMANDLINE_REMOVE \
+ "hugepages hugepagesz slub_debug quiet log_buf_len swiotlb vmcp_cma cma hugetlb_cma prot_virt"
+ update_param KDUMP_COMMANDLINE_APPEND \
+ "nr_cpus=1 cgroup_disable=memory numa=off udev.children-max=2 panic=10 transparent_hugepage=never novmcoredd vmcp_cma=0 cma=0 hugetlb_cma=0"
+ update_param KEXEC_ARGS "-s"
+ ;;
+x86_64)
+ update_param KDUMP_COMMANDLINE_APPEND \
+ "irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 acpi_no_memhotplug transparent_hugepage=never nokaslr hest_disable novmcoredd cma=0 hugetlb_cma=0"
+ update_param KEXEC_ARGS \
+ "-s"
+ ;;
+esac
+
+sed "$SED_EXP" "$TEMPLATE"
diff --git a/kdump.sysconfig.aarch64 b/kdump.sysconfig.aarch64
deleted file mode 100644
index 67a2af7..0000000
--- a/kdump.sysconfig.aarch64
+++ /dev/null
@@ -1,53 +0,0 @@
-# Kernel Version string for the -kdump kernel, such as 2.6.13-1544.FC5kdump
-# If no version is specified, then the init script will try to find a
-# kdump kernel with the same version number as the running kernel.
-KDUMP_KERNELVER=""
-
-# The kdump commandline is the command line that needs to be passed off to
-# the kdump kernel. This will likely match the contents of the grub kernel
-# line. For example:
-# KDUMP_COMMANDLINE="ro root=LABEL=/"
-# Dracut depends on proper root= options, so please make sure that appropriate
-# root= options are copied from /proc/cmdline. In general it is best to append
-# command line options using "KDUMP_COMMANDLINE_APPEND=".
-# If a command line is not specified, the default will be taken from
-# /proc/cmdline
-KDUMP_COMMANDLINE=""
-
-# This variable lets us remove arguments from the current kdump commandline
-# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
-# NOTE: some arguments such as crashkernel will always be removed
-KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb cma hugetlb_cma"
-
-# This variable lets us append arguments to the current kdump commandline
-# after processed by KDUMP_COMMANDLINE_REMOVE
-KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory udev.children-max=2 panic=10 swiotlb=noforce novmcoredd cma=0 hugetlb_cma=0"
-
-# Any additional kexec arguments required. In most situations, this should
-# be left empty
-#
-# Example:
-# KEXEC_ARGS="--elf32-core-headers"
-KEXEC_ARGS="-s"
-
-#Where to find the boot image
-#KDUMP_BOOTDIR="/boot"
-
-#What is the image type used for kdump
-KDUMP_IMG="vmlinuz"
-
-# Logging is controlled by following variables in the first kernel:
-# - @var KDUMP_STDLOGLVL - logging level to standard error (console output)
-# - @var KDUMP_SYSLOGLVL - logging level to syslog (by logger command)
-# - @var KDUMP_KMSGLOGLVL - logging level to /dev/kmsg (only for boot-time)
-#
-# In the second kernel, kdump will use the rd.kdumploglvl option to set the
-# log level in the above KDUMP_COMMANDLINE_APPEND.
-# - @var rd.kdumploglvl - logging level to syslog (by logger command)
-# - for example: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND
-#
-# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4)
-#
-# KDUMP_STDLOGLVL=3
-# KDUMP_SYSLOGLVL=0
-# KDUMP_KMSGLOGLVL=0
diff --git a/kdump.sysconfig.i386 b/kdump.sysconfig.i386
deleted file mode 100644
index 7e18c1c..0000000
--- a/kdump.sysconfig.i386
+++ /dev/null
@@ -1,56 +0,0 @@
-# Kernel Version string for the -kdump kernel, such as 2.6.13-1544.FC5kdump
-# If no version is specified, then the init script will try to find a
-# kdump kernel with the same version number as the running kernel.
-KDUMP_KERNELVER=""
-
-# The kdump commandline is the command line that needs to be passed off to
-# the kdump kernel. This will likely match the contents of the grub kernel
-# line. For example:
-# KDUMP_COMMANDLINE="ro root=LABEL=/"
-# Dracut depends on proper root= options, so please make sure that appropriate
-# root= options are copied from /proc/cmdline. In general it is best to append
-# command line options using "KDUMP_COMMANDLINE_APPEND=".
-# If a command line is not specified, the default will be taken from
-# /proc/cmdline
-KDUMP_COMMANDLINE=""
-
-# This variable lets us remove arguments from the current kdump commandline
-# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
-# NOTE: some arguments such as crashkernel will always be removed
-KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb cma hugetlb_cma"
-
-# This variable lets us append arguments to the current kdump commandline
-# after processed by KDUMP_COMMANDLINE_REMOVE
-KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices numa=off udev.children-max=2 panic=10 transparent_hugepage=never novmcoredd cma=0 hugetlb_cma=0"
-
-# Any additional kexec arguments required. In most situations, this should
-# be left empty
-#
-# Example:
-# KEXEC_ARGS="--elf32-core-headers"
-KEXEC_ARGS=""
-
-#Where to find the boot image
-#KDUMP_BOOTDIR="/boot"
-
-#What is the image type used for kdump
-KDUMP_IMG="vmlinuz"
-
-#What is the images extension. Relocatable kernels don't have one
-KDUMP_IMG_EXT=""
-
-# Logging is controlled by following variables in the first kernel:
-# - @var KDUMP_STDLOGLVL - logging level to standard error (console output)
-# - @var KDUMP_SYSLOGLVL - logging level to syslog (by logger command)
-# - @var KDUMP_KMSGLOGLVL - logging level to /dev/kmsg (only for boot-time)
-#
-# In the second kernel, kdump will use the rd.kdumploglvl option to set the
-# log level in the above KDUMP_COMMANDLINE_APPEND.
-# - @var rd.kdumploglvl - logging level to syslog (by logger command)
-# - for example: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND
-#
-# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4)
-#
-# KDUMP_STDLOGLVL=3
-# KDUMP_SYSLOGLVL=0
-# KDUMP_KMSGLOGLVL=0
diff --git a/kdump.sysconfig.ppc64 b/kdump.sysconfig.ppc64
deleted file mode 100644
index ebb22f6..0000000
--- a/kdump.sysconfig.ppc64
+++ /dev/null
@@ -1,58 +0,0 @@
-# Kernel Version string for the -kdump kernel, such as 2.6.13-1544.FC5kdump
-# If no version is specified, then the init script will try to find a
-# kdump kernel with the same version number as the running kernel.
-KDUMP_KERNELVER=""
-
-# The kdump commandline is the command line that needs to be passed off to
-# the kdump kernel. This will likely match the contents of the grub kernel
-# line. For example:
-# KDUMP_COMMANDLINE="ro root=LABEL=/"
-# Dracut depends on proper root= options, so please make sure that appropriate
-# root= options are copied from /proc/cmdline. In general it is best to append
-# command line options using "KDUMP_COMMANDLINE_APPEND=".
-# If a command line is not specified, the default will be taken from
-# /proc/cmdline
-KDUMP_COMMANDLINE=""
-
-# This variable lets us remove arguments from the current kdump commandline
-# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
-# NOTE: some arguments such as crashkernel will always be removed
-KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb hugetlb_cma"
-
-# This variable lets us append arguments to the current kdump commandline
-# after processed by KDUMP_COMMANDLINE_REMOVE
-KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd hugetlb_cma=0"
-
-# Any additional kexec arguments required. In most situations, this should
-# be left empty
-#
-# Example:
-# KEXEC_ARGS="--elf32-core-headers"
-KEXEC_ARGS="--dt-no-old-root"
-
-#Where to find the boot image
-#KDUMP_BOOTDIR="/boot"
-
-#What is the image type used for kdump
-KDUMP_IMG="vmlinuz"
-
-#What is the images extension. Relocatable kernels don't have one
-KDUMP_IMG_EXT=""
-
-#Specify the action after failure
-
-# Logging is controlled by following variables in the first kernel:
-# - @var KDUMP_STDLOGLVL - logging level to standard error (console output)
-# - @var KDUMP_SYSLOGLVL - logging level to syslog (by logger command)
-# - @var KDUMP_KMSGLOGLVL - logging level to /dev/kmsg (only for boot-time)
-#
-# In the second kernel, kdump will use the rd.kdumploglvl option to set the
-# log level in the above KDUMP_COMMANDLINE_APPEND.
-# - @var rd.kdumploglvl - logging level to syslog (by logger command)
-# - for example: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND
-#
-# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4)
-#
-# KDUMP_STDLOGLVL=3
-# KDUMP_SYSLOGLVL=0
-# KDUMP_KMSGLOGLVL=0
diff --git a/kdump.sysconfig.ppc64le b/kdump.sysconfig.ppc64le
deleted file mode 100644
index 270a2cf..0000000
--- a/kdump.sysconfig.ppc64le
+++ /dev/null
@@ -1,58 +0,0 @@
-# Kernel Version string for the -kdump kernel, such as 2.6.13-1544.FC5kdump
-# If no version is specified, then the init script will try to find a
-# kdump kernel with the same version number as the running kernel.
-KDUMP_KERNELVER=""
-
-# The kdump commandline is the command line that needs to be passed off to
-# the kdump kernel. This will likely match the contents of the grub kernel
-# line. For example:
-# KDUMP_COMMANDLINE="ro root=LABEL=/"
-# Dracut depends on proper root= options, so please make sure that appropriate
-# root= options are copied from /proc/cmdline. In general it is best to append
-# command line options using "KDUMP_COMMANDLINE_APPEND=".
-# If a command line is not specified, the default will be taken from
-# /proc/cmdline
-KDUMP_COMMANDLINE=""
-
-# This variable lets us remove arguments from the current kdump commandline
-# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
-# NOTE: some arguments such as crashkernel will always be removed
-KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb hugetlb_cma"
-
-# This variable lets us append arguments to the current kdump commandline
-# after processed by KDUMP_COMMANDLINE_REMOVE
-KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd hugetlb_cma=0"
-
-# Any additional kexec arguments required. In most situations, this should
-# be left empty
-#
-# Example:
-# KEXEC_ARGS="--elf32-core-headers"
-KEXEC_ARGS="--dt-no-old-root -s"
-
-#Where to find the boot image
-#KDUMP_BOOTDIR="/boot"
-
-#What is the image type used for kdump
-KDUMP_IMG="vmlinuz"
-
-#What is the images extension. Relocatable kernels don't have one
-KDUMP_IMG_EXT=""
-
-#Specify the action after failure
-
-# Logging is controlled by following variables in the first kernel:
-# - @var KDUMP_STDLOGLVL - logging level to standard error (console output)
-# - @var KDUMP_SYSLOGLVL - logging level to syslog (by logger command)
-# - @var KDUMP_KMSGLOGLVL - logging level to /dev/kmsg (only for boot-time)
-#
-# In the second kernel, kdump will use the rd.kdumploglvl option to set the
-# log level in the above KDUMP_COMMANDLINE_APPEND.
-# - @var rd.kdumploglvl - logging level to syslog (by logger command)
-# - for example: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND
-#
-# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4)
-#
-# KDUMP_STDLOGLVL=3
-# KDUMP_SYSLOGLVL=0
-# KDUMP_KMSGLOGLVL=0
diff --git a/kdump.sysconfig.s390x b/kdump.sysconfig.s390x
deleted file mode 100644
index 234cfe9..0000000
--- a/kdump.sysconfig.s390x
+++ /dev/null
@@ -1,59 +0,0 @@
-# Kernel Version string for the -kdump kernel, such as 2.6.13-1544.FC5kdump
-# If no version is specified, then the init script will try to find a
-# kdump kernel with the same version number as the running kernel.
-KDUMP_KERNELVER=""
-
-# The kdump commandline is the command line that needs to be passed off to
-# the kdump kernel. This will likely match the contents of the grub kernel
-# line. For example:
-# KDUMP_COMMANDLINE="ro root=LABEL=/"
-# Dracut depends on proper root= options, so please make sure that appropriate
-# root= options are copied from /proc/cmdline. In general it is best to append
-# command line options using "KDUMP_COMMANDLINE_APPEND=".
-# If a command line is not specified, the default will be taken from
-# /proc/cmdline
-KDUMP_COMMANDLINE=""
-
-# This variable lets us remove arguments from the current kdump commandline
-# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
-# NOTE: some arguments such as crashkernel will always be removed
-KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb vmcp_cma cma hugetlb_cma prot_virt"
-
-# This variable lets us append arguments to the current kdump commandline
-# after processed by KDUMP_COMMANDLINE_REMOVE
-KDUMP_COMMANDLINE_APPEND="nr_cpus=1 cgroup_disable=memory numa=off udev.children-max=2 panic=10 transparent_hugepage=never novmcoredd vmcp_cma=0 cma=0 hugetlb_cma=0"
-
-# Any additional /sbin/mkdumprd arguments required.
-MKDUMPRD_ARGS=""
-
-# Any additional kexec arguments required. In most situations, this should
-# be left empty
-#
-# Example:
-# KEXEC_ARGS="--elf32-core-headers"
-KEXEC_ARGS="-s"
-
-#Where to find the boot image
-#KDUMP_BOOTDIR="/boot"
-
-#What is the image type used for kdump
-KDUMP_IMG="vmlinuz"
-
-#What is the images extension. Relocatable kernels don't have one
-KDUMP_IMG_EXT=""
-
-# Logging is controlled by following variables in the first kernel:
-# - @var KDUMP_STDLOGLVL - logging level to standard error (console output)
-# - @var KDUMP_SYSLOGLVL - logging level to syslog (by logger command)
-# - @var KDUMP_KMSGLOGLVL - logging level to /dev/kmsg (only for boot-time)
-#
-# In the second kernel, kdump will use the rd.kdumploglvl option to set the
-# log level in the above KDUMP_COMMANDLINE_APPEND.
-# - @var rd.kdumploglvl - logging level to syslog (by logger command)
-# - for example: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND
-#
-# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4)
-#
-# KDUMP_STDLOGLVL=3
-# KDUMP_SYSLOGLVL=0
-# KDUMP_KMSGLOGLVL=0
diff --git a/kdump.sysconfig b/kdump.sysconfig.template
similarity index 96%
rename from kdump.sysconfig
rename to kdump.sysconfig.template
index 70ebf04..39b1bdf 100644
--- a/kdump.sysconfig
+++ b/kdump.sysconfig.template
@@ -36,6 +36,9 @@ KEXEC_ARGS=""
#What is the image type used for kdump
KDUMP_IMG="vmlinuz"
+#What is the images extension. Relocatable kernels don't have one
+KDUMP_IMG_EXT=""
+
# Logging is controlled by following variables in the first kernel:
# - @var KDUMP_STDLOGLVL - logging level to standard error (console output)
# - @var KDUMP_SYSLOGLVL - logging level to syslog (by logger command)
diff --git a/kdump.sysconfig.x86_64 b/kdump.sysconfig.x86_64
deleted file mode 100644
index 188ba3c..0000000
--- a/kdump.sysconfig.x86_64
+++ /dev/null
@@ -1,56 +0,0 @@
-# Kernel Version string for the -kdump kernel, such as 2.6.13-1544.FC5kdump
-# If no version is specified, then the init script will try to find a
-# kdump kernel with the same version number as the running kernel.
-KDUMP_KERNELVER=""
-
-# The kdump commandline is the command line that needs to be passed off to
-# the kdump kernel. This will likely match the contents of the grub kernel
-# line. For example:
-# KDUMP_COMMANDLINE="ro root=LABEL=/"
-# Dracut depends on proper root= options, so please make sure that appropriate
-# root= options are copied from /proc/cmdline. In general it is best to append
-# command line options using "KDUMP_COMMANDLINE_APPEND=".
-# If a command line is not specified, the default will be taken from
-# /proc/cmdline
-KDUMP_COMMANDLINE=""
-
-# This variable lets us remove arguments from the current kdump commandline
-# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
-# NOTE: some arguments such as crashkernel will always be removed
-KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb cma hugetlb_cma"
-
-# This variable lets us append arguments to the current kdump commandline
-# after processed by KDUMP_COMMANDLINE_REMOVE
-KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 acpi_no_memhotplug transparent_hugepage=never nokaslr hest_disable novmcoredd cma=0 hugetlb_cma=0"
-
-# Any additional kexec arguments required. In most situations, this should
-# be left empty
-#
-# Example:
-# KEXEC_ARGS="--elf32-core-headers"
-KEXEC_ARGS="-s"
-
-#Where to find the boot image
-#KDUMP_BOOTDIR="/boot"
-
-#What is the image type used for kdump
-KDUMP_IMG="vmlinuz"
-
-#What is the images extension. Relocatable kernels don't have one
-KDUMP_IMG_EXT=""
-
-# Logging is controlled by following variables in the first kernel:
-# - @var KDUMP_STDLOGLVL - logging level to standard error (console output)
-# - @var KDUMP_SYSLOGLVL - logging level to syslog (by logger command)
-# - @var KDUMP_KMSGLOGLVL - logging level to /dev/kmsg (only for boot-time)
-#
-# In the second kernel, kdump will use the rd.kdumploglvl option to set the
-# log level in the above KDUMP_COMMANDLINE_APPEND.
-# - @var rd.kdumploglvl - logging level to syslog (by logger command)
-# - for example: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND
-#
-# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4)
-#
-# KDUMP_STDLOGLVL=3
-# KDUMP_SYSLOGLVL=0
-# KDUMP_KMSGLOGLVL=0
diff --git a/kexec-tools.spec b/kexec-tools.spec
index db6374c..08957b7 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -11,10 +11,8 @@ Summary: The kexec/kdump userspace component
Source0: http://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{version}.tar.xz
Source1: kdumpctl
-Source2: kdump.sysconfig
-Source3: kdump.sysconfig.x86_64
-Source4: kdump.sysconfig.i386
-Source5: kdump.sysconfig.ppc64
+Source2: kdump.sysconfig.template
+Source3: kdump-gen-sysconfig.sh
Source7: mkdumprd
Source8: kdump.conf
Source9: https://github.com/makedumpfile/makedumpfile/archive/%{mkdf_ver}/makedump...
@@ -25,18 +23,15 @@ Source13: 98-kexec.rules
Source14: 98-kexec.rules.ppc64
Source15: kdump.conf.5
Source16: kdump.service
-Source18: kdump.sysconfig.s390x
Source19: https://github.com/lucchouina/eppic/archive/%{eppic_ver}/eppic-%{eppic_sh...
Source20: kdump-lib.sh
Source21: kdump-in-cluster-environment.txt
Source22: kdump-dep-generator.sh
Source23: kdump-lib-initramfs.sh
-Source24: kdump.sysconfig.ppc64le
Source25: kdumpctl.8
Source26: live-image-kdump-howto.txt
Source27: early-kdump-howto.txt
Source28: kdump-udev-throttler
-Source29: kdump.sysconfig.aarch64
Source30: 60-kdump.install
Source31: kdump-logger.sh
Source32: mkfadumprd
@@ -152,6 +147,9 @@ cp %{SOURCE26} .
cp %{SOURCE27} .
cp %{SOURCE34} .
+# Generate sysconfig file
+%{SOURCE3} %{SOURCE2} %{_target_cpu} > kdump.sysconfig
+
make
%ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64
make -C eppic-%{eppic_ver}/libeppic
@@ -183,13 +181,9 @@ install -m 755 build/sbin/vmcore-dmesg $RPM_BUILD_ROOT/usr/sbin/vmcore-dmesg
install -m 644 build/man/man8/kexec.8 $RPM_BUILD_ROOT%{_mandir}/man8/
install -m 644 build/man/man8/vmcore-dmesg.8 $RPM_BUILD_ROOT%{_mandir}/man8/
-SYSCONFIG=$RPM_SOURCE_DIR/kdump.sysconfig.%{_target_cpu}
-[ -f $SYSCONFIG ] || SYSCONFIG=$RPM_SOURCE_DIR/kdump.sysconfig.%{_arch}
-[ -f $SYSCONFIG ] || SYSCONFIG=$RPM_SOURCE_DIR/kdump.sysconfig
-install -m 644 $SYSCONFIG $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/kdump
-
install -m 755 %{SOURCE7} $RPM_BUILD_ROOT/usr/sbin/mkdumprd
install -m 644 %{SOURCE8} $RPM_BUILD_ROOT%{_sysconfdir}/kdump.conf
+install -m 644 kdump.sysconfig $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/kdump
install -m 644 kexec/kexec.8 $RPM_BUILD_ROOT%{_mandir}/man8/kexec.8
install -m 644 %{SOURCE12} $RPM_BUILD_ROOT%{_mandir}/man8/mkdumprd.8
install -m 644 %{SOURCE25} $RPM_BUILD_ROOT%{_mandir}/man8/kdumpctl.8
--
2.35.2
1 year, 4 months
[PATCH] spec: Use zlib/dfltcc as default to improve compression speed and ratio on s390x
by Pingfan Liu
s390x implements zlib/dfltcc dedicated instruction to improve
compression speed and ratio. Switching from 'makedumpfile -l' to
'makedumpfile -c' to benifit from this feature.
Signed-off-by: Pingfan Liu <piliu(a)redhat.com>
---
kexec-tools.spec | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kexec-tools.spec b/kexec-tools.spec
index 6673000..9f1ba34 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -275,6 +275,10 @@ fi
%systemd_post kdump.service
touch /etc/kdump.conf
+# s390 uses zlib/dfltcc as default to improve compression speed and ratio
+%ifarch s390x
+sed -i 's/makedumpfile -l/makedumpfile -c/' /etc/kdump.conf
+%endif
%ifarch ppc64 ppc64le
servicelog_notify --remove --command=/usr/lib/kdump/kdump-migrate-action.sh 2>/dev/null
--
2.31.1
1 year, 4 months
[PATCH v2] logger: save log after all kdump progress finished
by Kairui Song
From: Kairui Song <kasong(a)tencent.com>
Make log saving the last step of kdump.sh, so it can catch more info,
for example, the output of post.d hooks will be covered by the log now.
Signed-off-by: Kairui Song <kasong(a)tencent.com>
---
Update from V1:
- Skip save_log when "KDUMP_LOG_OP" is empty, eg. raw_target
Thanks to Philipp Rudo for the suggestion.
dracut-kdump.sh | 30 ++++++++++++++++++------------
1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/dracut-kdump.sh b/dracut-kdump.sh
index b17455a..f4456a1 100755
--- a/dracut-kdump.sh
+++ b/dracut-kdump.sh
@@ -15,6 +15,8 @@ fi
KDUMP_PATH="/var/crash"
KDUMP_LOG_FILE="/run/initramfs/kexec-dmesg.log"
+KDUMP_LOG_DEST=""
+KDUMP_LOG_OP=""
CORE_COLLECTOR=""
DEFAULT_CORE_COLLECTOR="makedumpfile -l --message-level 7 -d 31"
DMESG_COLLECTOR="/sbin/vmcore-dmesg"
@@ -113,12 +115,19 @@ get_kdump_confs()
# store the kexec kernel log to a file.
save_log()
{
+ # LOG_OP is empty when log can't be saved, eg. raw target
+ [ -n "$KDUMP_LOG_OP" ] || return
+
dmesg -T > $KDUMP_LOG_FILE
if command -v journalctl > /dev/null; then
journalctl -ab >> $KDUMP_LOG_FILE
fi
chmod 600 $KDUMP_LOG_FILE
+
+ dinfo "saving the $KDUMP_LOG_FILE to $KDUMP_LOG_DEST/"
+
+ eval "$KDUMP_LOG_OP"
}
# $1: dump path, must be a mount point
@@ -159,6 +168,9 @@ dump_fs()
save_opalcore_fs "$_dump_fs_path"
dinfo "saving vmcore"
+ KDUMP_LOG_DEST=$_dump_fs_path/
+ KDUMP_LOG_OP="mv '$KDUMP_LOG_FILE' '$KDUMP_LOG_DEST/'"
+
$CORE_COLLECTOR /proc/vmcore "$_dump_fs_path/vmcore-incomplete"
_dump_exitcode=$?
if [ $_dump_exitcode -eq 0 ]; then
@@ -167,12 +179,6 @@ dump_fs()
dinfo "saving vmcore complete"
else
derror "saving vmcore failed, exitcode:$_dump_exitcode"
- fi
-
- dinfo "saving the $KDUMP_LOG_FILE to $_dump_fs_path/"
- save_log
- mv "$KDUMP_LOG_FILE" "$_dump_fs_path/"
- if [ $_dump_exitcode -ne 0 ]; then
return 1
fi
@@ -395,8 +401,12 @@ dump_ssh()
ssh -q $_ssh_opt "$2" mkdir -p "$_ssh_dir" || return 1
save_vmcore_dmesg_ssh "$DMESG_COLLECTOR" "$_ssh_dir" "$_ssh_opt" "$2"
+
dinfo "saving vmcore"
+ KDUMP_LOG_DEST=$2:$_ssh_dir/
+ KDUMP_LOG_OP="scp -q $_ssh_opt '$KDUMP_LOG_FILE' '$_scp_address:$_ssh_dir/'"
+
save_opalcore_ssh "$_ssh_dir" "$_ssh_opt" "$2" "$_scp_address"
if [ "${CORE_COLLECTOR%%[[:blank:]]*}" = "scp" ]; then
@@ -421,12 +431,6 @@ dump_ssh()
derror "saving vmcore failed, exitcode:$_ret"
fi
- dinfo "saving the $KDUMP_LOG_FILE to $2:$_ssh_dir/"
- save_log
- if ! scp -q $_ssh_opt $KDUMP_LOG_FILE "$_scp_address:$_ssh_dir/"; then
- derror "saving log file failed, _exitcode:$_ret"
- fi
-
return $_ret
}
@@ -576,6 +580,8 @@ if ! do_kdump_post $DUMP_RETVAL; then
derror "kdump_post script exited with non-zero status!"
fi
+save_log
+
if [ $DUMP_RETVAL -ne 0 ]; then
exit 1
fi
--
2.35.2
1 year, 4 months
[PATCH v2 0/5] update kexec-tools documentation
by Coiby Xu
v2
- apply suggestions from Philipp
- add Reviewed-by tags
- fix a few typos and grammar mistakes
- clean up crashkernel.default in crashkernel-howto.txt
Coiby Xu (5):
add man documentation for kdumpctl get-default-crashkernel
update crashkernel-howto
update kexec-kdump-howto
update fadump-howto
remove the upper bound of default crashkernel value example
crashkernel-howto.txt | 25 ++++++++++++-------------
fadump-howto.txt | 24 ++++++++++++++----------
kdumpctl.8 | 21 ++++++++++++---------
kexec-kdump-howto.txt | 32 ++++++++++++++++++++------------
4 files changed, 58 insertions(+), 44 deletions(-)
--
2.35.1
1 year, 5 months
[PATCH 1/4] update kexec-kdump-howto
by Coiby Xu
1. yum is deprecated so use dnf instead
2. use the "kdumpctl reset-crashkernel" API
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
---
kexec-kdump-howto.txt | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/kexec-kdump-howto.txt b/kexec-kdump-howto.txt
index 1aeffc7..0121d0e 100644
--- a/kexec-kdump-howto.txt
+++ b/kexec-kdump-howto.txt
@@ -44,7 +44,7 @@ ia64 and ppc64.
If you're reading this document, you should already have kexec-tools
installed. If not, you install it via the following command:
- # yum install kexec-tools
+ # dnf install kexec-tools
Now load a kernel with kexec:
@@ -66,23 +66,24 @@ How to configure kdump
Again, we assume if you're reading this document, you should already have
kexec-tools installed. If not, you install it via the following command:
- # yum install kexec-tools
+ # dnf install kexec-tools
To be able to do much of anything interesting in the way of debug analysis,
you'll also need to install the kernel-debuginfo package, of the same arch
as your running kernel, and the crash utility:
- # yum --enablerepo=\*debuginfo install kernel-debuginfo.$(uname -m) crash
+ # dnf --enablerepo=\*debuginfo install kernel-debuginfo.$(uname -m) crash
-Next up, we need to modify some boot parameters to reserve a chunk of memory for
-the capture kernel. With the help of grubby, it's very easy to append
-"crashkernel=128M" to the end of your kernel boot parameters. Note that the X
-values are such that X = the amount of memory to reserve for the capture kernel.
-And based on arch and system configuration, one might require more than 128M to
-be reserved for kdump. One need to experiment and test kdump, if 128M is not
-sufficient, try reserving more memory.
+Next up, we need to reserve a chunk of memory for the capture kernel. To use
+the default crashkernel value, you can kdumpctl:
- # grubby --args="crashkernel=128M" --update-kernel=/boot/vmlinuz-`uname -r`
+ # kdumpctl reset-crashkernel --kernel=/boot/vmlinuz-`uname -r`
+
+If based on arch and system configuration, the default crashkernel isn't
+sufficent, you can specify a larger value e.g crashkernel=256M after
+experimenting and testing kdump with the help of grubby:
+
+ # grubby --args="crashkernel=256M" --update-kernel=/boot/vmlinuz-`uname -r`
Note that there is an alternative form in which to specify a crashkernel
memory reservation, in the event that more control is needed over the size and
--
2.34.1
1 year, 5 months
[PATCH 0/8] unit tests with ShellSpec
by Coiby Xu
v1:
- issues found by Tao
- clean up files creatd by mktemp
- use DUMMY_PARAM when calling a mocked
- clean up unsued parameters
- mock uname for kdump mode tests to fake current running kernel
- {add,remove}_kernel_arg_in_grub_etc_default replaced by _update_*
Potential benefits brought by unit tests
=======================================
- catch as many bugs as possible and catch them as early as possible
- improve the code quality and make the code robust
- Keep API stable
- prevent regressions from change during the development and in the future
(it's quite annoying to solve one problem only to find another cropping up)
- make it easy for code review because of concrete test cases
Why ShellSpec
=============
ShellSpec [1] is chosen for the following benefits,
- rich features: to name a few
- mocking
- Parameterized tests
- code coverage
- good documentation and examples
For the full comparison between shellspec and other frameworks, please
refer to [2].
How to run the tests
====================
After installing shellspec and optionally kcov
$ curl -fsSL https://git.io/shellspec | sh
$ sudo dnf install kcov
1. go to the root of this repo
2. create a file with _spec as suffix in the spec folder, e.g. spec/kdumpctl_spec.sh
3. run shellspec
shellspec --kcov --kcov-options "--include-pattern=kdumpctl,kdump-lib.sh,kdump-lib-initramfs.sh,kdump-logger.sh"
Running: /bin/sh [bash 5.1.0(1)-release]
................................................................
Finished in 11.15 seconds (user 6.97 seconds, sys 9.54 seconds)
64 examples, 0 failures
Code covered: 16.08%, Executed lines: 224, Instrumented lines: 1393
[1] https://github.com/shellspec/shellspec
[2] https://github.com/dodie/testing-in-bash#detailed-comparision
Coiby Xu (8):
unit tests: prepare for kdumpctl and kdump-lib.sh to be unit-tested
unit tests: add tests for get_grub_kernel_boot_parameter
unit tests: add tests for get_dump_mode_by_fadump_val
unit tests: add tests for kdumpctl read_proc_environ_var and
_is_osbuild
unit tests: add tests for
_{update,read}_kernel_arg_in_grub_etc_default in kdumpctl
unit tests: add tests for "kdumpctl reset-crashkernel"
unit tests: add tests for kdump_get_conf_val in kdump-lib-initramfs.sh
unit tests: add check_config with with the default kdump.conf
.shellspec | 0
kdump-lib.sh | 7 +-
kdumpctl | 24 +-
spec/kdump-lib-initramfs_spec.sh | 41 ++++
spec/kdumpctl_general_spec.sh | 183 ++++++++++++++
spec/kdumpctl_reset_crashkernel_spec.sh | 223 ++++++++++++++++++
spec/support/bin/@grubby | 3 +
...846f63134c7295458cf36300ba5b-0-rescue.conf | 8 +
...58cf36300ba5b-5.14.14-200.fc34.x86_64.conf | 8 +
...458cf36300ba5b-5.15.6-100.fc34.x86_64.conf | 8 +
spec/support/grub_env | 3 +
11 files changed, 499 insertions(+), 9 deletions(-)
create mode 100644 .shellspec
create mode 100644 spec/kdump-lib-initramfs_spec.sh
create mode 100644 spec/kdumpctl_general_spec.sh
create mode 100644 spec/kdumpctl_reset_crashkernel_spec.sh
create mode 100755 spec/support/bin/@grubby
create mode 100644 spec/support/boot_load_entries/e986846f63134c7295458cf36300ba5b-0-rescue.conf
create mode 100644 spec/support/boot_load_entries/e986846f63134c7295458cf36300ba5b-5.14.14-200.fc34.x86_64.conf
create mode 100644 spec/support/boot_load_entries/e986846f63134c7295458cf36300ba5b-5.15.6-100.fc34.x86_64.conf
create mode 100644 spec/support/grub_env
--
2.34.1
1 year, 5 months
[PATCH] x86_64: Reserve extra memory for crashkernel if AMD sme/sev enabled
by Tao Liu
When AMD sme/sev enabled, it will require extra memory reserved for swiotlb.
Currently the swiotlb kernel parameter is removed by /etc/sysconfig/kdump for
2nd kernel, so a 64MB memory for swiotlb will be reserved by default [1],
and the 2nd kernel will fail of OOM with the default crashkernel value.
swiotlb memory is mandatory for AMD sme/sev. For rhel8, kernel commit
0adb0f4 ("[x86] Reserve at most 64M of SWIOTLB memory for crashkernel")
implemented the reservation in the kernel side, as part of the kernel
crashkernel=auto implementation.
For rhel9 however, crashkernel=auto has been mirrored to userspace
kexec-tools, so this patch will enable the swiotlb reservation for AMD
sme/sev in kexec-tools as well.
[1]: https://elixir.bootlin.com/linux/v5.14/source/arch/x86/mm/mem_encrypt.c#L200
Signed-off-by: Tao Liu <ltao(a)redhat.com>
---
kdump-lib-initramfs.sh | 10 ++++++++++
kdump-lib.sh | 11 +++++++++--
kdumpctl | 7 ++++++-
3 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh
index 9be0fe9..699babd 100755
--- a/kdump-lib-initramfs.sh
+++ b/kdump-lib-initramfs.sh
@@ -8,6 +8,11 @@ KDUMP_CONFIG_FILE="/etc/kdump.conf"
FENCE_KDUMP_CONFIG_FILE="/etc/sysconfig/fence_kdump"
FENCE_KDUMP_SEND="/usr/libexec/fence_kdump_send"
+# Reserve 64MB for swiotlb when AMD sme/sev enabled.
+AMD_SME_SEV_SWIOTLB=64
+# Copied from include/linux/swiotlb.h
+IO_TLB_SHIFT=11
+
# Read kdump config in well formated style
kdump_read_conf()
{
@@ -130,3 +135,8 @@ is_fs_dump_target()
{
[ -n "$(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix")" ]
}
+
+is_amd_sme_sev_enabled()
+{
+ dmesg | grep -sq "AMD Memory Encryption Features active"
+}
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 4ed5035..8ea6bfe 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -831,7 +831,7 @@ get_recommend_size()
# $1 dump mode, if not specified, dump_mode will be judged by is_fadump_capable
kdump_get_arch_recommend_crashkernel()
{
- local _arch _ck_cmdline _dump_mode
+ local _arch _ck_cmdline _dump_mode _mem_enc
if [[ -z "$1" ]]; then
if is_fadump_capable; then
@@ -845,7 +845,14 @@ kdump_get_arch_recommend_crashkernel()
_arch=$(uname -m)
- if [[ $_arch == "x86_64" ]] || [[ $_arch == "s390x" ]]; then
+ if [[ $_arch == "x86_64" ]]; then
+ if is_amd_sme_sev_enabled; then
+ _mem_enc=$AMD_SME_SEV_SWIOTLB
+ else
+ _mem_enc=0
+ fi
+ _ck_cmdline="1G-4G:$((192+$_mem_enc))M,4G-64G:$((256+$_mem_enc))M,64G-:$((512+$_mem_enc))M"
+ elif [[ $_arch == "s390x" ]]; then
_ck_cmdline="1G-4G:192M,4G-64G:256M,64G-:512M"
elif [[ $_arch == "aarch64" ]]; then
_ck_cmdline="2G-:448M"
diff --git a/kdumpctl b/kdumpctl
index 1869753..50aafda 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -21,6 +21,7 @@ FADUMP_REGISTER_SYS_NODE="/sys/kernel/fadump_registered"
#kdump shall be the default dump mode
DEFAULT_DUMP_MODE="kdump"
image_time=0
+size_mb=$((1024 * 1024))
standard_kexec_args="-d -p"
@@ -622,6 +623,11 @@ load_kdump()
{
local ret
+ # Force 2nd kernel use swiotlb for AMD sme/sve to 64MB at most.
+ if is_amd_sme_sev_enabled; then
+ KDUMP_COMMANDLINE_APPEND+=" swiotlb=$((($AMD_SME_SEV_SWIOTLB * $size_mb) >> $IO_TLB_SHIFT)) "
+ fi
+
KEXEC_ARGS=$(prepare_kexec_args "${KEXEC_ARGS}")
KDUMP_COMMANDLINE=$(prepare_cmdline "${KDUMP_COMMANDLINE}" "${KDUMP_COMMANDLINE_REMOVE}" "${KDUMP_COMMANDLINE_APPEND}")
@@ -1189,7 +1195,6 @@ do_estimate()
local -A large_mods
local baseline
local kernel_size mod_size initrd_size baseline_size runtime_size reserved_size estimated_size recommended_size
- local size_mb=$((1024 * 1024))
setup_initrd
if [[ ! -f $TARGET_INITRD ]]; then
--
2.33.1
1 year, 5 months