commit:     7dfa05c4446d1d2290d4ba61520a8f6ee9e57332
Author:     KARBOWSKI Piotr <slashbeast <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 14 20:13:40 2023 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Sat Jan 14 21:02:21 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=7dfa05c4

SCHEDULING_POLICY: switch to scheduler policy IDs rather than aliases.

The os.SCHED_* aliases are not reliable enough, the mainline Python lacks
deadline, and the pypy lacks them all together. The IDs are not going to
change, at most new would arrive, so it is safe to use it as is.

By extension, the deadline policy was also added, since those originally
were not present in aliases.

Bug: https://bugs.gentoo.org/867031
Closes: https://github.com/gentoo/portage/pull/976
Signed-off-by: KARBOWSKI Piotr <slashbeast <AT> gentoo.org>
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>

 cnf/make.conf.example  | 12 ++++++------
 lib/_emerge/actions.py | 12 +++++++-----
 man/make.conf.5        | 16 ++++++++--------
 3 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/cnf/make.conf.example b/cnf/make.conf.example
index 2e33a6e50..4375665f4 100644
--- a/cnf/make.conf.example
+++ b/cnf/make.conf.example
@@ -292,12 +292,12 @@
 #PORTAGE_IONICE_COMMAND="ionice -c 3 -p \${PID}"
 #
 # PORTAGE_SCHEDULING_POLICY allows changing the current scheduling policy. The
-# supported options are 'other', 'batch', 'idle', 'fifo' and 'round-robin'. 
When
-# unset, the scheduling policy remains unchanged, by default Linux uses 'other'
-# policy. Users that wish to minimize the Portage's impact on system
-# responsiveness should set scheduling policy to 'idle' which significantly
-# reduces the disruption to the rest of the system by scheduling Portage as
-# extremely low priority processes.
+# supported options are 'other', 'batch', 'idle', 'fifo', 'round-robin' and
+# 'deadline'. When unset, the scheduling policy remains unchanged, by default
+# Linux uses 'other' policy. Users that wish to minimize the Portage's impact
+# on system responsiveness should set scheduling policy to 'idle' which
+# significantly reduces the disruption to the rest of the system by scheduling
+# Portage as extremely low priority processes.
 #
 #PORTAGE_SCHEDULING_POLICY="idle"
 #

diff --git a/lib/_emerge/actions.py b/lib/_emerge/actions.py
index 874c0312c..d8fd99d88 100644
--- a/lib/_emerge/actions.py
+++ b/lib/_emerge/actions.py
@@ -3117,12 +3117,14 @@ def set_scheduling_policy(settings):
     if platform.system() != "Linux" or not scheduling_policy:
         return os.EX_OK
 
+    # IDs sourced from linux/sched.h kernel's header.
     policies = {
-        "other": os.SCHED_OTHER,
-        "batch": os.SCHED_BATCH,
-        "idle": os.SCHED_IDLE,
-        "fifo": os.SCHED_FIFO,
-        "round-robin": os.SCHED_RR,
+        "other": 0,
+        "fifo": 1,
+        "round-robin": 2,
+        "batch": 3,
+        "idle": 5,
+        "deadline": 6,
     }
 
     out = portage.output.EOutput()

diff --git a/man/make.conf.5 b/man/make.conf.5
index ad8ece43f..34c3cd5b5 100644
--- a/man/make.conf.5
+++ b/man/make.conf.5
@@ -1101,14 +1101,14 @@ will set idle io priority. For more information about 
ionice, see
 Portage will also set the autogroup-nice value (see fBsched\fR(7))), if
 FEATURES="pid\-sandbox" is enabled.
 .TP
-\fBPORTAGE_SCHEDULING_POLICY\fR = \fI[policy name]\fR
-Allows changing the current scheduling policy. The supported options are
-\fBother\fR, \fBbatch\fR, \fBidle\fR, \fBfifo\fR, and \fBround-robin\fR. When
-unset, the scheduling policy remains unchanged, by default Linux uses 'other'
-policy. Users that wish to minimize the Portage's impact on system
-responsiveness should set scheduling policy to \fBidle\fR, which significantly
-reduces the disruption to the rest of the system by scheduling Portage as
-extremely low priority processes. see \fBsched\fR(7) for more information.
+\fBPORTAGE_SCHEDULING_POLICY\fR = \fI[policy name]\fR Allows changing the
+current scheduling policy. The supported options are \fBother\fR, \fBbatch\fR,
+\fBidle\fR, \fBfifo\fR, \fBround-robin\fR and \fBdeadline\fR. When unset, the
+scheduling policy remains unchanged, by default Linux uses 'other' policy.
+Users that wish to minimize the Portage's impact on system responsiveness
+should set scheduling policy to \fBidle\fR, which significantly reduces the
+disruption to the rest of the system by scheduling Portage as extremely low
+priority processes. see \fBsched\fR(7) for more information.
 .TP
 \fBPORTAGE_SCHEDULING_PRIORITY\fR = \fI[priority]\fR
 Allows changing the priority (1-99) of the current scheduling policy, only

Reply via email to