linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Kacur <jkacur@redhat.com>
To: linux-rt-users <linux-rt-users@vger.kernel.org>
Cc: Clark Williams <williams@redhat.com>,
	Tomas Glozar <tglozar@redhat.com>, John Kacur <jkacur@redhat.com>,
	Claude <noreply@anthropic.com>
Subject: [PATCH 11/12] rteval: Add --measurement-module command-line argument
Date: Fri,  7 Nov 2025 13:26:34 -0500	[thread overview]
Message-ID: <20251107182645.19545-12-jkacur@redhat.com> (raw)
In-Reply-To: <20251107182645.19545-1-jkacur@redhat.com>

Add a new command-line argument to select between cyclictest and
timerlat measurement modules, overriding the config file setting.

The argument is part of the "Group Options for measurement modules"
in the argument parser, making it consistent with other measurement
options like --measurement-cpulist and --measurement-run-on-isolcpus.

Usage:
  rteval --measurement-module cyclictest
  rteval --measurement-module timerlat

Implementation details:
- Added --measurement-module to measurement argument group in
  rteval/modules/__init__.py (SetupModuleOptions)
- Added early argument parsing in rteval-cmd to apply the override
  before modules are loaded
- The selected module is enabled while the other is disabled
- Fixed module loading to handle None values when modules are disabled

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
---
 rteval-cmd                             | 18 ++++++++++++++++++
 rteval/modules/__init__.py             |  7 +++++++
 rteval/modules/measurement/__init__.py |  2 +-
 3 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/rteval-cmd b/rteval-cmd
index 00873ce1196b..855934e42192 100755
--- a/rteval-cmd
+++ b/rteval-cmd
@@ -223,6 +223,24 @@ if __name__ == '__main__':
                 'cyclictest' : 'module',
                 'sysstat' : 'module'})
 
+        # Check for --measurement-module argument early to override config file
+        measurement_parser = argparse.ArgumentParser(add_help=False)
+        measurement_parser.add_argument('--measurement-module', dest='measurement_module',
+                                        type=str, choices=['cyclictest', 'timerlat'])
+        early_args, _ = measurement_parser.parse_known_args()
+
+        if early_args.measurement_module:
+            # Override measurement config based on command-line argument
+            msrcfg = config.GetSection('measurement')
+            # Disable both cyclictest and timerlat first
+            if 'cyclictest' in msrcfg:
+                msrcfg.cyclictest = None
+            if 'timerlat' in msrcfg:
+                msrcfg.timerlat = None
+            # Enable the selected measurement module
+            setattr(msrcfg, early_args.measurement_module, 'module')
+            logger.log(Log.INFO, f"Using measurement module: {early_args.measurement_module} (from command line)")
+
         # Prepare log levels before loading modules, not to have unwanted log messages
         # Use a minimal parser to extract logging-related flags early
         rtevcfg = config.GetSection('rteval')
diff --git a/rteval/modules/__init__.py b/rteval/modules/__init__.py
index d60877783670..7e5916c52965 100644
--- a/rteval/modules/__init__.py
+++ b/rteval/modules/__init__.py
@@ -303,6 +303,13 @@ reference from the first import"""
                                   metavar='IDLESTATE',
                                   default=None,
                                   help='Idle state depth to set on cpus running measurement modules')
+            grparser.add_argument('--measurement-module',
+                                  dest='measurement___measurement_module',
+                                  type=str,
+                                  choices=['cyclictest', 'timerlat'],
+                                  metavar='MODULE',
+                                  default=None,
+                                  help='Select measurement module: cyclictest or timerlat (overrides config file)')
 
         for (modname, mod) in list(self.__modsloaded.items()):
             opts = mod.ModuleParameters()
diff --git a/rteval/modules/measurement/__init__.py b/rteval/modules/measurement/__init__.py
index 44708ce0b035..e09dca683dbf 100644
--- a/rteval/modules/measurement/__init__.py
+++ b/rteval/modules/measurement/__init__.py
@@ -24,7 +24,7 @@ class MeasurementModules(RtEvalModules):
         for m in modcfg:
             # hope to eventually have different kinds but module is only on
             # for now (jcw)
-            if m[1].lower() == 'module':
+            if m[1] and m[1].lower() == 'module':
                 self._LoadModule(m[0])
 
     def SetupModuleOptions(self, parser):
-- 
2.51.1


  parent reply	other threads:[~2025-11-07 18:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-07 18:26 [PATCH 00/12] rteval updates John Kacur
2025-11-07 18:26 ` [PATCH 01/12] rteval: Fix spelling of 'occurrences' in measurement modules John Kacur
2025-11-07 18:26 ` [PATCH 02/12] rteval: Fix typo in comment John Kacur
2025-11-07 18:26 ` [PATCH 03/12] rteval: Remove unused function remove_offline John Kacur
2025-11-07 18:26 ` [PATCH 04/12] rteval: timerlat: Fix typo in log message John Kacur
2025-11-07 18:26 ` [PATCH 05/12] rteval: cyclictest: Fix typo in comment John Kacur
2025-11-07 18:26 ` [PATCH 06/12] rteval: rtevalConfig: Remove redundant 'is True' comparison John Kacur
2025-11-07 18:26 ` [PATCH 07/12] rteval: Clean up MANIFEST.in and fix newnet.py copyright header John Kacur
2025-11-07 18:26 ` [PATCH 08/12] rteval: Add pyproject.toml for modern Python packaging John Kacur
2025-11-07 18:26 ` [PATCH 09/12] rteval: Improve argparse implementation and remove manual sys.argv parsing John Kacur
2025-11-07 18:26 ` [PATCH 10/12] rteval: timerlat: Add dma_latency option with default value of 0 John Kacur
2025-11-07 18:26 ` John Kacur [this message]
2025-11-07 18:26 ` [PATCH 12/12] rteval: Add unit tests for --measurement-module argument John Kacur

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251107182645.19545-12-jkacur@redhat.com \
    --to=jkacur@redhat.com \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=noreply@anthropic.com \
    --cc=tglozar@redhat.com \
    --cc=williams@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).