From 5714ff3aaf67aa6e36f4bd8eb13430b992ce46be Mon Sep 17 00:00:00 2001 From: John Kacur Date: Tue, 7 Oct 2025 13:11:04 -0400 Subject: [PATCH] When a realtime scheduling policy is used, default the prio to 1 Resolves: RHEL-106072 Signed-off-by: John Kacur --- ...setting-a-realtime-scheduling-policy.patch | 66 +++++++++++++++++++ tuna.spec | 7 +- 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 tuna-Fix-setting-a-realtime-scheduling-policy.patch diff --git a/tuna-Fix-setting-a-realtime-scheduling-policy.patch b/tuna-Fix-setting-a-realtime-scheduling-policy.patch new file mode 100644 index 0000000..eb90c70 --- /dev/null +++ b/tuna-Fix-setting-a-realtime-scheduling-policy.patch @@ -0,0 +1,66 @@ +From 7f0b375a323be5e2830e4afbecd7ffbd0f4e9824 Mon Sep 17 00:00:00 2001 +From: John Kacur +Date: Tue, 7 Oct 2025 12:51:14 -0400 +Subject: [PATCH] tuna: Fix setting a realtime scheduling policy + +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 +--- + 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 + diff --git a/tuna.spec b/tuna.spec index 0a2b1b4..b7c2b7f 100644 --- a/tuna.spec +++ b/tuna.spec @@ -1,6 +1,6 @@ Name: tuna Version: 0.19 -Release: 10%{?dist} +Release: 11%{?dist} License: GPL-2.0-only AND LGPL-2.1-only Summary: Application tuning GUI & command line utility URL: https://git.kernel.org/pub/scm/utils/tuna/tuna.git @@ -30,6 +30,7 @@ Patch14: tuna-Add-U-and-K-to-the-spread-command.patch Patch15: tuna-Proofreading-fixes.patch Patch16: tuna-Remove-broken-testuna.patch Patch17: tuna-disable-cpu_power-functionality-for-RHEL9-curre.patch +Patch18: tuna-Fix-setting-a-realtime-scheduling-policy.patch %description Provides interface for changing scheduler and IRQ tunables, at whole CPU and at @@ -83,6 +84,10 @@ done %{_datadir}/polkit-1/actions/org.tuna.policy %changelog +* Tue Oct 07 2025 John Kacur - 0.19-11 +- When a realtime scheduling policy is used, default the prio to 1 +Resolves: RHEL-106072 + * Wed Oct 01 2025 John Kacur - 0.19-10 - Add -U and -K to the spread command - Add a few clean-ups