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

Signed-off-by: KUDOH Takashi <t-kudoh@fujitsu.com>
Signed-off-by: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
This commit is contained in:
root 2022-03-24 15:31:34 +09:00
parent b489389cf9
commit 14be4ebb0d
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 Name: trace-cmd
Version: %{srcversion} Version: %{srcversion}
Release: 1%{?dist} Release: 2%{?dist}
License: GPLv2 and LGPLv2 License: GPLv2 and LGPLv2
Summary: A user interface to Ftrace Summary: A user interface to Ftrace
Requires: libtracecmd Requires: libtracecmd
@ -21,6 +21,9 @@ URL: http://git.kernel.org/?p=linux/kernel/git/rostedt/trace-cmd.git;a=summary
# cd trace-cmd # cd trace-cmd
# git archive --prefix=trace-cmd-%%{version}/ -o trace-cmd-v%%{version}.tar.gz %%{git_commit} # 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 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
BuildRequires: make BuildRequires: make
BuildRequires: gcc BuildRequires: gcc
BuildRequires: xmlto BuildRequires: xmlto
@ -39,6 +42,7 @@ BuildRequires: libtracefs-devel
BuildRequires: audit-libs-devel BuildRequires: audit-libs-devel
BuildRequires: chrpath BuildRequires: chrpath
BuildRequires: swig BuildRequires: swig
BuildRequires: systemd-rpm-macros
%description %description
trace-cmd is a user interface to Ftrace. Instead of needing to use the 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 %prep
%autosetup -n %{name}-v%{srcversion} %autosetup -n %{name}-v%{srcversion}
cp %{SOURCE1} .
cp %{SOURCE2} .
cp %{SOURCE3} .
%build %build
# MANPAGE_DOCBOOK_XSL define is hack to avoid using locate # MANPAGE_DOCBOOK_XSL define is hack to avoid using locate
@ -90,7 +97,15 @@ make libdir=%{_libdir} prefix=%{_prefix} V=1 DESTDIR=%{buildroot}/ CFLAGS="%{opt
find %{buildroot}%{_mandir} -type f | xargs chmod u-x,g-x,o-x 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}%{_datadir} -type f | xargs chmod u-x,g-x,o-x
find %{buildroot}%{_libdir} -type f -iname "*.so" | xargs chmod 0755 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 %files
%doc COPYING COPYING.LIB README %doc COPYING COPYING.LIB README
@ -98,6 +113,9 @@ mkdir -p %{buildroot}/%{_sysconfdir}
%{_mandir}/man1/%{name}* %{_mandir}/man1/%{name}*
%{_mandir}/man5/%{name}* %{_mandir}/man5/%{name}*
%{_sysconfdir}/bash_completion.d/trace-cmd.bash %{_sysconfdir}/bash_completion.d/trace-cmd.bash
%{_sysconfdir}/sysconfig/trace-cmd.conf
%{_unitdir}/trace-cmd.service
%{_udevrulesdir}/98-trace-cmd.rules
%files python3 %files python3
%doc Documentation/README.PythonPlugin %doc Documentation/README.PythonPlugin
@ -117,6 +135,9 @@ mkdir -p %{buildroot}/%{_sysconfdir}
%{_includedir}/trace-cmd %{_includedir}/trace-cmd
%changelog %changelog
* Fri Mar 18 2022 KUDOH Takashi <t-kudoh@fujitsu.com> - 2.9.7-2
- Add flight recoder service
* Wed Feb 16 2022 Zamir SUN <sztsian@gmail.com> - 2.9.7-1 * Wed Feb 16 2022 Zamir SUN <sztsian@gmail.com> - 2.9.7-1
- Update to 2.9.7 - Update to 2.9.7