* [PATCH 0/6] rteval: multi-stressor support plus stressng and test fixes
@ 2026-11-24 1:07 John Kacur
2026-11-24 1:07 ` [PATCH 1/6] rteval: Add multi stressor support John Kacur
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: John Kacur @ 2026-11-24 1:07 UTC (permalink / raw)
To: linux-rt-users; +Cc: Sana Sharma, Clark Williams, Chris White
Applied to the rteval tree: Sana's multi-stressor support (v6), class-level
tests for the stressng opt-out and arg building, a docstring fix, and three test
robustness fixes -- making the core-sharing tests reproducible on hosts without
SMT, and making the cpuset tests select usable CPUs from cpuset.cpus.effective
instead of hardcoding CPUs that another isolated partition (e.g. intel_lpmd's)
may hold. Posting the series for the archive.
John Kacur (5):
rteval: Test stressng opt-out and arg building
rteval: Fix validate_stressors() docstring Raises claim
rteval: Make core-sharing tests independent of host SMT topology
rteval: Skip cpuset partition tests when CPUs are not cgroup-usable
rteval: Pick cpuset integration-test CPUs from cpuset.cpus.effective
Sana Sharma (1):
rteval: Add multi stressor support
rteval/modules/__init__.py | 4 +-
rteval/modules/loads/stressng.py | 81 ++++++++++++----
tests/cpusets/test-cpusets.sh | 65 +++++++++----
tests/test_core_sharing_validation.py | 24 +++++
tests/test_cpusetmanager.py | 39 ++++++++
tests/test_stressng.py | 132 +++++++++++++++++++++++++-
6 files changed, 309 insertions(+), 36 deletions(-)
--
2.56.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/6] rteval: Add multi stressor support
2026-11-24 1:07 [PATCH 0/6] rteval: multi-stressor support plus stressng and test fixes John Kacur
@ 2026-11-24 1:07 ` John Kacur
2026-11-24 1:07 ` [PATCH 2/6] rteval: Test stressng opt-out and arg building John Kacur
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: John Kacur @ 2026-11-24 1:07 UTC (permalink / raw)
To: linux-rt-users; +Cc: Sana Sharma, Clark Williams, Chris White
From: Sana Sharma <sansshar@redhat.com>
Add the ability for rteval to take multiple stressors in one
command to improve interface. The syntax works as follows:
--stressng-stressor cpu --stressng-stressor vm --stressng-workers 2
will use 2 workers for each stressor (in this case cpu and vm)
--stressng-stressors cpu,vm --stressng-workers 2
will use 2 workers for each stressor as in the above example
The second option exists to allow the user to access multiple
stressors in an easier way.
Update the tests/test_stressng file to reflect these changes.
Signed-off-by: Sana Sharma <sansshar@redhat.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
---
rteval/modules/__init__.py | 4 +-
rteval/modules/loads/stressng.py | 79 +++++++++++++++++++++++++-------
tests/test_stressng.py | 4 +-
3 files changed, 67 insertions(+), 20 deletions(-)
diff --git a/rteval/modules/__init__.py b/rteval/modules/__init__.py
index 183efd8ef813..abd88b6ecfc5 100644
--- a/rteval/modules/__init__.py
+++ b/rteval/modules/__init__.py
@@ -6,7 +6,6 @@
import time
from datetime import datetime
import threading
-import argparse
import libxml2
from rteval.Log import Log
from rteval.rtevalConfig import rtevalCfgSection
@@ -356,6 +355,7 @@ reference from the first import"""
for (o, s) in list(opts.items()):
descr = 'descr' in s and s['descr'] or ""
metavar = 'metavar' in s and s['metavar'] or None
+ action = 'action' in s and s['action'] or 'store'
try:
default = cfg and getattr(cfg, o) or None
@@ -369,7 +369,7 @@ reference from the first import"""
grparser.add_argument(f'--{shortmod}-{o}',
dest=f"{shortmod}___{o}",
- action='store',
+ action=action,
help='%s%s' % (descr,
default and ' (default: %s)' % default or ''),
default=default,
diff --git a/rteval/modules/loads/stressng.py b/rteval/modules/loads/stressng.py
index 564e7988b328..479248875fae 100644
--- a/rteval/modules/loads/stressng.py
+++ b/rteval/modules/loads/stressng.py
@@ -12,6 +12,33 @@ from rteval.systopology import SysTopology
from rteval.cpulist_utils import CpuList
from rteval.cpuset import cpuset_preexec
+
+def validate_stressors(stressor_list):
+ """Validate multiple stressor names.
+
+ Args:
+ stressor_list: stressor names to validate, either as a list
+ (from repeated --stressng-stressor) or a
+ comma-separated string (from --stressng-stressors)
+
+ Raises:
+ ValueError: If any stressor is invalid
+ """
+ valid = get_valid_stressors()
+ if isinstance(stressor_list, str):
+ stressor_list = stressor_list.split(",")
+ stressors = [word.strip() for word in stressor_list]
+ invalid = []
+ for stressor in stressors:
+ if stressor not in valid:
+ invalid.append(stressor)
+
+ if invalid:
+ print(f"Invalid stress-ng stressor: '{' '.join(invalid)}'. "
+ f"Run 'stress-ng --stressors' to see valid options.")
+ sys.exit(1)
+ return stressors
+
def get_valid_stressors():
"""Query stress-ng for list of valid stressor names."""
try:
@@ -25,14 +52,6 @@ def get_valid_stressors():
print(f"Failed to query stress-ng stressors: {e}")
sys.exit(1)
-def validate_stressor(stressor_name):
- """Validate a single stressor name against stress-ng's available stressors."""
- valid = get_valid_stressors()
- if stressor_name not in valid:
- print(f"Invalid stress-ng stressor: '{stressor_name}'. "
- f"Run 'stress-ng --stressors' to see valid options.")
- sys.exit(1)
-
class Stressng(CommandLineLoad):
" This class creates a load module that runs stress-ng "
def __init__(self, config, logger):
@@ -46,11 +65,31 @@ class Stressng(CommandLineLoad):
self.__err = None
self.__nullfp = None
self.args = None
+ " Warn if both stressor and stressors are invoked "
+ if (self.cfg.stressors is not None and self.cfg.stressor is not None):
+ self._log(Log.WARN,"In cases where stressng-stressor and stressng-stressors are both invoked, rteval will choose only stressors")
" Only run this module if the user specifies an stressor "
- if self.cfg.stressor is not None:
- self._donotrun = False
+ if (self.cfg.stressors is not None):
+ requested = self.cfg.stressors
+ elif (self.cfg.stressor is not None):
+ requested = list(self.cfg.stressor)
else:
+ requested = None
+
+ if requested is None:
self._donotrun = True
+ else:
+ self.cfg.stressors = validate_stressors(requested)
+ self._donotrun = False
+
+ if self.cfg.workers is not None:
+ try:
+ if int(self.cfg.workers) < 0:
+ raise ValueError
+ except (ValueError, TypeError):
+ self._log(Log.WARN,"Stress-ng workers must be an int >= 0")
+ self._donotrun = True
+
# When this module runs, other load modules should not
self.set_exclusive()
@@ -74,10 +113,12 @@ class Stressng(CommandLineLoad):
# stress-ng is only run if the user specifies an stressor
self.args = ['stress-ng']
- validate_stressor(self.cfg.stressor)
- self.args.append(f'--{str(self.cfg.stressor)}')
- if self.cfg.workers is not None:
- self.args.append(self.cfg.workers) #default is 0
+ stressors = self.cfg.stressors
+ workers = self.cfg.workers
+ for stressor in stressors:
+ self.args.append(f'--{stressor}')
+ if workers is not None:
+ self.args.append(workers)
if self.cfg.timeout is not None:
self.args.append('--timeout')
self.args.append(self.cfg.timeout)
@@ -164,8 +205,14 @@ def ModuleParameters():
""" Commandline options for Stress-ng """
return {
"stressor": {
- "descr": "stressor name (eg. vm, cpu)",
- "metavar": "STRESSOR"
+ "descr": "stressor to run; repeat the flag to run several in parallel "
+ "(e.g., --stressng-stressor cpu --stressng-stressor vm)",
+ "action": "append",
+ "metavar": "NAME"
+ },
+ "stressors": {
+ "descr": "comma-separated stressors to run in parallel (e.g., cpu,vm,io)",
+ "metavar": "LIST"
},
"workers": {
"descr": "number of workers(default: 0 = one per CPU)",
diff --git a/tests/test_stressng.py b/tests/test_stressng.py
index 6211fb36a42f..9da3bcb984e0 100644
--- a/tests/test_stressng.py
+++ b/tests/test_stressng.py
@@ -41,14 +41,14 @@ class TestValidateStressor(unittest.TestCase):
return_value=['cpu', 'vm'])
def test_valid_passes(self, _):
"""Test that a valid stressor is accepted"""
- stressng.validate_stressor('cpu') # should not raise
+ stressng.validate_stressors('cpu, vm') # should not raise
@patch('rteval.modules.loads.stressng.get_valid_stressors',
return_value=['cpu', 'vm'])
def test_invalid_exits(self, _):
"""Test that an invalid stressor is rejected"""
with self.assertRaises(SystemExit) as cm:
- stressng.validate_stressor('bogus')
+ stressng.validate_stressors('bogus')
self.assertEqual(cm.exception.code, 1)
def main():
--
2.56.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/6] rteval: Test stressng opt-out and arg building
2026-11-24 1:07 [PATCH 0/6] rteval: multi-stressor support plus stressng and test fixes John Kacur
2026-11-24 1:07 ` [PATCH 1/6] rteval: Add multi stressor support John Kacur
@ 2026-11-24 1:07 ` John Kacur
2026-11-24 1:07 ` [PATCH 3/6] rteval: Fix validate_stressors() docstring Raises claim John Kacur
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: John Kacur @ 2026-11-24 1:07 UTC (permalink / raw)
To: linux-rt-users; +Cc: Sana Sharma, Clark Williams, Chris White
The existing stressng tests only exercise the module-level functions
get_valid_stressors() and validate_stressors(). Both the opt-out decision
in Stressng.__init__() and the stress-ng command-line construction in
_WorkloadPrepare() were untested, which is how recent regressions shipped
green.
Add tests that drive the Stressng class itself, built from a real
rtevalCfgSection (not a mock) so they follow the same path rteval-cmd
uses. A make_stressng() helper disables logging and points build/report
dirs at a temp dir so construction has no side effects, and the
arg-building tests patch SysTopology for a deterministic topology.
Coverage:
- _donotrun must stay True when no stressor was requested, even though
'workers' always carries its "0" default from argparse;
- --stressng-stressors and repeated --stressng-stressor both opt in;
- negative and non-integer worker counts opt out rather than being
passed to stress-ng;
- _WorkloadPrepare() must not place a None in self.args when no worker
count is set (it would crash the " ".join() in _WorkloadTask());
- each stressor gets its own flag with the worker count.
These encode the intended behaviour and guard against regressions. Three of
them pin the opt-out and arg-building defects that earlier revisions of the
multi-stressor series shipped; all pass on the current tree.
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: John Kacur <jkacur@redhat.com>
---
tests/test_stressng.py | 128 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 128 insertions(+)
diff --git a/tests/test_stressng.py b/tests/test_stressng.py
index 9da3bcb984e0..e9c0701569e5 100644
--- a/tests/test_stressng.py
+++ b/tests/test_stressng.py
@@ -3,12 +3,54 @@
# Copyright 2026 Sana Sharma <sansshar@redhat.com>
""" Unit tests for the new stressng input validation """
+import os
import sys
+import shutil
+import tempfile
import subprocess
import unittest
from unittest.mock import patch, MagicMock
sys.path.insert(0,'.')
from rteval.modules.loads import stressng
+from rteval.rtevalConfig import rtevalConfig
+from rteval.Log import Log
+
+
+_TEST_TMPDIRS = []
+
+
+def _cleanup_test_tmpdirs():
+ while _TEST_TMPDIRS:
+ shutil.rmtree(_TEST_TMPDIRS.pop(), ignore_errors=True)
+
+
+def make_stressng(**opts):
+ """Build a Stressng instance from a real rtevalCfgSection.
+
+ Mirrors how rteval-cmd wires up the module: a genuine config section
+ (not a mock), with logging disabled and build/report dirs pointed at a
+ temp dir so construction has no side effects on the tree. 'workers'
+ defaults to '0' here to match ModuleParameters()'s default, which
+ argparse applies on every real run. Pass workers=None explicitly to
+ model a run where the value was never set. Caller is responsible for
+ patching get_valid_stressors().
+ """
+ tmp = tempfile.mkdtemp(prefix="rteval-test-stressng-")
+ section = {
+ 'stressor': None,
+ 'stressors': None,
+ 'workers': '0',
+ 'timeout': None,
+ 'logging': False,
+ 'builddir': tmp,
+ 'reportdir': tmp,
+ 'cpulist': '0-1',
+ }
+ section.update(opts)
+ _TEST_TMPDIRS.append(tmp)
+ cfg = rtevalConfig(logger=Log())
+ cfg.AppendConfig('stressng', section)
+ return stressng.Stressng(cfg.GetSection('stressng'), Log())
class TestGetValidStressors(unittest.TestCase):
"""Test suite for the function get_valid_stressors"""
@@ -51,6 +93,92 @@ class TestValidateStressor(unittest.TestCase):
stressng.validate_stressors('bogus')
self.assertEqual(cm.exception.code, 1)
+class TestDonotrun(unittest.TestCase):
+ """Whether the module opts in/out of running via _donotrun.
+
+ stressng is listed in the default [loads] config and is exclusive, so a
+ wrong _donotrun does not just misfire stressng - it disables kcompile
+ and hackbench too. It must opt out whenever no stressor was requested,
+ regardless of the always-present 'workers' default.
+ """
+
+ @patch('rteval.modules.loads.stressng.get_valid_stressors',
+ return_value=['cpu', 'vm'])
+ def test_no_stressor_opts_out_despite_workers_default(self, _):
+ """No stressor + default workers='0' must leave _donotrun True"""
+ mod = make_stressng(stressor=None, stressors=None, workers='0')
+ self.assertTrue(mod._donotrun)
+
+ @patch('rteval.modules.loads.stressng.get_valid_stressors',
+ return_value=['cpu', 'vm'])
+ def test_stressors_string_opts_in_and_validates(self, _):
+ """--stressng-stressors cpu,vm runs and is validated to a list"""
+ mod = make_stressng(stressors='cpu,vm', workers='0')
+ self.assertFalse(mod._donotrun)
+ self.assertEqual(mod.cfg.stressors, ['cpu', 'vm'])
+
+ @patch('rteval.modules.loads.stressng.get_valid_stressors',
+ return_value=['cpu', 'vm'])
+ def test_stressor_append_opts_in(self, _):
+ """Repeated --stressng-stressor (action='append') runs"""
+ mod = make_stressng(stressor=['cpu', 'vm'], workers='0')
+ self.assertFalse(mod._donotrun)
+
+ @patch('rteval.modules.loads.stressng.get_valid_stressors',
+ return_value=['cpu', 'vm'])
+ def test_negative_workers_rejected(self, _):
+ """A negative worker count must opt out, not be passed to stress-ng"""
+ mod = make_stressng(stressor=['cpu'], workers='-1')
+ self.assertTrue(mod._donotrun)
+
+ @patch('rteval.modules.loads.stressng.get_valid_stressors',
+ return_value=['cpu', 'vm'])
+ def test_noninteger_workers_rejected(self, _):
+ """A non-integer worker count must opt out"""
+ mod = make_stressng(stressor=['cpu'], workers='abc')
+ self.assertTrue(mod._donotrun)
+
+ def tearDown(self):
+ _cleanup_test_tmpdirs()
+
+
+class TestArgBuilding(unittest.TestCase):
+ """_WorkloadPrepare() builds the stress-ng command line correctly."""
+
+ def _prepare(self, mod):
+ """Run _WorkloadPrepare() with a deterministic, fake topology."""
+ with patch('rteval.modules.loads.stressng.SysTopology') as systop:
+ systop.return_value.getnodes.return_value = ['0']
+ systop.return_value.getcpus.return_value = [0, 1]
+ mod._WorkloadPrepare()
+ return mod.args
+
+ @patch('rteval.modules.loads.stressng.get_valid_stressors',
+ return_value=['cpu', 'vm'])
+ def test_multi_stressor_with_workers(self, _):
+ """Each stressor gets its own flag with the worker count"""
+ mod = make_stressng(stressor=['cpu', 'vm'], workers='2')
+ args = self._prepare(mod)
+ self.assertIn('--cpu', args)
+ self.assertIn('--vm', args)
+ # worker count follows each stressor flag
+ self.assertEqual(args[args.index('--cpu') + 1], '2')
+ self.assertEqual(args[args.index('--vm') + 1], '2')
+
+ @patch('rteval.modules.loads.stressng.get_valid_stressors',
+ return_value=['cpu', 'vm'])
+ def test_no_workers_leaves_no_none_in_args(self, _):
+ """workers=None must not inject a None into argv (crashes join/Popen)"""
+ mod = make_stressng(stressor=['cpu'], workers=None)
+ args = self._prepare(mod)
+ self.assertNotIn(None, args)
+ # _WorkloadTask does " ".join(self.args); it must not raise
+ " ".join(args)
+
+ def tearDown(self):
+ _cleanup_test_tmpdirs()
+
+
def main():
"""Run the test suite"""
unittest.main(verbosity=2)
--
2.56.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/6] rteval: Fix validate_stressors() docstring Raises claim
2026-11-24 1:07 [PATCH 0/6] rteval: multi-stressor support plus stressng and test fixes John Kacur
2026-11-24 1:07 ` [PATCH 1/6] rteval: Add multi stressor support John Kacur
2026-11-24 1:07 ` [PATCH 2/6] rteval: Test stressng opt-out and arg building John Kacur
@ 2026-11-24 1:07 ` John Kacur
2026-11-24 1:07 ` [PATCH 4/6] rteval: Make core-sharing tests independent of host SMT topology John Kacur
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: John Kacur @ 2026-11-24 1:07 UTC (permalink / raw)
To: linux-rt-users; +Cc: Sana Sharma, Clark Williams, Chris White
validate_stressors() does not raise ValueError on an invalid stressor;
it prints an error and calls sys.exit(1), consistent with
get_valid_stressors(). The docstring still carried the old "Raises:
ValueError" wording from an earlier revision, which was misleading.
Document the actual behaviour: it returns the list of stripped,
validated stressor names, and exits via sys.exit(1) on an invalid one.
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: John Kacur <jkacur@redhat.com>
---
rteval/modules/loads/stressng.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/rteval/modules/loads/stressng.py b/rteval/modules/loads/stressng.py
index 479248875fae..eed1263690a0 100644
--- a/rteval/modules/loads/stressng.py
+++ b/rteval/modules/loads/stressng.py
@@ -21,8 +21,10 @@ def validate_stressors(stressor_list):
(from repeated --stressng-stressor) or a
comma-separated string (from --stressng-stressors)
- Raises:
- ValueError: If any stressor is invalid
+ Returns:
+ The list of stripped, validated stressor names.
+
+ If any stressor is invalid, prints an error and exits via sys.exit(1).
"""
valid = get_valid_stressors()
if isinstance(stressor_list, str):
--
2.56.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/6] rteval: Make core-sharing tests independent of host SMT topology
2026-11-24 1:07 [PATCH 0/6] rteval: multi-stressor support plus stressng and test fixes John Kacur
` (2 preceding siblings ...)
2026-11-24 1:07 ` [PATCH 3/6] rteval: Fix validate_stressors() docstring Raises claim John Kacur
@ 2026-11-24 1:07 ` John Kacur
2026-11-24 1:07 ` [PATCH 5/6] rteval: Skip cpuset partition tests when CPUs are not cgroup-usable John Kacur
2026-11-24 1:07 ` [PATCH 6/6] rteval: Pick cpuset integration-test CPUs from cpuset.cpus.effective John Kacur
5 siblings, 0 replies; 7+ messages in thread
From: John Kacur @ 2026-11-24 1:07 UTC (permalink / raw)
To: linux-rt-users; +Cc: Sana Sharma, Clark Williams, Chris White
The core-sharing tests in tests/test_core_sharing_validation.py mocked the
isolated CPU list but not the core-sibling data, which is read from sysfs via
CoreSiblings. They therefore assumed an SMT topology where CPUs 0 and 8 are
thread siblings and 1 and 9 are thread siblings.
On a host without SMT (and on many VMs) no two CPUs share a core, so
validate_core_sharing() produced no warnings and, in turn, no
CoreSharingWarnings XML node. Four tests failed even though the product code
was correct:
- test_housekeeping_measurement_share_core
- test_multiple_conflicts
- test_isolated_marker_in_warnings
- test_xml_report_generation
Mock CoreSiblings.share_core() in setUp() so the sibling topology is
deterministic (0<->8 and 1<->9), making the suite reproducible on any machine
as the file originally intended.
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: John Kacur <jkacur@redhat.com>
---
tests/test_core_sharing_validation.py | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/tests/test_core_sharing_validation.py b/tests/test_core_sharing_validation.py
index 383b028516c1..05de4590bd35 100755
--- a/tests/test_core_sharing_validation.py
+++ b/tests/test_core_sharing_validation.py
@@ -26,6 +26,19 @@ from rteval.sysinfo.cputopology import CPUtopology
from rteval.Log import Log
+# These tests assume an SMT topology where CPUs 0 & 8 are thread siblings and
+# 1 & 9 are thread siblings. The real sibling relationships come from sysfs via
+# CoreSiblings, so mock share_core() here to keep the tests reproducible on any
+# machine -- otherwise they fail on hosts without SMT (where no CPUs share a
+# core) even though the product code is correct.
+_SIBLING_PAIRS = {frozenset((0, 8)), frozenset((1, 9))}
+
+
+def _fake_share_core(cpu1, cpu2):
+ """Deterministic stand-in for CoreSiblings.share_core()."""
+ return frozenset((cpu1, cpu2)) in _SIBLING_PAIRS
+
+
class TestCoreSharingValidation(unittest.TestCase):
"""Test suite for core sharing validation with mocked isolated CPUs"""
@@ -33,6 +46,17 @@ class TestCoreSharingValidation(unittest.TestCase):
# Based on typical topology: CPUs 0 and 8 share a core, 1 and 9 share a core
MOCK_ISOLATED_CPUS = [0, 8, 1, 9]
+ def setUp(self):
+ """Mock CoreSiblings so core-sharing is deterministic on any host.
+
+ validate_core_sharing() imports CoreSiblings from
+ rteval.sysinfo.coresiblings at call time, so patch it there.
+ """
+ patcher = patch('rteval.sysinfo.coresiblings.CoreSiblings')
+ mock_cs_cls = patcher.start()
+ self.addCleanup(patcher.stop)
+ mock_cs_cls.return_value.share_core.side_effect = _fake_share_core
+
@patch('rteval.systopology.SysTopology')
def test_housekeeping_measurement_share_core(self, mock_systopo):
"""Test warning when housekeeping and measurement share a core"""
--
2.56.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 5/6] rteval: Skip cpuset partition tests when CPUs are not cgroup-usable
2026-11-24 1:07 [PATCH 0/6] rteval: multi-stressor support plus stressng and test fixes John Kacur
` (3 preceding siblings ...)
2026-11-24 1:07 ` [PATCH 4/6] rteval: Make core-sharing tests independent of host SMT topology John Kacur
@ 2026-11-24 1:07 ` John Kacur
2026-11-24 1:07 ` [PATCH 6/6] rteval: Pick cpuset integration-test CPUs from cpuset.cpus.effective John Kacur
5 siblings, 0 replies; 7+ messages in thread
From: John Kacur @ 2026-11-24 1:07 UTC (permalink / raw)
To: linux-rt-users; +Cc: Sana Sharma, Clark Williams, Chris White
TestCpusetManagerHousekeepingPartitions hardcodes CPUs 0-3 and asserts that the
housekeeping/measurement cpusets become partition=isolated. Some systems hold
CPUs out of the root cgroup's cpuset.cpus.effective -- via isolcpus=, or a
systemd/tuned cpu-partitioning setup (e.g. Fedora CSB reserves CPUs 0-5 with no
isolcpus= boot parameter). Such CPUs cannot form an isolated partition, so the
kernel reports:
isolated invalid (Invalid cpu list in cpuset.cpus.exclusive)
and test_housekeeping_isolated_flag and test_measurement_always_isolated fail
under sudo make test-all. The product code is correct: an isolated partition
built from CPUs that are in cpuset.cpus.effective works.
Skip the two affected tests when the CPUs they use are not in
cpuset.cpus.effective, so the suite is green on such systems while still running
normally elsewhere. A follow-up should pick usable CPUs from
cpuset.cpus.effective instead of hardcoding them.
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: John Kacur <jkacur@redhat.com>
---
tests/test_cpusetmanager.py | 39 +++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/tests/test_cpusetmanager.py b/tests/test_cpusetmanager.py
index 3da042dbeaad..50ec478a7427 100644
--- a/tests/test_cpusetmanager.py
+++ b/tests/test_cpusetmanager.py
@@ -23,6 +23,43 @@ from rteval import cpuset
from rteval.Log import Log
+def _expand_cpulist(s):
+ """Expand a cpuset list string like '0-5,8' into a set of ints."""
+ cpus = set()
+ for part in s.split(','):
+ part = part.strip()
+ if not part:
+ continue
+ if '-' in part:
+ start, end = part.split('-')
+ cpus.update(range(int(start), int(end) + 1))
+ else:
+ cpus.add(int(part))
+ return cpus
+
+
+def _skip_if_isolated(test, cpus):
+ """Skip test if any of cpus are not usable by cgroup cpusets.
+
+ Some systems hold CPUs out of the root cgroup's cpuset.cpus.effective
+ (via isolcpus=, or a systemd/tuned cpu-partitioning setup -- e.g. Fedora
+ CSB reserves 0-5 with no isolcpus= boot parameter). Such CPUs cannot form
+ an isolated partition, so a test that hardcodes them would spuriously
+ fail. A later change should pick usable CPUs from cpuset.cpus.effective
+ instead of hardcoding them.
+ """
+ try:
+ with open('/sys/fs/cgroup/cpuset.cpus.effective') as f:
+ usable = _expand_cpulist(f.read().strip())
+ except OSError:
+ return
+ missing = sorted(set(cpus) - usable)
+ if missing:
+ test.skipTest(f"CPUs {missing} are not in cpuset.cpus.effective "
+ "(reserved outside the root cgroup); cannot form an "
+ "isolated partition")
+
+
class TestCpusetManagerBasic(unittest.TestCase):
"""Test basic CpusetManager functionality (non-root tests)"""
@@ -74,6 +111,7 @@ class TestCpusetManagerHousekeepingPartitions(unittest.TestCase):
def test_housekeeping_isolated_flag(self):
"""Test that housekeeping_isolated=True makes partition=isolated"""
+ _skip_if_isolated(self, [0, 1, 2, 3])
with CpusetManager(
housekeeping_cpus=[0, 1],
measurement_cpus=[2, 3],
@@ -89,6 +127,7 @@ class TestCpusetManagerHousekeepingPartitions(unittest.TestCase):
def test_measurement_always_isolated(self):
"""Test that measurement cpuset is always partition=isolated"""
+ _skip_if_isolated(self, [0, 1, 2, 3])
# Test with housekeeping_isolated=False
with CpusetManager(
housekeeping_cpus=[0, 1],
--
2.56.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 6/6] rteval: Pick cpuset integration-test CPUs from cpuset.cpus.effective
2026-11-24 1:07 [PATCH 0/6] rteval: multi-stressor support plus stressng and test fixes John Kacur
` (4 preceding siblings ...)
2026-11-24 1:07 ` [PATCH 5/6] rteval: Skip cpuset partition tests when CPUs are not cgroup-usable John Kacur
@ 2026-11-24 1:07 ` John Kacur
5 siblings, 0 replies; 7+ messages in thread
From: John Kacur @ 2026-11-24 1:07 UTC (permalink / raw)
To: linux-rt-users; +Cc: Sana Sharma, Clark Williams, Chris White
tests/cpusets/test-cpusets.sh picked its housekeeping/measurement/loads CPU
groups by nproc alone and hardcoded the numbers (0-3 4-7 8-11, ...), so it could
use CPUs that belong to another isolated partition. On a host running intel_lpmd
-- which reserves the low-power CPUs (0-5 here) in its own isolated "lpm"
partition -- those CPUs are not in the root cgroup's cpuset.cpus.effective, so
rteval cannot build an isolated partition from them and six subtests failed under
sudo make test-all.
Choose the CPU groups from cpuset.cpus.effective at runtime instead, emitting
them in the kernel's canonical cpulist form so the cpuset.cpus comparisons still
match. The tests now run on whatever CPUs are actually usable, so they pass
whether or not intel_lpmd (or isolcpus=) is holding some CPUs out of the cgroup
hierarchy.
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: John Kacur <jkacur@redhat.com>
---
tests/cpusets/test-cpusets.sh | 65 ++++++++++++++++++++++++++---------
1 file changed, 49 insertions(+), 16 deletions(-)
diff --git a/tests/cpusets/test-cpusets.sh b/tests/cpusets/test-cpusets.sh
index b5bca42f51b7..33cde278397c 100755
--- a/tests/cpusets/test-cpusets.sh
+++ b/tests/cpusets/test-cpusets.sh
@@ -138,25 +138,58 @@ check_cpuset_has_procs() {
[ "$count" -gt 0 ]
}
-get_test_cpus() {
- # Get available CPUs for testing
- # Returns: "0-3 4-7 8-11" for housekeeping, measurement, loads
- local online=$(cat /sys/devices/system/cpu/online)
-
- # Parse online CPUs (e.g., "0-15" or "0-3,8-11")
- # For simplicity, just use first 12 CPUs if available
- # Otherwise adapt based on what's available
+_collapse_cpus() {
+ # Collapse sorted integer args into kernel cpuset form,
+ # e.g. "6 7 8 10" -> "6-8,10". Matches how the kernel stores cpuset.cpus,
+ # so string comparisons in check_cpuset_cpus() succeed.
+ local out="" start="" prev="" c
+ for c in "$@"; do
+ if [ -z "$start" ]; then
+ start=$c; prev=$c
+ elif [ "$c" -eq $((prev + 1)) ]; then
+ prev=$c
+ else
+ if [ "$start" = "$prev" ]; then out+="${out:+,}$start"; else out+="${out:+,}$start-$prev"; fi
+ start=$c; prev=$c
+ fi
+ done
+ if [ -n "$start" ]; then
+ if [ "$start" = "$prev" ]; then out+="${out:+,}$start"; else out+="${out:+,}$start-$prev"; fi
+ fi
+ echo "$out"
+}
- local total=$(nproc)
+get_test_cpus() {
+ # Return three disjoint CPU groups "housekeeping measurement loads", chosen
+ # from the CPUs actually usable by cgroup cpusets (cpuset.cpus.effective).
+ # CPUs held in another isolated partition -- e.g. intel_lpmd's "lpm"
+ # partition, or isolcpus= -- are absent from that set and cannot form an
+ # rteval isolated partition, so hardcoding CPU numbers would spuriously fail.
+ local effective
+ effective=$(cat /sys/fs/cgroup/cpuset.cpus.effective 2>/dev/null)
+ [ -n "$effective" ] || effective=$(cat /sys/devices/system/cpu/online)
+
+ # Expand "6-15" / "0-3,8-11" into a sorted CPU list
+ local -a pool=()
+ local part lo hi i old_ifs="$IFS"
+ IFS=','
+ for part in $effective; do
+ if [[ "$part" == *-* ]]; then
+ lo=${part%-*}; hi=${part#*-}
+ for ((i = lo; i <= hi; i++)); do pool+=("$i"); done
+ else
+ pool+=("$part")
+ fi
+ done
+ IFS="$old_ifs"
- if [ "$total" -ge 12 ]; then
- echo "0-3 4-7 8-11"
- elif [ "$total" -ge 8 ]; then
- echo "0-1 2-4 5-7"
- elif [ "$total" -ge 4 ]; then
- echo "0 1-2 3"
+ local n=${#pool[@]}
+ if [ "$n" -ge 6 ]; then
+ echo "$(_collapse_cpus "${pool[0]}" "${pool[1]}") $(_collapse_cpus "${pool[2]}" "${pool[3]}") $(_collapse_cpus "${pool[4]}" "${pool[5]}")"
+ elif [ "$n" -ge 4 ]; then
+ echo "$(_collapse_cpus "${pool[0]}") $(_collapse_cpus "${pool[1]}" "${pool[2]}") $(_collapse_cpus "${pool[3]}")"
else
- echo "0 0 0" # Not ideal but at least won't crash
+ echo "${pool[0]:-0} ${pool[0]:-0} ${pool[0]:-0}"
fi
}
--
2.56.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-24 1:08 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 1:07 [PATCH 0/6] rteval: multi-stressor support plus stressng and test fixes John Kacur
2026-11-24 1:07 ` [PATCH 1/6] rteval: Add multi stressor support John Kacur
2026-11-24 1:07 ` [PATCH 2/6] rteval: Test stressng opt-out and arg building John Kacur
2026-11-24 1:07 ` [PATCH 3/6] rteval: Fix validate_stressors() docstring Raises claim John Kacur
2026-11-24 1:07 ` [PATCH 4/6] rteval: Make core-sharing tests independent of host SMT topology John Kacur
2026-11-24 1:07 ` [PATCH 5/6] rteval: Skip cpuset partition tests when CPUs are not cgroup-usable John Kacur
2026-11-24 1:07 ` [PATCH 6/6] rteval: Pick cpuset integration-test CPUs from cpuset.cpus.effective John Kacur
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.