tuna: Delete patches

Resolves: rhbz#2068629
This commit is contained in:
Leah Leshchinsky 2022-06-29 12:04:35 -04:00
parent 13b9caca55
commit 63c3e5c44f
7 changed files with 5 additions and 325 deletions

View File

@ -1,31 +0,0 @@
From 681304a9a57a9c2b05fcc2cc372e3d921b5ff415 Mon Sep 17 00:00:00 2001
From: Leah Leshchinsky <lleshchi@redhat.com>
Date: Tue, 10 May 2022 11:59:08 -0400
Subject: [PATCH 2/2] tuna: Add cleanlogs rule to Makefile
The logging infrastructure creates directories that contain log files.
It may be tedious for users to manually remove these directories and
files.
Add a Makefile rule that allows for easy removal of multiple logging
directories. The rule can be called via 'make cleanlogs'.
Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
diff --git a/Makefile b/Makefile
index 2c72feaa398c..50ded3985743 100644
--- a/Makefile
+++ b/Makefile
@@ -45,4 +45,8 @@ tags:
cleantags:
rm -f tags
+.PHONY: cleanlogs
+cleanlogs:
+ rm -rf tuna-20*
+
clean: pyclean rpmclean
--
2.27.0

View File

@ -1,159 +0,0 @@
From 85330a8ab1afec5370676e7c3d753a4528f24e6f Mon Sep 17 00:00:00 2001
From: Leah Leshchinsky <lleshchi@redhat.com>
Date: Tue, 10 May 2022 11:59:07 -0400
Subject: [PATCH 1/2] tuna: Add logging infrastructure to tuna-cmd
Currently, tuna does not have an easy way for developers and maintainers
to access necessary information about the state of the program.
Add logging infrastructure that allows the user to specify, at the
command line, what level of logging to print from the following levels:
(notset, debug, info, warning, error, critical). Levels may also be
specified numerically, ranging from 0-5.
A directory will be created with the current date and test run.
Logging statements will print to a log file within the created directory,
and can be specified with the '-L' and '--logging' flags. The '-D' and
'--debug' flags will print all debug information to the console.
Logging of other files outside of tuna-cmd.py can be implemented by
importing the logging directory and adding the necessary logging
statments.
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 ac21481df554..57b62298c48a 100755
--- a/tuna-cmd.py
+++ b/tuna-cmd.py
@@ -29,6 +29,50 @@ import ethtool
import tuna.tuna_sched as tuna_sched
import procfs
from tuna import tuna, sysfs
+import logging
+import time
+
+def get_loglevel(level):
+ if level.isdigit() and int(level) in range(0,5):
+ # logging built-in module levels:
+ # 0 - NOTSET
+ # 10 - DEBUG
+ # 20 - INFO,
+ # 30 - WARNING
+ # 40 - ERROR
+ return int(level) * 10
+ level_str = level.upper()
+ if level_str == "CRITICAL":
+ raise ValueError("CRITICAL level is not supported by tuna")
+ return level_str
+
+def setup_logging(logger_name):
+
+ logger = logging.getLogger(logger_name)
+ logger.setLevel(logging.DEBUG)
+ logger.propagate = False
+ return logger
+
+def add_handler(loglevel, tofile=False):
+
+ formatter = logging.Formatter('[%(levelname)s] %(message)s')
+
+ if tofile:
+ lognum = 1
+ date = time.strftime("%Y%m%d")
+ while os.path.exists("tuna-{}-{}".format(date, lognum)):
+ lognum += 1
+
+ path = "tuna-{}-{}/log/Log".format(date,lognum)
+ os.makedirs(os.path.dirname(path), exist_ok=True, mode=0o777)
+ handler = logging.FileHandler(path)
+ else:
+ handler = logging.StreamHandler(sys.stderr)
+
+ handler.setFormatter(formatter)
+ handler.setLevel(loglevel)
+
+ return handler
try:
import inet_diag
@@ -61,6 +105,7 @@ def usage():
_('Operation will affect children threads')))
print(fmt % ('-d, --disable_perf',
_('Explicitly disable usage of perf in GUI for process view')))
+ print(fmt % ('-D, --debug', _('Print DEBUG level logging details to console')))
print(fmt % ('-f, --filter',
_('Display filter the selected entities')))
print(fmt % ('-i, --isolate', _('Move all allowed threads and IRQs away from %(cpulist)s') %
@@ -69,6 +114,8 @@ def usage():
{"cpulist": _('CPU-LIST')}))
print(fmt % ('-K, --no_kthreads',
_('Operations will not affect kernel threads')))
+ print(fmt % ('-L, --logging',
+ _('Log application details to log file for given LOG-LEVEL')))
print(fmt % ('-m, --move', _('Move selected entities to %(cpulist)s') %
{"cpulist": _('CPU-LIST')}))
print(fmt % ('-N, --nohz_full',
@@ -490,14 +537,14 @@ def main():
i18n_init()
try:
- short = "a:c:dCfgGhiIKlmNp:PQq:r:R:s:S:t:UvWx"
+ short = "a:c:dDCfgGhiIKlmNp: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=",
- "config_file_list", "run=", "refresh=", "disable_perf"]
+ "config_file_list", "run=", "refresh=", "disable_perf", "logging=", "debug"]
if have_inet_diag:
short += "n"
long.append("show_sockets")
@@ -512,8 +559,10 @@ def main():
uthreads = True
cgroups = False
cpu_list = None
+ debug = False
irq_list = None
irq_list_str = None
+ log = False
rtprio = None
policy = None
thread_list = []
@@ -529,6 +578,30 @@ def main():
if o in ("-h", "--help"):
usage()
return
+ if o in ("-D", "--debug"):
+ if debug:
+ my_logger.warning("Debugging already set")
+ continue
+ debug = True
+ if not log:
+ my_logger = setup_logging("my_logger")
+ my_logger.addHandler(add_handler("DEBUG", tofile=False))
+ my_logger.info("Debug option set")
+ if o in ("-L", "--logging"):
+ if log:
+ my_logger.warning("Logging already set")
+ continue
+ log = True
+ loglevel = get_loglevel(a)
+ if not debug:
+ my_logger = setup_logging("my_logger")
+ try:
+ my_logger.addHandler(add_handler(loglevel, tofile=True))
+ except ValueError as e:
+ print(e, "tuna: --logging requires valid logging level\n")
+ print("Valid log levels: NOTSET, DEBUG, INFO, WARNING, ERROR")
+ print("Log levels may be specified numerically (0-4)")
+ my_logger.info("Logging option set")
if o in ("-a", "--config_file_apply"):
apply_config(a)
elif o in ("-l", "--config_file_list"):
--
2.27.0

View File

@ -1,35 +0,0 @@
From 7684169d22af5379d2f466730c450afc92e80da8 Mon Sep 17 00:00:00 2001
From: John Kacur <jkacur@redhat.com>
Date: Tue, 11 Jan 2022 16:58:58 -0500
Subject: [PATCH] tuna: Fix ModuleNotFoundError
commit 43b434867514934593ada5aa8ea448ef6a1778f9 fixed the problem with
relative imports but unfortunately created a new problem with installed
tuna
This fixes the original problem and also fixes the ModuleNotFoundError
in an installed (not running from git) version of tuna.
Signed-off-by: John Kacur <jkacur@redhat.com>
---
tuna/tuna.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tuna/tuna.py b/tuna/tuna.py
index 98a1725598dd..8fb42121e2e4 100755
--- a/tuna/tuna.py
+++ b/tuna/tuna.py
@@ -12,8 +12,8 @@ import platform
import ethtool
import procfs
from procfs import utilist
-import help
-import tuna_sched
+from tuna import help
+from tuna import tuna_sched
try:
fntable
--
2.27.0

View File

@ -1,26 +0,0 @@
From 8cad3c289471b985a8d0b7f698fcbf5ecbfa7bb5 Mon Sep 17 00:00:00 2001
From: Leah Leshchinsky <lleshchi@redhat.com>
Date: Wed, 2 Feb 2022 15:18:26 -0500
Subject: [PATCH 1/5] tuna: Fix typo for variable 'parm'
Variable 'parms' should be 'parm'. Fix typo.
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 8fb42121e2e4..126990339985 100755
--- a/tuna/tuna.py
+++ b/tuna/tuna.py
@@ -561,7 +561,7 @@ def threads_set_priority(tids, parm, affect_children=False):
try:
(policy, rtprio) = get_policy_and_rtprio(parm)
except ValueError:
- print("tuna: " + _("\"%s\" is unsupported priority value!") % parms[0])
+ print("tuna: " + _("\"%s\" is an unsupported priority value!") % parm[0])
return
for tid in tids:
--
2.27.0

View File

@ -1,39 +0,0 @@
From f857c822256d512d351cda0d8fa4d5d255d1e64f Mon Sep 17 00:00:00 2001
From: Leah Leshchinsky <lleshchi@redhat.com>
Date: Wed, 2 Feb 2022 15:18:27 -0500
Subject: [PATCH 2/5] tuna: Handle get_policy_and_rtprio exceptions
In tuna-cmd.py, if a thread list is passed along with the
'--priority' flag, tuna.get_policy_and_rtprio() is called twice, first
directly, and then again by tuna.threads_set_priority(). The
expectation is that tuna.threads_set_priority will handle exceptions
raised by tuna.get_policy_and_rtprio(). This results in a failure to
handle exceptions that are raised by the initial direct call to
tuna.get_policy_and_rtprio().
Handle exceptions that may be raised during direct calls to
get_policy_and_rtprio in tuna-cmd.py.
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 cf117ec046ff..2b6e91bd0104 100755
--- a/tuna-cmd.py
+++ b/tuna-cmd.py
@@ -601,7 +601,11 @@ def main():
tuna.include_cpus(cpu_list, get_nr_cpus())
elif o in ("-p", "--priority"):
# Save policy and rtprio for future Actions (e.g. --run).
- (policy, rtprio) = tuna.get_policy_and_rtprio(a)
+ try:
+ (policy, rtprio) = tuna.get_policy_and_rtprio(a)
+ except ValueError:
+ print("tuna: " + _("\"%s\" is an unsupported priority value!") % a)
+ sys.exit(2)
if not thread_list:
# For backward compatibility
p_waiting_action = True
--
2.27.0

View File

@ -1,34 +0,0 @@
From adba6d6cad1a5c9f062dcf5ee4b4be40d4dc134f Mon Sep 17 00:00:00 2001
From: Leah Leshchinsky <lleshchi@redhat.com>
Date: Wed, 2 Feb 2022 15:18:29 -0500
Subject: [PATCH 3/5] tuna: Remove finally block in get_policy_and_rtprio
The implementation of the error handling block in
tuna.get_policy_and_rtprio() caused the exceptions raised by
tuna_sched.Policy to be consumed by the finally block.
When an invalid policy is passed via the '--priority' flag,
this consumption of the exception causes tuna to fail silently.
Remove the finally block in tuna.get_policy_and_rtprio().
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 126990339985..31707c9cb69c 100755
--- a/tuna/tuna.py
+++ b/tuna/tuna.py
@@ -520,8 +520,8 @@ def get_policy_and_rtprio(parm):
rtprio = int(parms[1])
elif cp.is_rt():
rtprio = 1
- finally:
- return(policy, rtprio)
+
+ return (policy, rtprio)
def thread_filtered(tid, cpus_filtered, show_kthreads, show_uthreads):
if cpus_filtered:
--
2.27.0

View File

@ -1,6 +1,6 @@
Name: tuna
Version: 0.18
Release: 1%{?dist}
Release: 2%{?dist}
License: GPLv2
Summary: Application tuning GUI & command line utility
URL: https://git.kernel.org/pub/scm/utils/tuna/tuna.git
@ -67,6 +67,10 @@ done
%{_datadir}/polkit-1/actions/org.tuna.policy
%changelog
* 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
- Update to latest upstream tuna-0.18
Resolves: rhbz#2068629