Skip to contentSkip to conversation

rteval: Add --housekeeping-isolated flag

PATCH New John Kacur 1 participant 1 message Jul 16 Kbuild

lore
Share & tools
lore

John Kacur

author
#0 lore raw

PATCH 1/1 rteval: Add --housekeeping-isolated flag

Add optional --housekeeping-isolated flag to allow users to make the housekeeping cpuset use partition=isolated instead of the default partition=member. This provides strict CPU partitioning where tasks in the housekeeping cpuset cannot be scheduled on other CPUs, which may reduce RT latency for measurement workloads.

Changes to rteval-cmd:
- Add --housekeeping-isolated command-line argument
- Fix --housekeeping help text (removed incorrect "isolated CPUs")
- Add validation requiring both --cpusets and --housekeeping flags

Changes to rteval/cpusetmanager.py:
- Accept housekeeping_isolated parameter in __init__()
- Pass parameter to write_cpu_exclusive() during cpuset creation
- Default behavior unchanged: housekeeping uses partition=member
- Measurement cpuset always uses partition=isolated

Testing:
- Add comprehensive test suite (tests/test_cpusetmanager.py)
- 2 non-root tests for basic functionality
- 13 root-required tests for cpuset operations, partition types, CLI validation, cleanup, and task migration
- Add test-all Makefile target for running all tests with root
- Add tests/README.md documenting the test suite
- Update tests/run_tests.sh to include new tests

Usage:
# Default: housekeeping uses partition=member rteval --cpusets --housekeeping 0-1 --duration 60

  # Strict partitioning: housekeeping uses partition=isolated
  rteval --cpusets --housekeeping 0-1 --housekeeping-isolated --duration 60

This matches the interface implemented in tuna for consistency.

Assisted-by Claude:claude-sonnet-4-5
---
 Makefile                    |  14 +-
 rteval-cmd                  |  15 +-
 rteval/cpusetmanager.py     |   9 +-
 tests/README.md             | 322 ++++++++++++++++++++++++++++
 tests/run_tests.sh          |   5 +
 tests/test_cpusetmanager.py | 412 ++++++++++++++++++++++++++++++++++++
 6 files changed, 771 insertions(+), 6 deletions(-)
 create mode 100644 tests/README.md
 create mode 100644 tests/test_cpusetmanager.py
Makefile +13 -1
index 8b540c6c68b4..57b37334136a 100644
@@ -62,6 +62,17 @@ unit-tests:
 
 tests: unit-tests
 
+test-all:
+	@echo "Running ALL tests (including root-required tests)..."
+	@echo ""
+	@if [ "$$(id -u)" != "0" ]; then \
+		echo "ERROR: test-all must be run as root"; \
+		echo "Usage: sudo make test-all"; \
+		exit 1; \
+	fi
+	@echo "Running unit tests (including root-required)..."
+	$(PYTHON) -m unittest discover -s tests -p "test_*.py" -v
+
 clean:
 	rm -f *~ rteval/*~ rteval/*.py[co] *.tar.bz2 *.tar.gz doc/*~
 	rm -rf rteval-[0-9]*-[0-9]*
@@ -124,6 +135,7 @@ help:
 	@echo "        runit:            do a short testrun locally [default]"
 	@echo "        tests:            run unit tests (alias for unit-tests)"
 	@echo "        unit-tests:       run unit tests"
+	@echo "        test-all:         run ALL tests including root-required tests (requires root)"
 	@echo "        e2e-tests:        run end-to-end tests"
 	@echo "        regression-tests: run regression tests for measurement modules (requires root)"
 	@echo "        cpuset-tests:     run cpuset integration tests (requires root)"
@@ -145,4 +157,4 @@ tags:
 cleantags:
 	rm -f tags
 
-.PHONY: tests unit-tests e2e-tests regression-tests cpuset-tests uninstall
+.PHONY: tests unit-tests test-all e2e-tests regression-tests cpuset-tests uninstall
rteval-cmd +13 -2
index 82531e915833..69fad2cc80e4 100755
@@ -122,7 +122,10 @@ def parse_options(cfg, parser, cmdargs):
                       help="use cgroup v2 cpusets to isolate measurement and housekeeping workloads")
     parser.add_argument("--housekeeping", dest="rteval___housekeeping",
                       type=str, default="", metavar="CPULIST",
-                      help="isolated CPUs reserved for system tasks (not used by rteval)")
+                      help="CPUs reserved for system tasks (not used by measurement or loads)")
+    parser.add_argument("--housekeeping-isolated", dest="rteval___housekeeping_isolated",
+                      action="store_true", default=False,
+                      help="make housekeeping cpuset use partition=isolated instead of member (requires --cpusets and --housekeeping)")
     parser.add_argument("--warn-non-isolated-core-sharing", dest="rteval___warn_non_isolated_core_sharing",
                       action="store_true", default=False,
                       help="warn about measurement and load CPUs sharing cores even when neither is isolated")
@@ -410,6 +413,13 @@ if __name__ == '__main__':
         ldcfg = config.GetSection('loads')
         msrcfg = config.GetSection('measurement')
 
+        # Validate --housekeeping-isolated usage
+        if rtevcfg.housekeeping_isolated:
+            if not rtevcfg.cpusets:
+                raise RuntimeError("--housekeeping-isolated requires --cpusets")
+            if not rtevcfg.housekeeping:
+                raise RuntimeError("--housekeeping-isolated requires --housekeeping")
+
         # Validate and process housekeeping CPUs
         housekeeping_cpus = []
         if rtevcfg.housekeeping:
@@ -560,7 +570,8 @@ if __name__ == '__main__':
             cpuset_manager = CpusetManager(
                 housekeeping_cpus=housekeeping_cpus,
                 measurement_cpus=msrcfg_cpus,
-                logger=logger
+                logger=logger,
+                housekeeping_isolated=rtevcfg.housekeeping_isolated
             )
 
         # Pass cpuset_manager to RtEval (None if not using cpusets)
rteval/cpusetmanager.py +6 -3
index abf5760db28c..a204312eda9a 100644
@@ -71,7 +71,7 @@ class CpusetManager:
             except Exception as e:
                 logger.log(Log.WARN, f"Failed to clean up {cpuset_name}: {e}")
 
-    def __init__(self, housekeeping_cpus, measurement_cpus, logger):
+    def __init__(self, housekeeping_cpus, measurement_cpus, logger, housekeeping_isolated=False):
         """
         Initialize cpuset manager
 
@@ -79,6 +79,7 @@ class CpusetManager:
             housekeeping_cpus: List of CPU integers for housekeeping (may be empty)
             measurement_cpus: List of CPU integers for measurement workloads
             logger: rteval Log instance for logging
+            housekeeping_isolated: If True, use partition=isolated for housekeeping (default: False = partition=member)
 
         Note: Load workloads use taskset for CPU affinity and don't need cpusets.
         """
@@ -91,6 +92,7 @@ class CpusetManager:
         self.housekeeping_cpus = housekeeping_cpus
         self.measurement_cpus = measurement_cpus
         self.logger = logger
+        self.housekeeping_isolated = housekeeping_isolated
 
         # Cpuset objects (will be created in __enter__)
         self.housekeeping_cpuset = None
@@ -114,11 +116,12 @@ class CpusetManager:
 
         # Create housekeeping cpuset if requested
         if self.housekeeping_cpus:
-            self.logger.log(Log.DEBUG, f"Creating rteval_housekeeping cpuset with CPUs {collapse_cpulist(self.housekeeping_cpus)}")
+            partition_type = "isolated" if self.housekeeping_isolated else "member"
+            self.logger.log(Log.DEBUG, f"Creating rteval_housekeeping cpuset with CPUs {collapse_cpulist(self.housekeeping_cpus)} (partition={partition_type})")
             self.housekeeping_cpuset = Cpuset('rteval_housekeeping')
             self.housekeeping_cpuset.write_memnode(self.numa_nodes)
             self.housekeeping_cpuset.assign_cpus(collapse_cpulist(self.housekeeping_cpus))
-            self.housekeeping_cpuset.write_cpu_exclusive(False)  # partition=member
+            self.housekeeping_cpuset.write_cpu_exclusive(self.housekeeping_isolated)  # partition=isolated if True, member if False
 
         # Create measurement cpuset
         self.logger.log(Log.DEBUG, f"Creating rteval_measurement cpuset with CPUs {collapse_cpulist(self.measurement_cpus)}")
tests/README.md new file +322 -0

322 lines not on this page · raw message

tests/run_tests.sh +5 -0
index 5ac4e7bf2ff3..d61616070cec 100755
@@ -62,6 +62,11 @@ if [ -d "tests" ]; then
         run_test "tests/test_core_sharing_validation.py"
     fi
 
+    # Run test_cpusetmanager.py (non-root tests only)
+    if [ -f "tests/test_cpusetmanager.py" ]; then
+        run_test "tests/test_cpusetmanager.py"
+    fi
+
     # Add more tests here as they are created
     # Example:
     # if [ -f "tests/test_another_feature.py" ]; then
tests/test_cpusetmanager.py new file +412 -0

412 lines not on this page · raw message

Signature · 1 line
2.55.0