]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/exec-invoke: document calling setpriority() after sched_setattr()
authorIvan Shapovalov <intelfx@intelfx.name>
Wed, 21 Aug 2024 17:36:08 +0000 (19:36 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 21 Aug 2024 19:25:29 +0000 (04:25 +0900)
Fixes: 711a157738b ("core/exec-invoke: call setpriority() after sched_setattr()")
src/core/exec-invoke.c

index a867480300e848a7b7ff176253df66696a3c25fd..98d8b0c7d114c6cf9b4ee7ec56a59618a8279f00 100644 (file)
@@ -4450,6 +4450,13 @@ int exec_invoke(
                 }
         }
 
+        /*
+         * Set nice value _after_ the call to sched_setattr() because struct sched_attr includes sched_nice
+         * which we do not set, thus it will clobber any previously set nice value. Scheduling policy might
+         * be reasonably set together with nice value e.g. in case of SCHED_BATCH (see sched(7)).
+         * It would be ideal to set both with the same call, but we cannot easily do so because of all the
+         * extra logic in setpriority_closest().
+         */
         if (context->nice_set) {
                 r = setpriority_closest(context->nice);
                 if (r < 0) {