tuna: Cleanup and improvements for v0.21
cover tuna: Cleanup and improvements for v0.21
Patch 1: Remove obsolete ChangeLog, not updated since Feb 2013
Patch 2: Change cpuset profile default paths to be context-aware:
./cpuset-profile.yaml when running directly from git (tuna-cmd.py) /etc/tuna/cpuset-profile.yaml when running from production (tuna)
Patch 3: Update the man page to document cpuset save/apply commands,
fix cpuset destroy (now accepts multiple names), and correct housekeeping default (partition=member not partition=isolated)
Patch 4: Add path resolution for cpuset apply - searches current directory
first, then /etc/tuna/ for relative paths
Patch 5: Get the tuna version from one place (tuna/version.py) instead of
updating setup.py, pyproject.toml, and tuna-cmd.py separately
John Kacur (5):
tuna: Remove obsolete ChangeLog file
tuna: Use context-aware default path for cpuset profiles
tuna: Update man page for cpuset save/apply and recent changes
tuna: Add intelligent path resolution for cpuset apply
tuna: Get the tuna version from a single source
ChangeLog | 152 ------------------------------------------------ docs/tuna.8 | 52 ++++++++++++++--- pyproject.toml | 5 +- setup.py | 5 +- tuna-cmd.py | 61 +++++++++++++++++-- tuna/version.py | 7 +++ 6 files changed, 115 insertions(+), 167 deletions(-) delete mode 100644 ChangeLog create mode 100644 tuna/version.py
Signature · 1 line
2.55.0
PATCH 1/5 tuna: Remove obsolete ChangeLog file
The ChangeLog file has not been updated since February 2013 (v0.10.4), making it obsolete and potentially misleading. With 58 commits since v0.20 alone, maintaining a separate ChangeLog is impractical.
Users can view the complete commit history with git log, which provides more accurate and detailed information about changes.
--- ChangeLog | 152 ------------------------------------------------------ 1 file changed, 152 deletions(-) delete mode 100644 ChangeLog
ChangeLog deleted +0 -152
@@ -1,152 +0,0 @@ -* Fri Feb 1 2013 Arnaldo Carvalho de Melo <[email protected]> - 0.10.4-1 - -63580be procview: Allow configuring a single thread - Fixes https://bugzilla.redhat.com/show_bug.cgi?id=601234 -5d4ee70 tuna: Tighten "No such process" schedutils exception handling -cca561d tuna: Catch OSError exceptions from python-schedutils - Fixes https://bugzilla.redhat.com/show_bug.cgi?id=871598 -07907b3 tuna: Add man page for command line - -* Fri Aug 24 2012 Arnaldo Carvalho de Melo <[email protected]> - 0.10.3-1 - -. Fix exception on ARM -. Remove raw cycles column when perf events are used -. Don't touch the migration threads -. Update testuna to work with 3.6.0-rc1 - -* Thu Jul 28 2011 Arnaldo Carvalho de Melo <[email protected]> - 0.10.2-1 - -[acme@felicio tuna]$ git log v0.10.1.. --format=oneline --abbrev-commit -ddd2754 oscilloscope: Switch from "Bistream Vera Sans" to "Liberation Sans" -c5c558c oscilloscope: Switch from Numeric to numpy -28d87b6 MANIFEST: Add tuna/oscilloscope.py -4de7144 cmdline: Fix IRQ affinity setting -40bc92d procview gui: Load perf globally - -* Wed Feb 23 2011 Arnaldo Carvalho de Melo <[email protected]> - 0.10.1-1 - -24f19ce procview gui: Don't assume the perf binding is always available - -* Wed Feb 23 2011 Arnaldo Carvalho de Melo <[email protected]> - 0.10-1 - -[acme@emilia tuna]$ git log v0.9.4.. --format=oneline --abbrev-commit -3b54abd perf: Create the threads pidstat member when we notice the first thread -04f26d1 gui: Fixup perf.evlist constructor call -00a2aa4 gui: Use perf if available -f130d84 cmdline: Alert the user when GUI packages are not installed - -* Mon May 10 2010 Arnaldo Carvalho de Melo <[email protected]> - 0.9.3-1 - -[acme@mica tuna]$ git log v0.9.2.. --format=oneline --abbrev-commit -7d4f258 cmdline: Emit error when affinity operation can't be performed -a9e68d1 cmdline: Use tuna.cpustring_to_list in --cpus -21de19e tuna: Make is_hardirq_handler handle non thread group leaders -ab01211 cmdline: Handle unknown schedulers in -p/--priority: -bbdaf5a cmdline: Improve message about thread list being needed by -p/--priority -427f94c cmdline: Fix --priority error message when no threads are informed -85bb5d7 cmdline: Fix help line entry for --priority -6d0288b tuna: Make cpustring_to_list understand 0x prefixed hexadecimal numbers -7210b53 gui: fix use of cpu ranges -f2bc415 irqview: Fix some race conditions -a3e85fe cmdline: On threaded irq kernels, map irqs to threads -7d33dd1 cmdline: Fix threaded interrupt name bug -3a71dae cmdline: --priority/-p requires a thread list -[acme@mica tuna]$ - -* Thu Nov 12 2009 Arnaldo Carvalho de Melo <[email protected]> -- cmdline: -Q --show_irqs shows IRQs, so that we can see its affinity - masks even on non-threaded IRQ kernels -- tuna: Ignore non-existing threads in threads_set_priority -- tuna: i18n, Chinese - -* Thu Sep 3 2009 Arnaldo Carvalho de Melo <[email protected]> - 0.9.1-1 -- cmdline: --socket needs an argument -- tuna: Present more graceful failure mode when machine can't start gui -- tuna: Handle 2.6.31 style threaded irq names - -* Wed May 13 2009 Arnaldo Carvalho de Melo <[email protected]> - 0.9-1 -- tuna: i18n, pt_BR & Japanese -- oscilloscope: Fix scaling bugs and add --sample_multiplier -- oscilloscope: properly refresh all widgets -- oscilloscope: Remove needless shebang and reword the package summary -- cmdline: add --show_sockets/-n - -* Mon Oct 27 2008 Arnaldo Carvalho de Melo <[email protected]> - 0.8.4-1 -- cmdline: Allow globbing --irqs/-q -- cmdline: Allow globbing --threads/-t -- cmdline: Support regex on --thread -- cmdline: Check if thread names resolved to TIDs -- irqview: We have to pass an int to schedutils.setscheduler -- irqview: Initialize the rt_prio entry box -- gui: move procview to a separate file -- gui: Move irqview to a separate file -- gui: remove the Set/set trick in tuna/tuna_gui.py, not used anymore -- gui: Use schedutils.SCHED_{OTHER,FIFO,RR} -- gui: move cpuview classes to a separate file -- gui: Stop handling exceptions at procview.set_thread_columns -- oscilloscope: Ignore invalid samples, emitting just a warning - -* Mon Oct 27 2008 Arnaldo Carvalho de Melo <[email protected]> - 0.8-1 -- [Non]VolCtxtSwitch columns should be represented in the GUI as unsigned -- Several spelling fixes -- Handle some more schedutils exceptions -- Fix getopt long option for --priority, it requires an arg -- Set the irq affinity mask when setting a IRQ thread affinity -- Add a --spread command line option, it will spread the threads - passed thru --threads into the cpus specified in --cpu or --socket. - -* Mon Sep 15 2008 Arnaldo Carvalho de Melo <[email protected]> - 0.7-1 -- CPU topology support: operations now can be performed on CPU sockets in - addition to individual CPUs -- --show_threads: command line now can see the same information available - in the GUI - -* Tue Aug 12 2008 Arnaldo Carvalho de Melo <[email protected]> - 0.6-1 -- tuna: posix_cpu_timer is percpu but its too long to have '/' in the cmdline -- tuna: Fixup the message about what filename was really used (rtgroups) -- tuna: Save the affinity mask for non-percpu kthreads -- tuna: Ignore rtprio when changing sched policy to SCHED_OTHER - -* Thu Aug 7 2008 Arnaldo Carvalho de Melo <[email protected]> - 0.5-1 -- tuna_gui: Provide instructions on how to use the generated rtctl file -- tuna_gui: Add "Save kthreads tunings" menu entry in the process list box -- tuna: Implement saving current kthread sched policy and rtprio as an rtctl file -- help: Add more kernel thread help texts, written by the MRG crew - -* Tue Jun 17 2008 Arnaldo Carvalho de Melo <[email protected]> - 0.4-1 -- oscilloscope subpackage -- oscilloscope: Allow passing the number of samples to appear on screen -- oscilloscope: use io_add_watch instead of timeout_add -- oscilloscope: check if the latency tracer is available -- oscilloscope: Allow disabling auto-scaling -- oscilloscope: group the system info and help frames in a vbox -- oscilloscope: parse X geometry parameter -- tuna: Convert widget coords to bin_window coords -- tuna: Implement --affect_children and --priority - -* Fri May 16 2008 Arnaldo Carvalho de Melo <[email protected]> - 0.3-1 -- Add oscilloscope command, initially useful with signaltest and cyclictest, - but will also be used with the latencytest utility in the qpid project and - with any other source of signals. Requires python-matplotlib, that will - be added to the MRG repo soon. -- Allow toggling auto-refresh from the irq and threads views -- Changes to make tuna work on older RHEL versions, helpful when evaluating - RHEL-RT components. -- Allow using tuna without GUI libraries installed, please see: - tuna --help - For available commands. -- Several fixes - -* Thu Mar 27 2008 Arnaldo Carvalho de Melo <[email protected]> - 0.2-1 -- Command line interface -- Remove the requirement of a GUI packages -- Allow moving one child thread to a CPU -- Status icon -- "What is this?", for now just for some kernel threads -- Add "Restore CPU" to undo "Isolate CPU" -- Faster CPU isolation process -- Allow moving IRQs & Threads to all cpus -- CPU filtering - -* Mon Feb 26 2008 Arnaldo Carvalho de Melo <[email protected]> - 0.1-1 -- package created
Signature · 1 line
2.55.0
PATCH 2/5 tuna: Use context-aware default path for cpuset profiles
In reply to John KacurDetect execution context to set appropriate default path for cpuset profile files:
- Development (tuna-cmd.py or tuna-cmd): ./cpuset-profile.yaml
- Production (tuna): /etc/tuna/cpuset-profile.yaml
This allows developers to work with profile files in their git directory while production installations use the standard /etc/tuna/ location.
Users can always override by providing an explicit path argument.
--- tuna-cmd.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)
tuna-cmd.py +19 -4
@@ -104,6 +104,20 @@ class HelpMessageParser(argparse.ArgumentParser): self.print_help() sys.exit(2) +def get_default_cpuset_profile(): + """Get default cpuset profile filename based on execution context. + + Returns: + str: Default profile path + - './cpuset-profile.yaml' when running from dev (tuna-cmd.py or tuna-cmd) + - '/etc/tuna/cpuset-profile.yaml' when running from production (tuna) + """ + script_name = os.path.basename(sys.argv[0]) + if script_name in ('tuna-cmd.py', 'tuna-cmd'): + return 'cpuset-profile.yaml' + else: + return '/etc/tuna/cpuset-profile.yaml' + def gen_parser():
@@ -324,13 +338,14 @@ def gen_parser(): # cpuset save cpuset_save = cpuset_subparser.add_parser('save', description='Save cpuset configuration to YAML profile', help='Save cpuset configuration') - cpuset_save.add_argument('filename', nargs='?', default='cpuset-profile.yaml', - help='Output YAML file (default: cpuset-profile.yaml)') + default_profile = get_default_cpuset_profile() + cpuset_save.add_argument('filename', nargs='?', default=default_profile, + help=f'Output YAML file (default: {default_profile})') # cpuset apply cpuset_apply = cpuset_subparser.add_parser('apply', description='Apply cpuset configuration from YAML profile', help='Apply cpuset configuration') - cpuset_apply.add_argument('filename', nargs='?', default='cpuset-profile.yaml', - help='Input YAML file (default: cpuset-profile.yaml)') + cpuset_apply.add_argument('filename', nargs='?', default=default_profile, + help=f'Input YAML file (default: {default_profile})') cpuset_apply.add_argument('-v', '--verbose', action='store_true', help='Print detailed progress messages')
Signature · 1 line
2.55.0
PATCH 3/5 tuna: Update man page for cpuset save/apply and recent changes
In reply to John KacurUpdate documentation to reflect recent cpuset enhancements:
- Add cpuset save and apply subcommands to the command list
- Document cpuset save with context-aware default paths
- Document cpuset apply with verbose option
- Update cpuset destroy to accept multiple names
- Fix housekeeping cpuset default: partition=member (was partition=isolated)
- Update isolate example to clarify partition types
- Add usage examples for save/apply commands
The context-aware paths are documented: ./cpuset-profile.yaml for development (tuna-cmd.py) and /etc/tuna/cpuset-profile.yaml for production (tuna).
--- docs/tuna.8 | 52 +++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 7 deletions(-)
docs/tuna.8 +45 -7
@@ -64,7 +64,7 @@ optional arguments: partition=isolated) --cpuset-housekeeping [NAME] CPU-LIST Create housekeeping cpuset: [NAME] CPU-LIST (default name: - tuna_housekeeping, partition=isolated) + tuna_housekeeping, partition=member) .TP \fBtuna include\fR usage: tuna-cmd.py include [-h] (-c CPU-LIST | -S CPU-SOCKET-LIST | -N)
@@ -288,12 +288,12 @@ optional arguments: -K, --no_kthreads Operations will not affect kernel threads .TP \fB tuna cpuset\fR -usage: tuna-cmd.py cpuset [-h] {create,list,destroy,move,show,status,modify} +usage: tuna-cmd.py cpuset [-h] {create,list,destroy,move,show,status,modify,save,apply} Manage CPU sets (cgroup v2). Cpusets provide fine-grained control over which CPUs processes can run on, with NUMA-aware memory node assignment and kernel-enforced isolation. subcommands: - {create,list,destroy,move,show,status,modify} + {create,list,destroy,move,show,status,modify,save,apply} .B tuna cpuset create usage: tuna-cmd.py cpuset create [-h] -c CPU-LIST [-n NAME] [-i]
@@ -327,13 +327,14 @@ optional arguments: --no-recursive Only search top-level cpusets .B tuna cpuset destroy -usage: tuna-cmd.py cpuset destroy [-h] [NAME] [-p PATTERN] [-f] +usage: tuna-cmd.py cpuset destroy [-h] [-p PATTERN] [-f] [--include-empty] [--no-recursive] + [NAME ...] -Destroy cpuset(s). Use either NAME or --pattern, not both. +Destroy cpuset(s) positional arguments: - NAME Cpuset name to destroy (use this OR --pattern) + NAME Cpuset name(s) to destroy (one or more, OR use --pattern) optional arguments: -h, --help show this help message and exit
@@ -404,6 +405,33 @@ optional arguments: --isolated Set CPU partition to isolated --no-isolated Set CPU partition to member (not isolated) +.B tuna cpuset save +usage: tuna-cmd.py cpuset save [-h] [filename] + +Save cpuset configuration to YAML profile + +positional arguments: + filename Output YAML file. Default path depends on execution context: + ./cpuset-profile.yaml when running from development (tuna-cmd.py) + /etc/tuna/cpuset-profile.yaml when running from production (tuna) + +optional arguments: + -h, --help show this help message and exit + +.B tuna cpuset apply +usage: tuna-cmd.py cpuset apply [-h] [-v] [filename] + +Apply cpuset configuration from YAML profile + +positional arguments: + filename Input YAML file. Default path depends on execution context: + ./cpuset-profile.yaml when running from development (tuna-cmd.py) + /etc/tuna/cpuset-profile.yaml when running from production (tuna) + +optional arguments: + -h, --help show this help message and exit + -v, --verbose Print detailed progress messages + .IP \fIModifiers\fR .TP \fB\-c\fR, \fB\-\-cpus\fR=\fICPU\-LIST\fR
@@ -444,7 +472,7 @@ Isolate CPUs using cpusets (more powerful than traditional affinity): .TP .B tuna isolate -c 4-7 --cpuset my_isolated --cpuset-housekeeping my_hk 0-3 -Isolate CPUs 4-7 by creating 'my_isolated' cpuset with kernel-enforced exclusivity, and move all existing processes to 'my_hk' cpuset on CPUs 0-3. Both cpusets use partition=isolated for kernel enforcement. +Isolate CPUs 4-7 by creating 'my_isolated' cpuset with kernel-enforced exclusivity (partition=isolated), and move all existing processes to 'my_hk' cpuset on CPUs 0-3 (partition=member). .TP .B tuna move --cpuset rt_workload -t 'kworker/*'
@@ -465,3 +493,13 @@ Add CPUs 6-7 to the rt_workload cpuset without disrupting running processes. .B tuna cpuset status Display system-wide overview of all cpusets with statistics. + +.TP +.B tuna cpuset save /etc/tuna/my-rt-config.yaml + +Save current cpuset configuration to a YAML profile. When running the installed version (tuna), the default path is /etc/tuna/cpuset-profile.yaml. When running from development (tuna-cmd.py), it defaults to ./cpuset-profile.yaml in the current directory. + +.TP +.B tuna cpuset apply /etc/tuna/my-rt-config.yaml + +Apply a previously saved cpuset configuration from a YAML profile. This recreates all cpusets defined in the profile with their CPU assignments, memory nodes, and partition settings.
Signature · 1 line
2.55.0
PATCH 4/5 tuna: Add intelligent path resolution for cpuset apply
In reply to John KacurWhen applying a cpuset profile, search for the file in standard locations if the user provides just a filename (not a full path).
Search order for relative paths:
1. Current directory (./filename)
2. /etc/tuna/filename
Absolute paths are used as-is without searching.
This allows users to run 'tuna cpuset apply my-config.yaml' from any directory and have it automatically find the file in /etc/tuna/ if it's not in the current directory.
--- tuna-cmd.py | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-)
tuna-cmd.py +34 -1
@@ -118,6 +118,36 @@ def get_default_cpuset_profile(): else: return '/etc/tuna/cpuset-profile.yaml' +def resolve_cpuset_profile_path(filename): + """Resolve cpuset profile path by searching in standard locations. + + Args: + filename: User-provided filename or path + + Returns: + str: Resolved absolute path if file exists, otherwise original filename + + Search order for relative paths: + 1. Current directory (./filename) + 2. /etc/tuna/filename + Absolute paths are returned as-is. + """ + # If absolute path, use it directly + if os.path.isabs(filename): + return filename + + # Try current directory first + if os.path.exists(filename): + return filename + + # Try /etc/tuna/ as fallback + etc_path = os.path.join('/etc/tuna', filename) + if os.path.exists(etc_path): + return etc_path + + # Return original filename (will produce meaningful error if not found) + return filename + def gen_parser():
@@ -404,8 +434,11 @@ def apply_cpusets_cmd(filename, verbose=False): print("Error: cgroup v2 cpusets not supported on this system", file=sys.stderr) sys.exit(1) + # Resolve filename (search current dir, then /etc/tuna/) + resolved_path = resolve_cpuset_profile_path(filename) + # Apply cpusets using profile module (passes cpuset module for code reuse) - num_applied, num_warnings, num_errors = profile.apply_cpusets(filename, cpuset, verbose) + num_applied, num_warnings, num_errors = profile.apply_cpusets(resolved_path, cpuset, verbose) # Print summary if num_applied > 0:
Signature · 1 line
2.55.0
PATCH 5/5 tuna: Get the tuna version from a single source
In reply to John KacurCreate tuna/version.py with a TUNA_VERSION variable as the single source for the version number.
Changes:
- Add tuna/version.py with a TUNA_VERSION variable
- Update setup.py to import version from tuna.version
- Update tuna-cmd.py to import version from tuna.version
- Update pyproject.toml to use dynamic versioning via setuptools
For future releases, only tuna/version.py needs to be updated. All other files (setup.py, tuna-cmd.py, pyproject.toml) automatically pick up the version from this single source.
Version updated from 0.20 to 0.21.
--- pyproject.toml | 5 ++++- setup.py | 5 ++++- tuna-cmd.py | 3 ++- tuna/version.py | 7 +++++++ 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 tuna/version.py
pyproject.toml +4 -1
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "tuna" -version = "0.20" +dynamic = ["version"] description = "Application tuning GUI" license = "GPL-2.0-only" authors = [
@@ -37,5 +37,8 @@ Source = "https://git.kernel.org/pub/scm/utils/tuna/tuna.git/" tuna = "tuna.tuna:main" oscilloscope = "tuna.oscilloscope:main" +[tool.setuptools.dynamic] +version = {attr = "tuna.version.TUNA_VERSION"} + [tool.setuptools.packages.find] include = ["tuna*"]
setup.py +4 -1
@@ -5,6 +5,9 @@ import sysconfig from os.path import isfile, relpath from setuptools import setup +# Get the tuna version from a single source +from tuna.version import TUNA_VERSION + if isfile("MANIFEST"): os.unlink("MANIFEST")
@@ -16,7 +19,7 @@ if SCHEME not in sysconfig.get_scheme_names(): PYTHONLIB = relpath(sysconfig.get_path('platlib', SCHEME), '/usr') setup(name="tuna", - version = "0.20", + version = TUNA_VERSION, description = "Application tuning GUI", author = "Arnaldo Carvalho de Melo, John Kacur", author_email = "[email protected], [email protected]",
tuna-cmd.py +2 -1
@@ -23,6 +23,7 @@ import tuna.tuna_sched as tuna_sched import procfs from tuna import tuna, sysfs, utils from tuna import cpuset +from tuna.version import TUNA_VERSION import logging import time import shutil
@@ -162,7 +163,7 @@ def gen_parser(): MODS = { "logging": dict(dest='loglevel', metavar='LOG-LEVEL', type=get_loglevel, help="Log application details to file for given LOG-LEVEL"), "debug" : dict(action='store_true', dest='debug', help='Print DEBUG level logging details to console'), - "version": dict(action='version', version='0.20', help="show version"), + "version": dict(action='version', version=TUNA_VERSION, help="show version"), "warn": dict(action='store_true', dest='warn', help='Warn when thread/IRQ patterns match nothing'), "threads": dict(dest='thread_list', default='', metavar='THREAD-LIST', type=str, help="THREAD-LIST affected by commands"), "irqs": dict(dest='irq_list', default='', metavar='IRQ-LIST', type=str, help="IRQ-LIST affect by commands"),
tuna/version.py new file +7 -0
@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Copyright 2008 - 2009 Arnaldo Carvalho de Melo <[email protected]> +# Copyright 2015 - 2026 John Kacur <[email protected]> +# + +TUNA_VERSION = '0.21'
Signature · 1 line
2.55.0