Add -U and -K to the spread command

Add a few clean-ups
Resolves: RHEL-108968

Signed-off-by: John Kacur <jkacur@redhat.com>
This commit is contained in:
John Kacur 2025-10-01 16:10:49 -04:00
parent ed1e3ac474
commit 7778efb16c
5 changed files with 406 additions and 2 deletions

View File

@ -0,0 +1,40 @@
From b1ecd762250d3dcc0cc19b19d2f1c78b60438602 Mon Sep 17 00:00:00 2001
From: John Kacur <jkacur@redhat.com>
Date: Mon, 15 Sep 2025 11:30:38 -0400
Subject: [PATCH 1/4] tuna: Add -U and -K to the spread command
commit 4e10e5b34593052e6ce4a166796b10c72f978efd
add the feature
-U, --no_uthreads Operations will not affect user threads
-K, --no_kthreads Operations will not affect kernel
threads
to the move command
This also works for the spread command but the arguments need to be
added. Without this you also get an
AttributeError: 'Namespace' object has no attribute 'uthreads'
Fix this by adding the options to the spread group for argparse.
Signed-off-by: John Kacur <jkacur@redhat.com>
---
tuna-cmd.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tuna-cmd.py b/tuna-cmd.py
index d0a3e6b7dbf8..9f5ce918054d 100755
--- a/tuna-cmd.py
+++ b/tuna-cmd.py
@@ -183,6 +183,8 @@ def gen_parser():
spread_group.add_argument('-N', '--nohz_full', **MODS['nohz_full'])
spread.add_argument('-t', '--threads', **MODS['threads'])
spread.add_argument('-q', '--irqs', **MODS['irqs'])
+ spread.add_argument('-U', '--no_uthreads', **MODS['no_uthreads'])
+ spread.add_argument('-K', '--no_kthreads', **MODS['no_kthreads'])
priority.add_argument('priority', **POS['priority'])
priority.add_argument('-t', '--threads', **MODS['threads'], required=True)
--
2.49.0

View File

@ -0,0 +1,42 @@
From efc79373b714a2cef2101eacb7282c85655d8561 Mon Sep 17 00:00:00 2001
From: "John B. Wyatt IV" <jwyatt@redhat.com>
Date: Thu, 4 Sep 2025 10:21:31 -0400
Subject: [PATCH 3/4] tuna: Proofreading fixes
Fix some small proofreading errors.
Signed-off-by: John B. Wyatt IV <jwyatt@redhat.com>
Signed-off-by: John B. Wyatt IV <sageofredondo@gmail.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
---
etc/tuna/example.conf | 2 +-
tuna/gui/profileview.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/etc/tuna/example.conf b/etc/tuna/example.conf
index 7bb293e3d2ed..0d3353f4132f 100644
--- a/etc/tuna/example.conf
+++ b/etc/tuna/example.conf
@@ -55,5 +55,5 @@ net.core = core
#special section for this file description
[fileDescription]
-text = This file contain some features for tunning kernel params.Mainly this is example file for demonstrate tuna new features. Params are set as default or most uses value
+text = This file contains some features for tuning kernel params. Mainly this is an example file for demonstrating Tuna's new features. Params are set as default or the most used value.
diff --git a/tuna/gui/profileview.py b/tuna/gui/profileview.py
index 7570bc0e57ce..e5022b8b6dc1 100644
--- a/tuna/gui/profileview.py
+++ b/tuna/gui/profileview.py
@@ -104,7 +104,7 @@ class profileview:
"%s\n\n%s\n%s" % \
(_("Config file was changed!"),
_("All changes will be lost"),
- _("Realy continue?"),))
+ _("Really continue?"),))
ret = dialog.run()
dialog.destroy()
if ret == Gtk.ResponseType.NO:
--
2.49.0

View File

@ -0,0 +1,257 @@
From a4689278207652b1636553505b1991450b51afd5 Mon Sep 17 00:00:00 2001
From: "John B. Wyatt IV" <jwyatt@redhat.com>
Date: Wed, 17 Sep 2025 17:35:49 -0400
Subject: [PATCH 4/4] tuna: Remove broken testuna
This script relies on the older, incompatible Tuna syntax, and
rtctl which is no longer packaged for most distributions. No one
has complained so remove it since the changes to update it would
be extensive with no users.
Signed-off-by: John B. Wyatt IV <jwyatt@redhat.com>
Signed-off-by: John B. Wyatt IV <sageofredondo@gmail.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
---
testuna | 230 --------------------------------------------------------
1 file changed, 230 deletions(-)
delete mode 100755 testuna
diff --git a/testuna b/testuna
deleted file mode 100755
index cb98640c0167..000000000000
--- a/testuna
+++ /dev/null
@@ -1,230 +0,0 @@
-#!/bin/bash
-# Regression tests for tuna
-# (c) 2008 Red Hat Inc.
-# Arnaldo Carvalho de Melo <acme@redhat.com>
-# SPDX-License-Identifier: GPL-2.0-only
-
-dprint() {
- [ -n "$VERBOSE" ] && echo $1
-}
-
-ktpidof() {
- echo $(ps ax -To pid,cmd | grep "\[$1.*\]" | head -1 | cut -d'[' -f 1)
-}
-
-get_rtprio() {
- echo $(chrt -p $1 | grep priority | cut -d ':' -f 2)
-}
-
-get_policy() {
- echo $(chrt -p $1 | grep policy | cut -d ':' -f 2)
-}
-
-get_affinity() {
- echo $(taskset -p $1 | grep 'current affinity' | cut -d ':' -f 2)
-}
-
-get_nr_processors() {
- echo $(grep -i "^processor.*: " /proc/cpuinfo | tail -1 | cut -d ':' -f 2)
-}
-
-get_nr_cpu_sockets() {
- echo $(grep "^physical id" /proc/cpuinfo | cut -d: -f2 | sort -u | wc -l)
-}
-
-die() {
- [ -z "$VERBOSE" ] && echo -n "$2: "
- echo $1
- rtctl --file $INITIAL reset
- taskset -p $INITIAL_INIT_AFFINITY 1 > /dev/null
- rm -rf $TESTUNA_DIR
- exit 1
-}
-
-die_with_a_diff() {
- [ -n "$VERBOSE" ] && diff -u $INITIAL $NEW
- die "$1"
-}
-
-tuna_save() {
- tuna --save $TEMPCONF
- grep -v '^# rtctl --file ' $TEMPCONF > $1
- rm -f $TEMPCONF
-}
-
-die_if_not_saved() {
- dprint "$2"
- tuna_save $NEW
- (diff -u $INITIAL $NEW | diffstat | \
- grep -q "[ \t]*1 file changed, $1 insertions*(+), $1 deletions*(-)") ||
- die_with_a_diff 'FAILED!' "$2"
-}
-
-die_if_conf_changed() {
- dprint "$1"
- tuna_save $NEW
- diff -qu $INITIAL $NEW > /dev/null || die_with_a_diff 'FAILED!' "$1":
-}
-
-die_if_zero() {
- dprint "$2"
- [ $1 -eq 0 ] && die 'FAILED!' "$2"
-}
-
-die_if_not_zero() {
- dprint "$2"
- [ $1 -ne 0 ] && die 'FAILED!' "$2"
-}
-
-die_if_not_equal() {
- dprint "$3"
- [ $1 -ne $2 ] && die 'FAILED!' "$3"
-}
-
-die_if_not_str_equal() {
- dprint "$3"
- [ $1 != $2 ] && die 'FAILED!' "$3"
-}
-
-TESTUNA_DIR=$(mktemp -d -t testuna.XXXXXX) || exit 1
-INITIAL=$TESTUNA_DIR/initial.tuna
-INITIAL_INIT_AFFINITY=$(get_affinity 1)
-TEMPCONF=$TESTUNA_DIR/tempnew.tuna
-NEW=$TESTUNA_DIR/new.tuna
-
-[ $# -eq 1 ] && VERBOSE=1
-
-dprint "Saving initial configuration"
-
-tuna_save $INITIAL
-
-TUNA_RPM_VERSION=$(rpm -q --qf "%{version}\n" tuna)
-TUNA_BIN_VERSION=$(tuna --version)
-die_if_not_str_equal "$TUNA_RPM_VERSION" "$TUNA_BIN_VERSION" \
- "Verifying --version ($TUNA_BIN_VERSION) matches package version ($TUNA_RPM_VERSION)"
-
-rtctl --file $INITIAL reset
-
-die_if_conf_changed "Replaying initial config"
-
-PID=$(ktpidof "watchdog")
-RTPRIO=$(get_rtprio $PID)
-POLICY=$(get_policy $PID)
-POLICY=$(echo ${POLICY:6:1} | tr 'A-Z' 'a-z')
-chrt -$POLICY -p $((RTPRIO - 1)) $PID
-
-die_if_not_saved 1 'Saving changes to a kernel thread priority'
-
-chrt -$POLICY -p $RTPRIO $PID
-
-die_if_conf_changed 'Restoring kernel thread priority'
-
-new_policy=$(echo $POLICY | tr fr rf)
-
-chrt -$new_policy -p $RTPRIO $PID
-
-die_if_not_saved 1 'Changing kernel thread sched policy'
-
-chrt -$POLICY -p $RTPRIO $PID
-
-die_if_conf_changed 'Restoring kernel thread sched policy'
-
-PID=$(ktpidof "kthreadd")
-AFFINITY=$(get_affinity $PID)
-
-taskset -p 0x2 $PID > /dev/null
-
-die_if_not_saved 1 'Changing kernel thread SMP affinity mask'
-
-taskset -p $AFFINITY $PID > /dev/null
-
-die_if_conf_changed 'Restoring kernel thread SMP affinity mask'
-
-NR_PROCESSORS=$(get_nr_processors)
-for PROCESSOR in $(seq 0 $NR_PROCESSORS) ; do
- taskset -p 0xff 1 > /dev/null
-
- PROCESSOR_AFFINITY=$(printf "%#x\n" $((1 << PROCESSOR)))
- tuna --cpu $PROCESSOR --isolate
-
- AFFINITY=0x$(get_affinity 1)
-
- die_if_not_zero $((AFFINITY & PROCESSOR_AFFINITY)) "Isolating CPU $PROCESSOR"
-
- tuna --cpu $PROCESSOR --include
-
- AFFINITY=0x$(get_affinity 1)
-
- die_if_zero $((AFFINITY & PROCESSOR_AFFINITY)) "Including CPU $PROCESSOR"
-done
-
-NEW_AFFINITY=$((1 << NR_PROCESSORS | 1))
-
-if [ $NR_PROCESSORS -gt 2 ]; then
- tuna --cpu=0,$NR_PROCESSORS --isolate
-
- for PID in $(cd /proc; ls -d [0-9]*) ; do
- [ -n "$(cat /proc/$PID/cmdline 2> /dev/null)" ] || continue
- AFFINITY=0x$(get_affinity $PID) || continue
-
- die_if_not_zero $((AFFINITY & NEW_AFFINITY)) \
- "Verifying isolation of first and last processor for PID $PID"
- done
-fi
-
-tuna --cpu=0,$NR_PROCESSORS --include
-
-AFFINITY=0x$(get_affinity 1)
-
-die_if_not_equal $((AFFINITY & NEW_AFFINITY)) $NEW_AFFINITY "Including first and last processor"
-
-taskset -p 0xff 1 > /dev/null
-
-NEW_AFFINITY=$((1 << NR_PROCESSORS | 1))
-
-tuna --cpu=0,$NR_PROCESSORS --thread 1 --move
-
-AFFINITY=0x$(get_affinity 1)
-
-die_if_not_equal $((AFFINITY & NEW_AFFINITY)) $NEW_AFFINITY "Moving init to just first and last processor"
-
-NR_CPU_SOCKETS=$(get_nr_cpu_sockets)
-if [ $NR_CPU_SOCKETS -ge 2 ]; then
- CPU1_SIBLINGS=$(printf "%d" 0x$(cat /sys/devices/system/cpu/cpu1/topology/core_siblings | cut -d',' -f2))
- CPU1_SOCKET=$(cat /sys/devices/system/cpu/cpu1/topology/physical_package_id)
-
- tuna --sockets=$CPU1_SOCKET --isolate
- AFFINITY=0x$(get_affinity 1)
- die_if_not_zero $((AFFINITY & CPU1_SIBLINGS)) \
- "Verifying isolation of socket $CPU1_SOCKET"
-
- tuna --sockets=$CPU1_SOCKET --include
- AFFINITY=0x$(get_affinity 1)
- die_if_not_equal $((AFFINITY & CPU1_SIBLINGS)) $CPU1_SIBLINGS \
- "Verifying inclusion of socket $CPU1_SOCKET"
-
- tuna --sockets=$CPU1_SOCKET --isolate
- tuna --sockets=$CPU1_SOCKET --thread 1 --move
- AFFINITY=0x$(get_affinity 1)
- die_if_not_equal $((AFFINITY & CPU1_SIBLINGS)) $CPU1_SIBLINGS "Moving init to CPU socket $CPU1_SOCKET"
-fi
-
-if [ $NR_PROCESSORS -gt 2 ]; then
- THREAD_PREFIX="watchdog/"
- PID=$(ps h -C ${THREAD_PREFIX}0 -o pid)
- RTPRIO=$(get_rtprio $PID)
- NEW_RTPRIO=$((RTPRIO - 1))
- tuna -t $THREAD_PREFIX* -p $NEW_RTPRIO
- for CPU in $(seq 0 $((NR_PROCESSORS - 1))); do
- PID=$(ps h -C ${THREAD_PREFIX}$CPU -o pid)
- RTPRIO=$(get_rtprio $PID)
- die_if_not_equal $RTPRIO $NEW_RTPRIO "Using --thread globbing"
- done
-fi
-
-taskset -p $INITIAL_INIT_AFFINITY 1 > /dev/null
-rtctl --file $INITIAL reset
-
-echo 'PASS: Healthy tuna, no lead found, eat!'
-
-exit 0
--
2.49.0

View File

@ -0,0 +1,57 @@
From b238986588c765c5300d05493da4bdda541f273b Mon Sep 17 00:00:00 2001
From: "John B. Wyatt IV" <jwyatt@redhat.com>
Date: Thu, 21 Aug 2025 22:43:19 -0400
Subject: [PATCH 2/4] tuna: replace match with if statements
The match-case keyword statements were introduced in Python 3.10.
This patch will accomodate older distributions that only have Python 3.9
This patch will make it easier for older distributions to use newer versions
of Tuna.
Signed-off-by: John B. Wyatt IV <jwyatt@redhat.com>
- modified commit message
Signed-off-by: John Kacur <jkacur@redhat.com>
---
tuna/cpupower.py | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/tuna/cpupower.py b/tuna/cpupower.py
index ec04b908855a..ecb2507b2127 100755
--- a/tuna/cpupower.py
+++ b/tuna/cpupower.py
@@ -38,20 +38,19 @@ if have_cpupower:
self.__cpu_list = utils.get_all_cpu_list()
def handle_common_lcpw_errors(self, e, error_type, idle_name):
- match e:
- case 0:
- pass
- case -1:
- print(f"Idlestate {idle_name} not available", file=sys.stderr)
- case -2:
- print("Disabling is not supported by the kernel", file=sys.stderr)
- case -3:
- if error_type == Cpupower.LCPW_ERROR_THREE_CASE:
- print("No write access to disable/enable C-states: try using sudo", file=sys.stderr)
- else:
- print(f"Not documented: {e}", file=sys.stderr)
- case _:
+ if e == 0:
+ pass
+ elif e == -1:
+ print(f"Idlestate {idle_name} not available", file=sys.stderr)
+ elif e == -2:
+ print("Disabling is not supported by the kernel", file=sys.stderr)
+ elif e == -3:
+ if error_type == Cpupower.LCPW_ERROR_THREE_CASE:
+ print("No write access to disable/enable C-states: try using sudo", file=sys.stderr)
+ else:
print(f"Not documented: {e}", file=sys.stderr)
+ else:
+ print(f"Not documented: {e}", file=sys.stderr)
def get_idle_states(self, cpu):
"""
--
2.49.0

View File

@ -1,6 +1,6 @@
Name: tuna
Version: 0.19
Release: 9%{?dist}
Release: 10%{?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
@ -26,7 +26,10 @@ Patch10: 0002-tuna-help.py.patch
Patch11: tuna-Fix-show_threads-t-and-show_irqs-q.patch
Patch12: tuna-Fix-run-command-failing-to-apply-BATCH-policy.patch
Patch13: tuna-Add-U-and-K-to-the-move-command.patch
Patch14: tuna-disable-cpu_power-functionality-for-RHEL9-curre.patch
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
%description
Provides interface for changing scheduler and IRQ tunables, at whole CPU and at
@ -80,6 +83,11 @@ done
%{_datadir}/polkit-1/actions/org.tuna.policy
%changelog
* Wed Oct 01 2025 John Kacur <jkacur@redhat.com> - 0.19-10
- Add -U and -K to the spread command
- Add a few clean-ups
Resolves: RHEL-108968
* Wed Aug 06 2025 John B. Wyatt IV <jwyatt@redhat.com> - 0.19-9
- Disable cpu_power from showing in help menu and checking for cpu_power
match functionality.