From d35482cb66774b68822ed414ffa1c2dd1cc548ba Mon Sep 17 00:00:00 2001 From: Jerome Marchand Date: Thu, 31 Mar 2022 12:00:21 +0200 Subject: [PATCH] Add flight recoder service Flight recorder service, trace-cmd.service, provides a feature to automatically start trace-cmd command at every system start-up and to automatically reload trace-cmd command at every kernel module loading to enable tracepoints provided by kernel modules. Thanks to this feature, once system panic occurs, users retrieve ftrace ring buffer from crash dump that is created by some crash dump mechanism such as kdump and virsh dump using crash trace command [1] and can perform failure analysis based on ftrace event logs. Historically, this feature has been provided only in the RHEL7 and RHEL8 versions of trace-cmd packages so far. However, with the introduction of CentOS Stream, RHEL's development process changed and now CentOS Stream is an upstream of RHEL and Fedora Linux is the upstream of CentOS Stream [2], due to which, Red Hat now follows upstream-first policy strictly and requires this feature be provided in its upstream. [1] https://src.fedoraproject.org/rpms/crash-trace-command [2] https://www.redhat.com/en/topics/linux/what-is-centos-stream Resolves: rhbz#2070600 Signed-off-by: KUDOH Takashi Signed-off-by: HATAYAMA Daisuke Signed-off-by: Jerome Marchand --- 98-trace-cmd.rules | 1 + trace-cmd.conf | 4 ++++ trace-cmd.service | 15 +++++++++++++++ trace-cmd.spec | 25 +++++++++++++++++++++++-- 4 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 98-trace-cmd.rules create mode 100644 trace-cmd.conf create mode 100644 trace-cmd.service diff --git a/98-trace-cmd.rules b/98-trace-cmd.rules new file mode 100644 index 0000000..9575bd8 --- /dev/null +++ b/98-trace-cmd.rules @@ -0,0 +1 @@ +SUBSYSTEM=="module", ACTION=="add", PROGRAM="/usr/bin/systemctl is-active trace-cmd.service", PROGRAM="/usr/bin/systemctl reload trace-cmd.service" diff --git a/trace-cmd.conf b/trace-cmd.conf new file mode 100644 index 0000000..85c4fbe --- /dev/null +++ b/trace-cmd.conf @@ -0,0 +1,4 @@ +# ftrace based flightrecorder configuration file. + +# trace-cmd options +OPTS="-b 2048 -i -e block -e irq -e mce -e module -e power -e sched -e signal -e timer -e workqueue -e kvm -e net" diff --git a/trace-cmd.service b/trace-cmd.service new file mode 100644 index 0000000..27b07f5 --- /dev/null +++ b/trace-cmd.service @@ -0,0 +1,15 @@ +[Unit] +Description=trace-cmd Flightrecorder +DefaultDependencies=no +Before=sysinit.target + +[Service] +Type=oneshot +RemainAfterExit=yes +EnvironmentFile=/etc/sysconfig/trace-cmd.conf +ExecStart=/usr/bin/trace-cmd start $OPTS +ExecStop=/usr/bin/trace-cmd reset +ExecReload=/usr/bin/trace-cmd start $OPTS + +[Install] +WantedBy=multi-user.target diff --git a/trace-cmd.spec b/trace-cmd.spec index 9dd4496..9d29f13 100644 --- a/trace-cmd.spec +++ b/trace-cmd.spec @@ -6,7 +6,7 @@ Name: trace-cmd Version: %{srcversion} -Release: 8%{?dist} +Release: 9%{?dist} License: GPLv2 and LGPLv2 Summary: A user interface to Ftrace Requires: libtracecmd @@ -19,6 +19,9 @@ URL: http://git.kernel.org/?p=linux/kernel/git/rostedt/trace-cmd.git;a=summary # cd trace-cmd # git archive --prefix=trace-cmd-%%{version}/ -o trace-cmd-v%%{version}.tar.gz %%{git_commit} Source0: https://git.kernel.org/pub/scm/utils/trace-cmd/trace-cmd.git/snapshot/trace-cmd-v%{srcversion}.tar.gz +Source1: trace-cmd.conf +Source2: trace-cmd.service +Source3: 98-trace-cmd.rules Patch0: trace-cmd-Fix-broken-profile-command.patch Patch1: trace-cmd-utils.mk-don-t-ignore-LDFLAGS-when-linking-the-share.patch @@ -38,6 +41,7 @@ BuildRequires: json-c-devel BuildRequires: libtraceevent-devel BuildRequires: libtracefs-devel BuildRequires: chrpath +BuildRequires: systemd-rpm-macros %description trace-cmd is a user interface to Ftrace. Instead of needing to use the @@ -70,6 +74,9 @@ Development files of the libtracecmd library %prep %autosetup -p1 -n %{name}-v%{srcversion} +cp %{SOURCE1} . +cp %{SOURCE2} . +cp %{SOURCE3} . %build %set_build_flags @@ -92,7 +99,15 @@ make V=1 libdir=%{_libdir} prefix=%{_prefix} DESTDIR=%{buildroot}/ \ find %{buildroot}%{_mandir} -type f | xargs chmod u-x,g-x,o-x find %{buildroot}%{_datadir} -type f | xargs chmod u-x,g-x,o-x find %{buildroot}%{_libdir} -type f -iname "*.so" | xargs chmod 0755 -mkdir -p %{buildroot}/%{_sysconfdir} +mkdir -p -m755 %{buildroot}/%{_sysconfdir}/sysconfig/ +mkdir -p -m755 %{buildroot}/%{_unitdir}/ +mkdir -p -m755 %{buildroot}/%{_udevrulesdir}/ +install -p -m 644 trace-cmd.conf %{buildroot}/%{_sysconfdir}/sysconfig/ +install -p -m 644 trace-cmd.service %{buildroot}/%{_unitdir}/ +install -p -m 644 98-trace-cmd.rules %{buildroot}/%{_udevrulesdir}/ + +%preun +%systemd_preun %{name}.service %files %doc COPYING COPYING.LIB README @@ -100,6 +115,9 @@ mkdir -p %{buildroot}/%{_sysconfdir} %{_mandir}/man1/%{name}* %{_mandir}/man5/%{name}* %{_sysconfdir}/bash_completion.d/trace-cmd.bash +%{_sysconfdir}/sysconfig/trace-cmd.conf +%{_unitdir}/trace-cmd.service +%{_udevrulesdir}/98-trace-cmd.rules %files python3 %doc Documentation/README.PythonPlugin @@ -119,6 +137,9 @@ mkdir -p %{buildroot}/%{_sysconfdir} %{_includedir}/trace-cmd %changelog +* Thu Mar 31 2022 Jerome Marchand - 2.9.2-9 +- Add flight recorder service + * Fri Nov 12 2021 Jerome Marchand - 2.9.2-8 - Fix remaining gating runpath failure