From 684db02d31c59f1b8653b0dcd285d8f5e80534bb Mon Sep 17 00:00:00 2001 From: Clark Williams Date: Wed, 5 Jul 2023 08:19:59 -0500 Subject: [PATCH] initial checkin for rawhide Signed-off-by: Clark Williams --- Makefile | 72 ++++++ enable-netsocket-tstamp-static-key.c | 83 +++++++ kernel-is-rt | 2 + kernel-rt-protect.conf | 2 + kernel-rt-protect.py | 27 +++ realtime-entsk.service | 12 + realtime-setup-kdump | 171 +++++++++++++ realtime-setup.dracut | 2 + realtime-setup.service | 12 + realtime-setup.spec.save | 350 +++++++++++++++++++++++++++ realtime-setup.sysconfig | 4 + realtime-setup.systemd | 34 +++ realtime-setup.sysvinit | 125 ++++++++++ realtime.conf | 10 + rhel-rt.rules | 19 ++ rtapp-example.sh | 78 ++++++ slub_cpu_partial_off | 12 + what-do.txt | 43 ++++ 18 files changed, 1058 insertions(+) create mode 100644 Makefile create mode 100644 enable-netsocket-tstamp-static-key.c create mode 100755 kernel-is-rt create mode 100644 kernel-rt-protect.conf create mode 100644 kernel-rt-protect.py create mode 100644 realtime-entsk.service create mode 100644 realtime-setup-kdump create mode 100644 realtime-setup.dracut create mode 100644 realtime-setup.service create mode 100644 realtime-setup.spec.save create mode 100644 realtime-setup.sysconfig create mode 100755 realtime-setup.systemd create mode 100644 realtime-setup.sysvinit create mode 100644 realtime.conf create mode 100644 rhel-rt.rules create mode 100644 rtapp-example.sh create mode 100755 slub_cpu_partial_off create mode 100644 what-do.txt diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..fc1a489 --- /dev/null +++ b/Makefile @@ -0,0 +1,72 @@ +VERSION := $(shell awk '/^Version:/ { print $$2 }' realtime-setup.spec) +$(info "Version: $(VERSION)") +RPMDIR := $(shell pwd)/rpm +RPMARGS := --define "_topdir $(RPMDIR)" + +CC := gcc +ifeq ($(CFLAGS),) +CFLAGS := -O3 -g -Wall -D_GNU_SOURCE \ + -fstack-protector-all -fcf-protection \ + -fstack-clash-protection +endif +CFLAGS += -fPIC -fplugin=annobin +LDFLAGS += -Wl,-z,now -Wl,-z,relro -pie + +DISTVER := 8.0.0 +DISTGITDIR := ../realtime-setup.rhpkg +DISTGITBRANCH := rhel-$(DISTVER) + +FILES := realtime-setup-kdump \ + slub_cpu_partial_off \ + rhel-rt.rules \ + kernel-is-rt \ + realtime-setup.sysconfig \ + realtime-setup.systemd \ + realtime.conf \ + realtime-entsk.service \ + realtime-setup.service \ + realtime-setup.spec + +all: realtime-entsk + +realtime-entsk: enable-netsocket-tstamp-static-key.c + $(CC) $(CFLAGS) -c enable-netsocket-tstamp-static-key.c + $(CC) $(LDFLAGS) -o realtime-entsk enable-netsocket-tstamp-static-key.o + +rpm: rpmdir tarball + cp realtime-setup-$(VERSION).tar.bz2 rpm/SOURCES + rpmbuild $(RPMARGS) -ba realtime-setup.spec + +rpmdir: + @[ -d rpm ] || mkdir -p rpm/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS} + +srpm: clean rpmdir tarball + mv realtime-setup-$(VERSION).tar.bz2 rpm/SOURCES + rpmbuild $(RPMARGS) -bs realtime-setup.spec + +clean: + rm -f *~ *.tar.bz2 + rm -rf rpm + rm -f realtime-entsk *.o + +tarball: rpmdir + git archive --format=tar --prefix=realtime-setup-$(VERSION)/ HEAD | bzip2 >realtime-setup-$(VERSION).tar.bz2 + +install: + install -m 755 -D realtime-setup-kdump $(DEST)/usr/bin/realtime-setup-kdump + install -m 755 -D slub_cpu_partial_off $(DEST)/usr/bin/slub_cpu_partial_off + install -m 644 -D rhel-rt.rules $(DEST)/etc/udev/rules.d/99-rhel-rt.rules + install -m 755 -D kernel-is-rt $(DEST)/usr/sbin/kernel-is-rt + install -m 644 -D realtime-setup.sysconfig $(DEST)/etc/sysconfig/realtime-setup + install -m 755 -D realtime-setup.systemd $(DEST)/usr/bin/realtime-setup + install -m 644 -D realtime.conf $(DEST)/etc/security/limits.d/realtime.conf + install -m 644 -D realtime-entsk.service $(DEST)/usr/lib/systemd/system/realtime-entsk.service + install -m 755 -D -s realtime-entsk $(DEST)/usr/sbin/realtime-entsk + install -m 644 -D realtime-setup.service $(DEST)/usr/lib/systemd/system/realtime-setup.service + +dist-git: tarball + cd $(DISTGITDIR) && rhpkg switch-branch --fetch $(DISTGITBRANCH) + cp $(FILES) $(DISTGITDIR) + cp realtime-setup-$(VERSION).tar.bz2 $(DISTGITDIR) + cd $(DISTGITDIR) && rhpkg new-sources realtime-setup-$(VERSION).tar.bz2 + @echo "files copied to $(DISTGITDIR)" diff --git a/enable-netsocket-tstamp-static-key.c b/enable-netsocket-tstamp-static-key.c new file mode 100644 index 0000000..676cd87 --- /dev/null +++ b/enable-netsocket-tstamp-static-key.c @@ -0,0 +1,83 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * + * Copyright (c) 2018 Marcelo Tosatti + + * Open a socket, and enable timestamping on it. + * + * This is to avoid Chrony from changing timestamping + * user count from 0->1 and vice-versa, causing + * static key enable/disable IPIs. + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main (void) +{ + int option = SOF_TIMESTAMPING_OPT_TX_SWHW; + int sock_fd; + int ret; + int pid_fd; + pid_t pid; + char buf[50]; + + /* open a datagram socket */ + sock_fd = socket(AF_INET, SOCK_DGRAM, 0); + if (sock_fd < 0) { + printf("Error opening the socket\n"); + return 0; + } + + /* set the timestamping option + * this is to trigger the IPIs that notify all cpus of the change + */ + if (setsockopt(sock_fd, SOL_SOCKET, SO_TIMESTAMP, &option, sizeof (option)) < 0) { + printf("Could not enable timestamping option %x", (unsigned int)option); + close(sock_fd); + return 0; + } + + /* dameonize our task */ + ret = daemon(0, 0); + + if (ret == -1) { + perror("daemon"); + exit(0); + } + + /* write our pid file to make systemd happy */ + pid_fd = open("/run/rt-entsk.pid", O_RDWR|O_CREAT|O_TRUNC, 0644); + if (pid_fd < 0) { + perror("open of /run/rt-entsk.pid failed:"); + exit(errno); + } + pid = getpid(); + + sprintf(buf, "%d\n", pid); + + ret = write(pid_fd, buf, strlen(buf)); + if (ret == -1) { + perror("write"); + exit(1); + } + close(pid_fd); + + /* now just pause forever */ + while (1) { + pause(); + } +} diff --git a/kernel-is-rt b/kernel-is-rt new file mode 100755 index 0000000..6e8e8d4 --- /dev/null +++ b/kernel-is-rt @@ -0,0 +1,2 @@ +#!/usr/bin/bash -e +[ -e /sys/kernel/realtime ] diff --git a/kernel-rt-protect.conf b/kernel-rt-protect.conf new file mode 100644 index 0000000..8e4d76c --- /dev/null +++ b/kernel-rt-protect.conf @@ -0,0 +1,2 @@ +[main] +enabled=1 diff --git a/kernel-rt-protect.py b/kernel-rt-protect.py new file mode 100644 index 0000000..a7ecadf --- /dev/null +++ b/kernel-rt-protect.py @@ -0,0 +1,27 @@ +from yum.plugins import TYPE_INTERACTIVE +requires_api_version = '2.5' +plugin_type = (TYPE_INTERACTIVE,) + +def config_hook(conduit): + def get_running_kernel_pkgtup(ts): + """This takes the output of uname and figures out the pkgtup of the running + kernel (name, arch, epoch, version, release).""" + import os, glob + ver = os.uname()[2] + + # we glob for the file that MIGHT have this kernel + # and then look up the file in our rpmdb. + fns = sorted(glob.glob('/boot/vmlinuz*%s*' % ver)) + for fn in fns: + mi = ts.dbMatch('basenames', fn) + for h in mi: + e = h['epoch'] + if h['epoch'] is None: + e = '0' + else: + e = str(e) + return (h['name'], h['arch'], e, h['version'], h['release']) + return (None, None, None, None, None) + + from yum import misc + misc.get_running_kernel_pkgtup = get_running_kernel_pkgtup diff --git a/realtime-entsk.service b/realtime-entsk.service new file mode 100644 index 0000000..006402d --- /dev/null +++ b/realtime-entsk.service @@ -0,0 +1,12 @@ +[Unit] +Description=RT Enable Netsocket Timestap Static Key daemon +After=syslog.target network.target +StartLimitIntervalSec=0 + +[Service] +Type=forking +PIDFile=/run/rt-entsk.pid +ExecStart=/usr/sbin/rt-entsk + +[Install] +WantedBy=multi-user.target diff --git a/realtime-setup-kdump b/realtime-setup-kdump new file mode 100644 index 0000000..2219153 --- /dev/null +++ b/realtime-setup-kdump @@ -0,0 +1,171 @@ +#!/usr/bin/bash +# +# script to update /etc/sysconfig/kdump to use the latest +# kernel package as the dump kernel +# +# optional argument --grub causes kdump kernel cmdline to +# be added to rt kernel grub entries +# + +me=$(basename $0) +rpmcmd='rpm -q --last' + +function fatal () { + echo "$me: " $1 + exit -1 +} + +function usage () { + echo "usage: $me [-g|--grub] [-r|--rhel] [-v|--verbose] [-h|--help]" + echo " --grub - add crashkernel arg to rt grub entries" + echo " --rhel - use the RHEL-8 kernel as the kdump kernel" + echo " (the default is to use the RHEL-RT kernel)" + echo " --verbose - print out actions" + echo " --help - print this message" + exit -1 +} + +function report() { + [ $verbose -eq 1 ] && echo $1 +} + +# return the latest package version of specified package name +function latest_package_ver() { + local pkg=$1 + local ver=$($rpmcmd $pkg | head -1 | awk '{print $1}') + + if [ $? -ne 0 ]; then + fatal " error fetching version for $pkg" + fi + echo ${ver#$pkg-} + return 0 +} + +# get the kernel version of hhe latest installed kernel +function vmlinux_ver() { + local ver=$1 + local vmver='' + for i in $(cd /boot; echo vmlinuz-*); do + if [ "${i#vmlinuz-$ver}" != "$i" ]; then + vmver=${i#vmlinuz-} + echo $vmver + return 0 + fi + done + return 1 +} + +# find all the grub indexs for installed rhel-rt kernels +# returns a comma-separated list of indices for use +# by the grubby command +function find_rt_kernel_indexes_rhel_rt() { + local awkscript='BEGIN{FS="="; ORS=","} $1 ~ /^index/{idx=$2;} + $2 ~ /.rt.*.el8.x86_64/ && + $1 ~ /^kernel/ {print idx}' + local rt_idx_list=$(/sbin/grubby --info=ALL | /usr/bin/awk "$awkscript") + + echo $rt_idx_list | sed -e 's/,$//' + return 0 +} + +############################################################################# + +# make sure we're root +if [ $(id -u) -ne 0 ]; then + echo " must be root to run $me!" + usage +fi + +# process options +dogrub=0 +userhel=0 +verbose=0 +TEMP=$(getopt --options "grvh" --longoptions="grub,rhel,verbose,help" -- "$@") +if [ $? -ne 0 ]; then + usage +fi +eval set -- "$TEMP" +while true; do + case "$1" in + -g|--grub) + dogrub=1 + shift + ;; + -r|--rhel) + userhel=1 + shift + ;; + -v|--verbose) + verbose=1 + shift + ;; + -h|--help) + usage + ;; + --) shift ; break ;; + *) + echo "internal error!" + usage + ;; + esac +done + +# warn if /etc/sysconfig/kdump does not exist +if [ ! -f /etc/sysconfig/kdump ]; then + echo " File /etc/sysconfig/kdump not found." + echo " Please, check your kexec-tools installation." + exit 1 +fi + +if [ $dogrub = 0 ]; then + echo "Not performing changes to /etc/grub.conf" + echo + # check if there is memory reserved for the kexec kernel + if ! cat /proc/cmdline | grep -e crashkernel > /dev/null; then + echo " Kernel DOES NOT have memory reserved for kdump kernel..." + echo " Use --grub option to enable crashkernel option on kernel command line" + echo + fi +fi + +# select the right kdump kernel +if [ $userhel -eq 1 ]; then + KDUMP_KERNEL="kernel" +else + KDUMP_KERNEL="kernel-rt" +fi +# get the version of the latest installed kernel +kver=$(latest_package_ver $KDUMP_KERNEL) +if [ -z "$kver" ]; then + fatal " Can't find $KDUMP_KERNEL package information!" +fi + +report " making kernel-$kver the kdump kernel" + +# find the vmlinux version info for the latest kernel package +vmlinux_version=$(vmlinux_ver $kver) +if [ -z "$vmlinux_version" ]; then + fatal " Can't get vmlinux version!" +fi + +# now edit the /etc/sysconfig/kdump file +sed -e "s/^KDUMP_KERNELVER.*$/KDUMP_KERNELVER=\"$vmlinux_version\"/" \ + /etc/sysconfig/kdump >/tmp/kdump.$$ +mv /etc/sysconfig/kdump /etc/sysconfig/kdump.save && \ + mv /tmp/kdump.$$ /etc/sysconfig/kdump + +# if requested, update the grub entries for the rt kernels +if [ $dogrub = 1 ]; then + rtver=$(latest_package_ver kernel-rt) + if [ -z "$rtver" ]; then + fatal " Can't find kernel-rt package information!" + fi + # RHEL-RT kernel + kernels=$(find_rt_kernel_indexes_rhel_rt) + if [ ! -z $kernels ]; then + report " adding 'crashkernel=auto' arg to grub entries: $kernels" + /sbin/grubby --update-kernel=$kernels --args="crashkernel=auto" + fi +fi + +exit $? diff --git a/realtime-setup.dracut b/realtime-setup.dracut new file mode 100644 index 0000000..bf58c5d --- /dev/null +++ b/realtime-setup.dracut @@ -0,0 +1,2 @@ +fw_dir+=":/lib/firmware/$(uname -r)" + diff --git a/realtime-setup.service b/realtime-setup.service new file mode 100644 index 0000000..bea403e --- /dev/null +++ b/realtime-setup.service @@ -0,0 +1,12 @@ +[Unit] +Description=RHEL-RT environment details setup +After=syslog.target + +## Not a daemon +[Service] +Type=simple +ExecStart=/usr/bin/rt-setup + +[Install] +WantedBy=multi-user.target + diff --git a/realtime-setup.spec.save b/realtime-setup.spec.save new file mode 100644 index 0000000..8c3a6e3 --- /dev/null +++ b/realtime-setup.spec.save @@ -0,0 +1,350 @@ +Name: rt-setup +Version: 2.1 +Release: 1%{?dist} +License: GPL+ +Summary: Setup RHEL-RT environment details +Group: System Environment/Base +Source: rt-setup-%{version}.tar.bz2 + +ExclusiveArch: x86_64 +BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) +BuildRequires: gcc +BuildRequires: systemd +BuildRequires: annobin +Requires: pam >= 0.99.6.2-3.26 +Requires: /usr/sbin/groupadd +Requires: kexec-tools +Requires: tuna +Requires: tuned +Requires: tuned-profiles-realtime +Requires: systemd + +%global debug_package %{nil} + +%description +The 'rt-setup' package configures details required by RHEL-RT environment. + - creates realtime group + - adds realtime limits configuration for PAM + - adds /usr/bin/rt-setup-kdump to config kdump in RT + - adds udev specific rules for threaded irqs and /dev/rtc access + - adds /usr/bin/slub_cpu_partial_off to turn off cpu_partials in SLUB + - adds net-socket timestamp static key daemon (rt-entsk) + +%prep +%setup + +%build +%set_build_flags +make all + +%install +rm -Rf %{buildroot} +make DEST=%{buildroot} install + +%post +/usr/sbin/groupadd -f -g 71 realtime + +if grep kernel.hung_task_panic /etc/sysctl.conf >/dev/null 2>&1 +then + : +else + sysctl -w kernel.hung_task_panic=0 >/dev/null 2>&1 + cat <>/etc/sysctl.conf +# controls whether the system should reboot if it detects a hung task +# 1 means reboot after hung_task_timeout_secs after a hung task is detected +# default value is 0 +kernel.hung_task_panic = 0 +EOF +fi + +if grep kernel.hung_task_timeout_secs /etc/sysctl.conf >/dev/null 2>&1 +then + : +else + sysctl -w kernel.hung_task_timeout_secs=600 >/dev/null 2>&1 + cat <>/etc/sysctl.conf +# controls how long to reboot after a hung task is detected +# default is 600 seconds. +# note: this only matters if kernel.hung_task_panic=1 +kernel.hung_task_timeout_secs = 600 +EOF +fi + +# turn on the rt-setup startup file +systemctl enable rt-setup + +%preun +if [ "$1" = "0" ] ; then # uninstall +systemctl disable rt-setup +fi + +%clean +rm -rf %{buildroot} + +%files +%defattr(0644,root,root,0755) +%config(noreplace) %{_sysconfdir}/security/limits.d/realtime.conf +%config(noreplace) %{_sysconfdir}/udev/rules.d/99-rhel-rt.rules +%config(noreplace) %{_sysconfdir}/sysconfig/rt-setup +%attr(0755, root, root) %{_bindir}/rt-setup-kdump +%attr(0755, root, root) %{_bindir}/slub_cpu_partial_off +%attr(0755, root, root) %{_sbindir}/rt-entsk +%attr(0755, root, root) %{_sbindir}/kernel-is-rt +%attr(0644, root, root) %{_unitdir}/rt-setup.service +%attr(0755, root, root) %{_bindir}/rt-setup +%attr(0644, root, root) %{_unitdir}/rt-entsk.service + +%changelog +* Wed Mar 27 2019 Clark Williams 2.1.1 +- build for RHEL 8.1.0 +- added OSCI gating test framework +Resolves: rhbz#1682427 + +* Tue Oct 23 2018 Clark Williams 2.0.10 +- rebuild to see if build-id continues to appear in the rpm + +* Mon Sep 24 2018 Clark Williams 2.0.9 +- fix annocheck static source analysis errors +Resolves: rhbz#1619407 + +* Fri Sep 14 2018 Clark Williams 2.0.8 +- fix some coverity complaints about shell scripts +Resolves: rhbz#1619407 + +* Fri Sep 14 2018 Clark Williams 2.0.7 +- strip rt-entsk executable on installation +Resolves: rhbz#1619407 + +* Fri Aug 24 2018 Clark Williams 2.0.6 +- check for open failure to make coverity happy +Resolves: rhbz#1619407 + +* Fri Aug 24 2018 Clark Williams 2.0.5 +- move pidfile write to after daemonize in rt-entsk +Resolves: rhbz#1619407 + +* Wed Aug 22 2018 Clark Williams 2.0.4 +- add logic to write a pid file in rt-entsk (keep systemd happy) +Resolves: rhbz#1619407 + +* Wed Aug 22 2018 Clark Williams 2.0.3 +- sync with rhel-7.6 build +Resolves: rhbz#1619407 + +* Wed Aug 22 2018 Clark Williams 2.0.2 +- fix installation of rt-entsk +Resolves: rhbz#1619407 + +* Mon Aug 20 2018 Clark Williams 2.0.1 +- build for RHEL 8.0.0 +- add rt-entsk program for forcing network timestamps enabled +Resolves: rhbz#1619407 + +* Wed Aug 08 2018 Clark Williams 1.59-8 +- remove libcgroup requirement +- remove comment about irqbalance + +* Fri Jun 01 2018 Luis Claudio R. Goncalves 1.59-7 +- rt-setup no longer rrequires rtctl (1585198) +Resolves: rhbz#1585198 + +* Tue Jul 05 2016 John Kacur - 1.59-5 +- Rebuild for rhel-7.3 +Resolves: rhbz#1341783 + +* Tue Jun 14 2016 John Kacur - 1.59-3 +- Fix some spelling mistakes in the comments in rhel-rt.rules +- Add udev rules to allow the realtime group to access msr and cpuid registers +Resolves: rhbz#1341783 + +* Fri Jul 10 2015 Clark Williams - 1.59-2 +- removed post-install script that disables irqbalance (1203764) +- fixed typo in requires for tuned-profiles-realtime (1241936) + +* Thu Jul 2 2015 Clark Williams - 1.59-1 +- added tuned and tuna dependencies, removed sqlite (1203764) + +* Mon Dec 29 2014 Luis Claudio R. Goncalves - 1.58-2 +- fixed rt-setup shell script called on startup (1162769) +- removed the unnecessary mrg-rt-firmware logic (1162769) + +* Fri Dec 26 2014 Luis Claudio R. Goncalves - 1.58-1 +- make startup logic work with systemd (1162769) +- product name cleanup (1173312) + +* Fri Nov 28 2014 Luis Claudio R. Goncalves - 1.57-6 +- remove a reference to mrg-rt-release from initscript (1162766) + +* Mon Nov 24 2014 Luis Claudio R. Goncalves - 1.57-5 +- move kernel-is-rt from /sbin to /usr/sbin (1151563) + +* Tue Nov 18 2014 Luis Claudio R. Goncalves - 1.57-4 +- remove the database used by mrg-rt-release (1162766) + +* Tue Nov 11 2014 Luis Claudio R. Goncalves - 1.57-3 +- remove mrg-rt-release (1162766) + +* Tue Nov 04 2014 Luis Claudio R. Goncalves - 1.57-2 +- remove the old dracut rules from RHEL6 (1160440) + +* Wed Oct 29 2014 Clark Williams - 1.57-1 +- added mrg-2.5.8 release to mrg-rt-release database + +* Tue Sep 30 2014 Luis Claudio R. Goncalves - 1.56-2 +- added mrg-2.5.7 release to mrg-rt-release database + +* Wed Aug 20 2014 Clark Williams - 1.56-1 +- added mrg-2.5.6 release to mrg-rt-release database +- removed dracut rule that caused problems when adding firmware to initramfs + +* Fri Jul 25 2014 Clark Williams - 1.55-8 +- added mrg-2.5.2 and mrg-2.5.4 releases to mrg-rt-release database + +* Tue Jun 10 2014 John Kacur - 1.55-7 +- udev: Add udev rule to give group realtime write access to cpu_dma_latency + +* Mon Apr 28 2014 Luis Claudio R. Goncalves - 1.55-6 +- Added mrg-2.5 GA data to the mrg-rt-release database + +* Wed Apr 09 2014 Luis Claudio R. Goncalves - 1.55-5 +- Added mrg-2.4.6 data to the mrg-rt-release database + +* Fri Mar 28 2014 Luis Claudio R. Goncalves - 1.55-4 +- Trim the kernel version when read from uname -rt + +* Tue Feb 18 2014 Luis Claudio R. Goncalves - 1.55-3 +- Added mrg-2.4.5 data to the mrg-rt-release database + +* Wed Jan 22 2014 Luis Claudio R. Goncalves - 1.55-2 +- Added mrg-2.4.3 data to the mrg-rt-release database + +* Tue Dec 10 2013 Clark Williams - 1.55-1 +- First common build for RHEL7 and RHEL6 + +* Thu Nov 28 2013 Luis Claudio R. Goncalves 1.54-2 +- Enhanced update-mrg-rt-release + +* Thu Nov 28 2013 Luis Claudio R. Goncalves 1.54-1 +- Update mrg-rt-release on every boot [848433] + +* Thu Aug 29 2013 Luis Claudio R. Goncalves - 1.53-4 +- add /lib/firmware/$(uname -r) to dracut firmware search path (998920) +- ensure rt-firmware files are on udev firmware search path (998920) + +* Thu Aug 22 2013 Luis Claudio R. Goncalves - 1.53-3 +- removed the dracut config file + +* Tue Aug 20 2013 Luis Claudio R. Goncalves - 1.53-2 +- added configuration file for dracut (998920) +- fixed macro usage on the specfile + +* Thu Apr 25 2013 Clark Williams - 1.53-1 +- turn off cgroup mounting logic +- added Requires for libcgroup + +* Tue Apr 2 2013 Clark Williams - 1.52-1 +- added script slub_cpu_partial_off +- added cgroups to /etc/sysconfig/rt-setup + +* Wed Mar 27 2013 Clark Williams - 1.51-1 +- added code to turn off SLUB cpu_partial at startup + +* Mon Nov 12 2012 Luis Claudio R. Goncalves - 1.50-1 +- rt-setup-kdump: use mrg-2.x as the kdump kernel [868446] [868442] [868329] +- rt-setup-kdump: simplified the script and added --rhel option + +* Tue Mar 6 2012 Clark Williams - 1.11-1 +- removed %%post logic that disables bandwidth limiting [BZ# 791371] +- changed rtprio from 100 to 99 in realtime.conf + +* Thu Oct 13 2011 Clark Williams - 1.10-1 +- fixed thinko by removing firmware download logic + +* Tue Oct 11 2011 Clark Williams - 1.9-1 +- added sysconfig and init script for handling cgroup mounting +- changed script kernel-is-rt to use /sys/kernel/realtime + +* Wed May 11 2011 Clark Williams - 1.8-1 +- simplified mrg-rt-firmware.rules to fix boot time hang on + large core machines (BZ# 698481) + +* Fri Feb 11 2011 Luis Claudio R. Goncalves - 1.7-4 +- Normalized the RHEL6 firmware path search (due to uname -r changes) + +* Thu May 27 2010 John Kacur - 1.7-2 +- set kernel.hung_task_panic=0 (off) by default +- set kernel.hung_task_timeout_secs=600 by default +- used sysctl to set sched_rt_runtime_us at install time, not just boot time + +* Tue May 18 2010 Clark Williams - 1.7-1 +- removed requirement for kernel-rt (circular dependency) +- cleaned up mrg-rt-firmware.rules (added commas between all key/value pairs) + +* Wed Nov 25 2009 Luis Claudio R. Goncalves - 1.6-3 +- rt-setup-kdump: configure kdump on all MRG kernel flavors +- rt-setup-kdump: fix a log entry that was too verbose + +* Wed Nov 25 2009 Luis Claudio R. Goncalves - 1.6-2 +- rt-setup-kdump treats MRG v1 and v2 kernels accordingly (BZ# 517529) + +* Mon Nov 2 2009 Clark Williams - 1.6-1 +- removed "@16" specifier from rt-setup-kdump script (BZ# 517529) + +* Tue Sep 1 2009 Clark Williams - 1.5-2 +- fixed path mismatches reported by Vernon Maury + +* Wed Aug 26 2009 Clark Williams - 1.5-1 +- add udev rules and scripts for handling driver firmware download + +* Thu Jul 9 2009 Clark Williams - 1.4-1 +- blow away rtctl udev rule (compatibility problem with RHEL + version of udev) +- update /dev/rtc udev rule to use PROGRAM rather than SYMLINK + +* Tue Jul 7 2009 Clark Williams - 1.3-1 +- added udev rules file to address: + - BZ 510121 hwclock & /dev/rtc broken in rt-kernel + - BZ 466929 udev rule for hotplug rtctl + +* Thu May 21 2009 Clark Williams - 1.2-1 +- added post section to edit /etc/sysctl.conf and add the + kernel.sched_rt_runtime_us parameter = -1 line to disable + the RT scheduler bandwith limiter + +* Tue Jul 15 2008 Clark Williams - 1.1-6%{dist} +- fixed rt-setup-kdump to handle incorrect arguments (BZ 455536) +- added help argument to rt-setup-kdump + +* Fri Jun 13 2008 Luis Claudio R. Goncalves - 1.1-5%{dist} +- rt-setup-kdump now touches /etc/grub.conf only when requested + +* Tue Jun 03 2008 Luis Claudio R. Goncalves - 1.1-4%{dist} +- /usr/bin/rt-setup-kdump had wrong permissions +- changed rt-setup-kdump: added a few tests for reserved memory and for the + absence of /etc/sysconfig/kdump +- now rt-setup requires kexec-tools + +* Mon May 12 2008 Luis Claudio R. Goncalves - 1.1-3%{dist} +- disables irqbalance as it may hurt determinism in RT +- installs rt-setup-kdump in /usr/bin + +* Tue Apr 22 2008 Clark Williams - 1.1-2%{?dist} +- removed sed script to edit kdump config file (using updated + kexec-tools instead) + +* Mon Apr 21 2008 Clark Williams - 1.1-1%{?dist} +- removed --args-linux from /etc/sysconfig/kdump (BZ# 432378) +- changed BuildArch to noarch + +* Thu Feb 07 2008 Luis Claudio R. Goncalves - 1.0-3%{?dist} +- BZ:399591 - Fixed spec issues pointed by Jeremy Katz +- BZ:399591 - @realtime has gid=71. +- FIXES: BZ399591 + +* Thu Aug 02 2007 Luis Claudio R. Goncalves - 1.0-2%{?dist} +- Fixed package description + +* Mon Jul 30 2007 Luis Claudio R. Goncalves - 1.0-1%{?dist} +- Initial packaging +- Requires all the basic packages for RT +- Requires support for limits.d and no realtime.conf present in PAM package diff --git a/realtime-setup.sysconfig b/realtime-setup.sysconfig new file mode 100644 index 0000000..41e3842 --- /dev/null +++ b/realtime-setup.sysconfig @@ -0,0 +1,4 @@ +# +# Decide whether to turn off SLUB cpu_partial support +# +SLUB_CPU_PARTIAL="off" diff --git a/realtime-setup.systemd b/realtime-setup.systemd new file mode 100755 index 0000000..5fcf750 --- /dev/null +++ b/realtime-setup.systemd @@ -0,0 +1,34 @@ +#!/usr/bin/bash + +on_rt () { + if [ -f /sys/kernel/realtime ]; then + return 0 + fi + return 1 +} + +prog="rt-setup" + +[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog + +# is this a rhel-rt kernel? +if ! on_rt; then + echo "Not running on a RHEL-RT kernel!" + exit 0 +fi + +# make sure that cpusets are mounted +if ! grep cpuset /proc/mounts >/dev/null 2>&1; then + echo "cpusets not mounted!" + exit 2 +fi + +# if not running, start it up here, usually something like "daemon $exec" +if [ "$SLUB_CPU_PARTIAL" == "off" ]; then + slub_cpu_partial_off + slub_retval=$? +else + slub_retval=0 +fi + +exit $slub_retval diff --git a/realtime-setup.sysvinit b/realtime-setup.sysvinit new file mode 100644 index 0000000..45eb584 --- /dev/null +++ b/realtime-setup.sysvinit @@ -0,0 +1,125 @@ +#!/usr/bin/bash +# +# rt-setup - script to handle setup for running an RT kernel +# +# chkconfig: 2345 00 99 +# description: This script is used to setup services for use with a \ +# realtime Linux kernel \ +# The main use now is to setup cgroups + +# Source function library. +. /etc/rc.d/init.d/functions + +prog="rt-setup" + +[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog + +# if rt-firmware is installed +if [ -d /lib/firmware/mrg-rt-firmware ]; then + if ! grep mrg-rt-firmware /lib/udev/firmware.sh > /dev/null + then + logger -t rt-setup "adding rt-firmware to udev firmware search path" + sed -i 's#) /lib/firmware"#) /lib/firmware"\nFIRMWARE_DIRS="/lib/firmware/mrg-rt-firmware $FIRMWARE_DIRS"#' /lib/udev/firmware.sh + fi +fi + +lockfile=/var/lock/subsys/$prog + +isrt() { + [ -f /sys/kernel/realtime ] || return 1 + return 0 +} + +start() { + echo -n $"Starting $prog: " + # if not running, start it up here, usually something like "daemon $exec" + if [ "$SLUB_CPU_PARTIAL" == "off" ]; then + slub_cpu_partial_off + slub_retval=$? + else + slub_retval=0 + fi + echo + # Update /etc/mrg-rt-release based on the running kernel + /usr/bin/update-mrg-rt-release --update-etc + + [ $slub_retval -eq 0 ] && touch $lockfile + return $slub_retval +} + +stop() { + echo -n $"Stopping $prog: " + rm -f $lockfile + echo + return 0 +} + +restart() { + stop + start +} + +reload() { + restart +} + +force_reload() { + restart +} + +rh_status() { + if ! isrt; then + echo "$prog: Not running on an RT kernel!" + return 1 + fi + # make sure that cpusets are mounted + if ! grep cpuset /proc/mounts >/dev/null 2>&1; then + echo "$prog: cpusets not mounted!" + return 2 + fi + echo "$prog: Running RT kernel with cpusets mounted" + return 0 +} + +rh_status_q() { + rh_status >/dev/null 2>&1 +} + + + +# if we're not running on an RT kernel then bail +#if ! isrt; then +# exit 0 +#fi + +case "$1" in + start) + rh_status_q && exit 0 + $1 + ;; + stop) + rh_status_q || exit 0 + $1 + ;; + restart) + $1 + ;; + reload) + rh_status_q || exit 7 + $1 + ;; + force-reload) + force_reload + ;; + status) + rh_status + ;; + condrestart|try-restart) + rh_status_q || exit 0 + restart + ;; + *) + echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" + exit 2 +esac +exit $? diff --git a/realtime.conf b/realtime.conf new file mode 100644 index 0000000..237f3ed --- /dev/null +++ b/realtime.conf @@ -0,0 +1,10 @@ +# This file specifies reasonable default limits for users +# who should be able to run realtime processes. +# +# Such users must be added to group 'realtime' to be +# affected by these limits. + +@realtime soft cpu unlimited +@realtime - rtprio 99 +@realtime - nice -20 +@realtime - memlock unlimited diff --git a/rhel-rt.rules b/rhel-rt.rules new file mode 100644 index 0000000..5084f69 --- /dev/null +++ b/rhel-rt.rules @@ -0,0 +1,19 @@ +# udev rules specific to RHEL-RT Realtime kernel + +# insure /dev/rtc points to /dev/rtc0 +# we use PROGRAM rather than SYMLINK because there is +# a (good) possibility that a /dev/rtc device file +# already exists and we want to replace it (hence the +# ln -sf) +KERNEL=="rtc0", PROGRAM+="/bin/ln -sf rtc0 /dev/rtc" + +# Give permission to the realtime group to write a zero to /dev/cpu_dma_latency +# This will tell the power management system not to transition to a high cstate +KERNEL=="cpu_dma_latency", GROUP="realtime" + +# Give permission to the realtime group to read the per cpu msr and cpuid +# registers. This is needed by cyclictest in rt-tests when using the new +# feature to read the smi counters. This is necessary but not sufficient +# A program that wants to access these registers will also need CAP_SYS_RAWIO +SUBSYSTEM=="msr", GROUP="realtime", MODE="0640" +SUBSYSTEM=="cpuid", GROUP="realtime", MODE="0640" diff --git a/rtapp-example.sh b/rtapp-example.sh new file mode 100644 index 0000000..0cca355 --- /dev/null +++ b/rtapp-example.sh @@ -0,0 +1,78 @@ +#!/usr/bin/bash + +# the following is the chkconfig init header +# +# rtapp-example: processor frequency scaling support +# +# chkconfig: 345 99 01 +# description: Run realtime application +# + +# the following is the LSB init header see +# http://www.linux-foundation.org/spec//booksets/LSB-Core-generic/LSB-Core-generic.html#INITSCRCOMCONV +# +### BEGIN INIT INFO +# Provides: rtapp-example +# Should-Start: +# Default-Start: 3 4 5 +# Short-Description: launcher script for realtime application +# Description: This script performs all system manipulations required for +# starting/stopping rtapp-example (i.e. isolating cpus, moving IRQ +# affinities, etc). and then starts or stops the rt applications +# using the tuna command line tool + +### END INIT INFO + +# Source function library. +. /etc/rc.d/init.d/functions + +prog="rtapp-example" + +prep() { + # do core isolation and IRQ affinity mainipulations here +} + +rollback() { + # undo core isolation and IRQ affinity changes here +} + +startapp() { + # start application processes +} + +stopapp() { + # stop application processes +} + +start() { + prep + startapp +} + +stop() { + rollback + stopapp +} + +status() { +} + +usage() { + echo "$0: start|stop|status|help" + exit 1 +} + + +RETVAL=0 +case "$1" in + start) + start + ;; + stop) + stop + ;; + status) + ;; + *) +esac +exit $RETVAL diff --git a/slub_cpu_partial_off b/slub_cpu_partial_off new file mode 100755 index 0000000..ddf857f --- /dev/null +++ b/slub_cpu_partial_off @@ -0,0 +1,12 @@ +#!/usr/bin/bash +# +# shell script to turn SLUB cpu_partial logic off +# for improved determinism +# + +if [ "$(id -u)" != "0" ]; then + echo "Must be root to run $(basename $0)" + exit -1 +fi +find /sys/kernel/slab -name 'cpu_partial' -print | \ + while read f; do echo 0 > $f; done diff --git a/what-do.txt b/what-do.txt new file mode 100644 index 0000000..f368b71 --- /dev/null +++ b/what-do.txt @@ -0,0 +1,43 @@ +Looking at the specfile, here's what realtime-setup gets you: + +1. Create a realtime group: + /usr/sbin/groupadd -f -g 71 realtime +2. Turns on "panic on hung task": + sysctl -w kernel.hung_task_panic=0 >/dev/null 2>&1 +3. Sets "hung task" threshold to 600 seconds: + sysctl -w kernel.hung_task_timeout_secs=600 +4. Installs and enables systemd realtime-setup service file: + install -m 644 -D realtime-setup.service /usr/lib/systemd/system/realtime-setup.service + systemctl enable realtime-setup +5. installs realtime rules in /etc/security/limits.d/realtime.conf: + @realtime soft cpu unlimited + @realtime - rtprio 99 + @realtime - nice -20 + @realtime - memlock unlimited +6. install udev rules in /etc/udev/rules.d/99-rhel-rt.rules + # udev rules specific to RHEL-RT Realtime kernel + # insure /dev/rtc points to /dev/rtc0 + # we use PROGRAM rather than SYMLINK because there is + # a (good) possibility that a /dev/rtc device file + # already exists and we want to replace it (hence the + # ln -sf) + KERNEL=="rtc0", PROGRAM+="/bin/ln -sf rtc0 /dev/rtc" + # Give permission to the realtime group to write a zero to /dev/cpu_dma_latency + # This will tell the power management system not to transition to a high cstate + KERNEL=="cpu_dma_latency", GROUP="realtime" + # Give permission to the realtime group to read the per cpu msr and cpuid + # registers. This is needed by cyclictest in rt-tests when using the new + # feature to read the smi counters. This is necessary but not sufficient + # A program that wants to access these registers will also need CAP_SYS_RAWIO + SUBSYSTEM=="msr", GROUP="realtime", MODE="0640" + SUBSYSTEM=="cpuid", GROUP="realtime", MODE="0640" +7. install sysconfig rules for RT in /etc/sysconfig/realtime-setup + # + # Decide whether to turn off SLUB cpu_partial support + # + SLUB_CPU_PARTIAL="off" +8. install script to turn off SLUB cpu-partial support: + /usr/bin/slub_cpu_partial_off +9. install kernel-is-rt script in /usr/sbin/kernel-is-rt +10. install a C binary that enables socket timestamping: + install -m 755 -D -s realtime-entsk /usr/sbin/realtime-entsk