From 59a99653d561e0af6764cfa7fc75fa77fdc4c12c Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Apr 10 2018 05:44:21 +0000 Subject: import tuna-0.13-6.el7 --- diff --git a/SOURCES/tuna-Use-errno-codes-instead-of-numbers.patch b/SOURCES/tuna-Use-errno-codes-instead-of-numbers.patch new file mode 100644 index 0000000..081445d --- /dev/null +++ b/SOURCES/tuna-Use-errno-codes-instead-of-numbers.patch @@ -0,0 +1,279 @@ +From 876beba81c6b213e0fe4755409142cddb78e344d Mon Sep 17 00:00:00 2001 +From: John Kacur +Date: Tue, 12 Sep 2017 23:35:39 +0100 +Subject: [PATCH 1/2] tuna: Use errno codes instead of numbers + +Use errno codes instead of numbers since they +are self documenting. + +Simplify the comments as a result + +Signed-off-by: John Kacur +--- + tuna-cmd.py | 12 +++++----- + tuna/tuna.py | 78 ++++++++++++++++++++++++++++++------------------------------ + 2 files changed, 45 insertions(+), 45 deletions(-) + +diff --git a/tuna-cmd.py b/tuna-cmd.py +index 39666c7c77f1..f0c5c0662ebd 100755 +--- a/tuna-cmd.py ++++ b/tuna-cmd.py +@@ -14,7 +14,7 @@ + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + # General Public License for more details. + +-import getopt, ethtool, fnmatch, os, procfs, re, schedutils, sys ++import getopt, ethtool, fnmatch, errno, os, procfs, re, schedutils, sys + from tuna import tuna, sysfs + + import gettext +@@ -180,8 +180,8 @@ def ps_show_thread(pid, affect_children, ps, + global irqs + try: + affinity = format_affinity(schedutils.get_affinity(pid)) +- except (SystemError, OSError) as e: # (3, 'No such process') old python-schedutils incorrectly raised SystemError +- if e[0] == 3: ++ except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError ++ if e[0] == errno.ESRCH: + return + raise e + +@@ -262,8 +262,8 @@ def ps_show(ps, affect_children, thread_list, cpu_list, + continue + try: + affinity = schedutils.get_affinity(pid) +- except (SystemError, OSError) as e: # (3, 'No such process') old python-schedutils incorrectly raised SystemError +- if e[0] == 3: ++ except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError ++ if e[0] == errno.ESRCH: + continue + raise e + if cpu_list and not set(cpu_list).intersection(set(affinity)): +@@ -558,7 +558,7 @@ def main(): + else: + try: + tuna.threads_set_priority(thread_list, a, affect_children) +- except (SystemError, OSError) as err: # (3, 'No such process') old python-schedutils incorrectly raised SystemError ++ except (SystemError, OSError) as err: # old python-schedutils incorrectly raised SystemError + print "tuna: %s" % err + sys.exit(2) + elif o in ("-P", "--show_threads"): +diff --git a/tuna/tuna.py b/tuna/tuna.py +index 9aab16a409d2..562c7fcf92d9 100755 +--- a/tuna/tuna.py ++++ b/tuna/tuna.py +@@ -1,7 +1,7 @@ + # -*- python -*- + # -*- coding: utf-8 -*- + +-import copy, ethtool, os, procfs, re, schedutils, sys, shlex ++import copy, ethtool, errno, os, procfs, re, schedutils, sys, shlex + import help, fnmatch + from procfs import utilist + +@@ -209,8 +209,8 @@ def move_threads_to_cpu(cpus, pid_list, set_affinity_warning = None, + try: + try: + curr_affinity = schedutils.get_affinity(pid) +- except (SystemError, OSError) as e: # (3, 'No such process') old python-schedutils incorrectly raised SystemError +- if e[0] == 3: # 'No such process' ++ except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError ++ if e[0] == errno.ESRCH: + continue + curr_affinity = None + raise e +@@ -218,8 +218,8 @@ def move_threads_to_cpu(cpus, pid_list, set_affinity_warning = None, + try: + schedutils.set_affinity(pid, new_affinity) + curr_affinity = schedutils.get_affinity(pid) +- except (SystemError, OSError) as e: # (3, 'No such process') old python-schedutils incorrectly raised SystemError +- if e[0] == 3: # 'No such process' ++ except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError ++ if e[0] == errno.ESRCH: + continue + curr_affinity == None + raise e +@@ -247,16 +247,16 @@ def move_threads_to_cpu(cpus, pid_list, set_affinity_warning = None, + for tid in threads.keys(): + try: + curr_affinity = schedutils.get_affinity(tid) +- except (SystemError, OSError) as e: # (3, 'No such process') old python-schedutils incorrectly raised SystemError +- if e[0] == 3: ++ except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError ++ if e[0] == errno.ESRCH: + continue + raise e + if set(curr_affinity) != set(new_affinity): + try: + schedutils.set_affinity(tid, new_affinity) + curr_affinity = schedutils.get_affinity(tid) +- except (SystemError, OSError) as e: # (3, 'No such process') old python-schedutils incorrectly raised SystemError +- if e[0] == 3: ++ except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError ++ if e[0] == errno.ESRCH: + continue + raise e + if set(curr_affinity) == set(new_affinity): +@@ -267,12 +267,12 @@ def move_threads_to_cpu(cpus, pid_list, set_affinity_warning = None, + print "move_threads_to_cpu: %s " % \ + (_("could not change %(pid)d affinity to %(new_affinity)s") % \ + {'pid':pid, 'new_affinity':new_affinity}) +- except (SystemError, OSError) as e: # (3, 'No such process') old python-schedutils incorrectly raised SystemError +- if e[0] == 3: ++ except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError ++ if e[0] == errno.ESRCH: + # process died + continue +- elif e[0] == 22: # (22, EINVAL - unmovable thread) +- print "thread %(pid)d cannot be moved as requested" %{'pid':pid} ++ elif e[0] == errno.EINVAL: # unmovable thread) ++ print >> stderr, "thread %(pid)d cannot be moved as requested" %{'pid':pid} + continue + raise e + return changed +@@ -317,8 +317,8 @@ def move_irqs_to_cpu(cpus, irq_list, spread = False): + pid = int(pid[0]) + try: + schedutils.set_affinity(pid, new_affinity) +- except (SystemError, OSError) as e: # (3, 'No such process') old python-schedutils incorrectly raised SystemError +- if e[0] == 3: ++ except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError ++ if e[0] == errno.ESRCH: + unprocessed.append(i) + changed -= 1 + continue +@@ -351,8 +351,8 @@ def isolate_cpus(cpus, nr_cpus): + continue + try: + affinity = schedutils.get_affinity(pid) +- except (SystemError, OSError) as e: # (3, 'No such process') old python-schedutils incorrectly raised SystemError +- if e[0] == 3: ++ except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError ++ if e[0] == errno.ESRCH: + continue + raise e + if set(affinity).intersection(set(cpus)): +@@ -360,8 +360,8 @@ def isolate_cpus(cpus, nr_cpus): + affinity = affinity_remove_cpus(affinity, cpus, nr_cpus) + try: + schedutils.set_affinity(pid, affinity) +- except (SystemError, OSError) as e: # (3, 'No such process') old python-schedutils incorrectly raised SystemError +- if e[0] == 3: ++ except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError ++ if e[0] == errno.ESRCH: + continue + raise e + +@@ -373,8 +373,8 @@ def isolate_cpus(cpus, nr_cpus): + continue + try: + affinity = schedutils.get_affinity(tid) +- except (SystemError, OSError) as e: # (3, 'No such process') old python-schedutils incorrectly raised SystemError +- if e[0] == 3: ++ except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError ++ if e[0] == errno.ESRCH: + continue + raise e + if set(affinity).intersection(set(cpus)): +@@ -382,8 +382,8 @@ def isolate_cpus(cpus, nr_cpus): + affinity = affinity_remove_cpus(affinity, cpus, nr_cpus) + try: + schedutils.set_affinity(tid, affinity) +- except (SystemError, OSError) as e: # (3, 'No such process') old python-schedutils incorrectly raised SystemError +- if e[0] == 3: ++ except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError ++ if e[0] == errno.ESRCH: + continue + raise e + +@@ -419,8 +419,8 @@ def include_cpus(cpus, nr_cpus): + continue + try: + affinity = schedutils.get_affinity(pid) +- except (SystemError, OSError) as e: # (3, 'No such process') old python-schedutils incorrectly raised SystemError +- if e[0] == 3: ++ except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError ++ if e[0] == errno.ESRCH: + continue + raise e + if set(affinity).intersection(set(cpus)) != set(cpus): +@@ -428,8 +428,8 @@ def include_cpus(cpus, nr_cpus): + affinity = list(set(affinity + cpus)) + try: + schedutils.set_affinity(pid, affinity) +- except (SystemError, OSError) as e: # (3, 'No such process') old python-schedutils incorrectly raised SystemError +- if e[0] == 3: ++ except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError ++ if e[0] == errno.ESRCH: + continue + raise e + +@@ -441,8 +441,8 @@ def include_cpus(cpus, nr_cpus): + continue + try: + affinity = schedutils.get_affinity(tid) +- except (SystemError, OSError) as e: # (3, 'No such process') old python-schedutils incorrectly raised SystemError +- if e[0] == 3: ++ except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError ++ if e[0] == errno.ESRCH: + continue + raise e + if set(affinity).intersection(set(cpus)) != set(cpus): +@@ -450,8 +450,8 @@ def include_cpus(cpus, nr_cpus): + affinity = list(set(affinity + cpus)) + try: + schedutils.set_affinity(tid, affinity) +- except (SystemError, OSError) as e: # (3, 'No such process') old python-schedutils incorrectly raised SystemError +- if e[0] == 3: ++ except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError ++ if e[0] == errno.ESRCH: + continue + raise e + +@@ -518,8 +518,8 @@ def thread_filtered(tid, cpus_filtered, show_kthreads, show_uthreads): + if cpus_filtered: + try: + affinity = schedutils.get_affinity(tid) +- except (SystemError, OSError) as e: # (3, 'No such process') old python-schedutils incorrectly raised SystemError +- if e[0] == 3: ++ except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError ++ if e[0] == errno.ESRCH: + return False + raise e + +@@ -557,8 +557,8 @@ def threads_set_priority(tids, parm, affect_children = False): + for tid in tids: + try: + thread_set_priority(tid, policy, rtprio) +- except (SystemError, OSError) as e: # (3, 'No such process') old python-schedutils incorrectly raised SystemError +- if e[0] == 3: ++ except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError ++ if e[0] == errno.ESRCH: + continue + raise e + if affect_children: +@@ -566,8 +566,8 @@ def threads_set_priority(tids, parm, affect_children = False): + if child != tid: + try: + thread_set_priority(child, policy, rtprio) +- except (SystemError, OSError) as e: # (3, 'No such process') old python-schedutils incorrectly raised SystemError +- if e[0] == 3: ++ except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError ++ if e[0] == errno.ESRCH: + continue + raise e + +@@ -597,8 +597,8 @@ def get_kthread_sched_tunings(proc = None): + try: + policy = schedutils.get_scheduler(pid) + affinity = schedutils.get_affinity(pid) +- except (SystemError, OSError) as e: # (3, 'No such process') old python-schedutils incorrectly raised SystemError +- if e[0] == 3: ++ except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError ++ if e[0] == errno.ESRCH: + continue + raise e + percpu = iskthread(pid) and \ +-- +2.9.5 + diff --git a/SOURCES/tuna-isolate_cpus-exit-with-a-message.patch b/SOURCES/tuna-isolate_cpus-exit-with-a-message.patch new file mode 100644 index 0000000..2e31957 --- /dev/null +++ b/SOURCES/tuna-isolate_cpus-exit-with-a-message.patch @@ -0,0 +1,69 @@ +From 048250c4e0469f5ab3b6230092e1ce40b6b148c6 Mon Sep 17 00:00:00 2001 +From: John Kacur +Date: Wed, 13 Sep 2017 00:39:08 +0100 +Subject: [PATCH 2/2] tuna: isolate_cpus - exit with a message instead of a + traceback + +isolate_cpus can create a traceback if passed an illegal cpuset +If this happens, exit with a message instead of a traceback + +Signed-off-by: John Kacur +--- + tuna/tuna.py | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/tuna/tuna.py b/tuna/tuna.py +index 13b3743e8d06..1ed21353ab48 100755 +--- a/tuna/tuna.py ++++ b/tuna/tuna.py +@@ -343,6 +343,7 @@ def parse_irq_affinity_filename(filename, nr_cpus): + + + def isolate_cpus(cpus, nr_cpus): ++ fname = sys._getframe( ).f_code.co_name # Function name + ps = procfs.pidstats() + ps.reload_threads() + previous_pid_affinities = {} +@@ -354,6 +355,9 @@ def isolate_cpus(cpus, nr_cpus): + except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError + if e[0] == errno.ESRCH: + continue ++ elif e[0] == errno.EINVAL: ++ print >> sys.stderr, "Function:", fname, ",", e.strerror ++ sys.exit(2) + raise e + if set(affinity).intersection(set(cpus)): + previous_pid_affinities[pid] = copy.copy(affinity) +@@ -363,6 +367,9 @@ def isolate_cpus(cpus, nr_cpus): + except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError + if e[0] == errno.ESRCH: + continue ++ elif e[0] == errno.EINVAL: ++ print >> sys.stderr, "Function:", fname, ",", e.strerror ++ sys.exit(2) + raise e + + if not ps[pid].has_key("threads"): +@@ -376,6 +383,9 @@ def isolate_cpus(cpus, nr_cpus): + except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError + if e[0] == errno.ESRCH: + continue ++ elif e[0] == errno.EINVAL: ++ print >> sys.stderr, "Function:", fname, ",", e.strerror ++ sys.exit(2) + raise e + if set(affinity).intersection(set(cpus)): + previous_pid_affinities[tid] = copy.copy(affinity) +@@ -385,6 +395,9 @@ def isolate_cpus(cpus, nr_cpus): + except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError + if e[0] == errno.ESRCH: + continue ++ elif e[0] == errno.EINVAL: ++ print >> sys.stderr, "Function:", fname, ",", e.strerror ++ sys.exit(2) + raise e + + del ps +-- +2.9.5 + diff --git a/SPECS/tuna.spec b/SPECS/tuna.spec index 9c6081e..53a4c1b 100644 --- a/SPECS/tuna.spec +++ b/SPECS/tuna.spec @@ -3,7 +3,7 @@ Name: tuna Version: 0.13 -Release: 5%{?dist} +Release: 6%{?dist} License: GPLv2 Summary: Application tuning GUI & command line utility Group: Applications/System @@ -13,6 +13,8 @@ Patch1: tuna-cpuview.py-Omit-offline-cpus-in-socket_ids-list.patch Patch2: display-usage-instead-of-traceback-when-c-missing-args.patch Patch3: CLI-start-a-process-from-tuna.patch Patch4: docs-upgrade-tuna.8-man-page-with-option-r.patch +Patch5: tuna-Use-errno-codes-instead-of-numbers.patch +Patch6: tuna-isolate_cpus-exit-with-a-message.patch URL: https://git.kernel.org/pub/scm/utils/tuna/tuna.git BuildArch: noarch @@ -55,6 +57,8 @@ priority is changed, be it using tuna or plain chrt & taskset. %patch2 -p1 %patch3 -p1 %patch4 -p1 +%patch5 -p1 +%patch6 -p1 %build %{__python} setup.py build @@ -109,6 +113,11 @@ rm -rf %{buildroot} %doc docs/oscilloscope+tuna.pdf %changelog +* Wed Sep 13 2017 John Kacur - 0.13-6 +- Use errno codes instead of plain numbers +- Exit with a message instead of a traceback in isolate_cpus +Resolves: rhbz#1472840 + * Mon Jun 13 2016 John Kacur - 0.13-5 - Rebuild to document tuna thows an exception instead of an error message when sched_setaffinity returns EINVAL