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 <t-kudoh@fujitsu.com>
Signed-off-by: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
This commit is contained in:
Jerome Marchand 2022-03-31 12:00:21 +02:00
parent fd6689cbe5
commit d35482cb66
4 changed files with 43 additions and 2 deletions

1
98-trace-cmd.rules Normal file
View File

@ -0,0 +1 @@
SUBSYSTEM=="module", ACTION=="add", PROGRAM="/usr/bin/systemctl is-active trace-cmd.service", PROGRAM="/usr/bin/systemctl reload trace-cmd.service"

4
trace-cmd.conf Normal file
View File

@ -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"

15
trace-cmd.service Normal file
View File

@ -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

View File

@ -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 <jmarchan@redhat.com> - 2.9.2-9
- Add flight recorder service
* Fri Nov 12 2021 Jerome Marchand <jmarchan@redhat.com> - 2.9.2-8
- Fix remaining gating runpath failure