stalld:  first attempt at emulating DEADLINE using FIFO

This is a first cut at the logic to do stalled thread boosting using
SCHED_FIFO, when running on a kernel without SCHED_DEADLINE support.
The idea is that in the boost logic, we change the starving thread's
policy to SCHED_FIFO:98, then sleep up to the 'period' boundary (same
period used for DEADLINE), then change the thread back to it's original
policy and parameters.

Signed-off-by: Clark Williams <>
1 file changed
tree: 4cdcf3709fbc4b3fe40be08fa10dca8242be75ad
  1. .gitignore
  2. Makefile
  4. gpl-2.0.txt
  5. man/
  6. redhat/
  7. src/


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.

Command Line Options

Usage: stalld [-l] [-v] [-k] [-s] [-f] [-h] [-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]

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]


  • -h/--help: print this menu