Skip to content

tuna: Add comprehensive cgroup v2 cpuset support

John Kacur linux-rt-users 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest36 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/36tuna: Warn when user-specified patterns match zero threads or IRQstuna-cmd.py+9 -00 replies
2/36tuna: Suppress output when pattern matches zero resultstuna-cmd.py+23 -30 replies
3/36tuna: Make warnings opt-in with -w/--warn flagtuna-cmd.py+6 -40 replies
4/36tuna: Enhance what_is command with new kernel thread descriptions and usability improvementstuna-cmd.py tuna/help.py tuna/tuna.py+60 -160 replies
5/36tuna: Add comprehensive docstrings to converter functionstuna-cmd.py tuna/tuna.py+149 -00 replies
6/36tuna: Add centralized input validation for CPU numbers and RT prioritiestuna-cmd.py+26 -00 replies
7/36tuna: Add cpuset module for CPU isolation using cgroup v2tuna/cpuset.py tuna/tuna.py+667 -360 replies
8/36tuna: Add comprehensive test suite for cpuset moduletests/test_cpuset.py+616 -00 replies
9/36tuna: Add CLI commands for cpuset managementtuna-cmd.py+251 -00 replies
10/36tuna: Add comprehensive test suite for cpuset CLI commandstests/test_cpuset_cli.py+358 -00 replies
11/36tuna: Add comprehensive test targets and documentationMakefile tests/README.md+198 -280 replies
12/36tuna: Add cpuset move command for process migrationtuna-cmd.py tuna/cpuset.py+105 -70 replies
13/36tuna: Add comprehensive tests for cpuset move commandtests/README.md tests/test_cpuset.py tests/test_cpuset_cli.py+197 -170 replies
14/36tuna: Add NUMA-aware memory node assignment for cpusetstuna-cmd.py tuna/cpuset.py+120 -40 replies
15/36tuna: Add tests for NUMA-aware memory node assignmenttests/README.md tests/test_cpuset.py tests/test_cpuset_cli.py+143 -250 replies
16/36tuna: Add process blocklist to prevent shutdown issuestests/README.md tests/test_cpuset_cli.py tests/test_process_blocklist.py +2 more+260 -200 replies
17/36tuna: Add memory nodes and blocklist warnings to cpuset listtuna-cmd.py+42 -50 replies
18/36tuna: Add cpuset show and status commandstuna-cmd.py+269 -00 replies
19/36tuna: Add tests for cpuset show and status commandstests/README.md tests/test_cpuset_cli.py+203 -250 replies
20/36tuna: Dynamically find free CPU for test_cpu_exclusivetests/test_cpuset.py+55 -30 replies
21/36tuna: Change cpuset commands to skip empty by defaulttests/test_cpuset_cli.py tuna-cmd.py+29 -290 replies
22/36tuna: Add cpuset modify commandtuna-cmd.py tuna/cpuset.py+164 -00 replies
23/36tuna: Add tests for cpuset modify commandtests/README.md tests/test_cpuset.py tests/test_cpuset_cli.py+372 -200 replies
24/36tuna: Fix test_modify_cpus_empty_result for kernel constraintstests/test_cpuset.py+11 -40 replies
25/36tuna: Add --cpuset option to move commandtuna-cmd.py+64 -60 replies
26/36tuna: Add tests for tuna move --cpuset commandtests/README.md tests/test_cpuset_cli.py+145 -120 replies
27/36tuna: Add --cpuset option to isolate commandtuna-cmd.py+69 -00 replies
28/36tuna: Add tests for isolate --cpuset functionalityMakefile tests/README.md tests/test_cpuset_cli.py+207 -40 replies
29/36tuna: Document high-level workflow vs manual primitives for cpusetstuna/cpuset_README.md+597 -00 replies
30/36tuna: Add --cpuset filter option to show_threads commandtuna-cmd.py+21 -40 replies
31/36tuna: Add tests for show_threads --cpuset filterMakefile tests/README.md tests/test_show_threads_cpuset.py+304 -240 replies
32/36tuna: Enhance show_threads -G to display cpuset namestuna-cmd.py+41 -50 replies
33/36tuna: Add tests for cpuset name display in show_threads -GMakefile tests/README.md tests/test_show_threads_cgroups.py+267 -220 replies
34/36tuna: Add --cpuset option to run commandtuna-cmd.py tuna/tuna.py+39 -30 replies
35/36tuna: Add tests for run --cpuset functionalityMakefile tests/README.md tests/test_cpuset_cli.py+125 -150 replies
36/36tuna: Update man page for cpusets and current functionalitydocs/tuna.8+190 -110 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 00/36] tuna: Add comprehensive cgroup v2 cpuset support

This patch series adds comprehensive support for cgroup v2 cpusets to tuna, providing a modern, container-based approach to CPU and memory node isolation alongside the existing affinity-based mechanisms.

Background
==========

Traditional CPU isolation in tuna works by modifying process affinity masks system-wide. While effective, this approach has limitations for complex workloads that benefit from explicit container-based organization. Cgroup v2 cpusets provide kernel-enforced isolation with NUMA-aware memory node assignment, making them ideal for real-time and high-performance computing workloads.

This implementation maintains full backward compatibility with existing tuna functionality while adding new cpuset-based workflows for users who need stronger isolation guarantees.

Key Features
============

Core Infrastructure (patches 7-11):
- Complete cpuset module (tuna/cpuset.py) with context manager support
- NUMA-aware automatic memory node detection and assignment
- Process blocklist protection to prevent system instability
- Comprehensive test suite (146 tests: 45 non-root + 101 root-required)

Cpuset Management Commands (patches 12-23):
- create: Create cpusets with auto-naming (tuna0, tuna1, etc.)
- list: List cpusets with filtering and verbosity options
- destroy: Clean up cpusets individually or by pattern
- move: Migrate processes to cpusets with thread/PID support
- show: Display detailed cpuset information
- status: System-wide cpuset overview with statistics
- modify: Runtime modification of CPUs, memory nodes, and isolation

Integration with Existing Commands (patches 24-35):
- isolate --cpuset: Create isolated and housekeeping cpusets with automatic process migration
- move --cpuset: Move threads/IRQs to cpusets instead of setting affinity
- run --cpuset: Launch processes directly in cpusets
- show_threads --cpuset: Filter display by cpuset membership
- show_threads -G: Enhanced cgroup display showing cpuset names

General Improvements (patches 1-6):
- Pattern matching warnings with opt-in -w/--warn flag
- Enhanced what_is command with updated kernel thread descriptions
- Comprehensive docstrings for converter functions
- Centralized input validation for CPU numbers and RT priorities

Documentation and Testing
=========================

- Complete API documentation in tuna/cpuset_README.md
- Updated man page (docs/tuna.8) with full cpuset command reference
- 146 comprehensive tests with clear root/non-root separation
- Test documentation in tests/README.md
- Usage examples for common cpuset workflows

Design Decisions
================

- Skip empty cpusets by default in list/status commands to reduce noise
- Auto-detect NUMA nodes from CPU assignments for optimal performance
- Process blocklist prevents moving critical system processes (systemd, etc.)
- Cpuset and affinity modes are mutually exclusive per command
- Context managers ensure cleanup even when operations fail

All changes follow existing tuna coding style and commit message conventions. The implementation has been tested on both single-node and multi-NUMA systems.

John Kacur (36):
tuna: Warn when user-specified patterns match zero threads or IRQs
tuna: Suppress output when pattern matches zero results
tuna: Make warnings opt-in with -w/--warn flag
tuna: Enhance what_is command with new kernel thread descriptions and
usability improvements
tuna: Add comprehensive docstrings to converter functions
tuna: Add centralized input validation for CPU numbers and RT
priorities
tuna: Add cpuset module for CPU isolation using cgroup v2
tuna: Add comprehensive test suite for cpuset module
tuna: Add CLI commands for cpuset management
tuna: Add comprehensive test suite for cpuset CLI commands
tuna: Add comprehensive test targets and documentation
tuna: Add cpuset move command for process migration
tuna: Add comprehensive tests for cpuset move command
tuna: Add NUMA-aware memory node assignment for cpusets
tuna: Add tests for NUMA-aware memory node assignment
tuna: Add process blocklist to prevent shutdown issues
tuna: Add memory nodes and blocklist warnings to cpuset list
tuna: Add cpuset show and status commands
tuna: Add tests for cpuset show and status commands
tuna: Dynamically find free CPU for test_cpu_exclusive
tuna: Change cpuset commands to skip empty by default
tuna: Add cpuset modify command
tuna: Add tests for cpuset modify command
tuna: Fix test_modify_cpus_empty_result for kernel constraints
tuna: Add --cpuset option to move command
tuna: Add tests for tuna move --cpuset command
tuna: Add --cpuset option to isolate command
tuna: Add tests for isolate --cpuset functionality
tuna: Document high-level workflow vs manual primitives for cpusets
tuna: Add --cpuset filter option to show_threads command
tuna: Add tests for show_threads --cpuset filter
tuna: Enhance show_threads -G to display cpuset names
tuna: Add tests for cpuset name display in show_threads -G
tuna: Add --cpuset option to run command
tuna: Add tests for run --cpuset functionality
tuna: Update man page for cpusets and current functionality

 Makefile                           |   26 +-
 docs/tuna.8                        |  201 ++++-
 tests/README.md                    |  360 +++++++-
 tests/test_cpuset.py               |  944 +++++++++++++++++++
 tests/test_cpuset_cli.py           | 1344 ++++++++++++++++++++++++++++
 tests/test_process_blocklist.py    |  139 +++
 tests/test_show_threads_cgroups.py |  199 ++++
 tests/test_show_threads_cpuset.py  |  245 +++++
 tuna-cmd.py                        | 1192 +++++++++++++++++++++++-
 tuna/cpuset.py                     |  820 +++++++++++++++++
 tuna/cpuset_README.md              |  597 ++++++++++++
 tuna/help.py                       |   26 +-
 tuna/tuna.py                       |  187 +++-
 13 files changed, 6165 insertions(+), 115 deletions(-)
 create mode 100644 tests/test_cpuset.py
 create mode 100644 tests/test_cpuset_cli.py
 create mode 100644 tests/test_process_blocklist.py
 create mode 100644 tests/test_show_threads_cgroups.py
 create mode 100755 tests/test_show_threads_cpuset.py
 create mode 100644 tuna/cpuset.py
 create mode 100644 tuna/cpuset_README.md
Signature · 1 line
2.54.0