public inbox for linux-rt-users@vger.kernel.org
 help / color / mirror / Atom feed
From: John Kacur <jkacur@redhat.com>
To: linux-rt-users <linux-rt-users@vger.kernel.org>
Cc: Tomas Glozar <tglozar@redhat.com>,
	Clark Williams <williams@redhat.com>,
	John Kacur <jkacur@redhat.com>, Claude <noreply@anthropic.com>
Subject: [PATCH 1/2] rteval: Show both cyclictest and timerlat options in help menu
Date: Wed, 12 Nov 2025 12:48:34 -0500	[thread overview]
Message-ID: <20251112174835.188210-1-jkacur@redhat.com> (raw)

Previously, running './rteval-cmd -h' would only show options for one
measurement module (either cyclictest or timerlat), depending on which
was selected. This made it difficult for users to discover all available
options.

This commit modifies the module loading logic to:

1. Load both cyclictest and timerlat modules for help generation,
   ensuring all options are visible in the help menu

2. Determine which module should actually run based on:
   - Command-line argument (--measurement-module) takes precedence
   - Config file setting if no command-line override
   - Default to timerlat if neither is specified

3. After help is generated and arguments are parsed, disable the
   non-selected measurement module so only the chosen one runs

Additionally, changed the default measurement module from cyclictest
to timerlat when no config file exists.

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
---
 rteval-cmd | 56 ++++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 44 insertions(+), 12 deletions(-)

diff --git a/rteval-cmd b/rteval-cmd
index 855934e42192..45d9f3a58a11 100755
--- a/rteval-cmd
+++ b/rteval-cmd
@@ -220,7 +220,7 @@ if __name__ == '__main__':
 
         if not config.HasSection('measurement'):
             config.AppendConfig('measurement', {
-                'cyclictest' : 'module',
+                'timerlat' : 'module',
                 'sysstat' : 'module'})
 
         # Check for --measurement-module argument early to override config file
@@ -229,17 +229,35 @@ if __name__ == '__main__':
                                         type=str, choices=['cyclictest', 'timerlat'])
         early_args, _ = measurement_parser.parse_known_args()
 
+        # For help generation, we want to load both cyclictest and timerlat modules
+        # so users can see all available options regardless of which one is selected
+        msrcfg = config.GetSection('measurement')
+
+        # Determine which module should actually run before we load both for help
+        selected_measurement_module = None
         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)")
+            # Command-line argument takes precedence
+            selected_measurement_module = early_args.measurement_module
+            logger.log(Log.INFO, f"Using measurement module: {selected_measurement_module} (from command line)")
+        else:
+            # Check config file to see what's configured
+            cyclictest_in_config = hasattr(msrcfg, 'cyclictest') and msrcfg.cyclictest == 'module'
+            timerlat_in_config = hasattr(msrcfg, 'timerlat') and msrcfg.timerlat == 'module'
+
+            if cyclictest_in_config and not timerlat_in_config:
+                selected_measurement_module = 'cyclictest'
+            elif timerlat_in_config and not cyclictest_in_config:
+                selected_measurement_module = 'timerlat'
+            elif cyclictest_in_config and timerlat_in_config:
+                # Both in config - prefer timerlat as default
+                selected_measurement_module = 'timerlat'
+            else:
+                # Neither in config - default to timerlat
+                selected_measurement_module = 'timerlat'
+
+        # Now ensure both modules are loaded for option display
+        msrcfg.cyclictest = 'module'
+        msrcfg.timerlat = 'module'
 
         # Prepare log levels before loading modules, not to have unwanted log messages
         # Use a minimal parser to extract logging-related flags early
@@ -267,7 +285,7 @@ if __name__ == '__main__':
         if early_args.idle_set:
             rtevcfg.update({'usingCpupower': True})
 
-        # Load modules
+        # Load modules (both cyclictest and timerlat are loaded for help display)
         loadmods = LoadModules(config, logger=logger)
         measuremods = MeasurementModules(config, logger=logger)
 
@@ -277,6 +295,20 @@ if __name__ == '__main__':
         measuremods.SetupModuleOptions(parser)
         cmd_opts = parse_options(config, parser, sys.argv[1:])
 
+        # After parsing options, disable the measurement module that won't be used
+        # This must be done after option parsing so both modules' options appear in help
+        msrcfg = config.GetSection('measurement')
+        if hasattr(cmd_opts, 'measurement___measurement_module') and cmd_opts.measurement___measurement_module:
+            selected_measurement_module = cmd_opts.measurement___measurement_module
+
+        # Disable the non-selected measurement module
+        if selected_measurement_module == 'timerlat':
+            if hasattr(msrcfg, 'cyclictest'):
+                msrcfg.cyclictest = None
+        elif selected_measurement_module == 'cyclictest':
+            if hasattr(msrcfg, 'timerlat'):
+                msrcfg.timerlat = None
+
         if rtevcfg.noload:
             if rtevcfg.onlyload:
                 # Make up your mind!
-- 
2.51.1


             reply	other threads:[~2025-11-12 17:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-12 17:48 John Kacur [this message]
2025-11-12 17:48 ` [PATCH 2/2] rteval: timerlat: Disable auto-analysis with --no-aa 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=20251112174835.188210-1-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