public inbox for linux-rt-users@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] rteval: Show both cyclictest and timerlat options in help menu
@ 2025-11-12 17:48 John Kacur
  2025-11-12 17:48 ` [PATCH 2/2] rteval: timerlat: Disable auto-analysis with --no-aa John Kacur
  0 siblings, 1 reply; 2+ messages in thread
From: John Kacur @ 2025-11-12 17:48 UTC (permalink / raw)
  To: linux-rt-users; +Cc: Tomas Glozar, Clark Williams, John Kacur, Claude

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-11-12 17:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-12 17:48 [PATCH 1/2] rteval: Show both cyclictest and timerlat options in help menu John Kacur
2025-11-12 17:48 ` [PATCH 2/2] rteval: timerlat: Disable auto-analysis with --no-aa John Kacur

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox