kdump-utils/kdump-utils.spec
Philipp Rudo 24edf00fb8 kdump-lib-initramfs: Fix performance regression in kdump_get_conf_val
Resolves: https://issues.redhat.com/browse/RHEL-137945
Upstream: kdump-utils
Conflict: None

commit b43908c20f5a028c60b0096006a26a6e52a01279
Author: Philipp Rudo <prudo@redhat.com>
Date:   Wed Jan 14 15:54:25 2026 +0100

    kdump-lib-initramfs: Fix performance regression in kdump_get_conf_val

    Rewriting kdump_get_conf_val in Bash lead to a massive performance
    regression. On my test system starting the kdump service took

    $ time kdumpctl start
    real    0m13.134s
    user    0m8.828s
    sys     0m7.450s

    which is ~20 times slower compared to kdump-utils-1.0.59-1.fc44 with

    $ time kdumpctl start
    real    0m0.641s
    user    0m0.208s
    sys     0m0.538s

    Looking at the traces shows that this is caused because Bash now has to
    handle the whole kdump.conf, including the extensive comment at the
    start, every time kdump_get_conf_val is called. This is done multiple
    times when starting the kdump service and is often cloaked by other
    functions, e.g. is_ssh_dump_target() or get_save_path().

    To fix the issue remove comments and empty lines in a regex again so
    that the Bash code only has to handle valid config entries. With this
    change alone the performance is almost as good as the original version
    with

    $ time kdumpctl start
    real    0m0.780s
    user    0m0.330s
    sys     0m0.604s

    In the long run it would make sense to also reduce the number of calls
    to kdump_get_conf_val.

    This patch also fixes the issue that subsequent blanks are replaced by a
    single space. Usually this is not an issue but there are corner cases,
    e.g. in printf-like format strings passed as an argument, where the new
    behaviour is undesirable.

    Fixes: d81109c ("kdump-lib-initramfs: rewrite kdump_get_conf_val")
    Signed-off-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Philipp Rudo <prudo@redhat.com>
2026-01-20 13:44:29 +01:00

140 lines
4.5 KiB
RPMSpec

# kdump-utils has no debug source
%global debug_package %{nil}
Name: kdump-utils
Version:1.0.58
Release: %autorelease -b 1
Summary: Kernel crash dump collection utilities
License: GPL-2.0-only
URL: https://github.com/rhkdump/kdump-utils
Source0: https://github.com/rhkdump/kdump-utils/archive/v%{version}/%{name}-%{version}.tar.gz
Patch01: 0001-Strip-surrounding-quotes-from-configuration-values.patch
Patch02: 0002-unit-tests-Add-case-for-quoted-configuration-values.patch
Patch03: 0003-Allow-kdump.service-to-access-LUKS-volume-keys.patch
Patch04: 0004-Restore-SELinux-label-of-crypttab-file.patch
Patch05: 0005-Allow-sudo-kdumpctl-for-LUKS-dump-target.patch
Patch06: 0006-Revert-Strip-surrounding-quotes-from-configuration-v.patch
Patch07: 0007-kdump-lib-initramfs-rewrite-kdump_get_conf_val.patch
Patch08: 0008-Add-persisent-device-if-FIPS-is-enabled.patch
Patch09: 0009-kdump.sh-Centralize-the-F-suboption-handling.patch
Patch10: 0010-kdump.sh-Centralize-the-num-threads-sub-option-handl.patch
Patch11: 0011-kdump.sh-Skip-num-threads-when-E-and-F-option-is-pre.patch
Patch12: 0012-powerpc-consider-CPU-count-while-calculating-crashke.patch
Patch13: 0013-powerpc-Set-nr_cpus-16-for-kdump-kernel.patch
Patch14: 0014-kexec-kdump-howto.txt-update-paragraphs-related-to-d.patch
Patch15: 0015-kdump-lib-initramfs-Fix-performance-regression-in-kd.patch
%ifarch ppc64 ppc64le
Requires(post): servicelog
Recommends: keyutils
%endif
Requires(pre): coreutils
Requires(pre): sed
Requires: kexec-tools >= 2.0.28-8
Requires: makedumpfile
Requires: dracut >= 058
Requires: dracut-network >= 058
Requires: dracut-squash >= 058
Requires: ethtool
Requires: util-linux
# Needed for UKI support
Recommends: binutils
Recommends: grubby
Recommends: hostname
BuildRequires: make
BuildRequires: systemd-rpm-macros
%ifnarch s390x
Requires: systemd-udev%{?_isa}
%endif
%description
kdump-utils is responsible for collecting the crash kernel dump. It builds and
loads the kdump initramfs so when a kernel crashes, the system will boot the
kdump kernel and initramfs to save the collected crash kernel dump to specified
target.
%prep
%autosetup -p1
%install
%make_install sbindir=%_sbindir
%post
# kdumpctl will only set up default crashkernel when kdump.service is enabled
%systemd_post kdump.service
touch /etc/kdump.conf
%ifarch ppc64 ppc64le
servicelog_notify --remove --command=/usr/lib/kdump/kdump-migrate-action.sh 2>/dev/null
servicelog_notify --add --command=/usr/lib/kdump/kdump-migrate-action.sh --match='refcode="#MIGRATE" and serviceable=0' --type=EVENT --method=pairs_stdin >/dev/null
%endif
# RPM scriptlet should always return 0. Otherwise it can break
# installs/upgrades/erases.
:
%postun
%systemd_postun_with_restart kdump.service
%preun
%ifarch ppc64 ppc64le
servicelog_notify --remove --command=/usr/lib/kdump/kdump-migrate-action.sh >/dev/null
%endif
%systemd_preun kdump.service
%posttrans
# Try to reset kernel crashkernel value to new default value or set up
# crasherkernel value for new install
#
# Note
# 1. Skip ostree systems as they are not supported.
# 2. For Fedora 36 and RHEL9, "[ $1 == 1 ]" in posttrans scriptlet means both install and upgrade;
# For Fedora > 36, "[ $1 == 1 ]" only means install and "[ $1 == 2 ]" means upgrade
# 3. osbuild depends on "kdumpctl _reset-crashkernel-for-installed_kernel" to set up crashkernel
if [ ! -f /run/ostree-booted ] && [ $1 == 1 -o $1 == 2 ]; then
kdumpctl _reset-crashkernel-after-update
:
fi
%files
%ifarch ppc64 ppc64le
%{_sbindir}/mkfadumprd
%{_prefix}/lib/kernel/install.d/60-fadump.install
%endif
%{_bindir}/kdumpctl
%{_sbindir}/mkdumprd
%{_prefix}/lib/kdump
%config(noreplace,missingok) %{_sysconfdir}/sysconfig/kdump
%config(noreplace,missingok) %verify(not mtime) %{_sysconfdir}/kdump.conf
%ifnarch s390x
%{_udevrulesdir}
%{_udevrulesdir}/../kdump-udev-throttler
%endif
%{_prefix}/lib/dracut/modules.d/*
%dir %{_localstatedir}/crash
%dir %{_sysconfdir}/kdump
%dir %{_sysconfdir}/kdump/pre.d
%dir %{_sysconfdir}/kdump/post.d
%dir %{_sharedstatedir}/kdump
%{_mandir}/man8/kdumpctl.8*
%{_mandir}/man8/mkdumprd.8*
%{_mandir}/man5/kdump.conf.5*
%{_unitdir}/kdump.service
%{_prefix}/lib/systemd/system-generators/kdump-dep-generator.sh
%{_prefix}/lib/kernel/install.d/60-kdump.install
%{_prefix}/lib/kernel/install.d/92-crashkernel.install
%license COPYING
%doc kexec-kdump-howto.txt
%doc early-kdump-howto.txt
%doc fadump-howto.txt
%doc kdump-in-cluster-environment.txt
%doc live-image-kdump-howto.txt
%doc crashkernel-howto.txt
%doc supported-kdump-targets.txt
%changelog
%autochangelog