* [PATCH] tuna: Fix setting a realtime scheduling policy
@ 2025-10-07 16:55 John Kacur
0 siblings, 0 replies; only message in thread
From: John Kacur @ 2025-10-07 16:55 UTC (permalink / raw)
To: linux-rt-users; +Cc: John Kacur
According to the tuna documentation if a user specifies a real-time
scheduling policy then the default priority is 1 if not specified.
Fix this in the gui by explicitly setting it to one in
thread_set_attributes
There were also some incorrect debugging messages in
thread_set_attributes because the affinity was sometimes treated as a
list and sometimes treated as a set.
Fix this by converting the results of os.sched_getscheduler(pid) to a
list
Signed-off-by: John Kacur <jkacur@redhat.com>
---
tuna/gui/util.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/tuna/gui/util.py b/tuna/gui/util.py
index 92bd368179cc..68bd7578f1c8 100644
--- a/tuna/gui/util.py
+++ b/tuna/gui/util.py
@@ -68,6 +68,9 @@ def thread_set_attributes(pid_info, new_policy, new_prio, new_affinity, nr_cpus)
curr_prio = int(pid_info["stat"]["rt_priority"])
if new_policy == os.SCHED_OTHER:
new_prio = 0
+ if new_policy == os.SCHED_FIFO or new_policy == os.SCHED_RR:
+ if not new_prio:
+ new_prio = 1
if curr_policy != new_policy or curr_prio != new_prio:
param = os.sched_param(new_prio)
try:
@@ -82,6 +85,7 @@ def thread_set_attributes(pid_info, new_policy, new_prio, new_affinity, nr_cpus)
dialog.destroy()
return False
+
curr_policy = os.sched_getscheduler(pid)
if curr_policy != new_policy:
print(_("couldn't change pid %(pid)d from %(cpol)s(%(cpri)d) to %(npol)s(%(npri)d)!") % \
@@ -93,7 +97,7 @@ def thread_set_attributes(pid_info, new_policy, new_prio, new_affinity, nr_cpus)
changed = True
try:
- curr_affinity = os.sched_getaffinity(pid)
+ curr_affinity = list(os.sched_getaffinity(pid))
except OSError as err:
if err.args[0] == errno.ESRCH:
return False
@@ -116,7 +120,7 @@ def thread_set_attributes(pid_info, new_policy, new_prio, new_affinity, nr_cpus)
return invalid_affinity()
try:
- curr_affinity = os.sched_getaffinity(pid)
+ curr_affinity = list(os.sched_getaffinity(pid))
except OSError as err:
if err.args[0] == errno.ESRCH:
return False
--
2.51.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2025-10-07 16:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-07 16:55 [PATCH] tuna: Fix setting a realtime scheduling policy John Kacur
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox