Compare commits

...

No commits in common. "c8" and "c9-beta" have entirely different histories.
c8 ... c9-beta

15 changed files with 292 additions and 1270 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/tuna-0.18.tar.xz
SOURCES/tuna-0.20.tar.xz

1
.tuna.metadata Normal file
View File

@ -0,0 +1 @@
d239e8e6eccff89ec28f8eaa8fbb4cb7ef9bac5e SOURCES/tuna-0.20.tar.xz

View File

@ -1,357 +0,0 @@
From 8c9b74f89c616a7aebbbd159e71aeb3c49979472 Mon Sep 17 00:00:00 2001
From: Clark Williams <clrkwllms@kernel.org>
Date: Thu, 17 Aug 2023 08:12:38 -0500
Subject: [PATCH 1/2] Add SPDX license identifiers
use SPDX license identifiers to clarify the licences under which
tuna is released.
Signed-off-by: Clark Williams <williams@redhat.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
---
Makefile | 3 +++
org.tuna.policy | 1 +
oscilloscope-cmd.py | 15 +--------------
setup.py | 1 +
testuna | 10 +++++-----
tuna-cmd.py | 9 +--------
tuna.desktop | 1 +
tuna/__init__.py | 2 +-
tuna/config.py | 2 ++
tuna/gui/__init__.py | 2 ++
tuna/gui/commonview.py | 2 ++
tuna/gui/cpuview.py | 1 +
tuna/gui/irqview.py | 1 +
tuna/gui/procview.py | 1 +
tuna/gui/profileview.py | 1 +
tuna/gui/util.py | 1 +
tuna/new_eth.py | 1 +
tuna/oscilloscope.py | 15 +--------------
tuna/sysfs.py | 2 ++
tuna/tuna.py | 7 ++++---
tuna/tuna_gui.py | 1 +
tuna/tuna_sched.py | 1 +
22 files changed, 35 insertions(+), 45 deletions(-)
diff --git a/Makefile b/Makefile
index 50ded3985743..a3d71d2de896 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,6 @@
+#
+# SPDX-License-Identifier: GPL-2.0-only
+#
PACKAGE := tuna
VERSION := $(shell rpm -q --qf '%{VERSION} ' --specfile rpm/SPECS/$(PACKAGE).spec | cut -d' ' -f1)
diff --git a/org.tuna.policy b/org.tuna.policy
index 4f71d4ad65f4..b3b3900a4d76 100644
--- a/org.tuna.policy
+++ b/org.tuna.policy
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!-- SPDX-License-Identifier: GPL-2.0-only -->
<!DOCTYPE policyconfig PUBLIC "-//freedesktop//DTD polkit Policy Configuration 1.0//EN"
"http://www.freedesktop.org/software/polkit/policyconfig-1.dtd">
<policyconfig>
diff --git a/oscilloscope-cmd.py b/oscilloscope-cmd.py
index 2ca87e9edc62..a65117637160 100755
--- a/oscilloscope-cmd.py
+++ b/oscilloscope-cmd.py
@@ -5,20 +5,7 @@
# http://git.kernel.org/?p=linux/kernel/git/acme/tuna.git;a=tree
# For newer versions and to see it integrated with tuna
#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation;
-# version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-# USA
+# SPDX-License-Identifier: LGPL-2.1-only
import getopt
import sys
diff --git a/setup.py b/setup.py
index f3e36529fefb..a00adb9721a8 100755
--- a/setup.py
+++ b/setup.py
@@ -1,4 +1,5 @@
#!/usr/bin/python3
+# SPDX-License-Identifier: GPL-2.0-only
from distutils.sysconfig import get_python_lib
from distutils.core import setup
from os.path import isfile, join
diff --git a/testuna b/testuna
index 4bf91ebdb76f..cb98640c0167 100755
--- a/testuna
+++ b/testuna
@@ -2,7 +2,7 @@
# Regression tests for tuna
# (c) 2008 Red Hat Inc.
# Arnaldo Carvalho de Melo <acme@redhat.com>
-# Released under the GPLv2
+# SPDX-License-Identifier: GPL-2.0-only
dprint() {
[ -n "$VERBOSE" ] && echo $1
@@ -111,21 +111,21 @@ 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
+chrt -$POLICY -p $((RTPRIO - 1)) $PID
die_if_not_saved 1 'Saving changes to a kernel thread priority'
-chrt -$POLICY -p $RTPRIO $PID
+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
+chrt -$new_policy -p $RTPRIO $PID
die_if_not_saved 1 'Changing kernel thread sched policy'
-chrt -$POLICY -p $RTPRIO $PID
+chrt -$POLICY -p $RTPRIO $PID
die_if_conf_changed 'Restoring kernel thread sched policy'
diff --git a/tuna-cmd.py b/tuna-cmd.py
index f5dafa739da2..38e7017336a5 100755
--- a/tuna-cmd.py
+++ b/tuna-cmd.py
@@ -5,14 +5,7 @@
# Copyright (C) 2008, 2009, 2010, 2011 Red Hat Inc.
# Arnaldo Carvalho de Melo <acme@redhat.com>
#
-# This application is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; version 2.
-#
-# This application is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
+# SPDX-License-Identifier: GPL-2.0-only
""" tuna - Application Tuning GUI """
diff --git a/tuna.desktop b/tuna.desktop
index 603011f79467..87ca3a35ce63 100644
--- a/tuna.desktop
+++ b/tuna.desktop
@@ -1,3 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0-only
[Desktop Entry]
Name=tuna
GenericName=Application Tuner
diff --git a/tuna/__init__.py b/tuna/__init__.py
index 30924a00cf96..614e3e4c7ed8 100755
--- a/tuna/__init__.py
+++ b/tuna/__init__.py
@@ -4,4 +4,4 @@ Copyright (c) 2008, 2009 Red Hat Inc.
Application Tuning GUI
"""
__author__ = "Arnaldo Carvalho de Melo <acme@redhat.com>"
-__license__ = "GPLv2 License"
+__license__ = "SPDX-License-Identifier: GPL-2.0-only"
diff --git a/tuna/config.py b/tuna/config.py
index 09d26dd87029..63c9f23bb09b 100644
--- a/tuna/config.py
+++ b/tuna/config.py
@@ -1,3 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
import io
import os
import re
diff --git a/tuna/gui/__init__.py b/tuna/gui/__init__.py
index ad1191c13d8d..a40f86292e6f 100755
--- a/tuna/gui/__init__.py
+++ b/tuna/gui/__init__.py
@@ -1,3 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
"""
Copyright (c) 2009 Red Hat Inc.
diff --git a/tuna/gui/commonview.py b/tuna/gui/commonview.py
index cc8f913819a2..8089ed154dae 100644
--- a/tuna/gui/commonview.py
+++ b/tuna/gui/commonview.py
@@ -1,3 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
from gi.repository import Gtk
from tuna import tuna
diff --git a/tuna/gui/cpuview.py b/tuna/gui/cpuview.py
index cc3f0f905ae7..844705a4bb21 100755
--- a/tuna/gui/cpuview.py
+++ b/tuna/gui/cpuview.py
@@ -1,5 +1,6 @@
# -*- python -*-
# -*- coding: utf-8 -*-
+# SPDX-License-Identifier: GPL-2.0-only
from functools import reduce
diff --git a/tuna/gui/irqview.py b/tuna/gui/irqview.py
index 5143d6dc0df5..e89fb70197fc 100755
--- a/tuna/gui/irqview.py
+++ b/tuna/gui/irqview.py
@@ -1,5 +1,6 @@
# -*- python -*-
# -*- coding: utf-8 -*-
+# SPDX-License-Identifier: GPL-2.0-only
from tuna import tuna, gui
import procfs
from gi.repository import Gdk
diff --git a/tuna/gui/procview.py b/tuna/gui/procview.py
index 440a289a1b29..78d5f573dd49 100755
--- a/tuna/gui/procview.py
+++ b/tuna/gui/procview.py
@@ -1,3 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0-only
import re
import os
import tuna.tuna_sched as tuna_sched
diff --git a/tuna/gui/profileview.py b/tuna/gui/profileview.py
index 26f58cbc8f4f..7570bc0e57ce 100644
--- a/tuna/gui/profileview.py
+++ b/tuna/gui/profileview.py
@@ -1,3 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0-only
import os
import shutil
import gi
diff --git a/tuna/gui/util.py b/tuna/gui/util.py
index ec368ae4b2c9..92bd368179cc 100644
--- a/tuna/gui/util.py
+++ b/tuna/gui/util.py
@@ -1,3 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0-only
import errno
import os
import gi
diff --git a/tuna/new_eth.py b/tuna/new_eth.py
index 98f9179d5695..e2888d4cef36 100755
--- a/tuna/new_eth.py
+++ b/tuna/new_eth.py
@@ -1,4 +1,5 @@
# Copyright (C) 2022 John Kacur
+# SPDX-License-Identifier: GPL-2.0-only
""" A few functions similar to ethtool """
import os
import socket
diff --git a/tuna/oscilloscope.py b/tuna/oscilloscope.py
index 317fe4554c60..a44ace53ec27 100755
--- a/tuna/oscilloscope.py
+++ b/tuna/oscilloscope.py
@@ -8,20 +8,7 @@
# http://git.kernel.org/?p=linux/kernel/git/acme/tuna.git;a=tree
# For newer versions and to see it integrated with tuna
#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation;
-# version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-# USA
+# SPDX-License-Identifier: LGPL-2.1-only
import os
import sys
diff --git a/tuna/sysfs.py b/tuna/sysfs.py
index 1c903e106a44..cd2377a8df26 100755
--- a/tuna/sysfs.py
+++ b/tuna/sysfs.py
@@ -1,5 +1,7 @@
# -*- python -*-
# -*- coding: utf-8 -*-
+# SPDX-License-Identifier: GPL-2.0-only
+
"""
classes for /sys/devices/system/cpu/
so we can get topology information and do CPU hotplug operations
diff --git a/tuna/tuna.py b/tuna/tuna.py
index e64211b88fc3..464d7f73212e 100755
--- a/tuna/tuna.py
+++ b/tuna/tuna.py
@@ -1,5 +1,6 @@
# -*- python -*-
# -*- coding: utf-8 -*-
+# SPDX-License-Identifier: GPL-2.0-only
import copy
import errno
@@ -649,12 +650,12 @@ def generate_rtgroups(filename, kthreads, nr_cpus):
f.write('''# Generated by tuna
#
# Use it with rtctl:
-#
+#
# rtctl --file %s reset
#
# Please use 'man rtctl' for more operations
#
-# Associate processes into named groups with default priority and
+# Associate processes into named groups with default priority and
# scheduling policy.
#
# Format is: <groupname>:<sched>:<prio>:<regex>
@@ -663,7 +664,7 @@ def generate_rtgroups(filename, kthreads, nr_cpus):
# sched must be one of: 'f' (fifo)
# 'b' (batch)
# 'r' (round-robin)
-# 'o' (other)
+# 'o' (other)
# '*' (leave alone)
# regex is an awk regex
#
diff --git a/tuna/tuna_gui.py b/tuna/tuna_gui.py
index 459f90303ed5..cefee4a57697 100755
--- a/tuna/tuna_gui.py
+++ b/tuna/tuna_gui.py
@@ -1,5 +1,6 @@
# -*- python -*-
# -*- coding: utf-8 -*-
+# SPDX-License-Identifier: GPL-2.0-only
import sys
import os
diff --git a/tuna/tuna_sched.py b/tuna/tuna_sched.py
index de9846bb5fae..1051983e53f9 100644
--- a/tuna/tuna_sched.py
+++ b/tuna/tuna_sched.py
@@ -1,5 +1,6 @@
#!/usr/bin/python3
# Copyright (C) 2022 John Kacur
+# SPDX-License-Identifier: GPL-2.0-only
"""
Functions to translate a scheduling policy into either a string name or an
equivalent integer
--
2.41.0

View File

@ -1,175 +0,0 @@
From 9dfaafe278f6cccf6911cddef413dc59e87722e7 Mon Sep 17 00:00:00 2001
From: Leah Leshchinsky <lleshchi@redhat.com>
Date: Wed, 16 Nov 2022 10:38:10 -0500
Subject: [PATCH] tuna: Adapt show_threads cgroup output to terminal size
Passing the --cgroup flag for the --show_threads command currently displays
long cgroup strings on the thread output and decreases readability.
Adapt the show_threads output to account for output string and terminal
size, and format output accordingly to improve readability. Add
--spaced flag to --show_threads to print cgroups spacing in
between thread outputs.
Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
---
target branch: getopt
Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
diff --git a/docs/tuna.8 b/docs/tuna.8
index 3a06556..218ba14 100644
--- a/docs/tuna.8
+++ b/docs/tuna.8
@@ -80,6 +80,9 @@ Disable display of selected CPUs in \fB--gui\fR. Requires \fB-c\R.
\fB\-G\fR, \fB\-\-cgroup\fR
Display the processes with the type of cgroups they are in. Requires \fB-P\R.
.TP
+\fB\-z\fR, \fB\-\-spaced\fR
+Display spaced view for cgroups. Requires \fB-G\R.
+.TP
\fB\-K\fR, \fB\-\-no_kthreads\fR
Operations will not affect kernel threads.
.TP
diff --git a/tuna-cmd.py b/tuna-cmd.py
index 75b63da..54dc567 100755
--- a/tuna-cmd.py
+++ b/tuna-cmd.py
@@ -99,6 +99,8 @@ def usage():
print(fmt % ('-g, --gui', _('Start the GUI')))
print(fmt % ('-G, --cgroup',
_('Display the processes with the type of cgroups they are in')))
+ print(fmt % ('-z, --spaced',
+ "Display spaced view for cgroups"))
print(fmt % ('-c, --cpus=' + _('CPU-LIST'), _('%(cpulist)s affected by commands') %
{"cpulist": _('CPU-LIST')}))
print(fmt % ('-C, --affect_children',
@@ -249,7 +251,7 @@ def format_affinity(affinity):
return ",".join(str(hex(a)) for a in procfs.hexbitmask(affinity, get_nr_cpus()))
def ps_show_thread(pid, affect_children, ps, has_ctxt_switch_info, sock_inodes,
- sock_inode_re, cgroups):
+ sock_inode_re, cgroups, columns=None, compact=True):
global irqs
try:
affinity = format_affinity(os.sched_getaffinity(pid))
@@ -286,10 +288,20 @@ def ps_show_thread(pid, affect_children, ps, has_ctxt_switch_info, sock_inodes,
nonvoluntary_ctxt_switches)
# Indent affected children
- print(" %-5d " % pid if affect_children else " %-5d" % pid, end=' ')
- print("%6s %5d %8s%s %15s %s" % (sched, rtprio, affinity,
- ctxt_switch_info, cmd, users), end=' ')
- print(" %9s" % cgout if cgroups else "")
+ s1 = " %-5d " % pid if affect_children else " %-5d" % pid
+ print(s1, end=' ')
+ s2 = "%6s %5d %8s%s %15s %s" % (sched, rtprio, affinity,
+ ctxt_switch_info, cmd, users)
+ print(s2, end=' ')
+
+ if cgroups:
+ length = int(columns) - len(s1 + " ") - len(s2 + " ")
+ if len(" %9s" % cgout) <= length:
+ print("%s" % cgout)
+ else:
+ print("\n %s" % cgout + ("" if compact else "\n"))
+ else:
+ print()
if sock_inodes:
ps_show_sockets(pid, ps, sock_inodes, sock_inode_re,
@@ -298,12 +310,12 @@ def ps_show_thread(pid, affect_children, ps, has_ctxt_switch_info, sock_inodes,
for tid in list(ps[pid]["threads"].keys()):
ps_show_thread(tid, False, ps[pid]["threads"],
has_ctxt_switch_info,
- sock_inodes, sock_inode_re, cgroups)
+ sock_inodes, sock_inode_re, cgroups, columns, compact)
def ps_show(ps, affect_children, thread_list, cpu_list,
irq_list_numbers, show_uthreads, show_kthreads,
- has_ctxt_switch_info, sock_inodes, sock_inode_re, cgroups):
+ has_ctxt_switch_info, sock_inodes, sock_inode_re, cgroups, compact):
ps_list = []
for pid in list(ps.keys()):
@@ -340,9 +352,14 @@ def ps_show(ps, affect_children, thread_list, cpu_list,
ps_list.sort()
+ # Width of terminal in columns
+ columns = None
+ if cgroups:
+ _, columns = os.popen('stty size', 'r').read().split()
+
for pid in ps_list:
ps_show_thread(pid, affect_children, ps, has_ctxt_switch_info,
- sock_inodes, sock_inode_re, cgroups)
+ sock_inodes, sock_inode_re, cgroups, columns, compact)
def load_socktype(socktype, inodes):
@@ -363,7 +380,7 @@ def load_sockets():
def do_ps(thread_list, cpu_list, irq_list, show_uthreads, show_kthreads,
- affect_children, show_sockets, cgroups):
+ affect_children, show_sockets, cgroups, compact):
ps = procfs.pidstats()
if affect_children:
ps.reload_threads()
@@ -380,7 +397,7 @@ def do_ps(thread_list, cpu_list, irq_list, show_uthreads, show_kthreads,
ps_show_header(has_ctxt_switch_info, cgroups)
ps_show(ps, affect_children, thread_list,
cpu_list, irq_list, show_uthreads, show_kthreads,
- has_ctxt_switch_info, sock_inodes, sock_inode_re, cgroups)
+ has_ctxt_switch_info, sock_inodes, sock_inode_re, cgroups, compact)
except IOError:
# 'tuna -P | head' for instance
pass
@@ -535,13 +552,13 @@ def main():
i18n_init()
try:
- short = "a:c:dDCfgGhiIKlmNp:PQq:r:R:s:S:t:UvWxL:"
+ short = "a:c:dDCfgGzhiIKlmNp:PQq:r:R:s:S:t:UvWxL:"
long = ["cpus=", "affect_children", "filter", "gui", "help",
"isolate", "include", "no_kthreads", "move", "nohz_full",
"show_sockets", "priority=", "show_threads",
"show_irqs", "irqs=",
"save=", "sockets=", "threads=", "no_uthreads",
- "version", "what_is", "spread", "cgroup", "config_file_apply=",
+ "version", "what_is", "spread", "cgroup", "spaced", "config_file_apply=",
"config_file_list", "run=", "refresh=", "disable_perf", "logging=", "debug"]
if have_inet_diag:
short += "n"
@@ -556,6 +573,7 @@ def main():
kthreads = True
uthreads = True
cgroups = False
+ compact = True
cpu_list = None
debug = False
irq_list = None
@@ -623,6 +641,8 @@ def main():
affect_children = True
elif o in ("-G", "--cgroup"):
cgroups = True
+ elif o in ("-z", "--spaced"):
+ compact = False
elif o in ("-t", "--threads"):
# The -t - will reset thread list
if a == '-':
@@ -691,7 +711,7 @@ def main():
if thread_list_str or irq_list_str:
continue
do_ps(thread_list, cpu_list, irq_list, uthreads,
- kthreads, affect_children, show_sockets, cgroups)
+ kthreads, affect_children, show_sockets, cgroups, compact)
elif o in ("-Q", "--show_irqs"):
# If the user specified IRQ names that weren't
# resolved to IRQs, don't show all IRQs.
--
2.38.1

View File

@ -0,0 +1,54 @@
From 959a16cefa6df216e42864534bc1eab9fd4d02c9 Mon Sep 17 00:00:00 2001
From: John Kacur <jkacur@redhat.com>
Date: Mon, 12 Jan 2026 15:23:05 -0500
Subject: [PATCH 1/2] tuna: Disable the tuna apply functionality
Currently tuned is the recommended way to apply a profile.
Since tuna apply is currently broken, disabling it.
Signed-off-by: John Kacur <jkacur@redhat.com>
---
tuna-cmd.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/tuna-cmd.py b/tuna-cmd.py
index 886824a4013c..6208bd116cea 100755
--- a/tuna-cmd.py
+++ b/tuna-cmd.py
@@ -150,8 +150,8 @@ def gen_parser():
help="Fork a new process and run the COMMAND")
save = subparser.add_parser('save', description="Save kthreads sched tunables to FILENAME",
help="Save kthreads sched tunables to FILENAME")
- apply = subparser.add_parser('apply', description="Apply changes described in profile",
- help="Apply changes described in profile")
+ # apply = subparser.add_parser('apply', description="Apply changes described in profile",
+ # help="Apply changes described in profile")
show_threads = subparser.add_parser('show_threads', description='Show thread list', help='Show thread list')
show_irqs = subparser.add_parser('show_irqs', description='Show IRQ list', help='Show IRQ list')
show_configs = subparser.add_parser('show_configs', description='List preloaded profiles', help='List preloaded profiles')
@@ -205,7 +205,7 @@ def gen_parser():
save_group.add_argument('-N', '--nohz_full', **MODS['nohz_full'])
save.add_argument('-t', '--threads', **MODS['threads'])
- apply.add_argument('profilename', **POS['profilename'])
+ # apply.add_argument('profilename', **POS['profilename'])
show_threads_group1 = show_threads.add_mutually_exclusive_group(required=False)
show_threads_group1.add_argument('-c', '--cpus', **MODS['cpus'])
@@ -712,10 +712,10 @@ def main():
if 'nohz_full' in vars(args) and args.nohz_full:
args.cpu_list = nohz_full_to_cpu()
- if args.command in ['apply', 'a']:
- apply_config(args.profilename)
+ # if args.command in ['apply', 'a']:
+ # apply_config(args.profilename)
- elif args.command in ['include', 'I']:
+ if args.command in ['include', 'I']:
tuna.include_cpus(args.cpu_list, utils.get_nr_cpus())
elif args.command in ['isolate', 'i']:
--
2.52.0

View File

@ -1,34 +0,0 @@
From f2763aaed8f421bcf266a3122a84c41a7441a5d9 Mon Sep 17 00:00:00 2001
From: John Kacur <jkacur@redhat.com>
Date: Mon, 11 Dec 2023 16:29:02 -0500
Subject: [PATCH] tuna: Don't start the gui if a display is not available
This is intended for the getopt branch of tuna
Don't start the gui if a display is not available.
Signed-off-by: John Kacur <jkacur@redhat.com>
---
tuna-cmd.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tuna-cmd.py b/tuna-cmd.py
index 38e7017336a5..ff2920f06d6f 100755
--- a/tuna-cmd.py
+++ b/tuna-cmd.py
@@ -821,6 +821,12 @@ def main():
sys.exit(2)
if run_gui:
+ # Don't try to start the gui if no display is available
+ display = os.getenv("DISPLAY")
+ if not display:
+ usage()
+ return
+
try:
from tuna import tuna_gui
except ImportError:
--
2.42.0

View File

@ -1,52 +0,0 @@
From 3f1fbb092f5ef07d04fef7ddec9e538f36d84450 Mon Sep 17 00:00:00 2001
From: John Kacur <jkacur@redhat.com>
Date: Fri, 2 Sep 2022 11:55:07 -0400
Subject: [PATCH] tuna: Fix matching irqs in ps_show_thread
The new format to match irqs is "irqs/"
We already test this when we call is_irq_thread(cmd):
With this fix if you do
tuna show_threads
You will get nic information that was previously missed such as
986 FIFO 50 9 69286 2 irq/164-iwlwifi:default_que
ue iwlwifi:default_queue
Signed-off-by: John Kacur <jkacur@redhat.com>
---
tuna-cmd.py | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/tuna-cmd.py b/tuna-cmd.py
index b13b25b8a801..80e27523acc6 100755
--- a/tuna-cmd.py
+++ b/tuna-cmd.py
@@ -351,17 +351,12 @@ def ps_show_thread(pid, affect_children, ps, has_ctxt_switch_info, sock_inodes,
try:
if not irqs:
irqs = procfs.interrupts()
- if cmd[:4] == "IRQ-":
- users = irqs[tuna.irq_thread_number(cmd)]["users"]
- for u in users:
- if u in get_nics():
- users[users.index(u)] = "%s(%s)" % (
- u, ethtool.get_module(u))
- users = ",".join(users)
- else:
- u = cmd[cmd.find('-') + 1:]
+ users = irqs[tuna.irq_thread_number(cmd)]["users"]
+ for u in users:
if u in get_nics():
- users = ethtool.get_module(u)
+ users[users.index(u)] = "%s(%s)" % (
+ u, ethtool.get_module(u))
+ users = ",".join(users)
except:
users = "Not found in /proc/interrupts!"
--
2.37.3

View File

@ -1,42 +0,0 @@
From 613bc73f6ad821db682e9efc097c29af9cb40858 Mon Sep 17 00:00:00 2001
From: Leah Leshchinsky <lleshchi@redhat.com>
Date: Wed, 23 Nov 2022 14:14:36 -0500
Subject: [PATCH] tuna: Fix --show_threads --cgroup without a term
When tuna --show_threads --cgroups is run without a term,
provide a default column size of 80 to fix a traceback
that occurred when querying the terminal size.
Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
- Edited the commit title
- Edited the description
Signed-off-by: John Kacur <jkacur@redhat.com>
diff --git a/tuna-cmd.py b/tuna-cmd.py
index 54dc567..f5dafa7 100755
--- a/tuna-cmd.py
+++ b/tuna-cmd.py
@@ -31,6 +31,7 @@ import procfs
from tuna import tuna, sysfs
import logging
import time
+import shutil
def get_loglevel(level):
if level.isdigit() and int(level) in range(0,5):
@@ -353,9 +354,10 @@ def ps_show(ps, affect_children, thread_list, cpu_list,
ps_list.sort()
# Width of terminal in columns
- columns = None
+ columns = 80
if cgroups:
- _, columns = os.popen('stty size', 'r').read().split()
+ if os.isatty(sys.stdout.fileno()):
+ columns = shutil.get_terminal_size().columns
for pid in ps_list:
ps_show_thread(pid, affect_children, ps, has_ctxt_switch_info,
--
2.38.1

View File

@ -1,220 +0,0 @@
From 2d0f78751760bcc737bc4b3530d77b05aaa1c286 Mon Sep 17 00:00:00 2001
From: John Kacur <jkacur@redhat.com>
Date: Wed, 18 Oct 2023 10:54:49 -0400
Subject: [PATCH 2/2] tuna: Remove spec file from git
The specfile should be maintained in the distribution and not upstream
The specfile that is upstream is largely unmaintained anyway.
This change also guts the Makefile which uses the specfile.
Most of the functionality in the Makefile is available through tools
such as rpmbuild anyway. Leaving the Makefile in place for a few
minor things like makeing tagfiles
Signed-off-by: John Kacur <jkacur@redhat.com>
---
Makefile | 39 +------------
rpm/SPECS/tuna.spec | 137 --------------------------------------------
2 files changed, 3 insertions(+), 173 deletions(-)
delete mode 100644 rpm/SPECS/tuna.spec
diff --git a/Makefile b/Makefile
index a3d71d2de896..a55821a8f908 100644
--- a/Makefile
+++ b/Makefile
@@ -1,42 +1,8 @@
#
# SPDX-License-Identifier: GPL-2.0-only
#
-PACKAGE := tuna
-VERSION := $(shell rpm -q --qf '%{VERSION} ' --specfile rpm/SPECS/$(PACKAGE).spec | cut -d' ' -f1)
-
-rpmdirs:
- @[ -d rpm/BUILD ] || mkdir rpm/BUILD
- @[ -d rpm/RPMS ] || mkdir rpm/RPMS
- @[ -d rpm/SRPMS ] || mkdir rpm/SRPMS
- @[ -d rpm/SOURCES ] || mkdir rpm/SOURCES
-
-bz2: rpmdirs
- git archive --format=tar --prefix=$(PACKAGE)-$(VERSION)/ HEAD | \
- bzip2 -9 > rpm/SOURCES/$(PACKAGE)-$(VERSION).tar.bz2
-
-rpm: bz2 rpmdirs
- rpmbuild -ba --define "_topdir $(PWD)/rpm" rpm/SPECS/$(PACKAGE).spec
-
-bz2dev: rpmdirs
- @mkdir -p /tmp/$(PACKAGE)-$(VERSION)
- @tar cf - `cat MANIFEST` | (cd /tmp/$(PACKAGE)-$(VERSION) ; tar xf -)
- @(cd /tmp; tar cf - $(PACKAGE)-$(VERSION)) | bzip2 -9 > rpm/SOURCES/$(PACKAGE)-$(VERSION).tar.bz2
-
-rpmdev: bz2dev rpmdirs
- rpmbuild -ba --define "_topdir $(PWD)/rpm" rpm/SPECS/$(PACKAGE).spec
-
-po/$(PACKAGE).pot:
- xgettext -k_ -kN_ -f po/POTFILES.in -o $@
-
-po/%.po: po/$(PACKAGE).pot
- msgmerge --suffix=.old -U $@ $< && rm -f $@.old
-
-rpmclean:
- @rm -f rpm/RPMS/*/$(PACKAGE)-$(VERSION)-*.rpm
- @rm -f rpm/SRPMS/$(PACKAGE)-$(VERSION)-*.src.rpm
- @rm -f rpm/SOURCES/$(PACKAGE)-$(VERSION).tar.bz2
- @rm -rf rpm/BUILD/$(PACKAGE)-$(VERSION)*
+.PHONY: pyclean
pyclean:
@find . -type f \( -name \*~ -o -name \*.pyc \) -delete
@@ -52,4 +18,5 @@ cleantags:
cleanlogs:
rm -rf tuna-20*
-clean: pyclean rpmclean
+.PHONY: clean
+clean: pyclean
diff --git a/rpm/SPECS/tuna.spec b/rpm/SPECS/tuna.spec
deleted file mode 100644
index eca96c833265..000000000000
--- a/rpm/SPECS/tuna.spec
+++ /dev/null
@@ -1,137 +0,0 @@
-Name: tuna
-Version: 0.15
-Release: 1%{?dist}
-License: GPLv2
-Summary: Application tuning GUI & command line utility
-Group: Applications/System
-Source: http://userweb.kernel.org/~acme/tuna/%{name}-%{version}.tar.bz2
-URL: http://userweb.kernel.org/~acme/tuna/
-BuildArch: noarch
-BuildRequires: python-devel, gettext, desktop-file-utils
-Requires: python-ethtool
-Requires: python-linux-procfs >= 0.6
-# This really should be a Suggests...
-# Requires: python-inet_diag
-BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
-
-%description
-Provides interface for changing scheduler and IRQ tunables, at whole CPU and at
-per thread/IRQ level. Allows isolating CPUs for use by a specific application
-and moving threads and interrupts to a CPU by just dragging and dropping them.
-Operations can be done on CPU sockets, understanding CPU topology.
-
-Can be used as a command line utility without requiring the GUI libraries to be
-installed.
-
-%package -n oscilloscope
-Summary: Generic graphical signal plotting tool
-Group: Applications/System
-Requires: python-matplotlib
-Requires: numpy
-Requires: pygtk2
-Requires: tuna = %{version}-%{release}
-
-%description -n oscilloscope
-Plots stream of values read from standard input on the screen together with
-statistics and a histogram.
-
-Allows to instantly see how a signal generator, such as cyclictest, signaltest
-or even ping, reacts when, for instance, its scheduling policy or real time
-priority is changed, be it using tuna or plain chrt & taskset.
-
-%prep
-%setup -q
-
-%build
-%{python3} setup.py build
-
-%install
-rm -rf %{buildroot}
-%{python3} setup.py install --skip-build --root %{buildroot}
-mkdir -p %{buildroot}/%{_sysconfdir}/tuna/
-mkdir -p %{buildroot}/{%{_bindir},%{_datadir}/tuna/help/kthreads,%{_mandir}/man8}
-mkdir -p %{buildroot}/%{_datadir}/polkit-1/actions/
-install -p -m644 tuna/tuna_gui.glade %{buildroot}/%{_datadir}/tuna/
-install -p -m755 tuna-cmd.py %{buildroot}/%{_bindir}/tuna
-install -p -m755 oscilloscope-cmd.py %{buildroot}/%{_bindir}/oscilloscope
-install -p -m644 help/kthreads/* %{buildroot}/%{_datadir}/tuna/help/kthreads/
-install -p -m644 docs/tuna.8 %{buildroot}/%{_mandir}/man8/
-install -p -m644 etc/tuna/example.conf %{buildroot}/%{_sysconfdir}/tuna/
-install -p -m644 etc/tuna.conf %{buildroot}/%{_sysconfdir}/
-install -p -m644 org.tuna.policy %{buildroot}/%{_datadir}/polkit-1/actions/
-desktop-file-install --dir=%{buildroot}/%{_datadir}/applications tuna.desktop
-
-# l10n-ed message catalogues
-for lng in `cat po/LINGUAS`; do
- po=po/"$lng.po"
- mkdir -p %{buildroot}/%{_datadir}/locale/${lng}/LC_MESSAGES
- msgfmt $po -o %{buildroot}/%{_datadir}/locale/${lng}/LC_MESSAGES/%{name}.mo
-done
-
-%find_lang %name
-
-%clean
-rm -rf %{buildroot}
-
-%files -f %{name}.lang
-%defattr(-,root,root,-)
-%doc ChangeLog
-%if "%{python_ver}" >= "2.5"
-%{python2_sitelib}/*.egg-info
-%endif
-%{_bindir}/tuna
-%{_datadir}/tuna/
-%{python3_sitelib}/tuna/
-%{_mandir}/man8/tuna.8*
-%{_sysconfdir}/tuna.conf
-%{_sysconfdir}/tuna/*
-%{_datadir}/polkit-1/actions/org.tuna.policy
-%{_datadir}/applications/tuna.desktop
-
-%files -n oscilloscope
-%defattr(-,root,root,-)
-%{_bindir}/oscilloscope
-%doc docs/oscilloscope+tuna.html
-%doc docs/oscilloscope+tuna.pdf
-
-%changelog
-* Fri Feb 1 2013 Arnaldo Carvalho de Melo <acme@redhat.com> - 0.10.4-1
-- New upstream release
-
-* Fri Aug 24 2012 Arnaldo Carvalho de Melo <acme@redhat.com> - 0.10.3-1
-- New upstream release
-
-* Thu Jul 28 2011 Arnaldo Carvalho de Melo <acme@redhat.com> - 0.10.2-1
-- New upstream release
-
-* Wed Feb 23 2011 Arnaldo Carvalho de Melo <acme@redhat.com> - 0.10.1-1
-- New upstream release
-
-* Wed Feb 23 2011 Arnaldo Carvalho de Melo <acme@redhat.com> - 0.10-1
-- New upstream release
-
-* Mon May 17 2010 Arnaldo Carvalho de Melo <acme@redhat.com> - 0.9.3-1
-- New upstream release
-- Fixes the folowing bugzilla.redhat.com tickets:
-- 563355 error in tuna --help output
-- 574950 cannot use cpu ranges in the tuna GUI
-- 559770 tuna backtrace when moving threads
-- 563352 tuna backtrace when no thread list is given for --priority
-- 563350 tuna backtrace when scheduler is mis-typed.
-
-* Thu Nov 12 2009 Arnaldo Carvalho de Melo <acme@redhat.com> - 0.9.2-1
-- New upstream release
-
-* Thu Sep 03 2009 Arnaldo Carvalho de Melo <acme@redhat.com> - 0.9.1-1
-- New upstream release
-
-* Wed Aug 26 2009 Arnaldo Carvalho de Melo <acme@redhat.com> - 0.9-3
-- Rewrite the oscilloscope package summary
-- Remove the shebang in tuna/oscilloscope.py
-
-* Mon Aug 17 2009 Arnaldo Carvalho de Melo <acme@redhat.com> - 0.9-2
-- Use install -p
-- Add BuildRequires for gettext
-
-* Fri Jul 10 2009 Arnaldo Carvalho de Melo <acme@redhat.com> - 0.9-1
-- Fedora package reviewing changes: introduce ChangeLog file
--
2.41.0

View File

@ -0,0 +1,48 @@
From 09ba81b4a78d98ce8a8e289842571f19416cdaea Mon Sep 17 00:00:00 2001
From: John Kacur <jkacur@redhat.com>
Date: Mon, 12 Jan 2026 15:24:07 -0500
Subject: [PATCH 2/2] tuna: Remove tuna apply from the man page
tuna apply has been disabled so remove it from the man page
Signed-off-by: John Kacur <jkacur@redhat.com>
---
docs/tuna.8 | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/docs/tuna.8 b/docs/tuna.8
index 6e30537e9509..8c15c2ef535c 100644
--- a/docs/tuna.8
+++ b/docs/tuna.8
@@ -169,17 +169,17 @@ optional arguments:
-t THREAD-LIST, --threads THREAD-LIST
THREAD-LIST affected by commands
.TP
-\fBtuna apply\fR
-usage: tuna-cmd.py apply [-h] profilename
-
-Apply changes described in profile
-
-positional arguments:
- profilename Apply changes described in this file
-
-optional arguments:
- -h, --help show this help message and exit
-
+.\"\fBtuna apply\fR
+.\"usage: tuna-cmd.py apply [-h] profilename
+.\"
+.\"Apply changes described in profile
+.\"
+.\"positional arguments:
+.\" profilename Apply changes described in this file
+.\"
+.\"optional arguments:
+.\" -h, --help show this help message and exit
+.\"
.TP
\fBtuna show_threads\fR
usage: tuna-cmd.py show_threads [-h] [-c CPU-LIST | -N | -S CPU-SOCKET-LIST]
--
2.52.0

View File

@ -1,104 +0,0 @@
From ff1963daf4d5a23e5f9476710e983ab781210608 Mon Sep 17 00:00:00 2001
From: John Kacur <jkacur@redhat.com>
Date: Tue, 27 Sep 2022 12:59:54 -0400
Subject: [PATCH 1/2] tuna: Replace python_ethtool with builtin funtionality
This patch replaces the dependency on python_ethtool with some
simplified functions to achieve the same result.
Reviewed-by: Federico Pellegrin <fede@evolware.org>
- return 'tun' only if tun_flags exists
Signed-off-by: John Kacur <jkacur@redhat.com>
---
tuna-cmd.py | 2 +-
tuna/gui/irqview.py | 2 +-
tuna/new_eth.py | 37 +++++++++++++++++++++++++++++++++++++
tuna/tuna.py | 2 +-
4 files changed, 40 insertions(+), 3 deletions(-)
create mode 100755 tuna/new_eth.py
diff --git a/tuna-cmd.py b/tuna-cmd.py
index bdaa70ffc156..21a70cf1d37d 100755
--- a/tuna-cmd.py
+++ b/tuna-cmd.py
@@ -25,7 +25,7 @@ import fnmatch
import gettext
import locale
from functools import reduce
-import ethtool
+import tuna.new_eth as ethtool
import tuna.tuna_sched as tuna_sched
import procfs
from tuna import tuna, sysfs
diff --git a/tuna/gui/irqview.py b/tuna/gui/irqview.py
index 35fc3fd0b0ca..5143d6dc0df5 100755
--- a/tuna/gui/irqview.py
+++ b/tuna/gui/irqview.py
@@ -7,7 +7,7 @@ from gi.repository import Gtk
from gi.repository import GObject
import os
from functools import reduce
-import ethtool
+import tuna.new_eth as ethtool
import tuna.tuna_sched as tuna_sched
import gi
diff --git a/tuna/new_eth.py b/tuna/new_eth.py
new file mode 100755
index 000000000000..98f9179d5695
--- /dev/null
+++ b/tuna/new_eth.py
@@ -0,0 +1,37 @@
+# Copyright (C) 2022 John Kacur
+""" A few functions similar to ethtool """
+import os
+import socket
+
+def get_active_devices():
+ """ return a list of network devices """
+ ret = []
+
+ for device in socket.if_nameindex():
+ ret.append(device[1])
+
+ return ret
+
+def get_module(intf):
+ """ return the kernel module for the given network interface """
+ if intf == 'lo':
+ return ""
+ myp = f'/sys/class/net/{intf}/device/driver'
+ if os.path.exists(myp):
+ return os.path.basename(os.readlink(myp))
+ if os.path.exists(f'/sys/class/net/{intf}/bridge'):
+ return 'bridge'
+ if os.path.exists(f'/sys/class/net/{intf}/tun_flags'):
+ return 'tun'
+ return ""
+
+if __name__ == "__main__":
+ nics = get_active_devices()
+ print(f'nics = {nics}')
+
+ for intf in nics:
+ driver = get_module(intf)
+ if driver:
+ print(f'{intf}, {driver}')
+ else:
+ print(f'{intf}')
diff --git a/tuna/tuna.py b/tuna/tuna.py
index 31707c9cb69c..84419c957b1b 100755
--- a/tuna/tuna.py
+++ b/tuna/tuna.py
@@ -9,7 +9,7 @@ import sys
import shlex
import fnmatch
import platform
-import ethtool
+import tuna.new_eth as ethtool
import procfs
from procfs import utilist
from tuna import help
--
2.37.3

View File

@ -1,66 +0,0 @@
From e9f60274865475c4e9081ee356ffbc61d1df2ade Mon Sep 17 00:00:00 2001
From: Leah Leshchinsky <lleshchi@redhat.com>
Date: Wed, 2 Nov 2022 10:57:19 -0400
Subject: [PATCH 3/3] tuna: tuna-cmd.py use fstrings
Add fstrings where possible to improve readabilty
Due to the discussion regarding dropping the language feature, gettext
shorthand _() have been removed.
Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
diff --git a/tuna-cmd.py b/tuna-cmd.py
index 79e33371837e..75b63da972c2 100755
--- a/tuna-cmd.py
+++ b/tuna-cmd.py
@@ -176,13 +176,16 @@ def thread_help(tid):
ps = procfs.pidstats()
if tid not in ps:
- print("tuna: " + _("thread %d doesn't exists!") % tid)
+ print(f"tuna: thread {tid} doesn't exist!")
return
pinfo = ps[tid]
cmdline = procfs.process_cmdline(pinfo)
help, title = tuna.kthread_help_plain_text(tid, cmdline)
- print("%s\n\n%s" % (title, _(help)))
+ print(title, "\n\n")
+ if help.isspace():
+ help = "No help description available."
+ print(help)
def save(cpu_list, thread_list, filename):
@@ -208,7 +211,7 @@ def ps_show_header(has_ctxt_switch_info, cgroups=False):
def ps_show_sockets(pid, ps, inodes, inode_re, indent=0):
header_printed = False
- dirname = "/proc/%s/fd" % pid
+ dirname = f"/proc/{pid}/fd"
try:
filenames = os.listdir(dirname)
except: # Process died
@@ -650,7 +653,7 @@ def main():
try:
gui_refresh=int(a)
except Exception as err:
- print("tuna: --refresh %s" % err)
+ print(f"tuna: --refresh {err}")
sys.exit(2)
elif o in ("-d", "--disable_perf"):
run_gui = True
@@ -679,7 +682,7 @@ def main():
try:
tuna.threads_set_priority(thread_list, a, affect_children)
except OSError as err:
- print("tuna: %s" % err)
+ print(f"tuna: {err}")
sys.exit(2)
elif o in ("-P", "--show_threads"):
# If the user specified process names that weren't
--
2.31.1

View File

@ -1,94 +0,0 @@
From 5f90d8b80a259884d3ca2a647fdf9471b7d7091c Mon Sep 17 00:00:00 2001
From: Leah Leshchinsky <lleshchi@redhat.com>
Date: Mon, 31 Oct 2022 13:15:07 -0400
Subject: [PATCH 1/3] tuna: tuna.py use fstrings
Add fstrings where possible to improve readabilty
Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
diff --git a/tuna/tuna.py b/tuna/tuna.py
index 84419c957b1b..e64211b88fc3 100755
--- a/tuna/tuna.py
+++ b/tuna/tuna.py
@@ -58,7 +58,7 @@ def iskthread(pid):
# in this function, so that they know that the thread vanished and
# can act accordingly, removing entries from tree views, etc
try:
- f = open("/proc/%d/smaps" % pid)
+ f = open(f"/proc/{pid}/smaps")
except IOError:
# Thread has vanished
return True
@@ -88,7 +88,7 @@ def is_irq_thread(cmd):
return cmd[:4] in ("IRQ-", "irq/")
def threaded_irq_re(irq):
- return re.compile("(irq/%s-.+|IRQ-%s)" % (irq, irq))
+ return re.compile(f"(irq/{irq}-.+|IRQ-{irq})")
# FIXME: Move to python-linux-procfs
def has_threaded_irqs(ps):
@@ -96,10 +96,10 @@ def has_threaded_irqs(ps):
return len(ps.find_by_regex(irq_re)) > 0
def set_irq_affinity_filename(filename, bitmasklist):
- pathname = "/proc/irq/%s" % filename
+ pathname = f"/proc/irq/{filename}"
f = open(pathname, "w")
text = ",".join(["%x" % a for a in bitmasklist])
- f.write("%s\n" % text)
+ f.write(f"{text}\n")
try:
f.close()
except IOError:
@@ -225,7 +225,7 @@ def move_threads_to_cpu(cpus, pid_list, set_affinity_warning=None, spread=False)
if pid not in ps:
continue
- threads = procfs.pidstats("/proc/%d/task" % pid)
+ threads = procfs.pidstats(f"/proc/{pid}/task")
for tid in list(threads.keys()):
try:
curr_affinity = os.sched_getaffinity(tid)
@@ -320,11 +320,11 @@ def affinity_remove_cpus(affinity, cpus, nr_cpus):
# Should be moved to python_linux_procfs.interrupts, shared with interrupts.parse_affinity, etc.
def parse_irq_affinity_filename(filename, nr_cpus):
try:
- f = open("/proc/irq/%s" % filename)
+ f = open(f"/proc/irq/{filename}")
except IOError as err:
if procfs.is_s390():
print("This operation is not supported on s390", file=sys.stderr)
- print("tuna: %s" % err, file=sys.stderr)
+ print(f"tuna: {err}", file=sys.stderr)
sys.exit(2)
line = f.readline()
@@ -627,19 +627,19 @@ def run_command(cmd, policy, rtprio, cpu_list):
try:
thread_set_priority(pid, policy, rtprio)
except (SystemError, OSError) as err:
- print("tuna: %s" % err)
+ print(f"tuna: {err}")
sys.exit(2)
if cpu_list:
try:
os.sched_setaffinity(pid, cpu_list)
except (SystemError, OSError) as err:
- print("tuna: %s" % err)
+ print(f"tuna: {err}")
sys.exit(2)
try:
os.execvp(cmd_list[0], cmd_list)
except (SystemError, OSError) as err:
- print("tuna: %s" % err)
+ print(f"tuna: {err}")
sys.exit(2)
else:
os.waitpid(newpid, 0)
--
2.31.1

View File

@ -1,26 +0,0 @@
From f53f77f73199f398713f8edfdfa417cf8b9e1a74 Mon Sep 17 00:00:00 2001
From: Leah Leshchinsky <lleshchi@redhat.com>
Date: Fri, 28 Oct 2022 13:14:04 -0400
Subject: [PATCH 2/3] tuna: tuna_gui.py use fstrings
Add fstrings where possible to improve readabilty
Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
diff --git a/tuna/tuna_gui.py b/tuna/tuna_gui.py
index f1f2caacbcba..459f90303ed5 100755
--- a/tuna/tuna_gui.py
+++ b/tuna/tuna_gui.py
@@ -33,7 +33,7 @@ class main_gui:
if self.check_root():
sys.exit(1)
for dir in tuna_glade_dirs:
- tuna_glade = "%s/tuna_gui.glade" % dir
+ tuna_glade = f"{dir}/tuna_gui.glade"
if os.access(tuna_glade, os.F_OK):
break
self.wtree = Gtk.Builder()
--
2.31.1

View File

@ -1,30 +1,20 @@
Name: tuna
Version: 0.18
Release: 9%{?dist}
Version: 0.20
Release: 2%{?dist}
License: GPL-2.0-only AND LGPL-2.1-only
Summary: Application tuning GUI & command line utility
Group: Applications/System
Source: https://www.kernel.org/pub/software/utils/tuna/%{name}-%{version}.tar.xz
URL: https://git.kernel.org/pub/scm/utils/tuna/tuna.git
Source: https://www.kernel.org/pub/software/utils/%{name}/%{name}-%{version}.tar.xz
BuildArch: noarch
BuildRequires: python3-devel, gettext
Requires: python3-linux-procfs >= 0.6
# This really should be a Suggests...
# Requires: python-inet_diag
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
# PATCHES
Patch1: tuna-Replace-python_ethtool-with-builtin-funtionalit.patch
Patch2: tuna-Fix-matching-irqs-in-ps_show_thread.patch
Patch3: tuna-tuna.py-use-fstrings.patch
Patch4: tuna-tuna_gui.py-use-fstrings.patch
Patch5: tuna-tuna-cmd.py-use-fstrings.patch
Patch6: tuna-Adapt-show_threads-cgroup-output-to-terminal-si.patch
Patch7: tuna-Fix-show_threads-cgroup-without-a-term.patch
Patch8: Add-SPDX-license-identifiers.patch
Patch9: tuna-Remove-spec-file-from-git.patch
Patch10: tuna-Don-t-start-the-gui-if-a-display-is-not-availab.patch
# Patches
Patch1: tuna-Disable-the-tuna-apply-functionality.patch
Patch2: tuna-Remove-tuna-apply-from-the-man-page.patch
%description
Provides interface for changing scheduler and IRQ tunables, at whole CPU and at
@ -36,14 +26,20 @@ Can be used as a command line utility without requiring the GUI libraries to be
installed.
%prep
%autosetup -p1
%autosetup -v -p1
%build
%{__python3} setup.py build
%py3_build
%py3_shebang_fix tuna/
%py3_shebang_fix tuna-cmd.py
%install
rm -rf %{buildroot}
%{__python3} setup.py install --skip-build --root %{buildroot}
%py3_install
# Remove oscilloscope (unsupported in RHEL)
rm -f %{buildroot}/%{_bindir}/oscilloscope
mkdir -p %{buildroot}/%{_sysconfdir}/tuna/
mkdir -p %{buildroot}/{%{_bindir},%{_datadir}/tuna/help/kthreads,%{_mandir}/man8}
mkdir -p %{buildroot}/%{_datadir}/polkit-1/actions/
@ -55,9 +51,6 @@ install -p -m644 etc/tuna/example.conf %{buildroot}/%{_sysconfdir}/tuna/
install -p -m644 etc/tuna.conf %{buildroot}/%{_sysconfdir}/
install -p -m644 org.tuna.policy %{buildroot}/%{_datadir}/polkit-1/actions/
# Manually fix the shebang
pathfix.py -pni "%{__python3}" %{buildroot}%{_bindir}/tuna
# l10n-ed message catalogues
for lng in `cat po/LINGUAS`; do
po=po/"$lng.po"
@ -67,11 +60,7 @@ done
%find_lang %name
%clean
rm -rf %{buildroot}
%files -f %{name}.lang
%defattr(-,root,root,-)
%doc ChangeLog
%{python3_sitelib}/*.egg-info
%{_bindir}/tuna
@ -83,122 +72,222 @@ rm -rf %{buildroot}
%{_datadir}/polkit-1/actions/org.tuna.policy
%changelog
* Wed Dec 13 2023 John Kacur <jkacur@redhat.com> - 0.18-9
* Mon Jan 12 2026 John Kacur <jkacur@redhat.com> - 0.20-2
- Disable tuna apply
Resolves: RHEL-140839
* Tue Oct 28 2025 John Kacur <jkacur@redhat.com> - 0.20-1
- Update to upstream version 0.20
- Remove all patches (now included in upstream)
- Remove oscilloscope (unsupported in RHEL)
Resolves: RHEL-83079
* Tue Oct 07 2025 John Kacur <jkacur@redhat.com> - 0.19-11
- When a realtime scheduling policy is used, default the prio to 1
Resolves: RHEL-106072
* 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.
Resolves: RHEL-107847
* Wed Aug 06 2025 John Kacur <jkacur@redhat.com> - 0.19-8
- Fix show_threads -t and show_irqs -q to not match everything if no match
- Fix run command failing to apply BATCH policy
- Add -U and -K to the move command
Resolves: RHEL-86862 RHEL-106065 RHEL-106066
* Thu Jul 31 2025 John B. Wyatt IV <jwyatt@redhat.com> - 0.19-7
- Applied tuna: Fix help.py syntax warnings and tuna: help.py
Resolves: RHEL-106289
* Thu Jul 31 2025 John B. Wyatt IV - 0.19-6
- Fix syntax warnings with raw strings
Resolves: RHEL-106287
* Tue Jul 29 2025 John B. Wyatt IV - 0.19-5
- Add cpu_power command
Resolves: RHEL-106293
* Wed Dec 13 2023 John Kacur <jkacur@redhat.com> - 0.19-4
- Add an rpminspect.yaml file
Resolves: RHEL-19396
* Wed Dec 13 2023 John Kacur <jkacur@redhat.com> - 0.19-3
- Don't start the gui if a display is not available
- Revert removing distutils for rhel8
- Update the License tag in the specfile to the spdx version
Resolves: RHEL-19179
- Change to SPDX licence tag in the specfile
Resolves: RHEL-8859
* Mon Dec 11 2023 John Kacur <jkacur@redhat.com> - 0.18-8
- Remove deprecated distutils from setup
- Adjust SPDX patch to accomdate the removed distutils
Resolves: RHEL-19037
* Thu Nov 02 2023 John Kacur <jkacur@redhat.com> - 0.19-2
- Add SPDX licenses
- Remove the git maintained spec file
Resolves: RHEL-7611
* Wed Nov 01 2023 John Kacur <jkacur@redhat.com> - 0.18-7
- Remove specfile from upstream source
Resolves: RHEL-9197
* Thu Nov 02 2023 John Kacur <jkacur@redhat.com> - 0.19-1
- Update to latest upstream version, tuna-0.19
Resolves: RHEL-7862
* Wed Nov 23 2022 Leah Leshchinsky <lleshchi@redhat.com> - 0.18-6
- Fix show_threads --cgroups without a term
Resolves: rhbz#2121518
* Wed Nov 23 2022 Leah Leshchinsky <lleshchi@redhat.com> - 0.18-12
- Fix show_threads --cgroups run without term
Resolves: rhbz#2121517
* Fri Nov 18 2022 Leah Leshchinsky <lleshchi@redhat.com> - 0.18-5
* Fri Nov 18 2022 Leah Leshchinsky <lleshchi@redhat.com> - 0.18-11
- Adapt show_threads cgroup output to terminal size
Resolves: rhbz#2121518
Resolves: rhbz#2121517
* Wed Nov 02 2022 Leah Leshchinsky <lleshchi@redhat.com> - 0.18-4
* Wed Nov 09 2022 Leah Leshchinsky <lleshchi@redhat.com> - 0.18-10
- Edit run_tests.sh to support new CLI changes
Resolves: rhbz#2141349
* Tue Nov 08 2022 Leah Leshchinsky <lleshchi@redhat.com> - 0.18-9
- Remove import and fix help message
- Update manpages for argparse CLI changes
Resolves: rhbz#2138692
* Wed Nov 02 2022 Leah Leshchinsky <lleshchi@redhat.com> - 0.18-8
- Use f-strings in tuna where possible
Resolves: rhbz#2120805
Resolves: rhbz#2120803
* Mon Oct 03 2022 John Kacur <jkacur@redhat.com> - 0.18-3
* Wed Oct 26 2022 Leah Leshchinsky <lleshchi@redhat.com> - 0.18-7
- Add sockets command line option
Resolves: rhbz#2122781
* Wed Oct 26 2022 Leah Leshchinsky <lleshchi@redhat.com> - 0.18-6
- Update tuna command line interface
- Move get_policy_and_rtprio call to parser level
- Remove threads print statement
Resolves: rhbz#2062865
* Mon Oct 03 2022 John Kacur <jkacur@redhat.com> - 0.18-5
- Match irqs with "irqs/"
Resolves: rhbz#2131353
Resolves: rhbz#2131343
* Fri Sep 30 2022 John Kacur <jkacur@redhat.com> - 0.18-2
* Fri Sep 30 2022 John Kacur <jkacur@redhat.com> - 0.18-4
- Remove the "Requires" of python-ethtool from the specfile
Resolves: rhbz#2123751
* Fri Sep 30 2022 John Kacur <jkacur@redhat.com> - 0.18-3
- Replace dependency on python-ethtool with built-in functionality
Resolves: rhbz#2123753
Resolves: rhbz#2123751
* Wed Jun 29 2022 Leah Leshchinsky <lleshchi@redhat.com> - 0.18-2
- Delete patches
Resolves: rhbz#2068629
* Wed Jun 29 2022 Leah Leshchinsky <lleshchi@redhat.com> - 0.18-1
- Rebase to upstream version 0.18
Resolves: rhbz#2073555
- Update to latest upstream tuna-0.18
Resolves: rhbz#2068629
* Thu May 19 2022 Leah Leshchinsky <lleshchi@redhat.com> - 0.17-3
- Add logging infrastructure to tuna
* Wed May 11 2022 Leah Leshchinsky <lleshchi@redhat.com> - 0.17-4
- Add logging infrastructure to tuna cmd
- Add cleanlogs rule to Makefile
Resolves: rhbz#2062882
Resolves: rhbz#2062881
* Mon Apr 11 2022 Leah Leshchinsky <lleshchi@redhat.com> - 0.17-2
* Mon Apr 11 2022 Leah Leshchinsky <lleshchi@redhat.com> - 0.17-3
- Fix typo for variable parm
- Handle get_policy_and_rtprio exceptions
- Remove finally block in get_policy_and_rtprio
Resolves: rhbz#2049746
Resolves: rhbz#2049303
* Thu Jan 13 2022 Leah Leshchinsky <lleshchi@redhat.com> - 0.17-1
- Rebase to upstream version 0.17
* Thu Jan 13 2022 Leah Leshchinsky <lleshchi@redhat.com> - 0.17-2
- Fix ModuleNotFoundError
Resolves: rhbz#2012306
Resolves: rhbz#2012307
* Tue Dec 14 2021 John Kacur <jkacur@redhat.com> - 0.16-5
* Tue Jan 11 2022 Leah Leshchinsky <lleshchi@redhat.com> - 0.17-1
- Rebase to upstream version 0.17
Resolves: rhbz#2012307
* Tue Dec 14 2021 John Kacur <jkacur@redhat.com> - 0.16-6
- Display correct cpu-affinity when a cpu is disabled
Resolves: rhbz#2032614
Resolves: rhbz#2032460
* Wed Nov 10 2021 John Kacur <jkacur@redhat.com> - 0.16-4
* Thu Nov 11 2021 John Kacur <jkacur@redhat.com> - 0.16-5
- Make it clear in online help and man pages that --include and --isolate
affect IRQs as well as threads
Resolves: rhbz#1886804
Resolves: rhbz#2022142
* Tue Nov 02 2021 Leah Leshchinsky <lleshchi@redhat.com> - 0.16-4
- Add distinction between spread and move to error message
Resolves: rhbz#2012243
* Thu Oct 28 2021 John Kacur <jkacur@redhat.com> - 0.16-3
- Print warning if setaffinity causes EBUSY and continue
Resolves: rhbz#2018285
Resolves: rhbz#2016540
* Tue Oct 26 2021 Leah Leshchinsky <lleshchi@redhat.com> - 0.16-2
- Add distinction between --spread and --move to error message
Resolves: rhbz#2012241
* Tue Aug 10 2021 Mohan Boddu <mboddu@redhat.com> - 0.16-2
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Wed Jun 30 2021 John Kacur <jkacur@redhat.com> - 0.16-1
- Upgrade to latest upstream
Resolves: rhbz#1947069
- Update to latest upstream tuna-0.16
Resolves: rhbz#1890565
* Thu Jan 21 2021 John Kacur <jkacur@redhat.com> - 0.15-1
- Upgrade to latest upstream code
- Upstream drops python-schedutils and uses built-in schedutils
Resolves: rhbz#1890558
* Mon Jun 14 2021 John Kacur <jkacur@redhat.com> - 0.15-3
- Remove oscilloscope from tuna
Resolves: rhbz#1970997
* Tue Apr 02 2019 Clark Williams <williams@redhat.com> - 0.14-4
- added OSCI gating framework
Resolves: rhbz#1682423
* Fri May 21 2021 John Kacur <jkacur@redhat.com> - 0.15-2
- Remove python3-schedutils from the Requires in the spec file
- Update the URL in the spec file
Resolves: rhbz#1890541
* Fri Feb 01 2019 John Kacur <jkacur@redhat.com> - 0.14-3
- fix undefined global name stderr
Resolves: rhbz#1671440
* Mon May 17 2021 John Kacur <jkacur@redhat.com> - 0.15-1
- Rebase to tuna-0.15
- This includes changes to remove the python-schedutils dependency
Resolves: rhbz#1890541
* Tue Dec 04 2018 John Kacur <jkacur@redhat.com> - 0.14-2
- Add method to compare class cpu for sorting
- Use args attributes for exceptions for python3
Resolves: rhbz#1651465
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 0.14.1-5
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Fri Aug 10 2018 John Kacur <jkacur@redhat.com> - 0.14-1
- Sync with upstream and fix URL reference in spec
Resolves: rhbz#1596855
* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.14.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Wed Aug 08 2018 John Kacur <jkacur@redhat.com> - 0.13.3-5
- Remove some functions that are now available in python-linux-procfs
Resolves: rhbz#1522865
* Wed Jul 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.14.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Tue Jul 03 2018 Tomas Orsava <torsava@redhat.com> - 0.13.3-4
- Switch hardcoded python3 shebangs into the %%{__python3} macro
* Tue May 26 2020 Miro Hrončok <mhroncok@redhat.com> - 0.14.1-2
- Rebuilt for Python 3.9
* Thu May 31 2018 John Kacur <jkacur@redhat.com> - 0.13.3-3
- Remove deprecated oscilloscope
Resolves: rhbz#1584302
* Thu May 21 2020 Jiri Kastner <jkastner@fedoraproject.org> - 0.14.1
- update to 0.14.1
- fixes RHBZ#1773339
* Fri May 25 2018 John Kacur <jkacur@redhat.com> - 0.13.3-2
- Correct the dependencies to require python3 package versions
Resolves: rhbz#1581192
* Fri Jan 31 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.14-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Wed May 16 2018 John Kacur <jkacur@redhat.com> - 0.13.3-1
- Changes for python3
Resolves: rhbz#1518679
* Thu Oct 03 2019 Miro Hrončok <mhroncok@redhat.com> - 0.14-5
- Rebuilt for Python 3.8.0rc1 (#1748018)
* Mon Aug 19 2019 Miro Hrončok <mhroncok@redhat.com> - 0.14-4
- Rebuilt for Python 3.8
* Sat Jul 27 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.14-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Tue Feb 12 2019 Jiri Kastner <jkastner@fedoraproject.org> - 0.14-3
- upload patch
* Tue Feb 12 2019 Jiri Kastner <jkastner@fedoraproject.org> - 0.14-2
- oscilloscope gtk3 patch
* Tue Feb 12 2019 Jiri Kastner <jkastner@fedoraproject.org> - 0.14-1
- update to 0.14
- switch to python3
* Sun Feb 03 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.13.1-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.13.1-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Wed Feb 14 2018 Iryna Shcherbina <ishcherb@redhat.com> - 0.13.1-6
- Update Python 2 dependency declarations to new packaging standards
(See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3)
* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.13.1-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild