From fd1e4a384af44a8687b3a5369283f80f1cf29d84 Mon Sep 17 00:00:00 2001 From: Matt Whitlock Date: Sat, 31 Jul 2021 17:41:57 -0400 Subject: add option for OOM score adjustment This commit adds a new --oom-score-adj option to start-stop-daemon and supervise-daemon, as well as an equivalent SSD_OOM_SCORE_ADJ environment variable. If either of these are specified (with the command-line option taking precedence), then the specified adjustment value is written to /proc/self/oom_score_adj after forking but prior to exec'ing the daemon (at the time when nice and ionice are applied). Additionally, per a suggestion by Mike Frysinger, the suggested values for the SSD_NICELEVEL, SSD_IONICELEVEL, and SSD_OOM_SCORE_ADJ variables in the example config file are now given as zeros, which are the kernel's default values of these process knobs for the init process at boot. Note that uncommenting any of these zero-valued suggestions will cause SSD/SD to set the corresponding process knob affirmatively to zero, whereas leaving the variable unset (and the equivalent command- line option unspecified) means SSD/SD will not change the corresponding process knob from its inherited value. See: https://github.com/OpenRC/openrc/pull/435#discussion_r688310672 This fixes #435. --- man/start-stop-daemon.8 | 6 ++++++ man/supervise-daemon.8 | 8 ++++++++ 2 files changed, 14 insertions(+) (limited to 'man') diff --git a/man/start-stop-daemon.8 b/man/start-stop-daemon.8 index d5eb5123..e5aa4684 100644 --- a/man/start-stop-daemon.8 +++ b/man/start-stop-daemon.8 @@ -128,6 +128,8 @@ Class can be 0 for none, 1 for real time, 2 for best effort and 3 for idle. Data can be from 0 to 7 inclusive. .It Fl N , -nicelevel Ar level Modifies the scheduling priority of the daemon. +.It Fl -oom-score-adj Ar adj +Modifies the OOM score adjustment of the daemon. .It Fl 1 , -stdout Ar logfile Redirect the standard output of the process to logfile when started with .Fl background . @@ -187,6 +189,10 @@ option takes precedence. can also set the scheduling priority of the daemon, but the command line option takes precedence. .Pp +.Va SSD_OOM_SCORE_ADJ +can also set the OOM score adjustment of the daemon, but the command line +option takes precedence. +.Pp .Va SSD_STARTWAIT As the .Fl w , -wait option above. diff --git a/man/supervise-daemon.8 b/man/supervise-daemon.8 index ffd64f97..69e2ff3f 100644 --- a/man/supervise-daemon.8 +++ b/man/supervise-daemon.8 @@ -37,6 +37,8 @@ servicename .Ar count .Fl N , -nicelevel .Ar level +.Fl -oom-score-adj +.Ar adj .Fl p , -pidfile .Ar supervisorpidfile .Fl P , -respawn-period @@ -129,6 +131,8 @@ Sets a path for the supervisor's pid file. Note that this is not the pid file of the process that is being supervised. .It Fl N , -nicelevel Ar level Modifies the scheduling priority of the daemon. +.It Fl -oom-score-adj Ar adj +Modifies the OOM score adjustment of the daemon. .It Fl P , -respawn-period Ar seconds Sets the length of a respawn period. See the description of --respawn-max for more information. @@ -163,6 +167,10 @@ option takes precedence. .Va SSD_NICELEVEL can also set the scheduling priority of the daemon, but the command line option takes precedence. +.Pp +.Va SSD_OOM_SCORE_ADJ +can also set the OOM score adjustment of the daemon, but the command line +option takes precedence. .Sh NOTE .Nm uses -- cgit v1.2.3