Skip to content

tuna: cpuset isolation error handling, state save/restore, and robust teardown

Chris White linux-rt-users 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5tuna: Check cpuset partition state on isolation and propagate errorstests/test_cpuset_errors.py tuna/cpuset.py+156 -100 replies
2/5tuna: Verify cpuset controller is enabled in parent cgrouptests/test_cpuset_errors.py tuna/cpuset.py+117 -50 replies
3/5tuna: Handle thread EBUSY/EPERM and aggregate unmovable IRQ warningstests/test_isolate_errors.py tuna/tuna.py+207 -20 replies
4/5tuna: Add --save-state to isolate and a restore commandMakefile docs/tuna.8 tests/README.md +4 more+1001 -100 replies
5/5tuna: Demote partition and retry rmdir on EBUSY in destroy_cpusettests/test_cpuset_errors.py tuna/cpuset.py+242 -50 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH 0/5] tuna: cpuset isolation error handling, state save/restore, and robust teardown

This series hardens tuna's cgroup v2 cpuset isolation and teardown paths and adds state save/restore capabilities to allow cleanly undoing CPU isolation.

Overview of changes:
- Patch 1: Check cpuset partition state on isolation and propagate errors. Ensures that when creating an isolated partition, tuna verifies the partition state became 'isolated' (and raises with kernel reason text if invalid), rather than silently ignoring errors or invalid partitions.
- Patch 2: Verify cpuset controller is enabled in parent cgroup before creating child cpusets, and remove the new directory if activation fails.
- Patch 3: Handle EBUSY and EPERM in thread isolation loops consistently with processes, and aggregate unmovable IRQ warnings on stderr into a single line. The single line is deliberate: callers can parse it to learn which IRQs stayed on the isolated CPUs. The pre-isolation IRQ masks are also read at the runtime CPU count rather than from procfs's online-CPU-width copy, so masks referencing offline CPUs are not truncated and mistaken for modifications.
- Patch 4: Add 'tuna isolate --save-state <file>' and 'tuna restore --state <file>'. Saves pre/post thread affinities, IRQ affinities, default SMP affinity, and boot_id atomically to JSON. On restore, tasks whose affinity drifted or whose PID was reused are skipped, while unaffected tasks and IRQs are restored. tests/test_isolate_state.py drives every branch of save, load, capture and restore with the /proc helpers mocked, and needs no root.
- Patch 5: In destroy_cpuset, demote partition to 'member' before rmdir so that isolated CPUs are immediately released back to root, and retry rmdir on EBUSY with a 1-second bounded backoff to allow terminating or migrating tasks to finish draining. The same helper backs Cpuset.destroy(), so the auto_destroy context manager drains the same way. The EBUSY case is reproducible, not theoretical: a caller tearing the partition down right after workload exit needed its own 20 x 50 ms retry around
'tuna cpuset destroy' to keep runs from failing, and that retry now lives in tuna where the drain happens.

All five patches were tested and verified by running tuna isolation scenarios with SameStack's runtime isolation lease, which drives 'tuna isolate ... --save-state', reads the partition state back, and calls 'tuna restore --state' on release. The B-tuna campaign ran this series on realtime-04, and a 40-round isolate/destroy/restore soak covered centos-dev. Every commit also carries unit tests that run without root, except the invalid-partition test, which requires root and cgroup v2.

Chris White (5):
tuna: Check cpuset partition state on isolation and propagate errors
tuna: Verify cpuset controller is enabled in parent cgroup
tuna: Handle thread EBUSY/EPERM and aggregate unmovable IRQ warnings
tuna: Add --save-state to isolate and a restore command
tuna: Demote partition and retry rmdir on EBUSY in destroy_cpuset

 Makefile                      |   7 +-
 docs/tuna.8                   |  13 +
 tests/README.md               |  15 +-
 tests/test_cpuset_errors.py   | 411 +++++++++++++++++++++++++
 tests/test_isolate_errors.py  | 174 +++++++++++
 tests/test_isolate_restore.py | 155 ++++++++++
 tests/test_isolate_state.py   | 550 ++++++++++++++++++++++++++++++++++
 tuna-cmd.py                   |  38 ++-
 tuna/cpuset.py                | 124 ++++++--
 tuna/isolate_state.py         | 233 ++++++++++++++
 tuna/tuna.py                  |  35 ++-
 11 files changed, 1723 insertions(+), 32 deletions(-)
 create mode 100644 tests/test_cpuset_errors.py
 create mode 100644 tests/test_isolate_errors.py
 create mode 100644 tests/test_isolate_restore.py
 create mode 100644 tests/test_isolate_state.py
 create mode 100644 tuna/isolate_state.py
Signature · 1 line
2.52.0