Compare commits

...

No commits in common. "c8" and "c9s" have entirely different histories.
c8 ... c9s

10 changed files with 182 additions and 49 deletions

16
.gitignore vendored
View File

@ -1 +1,15 @@
SOURCES/stalld-1.17.1.tar.bz2
/stalld-1.0.tar.xz
/stalld-1.1.tar.xz
/stalld-1.2.tar.xz
/stalld-1.4.tar.xz
/stalld-1.6.tar.xz
/stalld-1.8.tar.xz
/stalld-1.9.tar.xz
/stalld-1.13.tar.bz2
/stalld-1.14.1.tar.bz2
/stalld-1.15.tar.bz2
/stalld-1.16.tar.bz2
/stalld-1.17.tar.xz
/stalld-1.17.1.tar.bz2
/stalld-v1.19.1.tar.bz2
/stalld-1.19.1.tar.bz2

View File

@ -1 +0,0 @@
449566fc8c5f8568a92ed0a04d15c31d64878741 SOURCES/stalld-1.17.1.tar.bz2

View File

@ -0,0 +1,34 @@
From f9c0ade7cd9a514d4ca6f81f797284e11c56b31a Mon Sep 17 00:00:00 2001
From: Chris White <chwhite@redhat.com>
Date: Wed, 21 Feb 2024 15:22:44 -0500
Subject: [PATCH] Make fill_process_comm() open comm file as READ_ONLY
The fill_process_comm() opens the comm file using O_RDWR. The
function itself does not perform a write operation on the file,
and opening this in read and write mode can cause selinux policy
violations where opening the file with write permission is
restricted. Since the function itself only needs to read from this
fd, changing this to READ_ONLY (O_RDONLY)
Signed-off-by: Chris White <chwhite@redhat.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
---
src/utils.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/utils.c b/src/utils.c
index f6feca7040d8..898f4a5d06a7 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -55,7 +55,7 @@ int fill_process_comm(int tgid, int pid, char *comm, int comm_size)
if (retval < 0)
goto out_error;
- fd = open(path, O_RDWR);
+ fd = open(path, O_RDONLY);
if (fd < 0) {
log_msg("failed to open comm file at %s\n", path);
goto out_error;
--
2.43.0

54
README.md Normal file
View File

@ -0,0 +1,54 @@
# stalld
The stalld program (which stands for 'stall daemon') is a
mechanism to prevent the *starvation* of operating system threads in a
Linux system. The premise is to start up on a *housekeeping* cpu (one
that is not used for real-application purposes) and to periodically
monitor the state of each thread in the system, looking for a thread
that has been on a run queue (i.e. ready to run) for a specifed length
of time without being run. This condition is usually hit when the
thread is on the same cpu as a high-priority cpu-intensive task and
therefore is being given no opportunity to run.
When a thread is judged to be starving, stalld changes
that thread to use the SCHED_DEADLINE policy and gives the thread a
small slice of time for that cpu (specified on the command line). The
thread then runs and when that timeslice is used, the thread is then
returned to its original scheduling policy and stalld then
continues to monitor thread states.
There is now an experimental option to boost using SCHED_FIFO. This
logic is used if the running kernel does not support the
SCHED_DEADLINE policy and may be forced by using the -F/--force_fifo
option.
## Command Line Options
`Usage: stalld [-l] [-v] [-k] [-s] [-f] [-h] [-F]
[-c cpu-list]
[-p time in ns] [-r time in ns]
[-d time in seconds] [-t time in seconds]`
### Logging options
- -l/--log_only: only log information (do not boost) [false]
- -v/--verbose: print info to the std output [false]
- -k/--log_kmsg: print log to the kernel buffer [false]
- -s/--log_syslog: print log to syslog [true]
### Startup options
- -c/--cpu: list of cpus to monitor for stalled threads [all cpus]
- -f/--foreground: run in foreground [false but true when -v]
- -P/--pidfile: write daemon pid to specified file [no pidfile]
### Boosting options
- -p/--boost_period: SCHED_DEADLINE period [ns] that the starving task will receive [1000000000]
- -r/--boost_runtime: SCHED_DEADLINE runtime [ns] that the starving task will receive [20000]
- -d/--boost_duration: how long [s] the starving task will run with SCHED_DEADLINE [3]
- -F/--force_fifo: force using SCHED_FIFO for boosting
### Monitoring options
- -t/--starving_threshold: how long [s] the starving task will wait before being boosted [60]
- -A/--aggressive_mode: dispatch one thread per run queue, even when there is no starving
threads on all CPU (uses more CPU/power). [false]
### Miscellaneous
- -h/--help: print this menu

View File

@ -1,27 +0,0 @@
From 476152742021303d2defeb69f524bcc302618081 Mon Sep 17 00:00:00 2001
From: Leah Leshchinsky <lleshchi@redhat.com>
Date: Mon, 29 Aug 2022 14:07:39 -0400
Subject: [PATCH] Start stalld service as initrc_t
Stalld currently runs as an unconfined_service_t.
Edit to service file so that the daemon is launched as an initrc_t.
Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
diff --git a/redhat/stalld.service b/redhat/stalld.service
index e0eb4b77b0a7..bcd4b767f629 100644
--- a/redhat/stalld.service
+++ b/redhat/stalld.service
@@ -9,7 +9,7 @@ ExecStartPre=/usr/bin/throttlectl off
# In case the regex passed to IT or IP includes C escape sequences,
# use ${IT} or ${IP} instead of $IT or $IP
-ExecStart=/usr/bin/stalld --systemd $CLIST $AGGR $BP $BR $BD $THRESH $LOGGING $FG $PF $IT $IP
+ExecStart=/bin/sh -c "/usr/bin/stalld --systemd $CLIST $AGGR $BP $BR $BD $THRESH $LOGGING $FG $PF $IT $IP"
ExecStopPost=/usr/bin/throttlectl on
CPUSchedulingPolicy=fifo
CPUSchedulingPriority=10
--
2.31.1

6
gating.yaml Normal file
View File

@ -0,0 +1,6 @@
--- !Policy
product_versions:
- rhel-9
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}

1
sources Normal file
View File

@ -0,0 +1 @@
SHA512 (stalld-1.19.1.tar.bz2) = 3b5c8d1577fafa93dea44b299578b5f05764c4aa9770ccc4b54c8d247f80ab2da27fee61f9b462af0d1df49c5bebf6cb6fc5659d12c2627256c4dfc6250bd56b

View File

@ -1,6 +1,6 @@
Name: stalld
Version: 1.17.1
Release: 1%{?dist}
Version: 1.19.1
Release: 2%{?dist}
Summary: Daemon that finds starving tasks and gives them a temporary boost
License: GPLv2
@ -14,7 +14,16 @@ BuildRequires: systemd-rpm-macros
Requires: systemd
Patch0: Start-stalld-service-as-initrc_t.patch
%ifnarch i686
BuildRequires: bpftool
BuildRequires: clang
BuildRequires: libbpf-devel
Requires: libbpf
%endif
# Patches
Patch1: Make-fill_process_comm-open-comm-file-as-READ_ONLY.patch
%description
The stalld program monitors the set of system threads,
@ -32,7 +41,7 @@ allow 10 microseconds of runtime for 1 second of clock time.
%install
%make_install DOCDIR=%{_docdir} MANDIR=%{_mandir} BINDIR=%{_bindir} DATADIR=%{_datadir} VERSION=%{version}
%make_install -C redhat UNITDIR=%{_unitdir}
%make_install -C systemd UNITDIR=%{_unitdir}
%files
%{_bindir}/%{name}
@ -53,19 +62,23 @@ allow 10 microseconds of runtime for 1 second of clock time.
%systemd_postun_with_restart %{name}.service
%changelog
* Fri Oct 21 2022 Leah Leshchinsky <lleshchi@redhat.com> - 1.17.1-1
* Wed Feb 21 2024 John Kacur <jkacur@redhat.com> - 1.19.1-2
- Make fill_process_comm() open comm file as READ_ONLY
Resolves: RHEL-25846
* Fri Feb 09 2024 John Kacur <jkacur@redhat.com> - 1.19.1-1
- Rebase to upstream stalld-1.19.1
Resolves: RHEL-7865
* Tue Oct 18 2022 Leah Leshchinsky <lleshchi@redhat.com> - 1.17.1-1
- stalld: Fix memory leak in print_boosted_info()
- utils: Check if the system is in lockdown mode
- stalld: print process comm and cpu when boosting
Resolves: rhbz#2136559
* Tue Sep 13 2022 Leah Leshchinsky <lleshchi@redhat.com> - 1.17-2
- Start stalld service as initrc_t
Resolves:rhbz#2126494
Resolves: rhbz#2120799
* Thu Jul 14 2022 John Kacur <jkacur@redhat.com> - 1.17-1
- rebase to upstream v1.17
Resolves:rhbz#2107273
Resolves:rhbz#2107275
* Thu Mar 31 2022 Fernando Pacheco <fpacheco@redhat.com> - 1.16-1
- stald/utils: Space, lines and voids clenaups
@ -74,7 +87,7 @@ Resolves:rhbz#2107273
- src/utils: Comments cleanup
- src/throttling: Comments cleanup
- src/stalld.h Comments cleanup
Resolves: rhbz#2068549
Resolves: rhbz#2068550
* Mon Nov 15 2021 Fernando Pacheco <fpacheco@redhat.com> - 1.15-1
- stalld: Fix incorrect open() return value checks
@ -84,7 +97,11 @@ Resolves:rhbz#2107273
- tests: Fix uninitialized value action.sa_mask
- utils: Bail if malloc() returns null in parse_cpu_list()
- stalld: Use correct format specifier for long types
Resolves: rhbz#1990057, rhbz#1996799, rhbz#1996825
Resolves: rhbz#2016010
* Tue Aug 10 2021 Mohan Boddu <mboddu@redhat.com> - 1.14.1-2
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Mon Jul 19 2021 Fernando Pacheco <fpacheco@redhat.com> - 1.14.1-1
- stalld: Coding style cleanup
@ -97,7 +114,7 @@ Resolves:rhbz#2107273
- stalld: Adjust variables in parse_old_task_format()
- utils.c: Use MAX_PATH for pidfile
- stalld.c: Remove variable declaration from the middle of the function
- stalld: Respect -l option in single threaded mode (1983100)
- stalld: Respect -l option in single threaded mode (1983103)
- utils: s/try_to_open_file/check_file_exists/
- utils: use check_file_exists in setup_hr_tick()
- utils: Check for the new sched_features path
@ -108,22 +125,22 @@ Resolves:rhbz#2107273
- stalld: Add the adaptive mode option
- stalld: Use the last mode set in the cmdline
- stalld: Fallback to the adaptive mode if force_fifo is selected
- stalld: Make single-threaded mode the default one (1920041)
- stalld: Make single-threaded mode the default one
- stalld.service: Always restart stalld on exit
- utils.c: Fail if user is not root
- utils.c: Make the path to sched_debug path dynamic (1977663)
- utils.c: Make the path to sched_debug path dynamic
* Tue Jun 29 2021 Fernando Pacheco <fpacheco@redhat.com> - 1.12-1
- stalld.8: fix diff cruft left in manpage source
- stalld.c: clean up handling of nr_running
- stalld.c: remove duplicate parameter to fill_waiting_task() (1934582)
- stalld.c: remove duplicate parameter to fill_waiting_task()
- stalld: Add error handling in get_cpu_idle_time()
- stalld.service: Run stalld as sched_fifo via systemd
- stalld: Add error handling in get_cpu_idle_time() (1966259)
- packaging: clean up Makefiles and rpm specfile (1972806)
- packaging: clean up Makefiles and rpm specfile
- stalld: Always print current function for info messages
- stalld: Always print current function for warn messages
- stalld: Always print current function for die messages
- utils: change PATHMAX to 4096 (1934581)
- utils: change PATHMAX to 4096
* Thu May 13 2021 Clark Williams <williams@redhat.com> - 1.11-1
- redhat/stalld.spec: pick up gating test version for changelog
@ -135,6 +152,9 @@ Resolves:rhbz#2107273
- stalld: Support denylisting of tasks in stalld
- src/utils: use right argument for warning printf
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 1.9-2
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Wed Feb 17 2021 Clark Williams <williams@redhat.com> - 1.9-2
- update to pick up latest gating test

View File

@ -0,0 +1,21 @@
#!/usr/bin/bash
# This will get uncommented once we have the rpm
# make sure we have stalld installed
if rpm -q --quiet stalld; then
:
else
sudo dnf install -y stalld
if [[ $? != 0 ]]; then
echo "install of stalld failed!"
exit 1
fi
fi
STALLD="/usr/bin/stalld"
# See if stalld is installed and executable
$STALLD --help 2>> /dev/null
if [[ $? != 0 ]]; then
exit 2
fi

11
tests/tests.yml Normal file
View File

@ -0,0 +1,11 @@
- hosts: localhost
roles:
- role: standard-test-basic
tags:
- classic
tests:
- simple:
dir: scripts
run: ./run_tests.sh
required_packages:
- stalld