From 274378eecf21ebebe5db3cc7f77f29084151741b Mon Sep 17 00:00:00 2001 From: Forza Date: Wed, 21 Feb 2024 23:14:57 +0100 Subject: [PATCH 1/2] start-stop-daemon: support cpu scheduler env variable Introduced `SSD_CPUSCHEDULER` and `SSD_CPUSCHEDULER_PRIO` environment variables to complement the `--scheduler` command line argument. --- src/start-stop-daemon/start-stop-daemon.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/start-stop-daemon/start-stop-daemon.c b/src/start-stop-daemon/start-stop-daemon.c index 3e4a19a19..03762b18d 100644 --- a/src/start-stop-daemon/start-stop-daemon.c +++ b/src/start-stop-daemon/start-stop-daemon.c @@ -379,6 +379,19 @@ int main(int argc, char **argv) eerror("%s: invalid oom_score_adj `%s' (SSD_OOM_SCORE_ADJ)", applet, tmp); + // Handle SSD_CPUSCHEDULER for scheduler type + if ((tmp = getenv("SSD_CPUSCHEDULER"))) { + scheduler = strdup(tmp); + } + + // Handle SSD_CPUSCHEDULER_PRIO for scheduler priority + if ((tmp = getenv("SSD_CPUSCHEDULER_PRIO"))) { + if (sscanf(tmp, "%d", &sched_prio) != 1) { + eerror("%s: invalid scheduler priority `%s' (SSD_CPUSCHEDULER_PRIO)", + applet, tmp); + } + } + /* Get our user name and initial dir */ p = getenv("USER"); home = getenv("HOME"); From 8b586de249d599e4855b5c29b0fe34ad11de5d0d Mon Sep 17 00:00:00 2001 From: Forza Date: Wed, 21 Feb 2024 23:25:45 +0100 Subject: [PATCH 2/2] start-stop-daemon: update man page Introduced `SSD_CPUSCHEDULER` and `SSD_CPUSCHEDULER_PRIO` environment variables to complement the `--scheduler` command line argument. --- man/start-stop-daemon.8 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/man/start-stop-daemon.8 b/man/start-stop-daemon.8 index 77684852e..a00351f7a 100644 --- a/man/start-stop-daemon.8 +++ b/man/start-stop-daemon.8 @@ -203,6 +203,14 @@ option takes precedence. can also set the scheduling priority of the daemon, but the command line option takes precedence. .Pp +.Va SSD_CPUSCHEDULER +can also set the CPU scheduler of the daemon, but the command line +option takes precedence. +.Pp +.Va SSD_CPUSCHEDULER_PRIO +can also set the CPU 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.