diff mbox series

[v2] rteval: Add --noload option

Message ID 20240708194822.221496-1-crwood@redhat.com
State Superseded
Headers show
Series [v2] rteval: Add --noload option | expand

Commit Message

Crystal Wood July 8, 2024, 7:48 p.m. UTC
This option allows measurement to be done without any loads.

Signed-off-by: Crystal Wood <crwood@redhat.com>
---
v2: I forgot to update the man page

This patch is on top of the "rteval: Remove measurement profiles and
make latency mods exclusive" patchset I previously sent.

 doc/rteval.8           |  3 +++
 rteval-cmd             |  9 +++++++
 rteval/__init__.py     | 54 ++++++++++++++++++++++--------------------
 rteval/rtevalReport.py |  3 ++-
 4 files changed, 42 insertions(+), 27 deletions(-)

Comments

John Kacur July 18, 2024, 8:23 p.m. UTC | #1
On Mon, 8 Jul 2024, Crystal Wood wrote:

> This option allows measurement to be done without any loads.
> 
> Signed-off-by: Crystal Wood <crwood@redhat.com>
> ---
> v2: I forgot to update the man page
> 
> This patch is on top of the "rteval: Remove measurement profiles and
> make latency mods exclusive" patchset I previously sent.
> 
>  doc/rteval.8           |  3 +++
>  rteval-cmd             |  9 +++++++
>  rteval/__init__.py     | 54 ++++++++++++++++++++++--------------------
>  rteval/rtevalReport.py |  3 ++-
>  4 files changed, 42 insertions(+), 27 deletions(-)
> 
> diff --git a/doc/rteval.8 b/doc/rteval.8
> index bfdeb9d36d9e..1eca63721b75 100644
> --- a/doc/rteval.8
> +++ b/doc/rteval.8
> @@ -108,6 +108,9 @@ Print rteval version and exit.
>  .TP
>  .B \-S KERNEL_VERSION, \-\-source\-download=KERNEL_VERSION
>  download a source kernel from kernel.org and exit
> +.TP
> +.B \-\-noload
> +Only run the measurements (don't run loads)
>  
>  .SH GROUP OPTIONS
>  .TP
> diff --git a/rteval-cmd b/rteval-cmd
> index 5cb6d7a44523..36b167a034e5 100755
> --- a/rteval-cmd
> +++ b/rteval-cmd
> @@ -146,6 +146,9 @@ def parse_options(cfg, parser, cmdargs):
>      parser.add_argument("-S", "--source-download", nargs="*", dest="rteval___srcdownload",
>                          type=str, default=None, metavar="KERNEL_VERSION",
>                          help='download a source kernel from kernel.org and exit')
> +    parser.add_argument("--noload", dest="rteval___noload",
> +                        action="store_true", default=False,
> +                        help="only run the measurements (don't run loads)")
>  
>  
>      if not cmdargs:
> @@ -273,6 +276,12 @@ if __name__ == '__main__':
>          measuremods.SetupModuleOptions(parser)
>          cmd_args = parse_options(config, parser, sys.argv[1:])
>  
> +        if rtevcfg.noload:
> +            if rtevcfg.onlyload:
> +                # Make up your mind!
> +                raise RuntimeError('The --noload and --onlyload options are incompatible.')
> +            loadmods = None
> +
>          # download kernel tarball
>          if rtevcfg.srcdownload:
>              logger.log(Log.DEBUG, f"Kernel Version to download = {rtevcfg.srcdownload}")
> diff --git a/rteval/__init__.py b/rteval/__init__.py
> index 226d14f80f48..4d3e0c23e5ab 100644
> --- a/rteval/__init__.py
> +++ b/rteval/__init__.py
> @@ -46,9 +46,6 @@ class RtEval(rtevalReport):
>          if not isinstance(config, rtevalConfig.rtevalConfig):
>              raise TypeError("config variable is not an rtevalConfig object")
>  
> -        if not isinstance(loadmods, LoadModules):
> -            raise TypeError("loadmods variable is not a LoadModules object")
> -
>          if not isinstance(measuremods, MeasurementModules):
>              raise TypeError("measuremods variable is not a MeasurementModules object")
>  
> @@ -111,20 +108,21 @@ class RtEval(rtevalReport):
>          except Exception as err:
>              raise RuntimeError(f"Cannot create report directory (NFS with rootsquash on?) [{err}]]")
>  
> +        params = {'workdir':self.__rtevcfg.workdir,
> +                  'reportdir':self.__reportdir and self.__reportdir or "",
> +                  'builddir':builddir,
> +                  'srcdir':self.__rtevcfg.srcdir,
> +                  'verbose': self.__rtevcfg.verbose,
> +                  'debugging': self.__rtevcfg.debugging,
> +                  'numcores':self._sysinfo.cpu_getCores(True),
> +                  'logging':self.__rtevcfg.logging,
> +                  'memsize':self._sysinfo.mem_get_size(),
> +                  'numanodes':self._sysinfo.mem_get_numa_nodes(),
> +                  'duration': float(self.__rtevcfg.duration),
> +                  }
> +
>          if self._loadmods:
>              self.__logger.log(Log.INFO, "Preparing load modules")
> -            params = {'workdir':self.__rtevcfg.workdir,
> -                      'reportdir':self.__reportdir and self.__reportdir or "",
> -                      'builddir':builddir,
> -                      'srcdir':self.__rtevcfg.srcdir,
> -                      'verbose': self.__rtevcfg.verbose,
> -                      'debugging': self.__rtevcfg.debugging,
> -                      'numcores':self._sysinfo.cpu_getCores(True),
> -                      'logging':self.__rtevcfg.logging,
> -                      'memsize':self._sysinfo.mem_get_size(),
> -                      'numanodes':self._sysinfo.mem_get_numa_nodes(),
> -                      'duration': float(self.__rtevcfg.duration),
> -                      }
>              self._loadmods.Setup(params)
>  
>          self.__logger.log(Log.INFO, "Preparing measurement modules")
> @@ -144,15 +142,18 @@ class RtEval(rtevalReport):
>  
>              print(f"rteval run on {os.uname()[2]} started at {time.asctime()}")
>              onlinecpus = self._sysinfo.cpu_getCores(True)
> -            cpulist = self._loadmods._cfg.GetSection("loads").cpulist
> -            if cpulist:
> -                print(f"started {self._loadmods.ModulesLoaded()} loads on cores {cpulist}", end=' ')
> -            else:
> -                print(f"started {self._loadmods.ModulesLoaded()} loads on {onlinecpus} cores", end=' ')
> -            if self._sysinfo.mem_get_numa_nodes() > 1:
> -                print(f" with {self._sysinfo.mem_get_numa_nodes()} numa nodes")
> -            else:
> -                print("")
> +            if self._loadmods:
> +                cpulist = self._loadmods._cfg.GetSection("loads").cpulist
> +                if cpulist:
> +                    print(f"started {self._loadmods.ModulesLoaded()} loads on cores {cpulist}",
> +                          end=' ')
> +                else:
> +                    print(f"started {self._loadmods.ModulesLoaded()} loads on {onlinecpus} cores",
> +                          end=' ')
> +                if self._sysinfo.mem_get_numa_nodes() > 1:
> +                    print(f" with {self._sysinfo.mem_get_numa_nodes()} numa nodes")
> +                else:
> +                    print("")
>              cpulist = self._measuremods._cfg.GetSection("measurement").cpulist
>              if cpulist:
>                  print(f"started measurement threads on cores {cpulist}")
> @@ -192,7 +193,7 @@ class RtEval(rtevalReport):
>                      if threading.active_count() < nthreads:
>                          raise RuntimeError("load thread died!")
>  
> -                if not load_avg_checked:
> +                if self._loadmods and not load_avg_checked:
>                      self._loadmods.SaveLoadAvg()
>                      load_avg_checked = 5
>                  else:
> @@ -202,7 +203,8 @@ class RtEval(rtevalReport):
>                      left_to_run = stoptime - currtime
>                      self.__show_remaining_time(left_to_run)
>                      rpttime = currtime + report_interval
> -                    print(f"load average: {self._loadmods.GetLoadAvg():.2f}")
> +                    if self._loadmods:
> +                        print(f"load average: {self._loadmods.GetLoadAvg():.2f}")
>                  currtime = time.time()
>  
>              self.__logger.log(Log.DEBUG, "out of measurement loop")
> diff --git a/rteval/rtevalReport.py b/rteval/rtevalReport.py
> index 57d99f520f50..7379a7904f3f 100644
> --- a/rteval/rtevalReport.py
> +++ b/rteval/rtevalReport.py
> @@ -57,7 +57,8 @@ class rtevalReport:
>          self.__xmlreport.AppendXMLnodes(self._sysinfo.MakeReport())
>  
>          # Add load info
> -        self.__xmlreport.AppendXMLnodes(self._loadmods.MakeReport())
> +        if self._loadmods:
> +            self.__xmlreport.AppendXMLnodes(self._loadmods.MakeReport())
>  
>          # Add measurement data
>          self.__xmlreport.AppendXMLnodes(self._measuremods.MakeReport())
> -- 
> 2.45.1
> 
> 
> 

When I run with loads, I the report says something like,
 "Loads:        3 loads run on cores 0-11"

When I run with your --noload option, it says:
"Loads:         loads run on cores"

It should probably say, 0 loads, run on 0 cores

John
Crystal Wood July 19, 2024, 6:24 p.m. UTC | #2
On Thu, 2024-07-18 at 16:23 -0400, John Kacur wrote:
> 
> 
> On Mon, 8 Jul 2024, Crystal Wood wrote:
> 
> > This option allows measurement to be done without any loads.
> > 
> > Signed-off-by: Crystal Wood <crwood@redhat.com>
> > ---
> > v2: I forgot to update the man page
> > 
> > This patch is on top of the "rteval: Remove measurement profiles and
> > make latency mods exclusive" patchset I previously sent.
> > 
> >  doc/rteval.8           |  3 +++
> >  rteval-cmd             |  9 +++++++
> >  rteval/__init__.py     | 54 ++++++++++++++++++++++--------------------
> >  rteval/rtevalReport.py |  3 ++-
> >  4 files changed, 42 insertions(+), 27 deletions(-)
> > 
> 
> When I run with loads, I the report says something like,
>  "Loads:        3 loads run on cores 0-11"
> 
> When I run with your --noload option, it says:
> "Loads:         loads run on cores"
> 
> It should probably say, 0 loads, run on 0 cores

Which means now I get to learn how to actually do stuff in xml rather than
just changing pathnames and such :-P

-Crystal
diff mbox series

Patch

diff --git a/doc/rteval.8 b/doc/rteval.8
index bfdeb9d36d9e..1eca63721b75 100644
--- a/doc/rteval.8
+++ b/doc/rteval.8
@@ -108,6 +108,9 @@  Print rteval version and exit.
 .TP
 .B \-S KERNEL_VERSION, \-\-source\-download=KERNEL_VERSION
 download a source kernel from kernel.org and exit
+.TP
+.B \-\-noload
+Only run the measurements (don't run loads)
 
 .SH GROUP OPTIONS
 .TP
diff --git a/rteval-cmd b/rteval-cmd
index 5cb6d7a44523..36b167a034e5 100755
--- a/rteval-cmd
+++ b/rteval-cmd
@@ -146,6 +146,9 @@  def parse_options(cfg, parser, cmdargs):
     parser.add_argument("-S", "--source-download", nargs="*", dest="rteval___srcdownload",
                         type=str, default=None, metavar="KERNEL_VERSION",
                         help='download a source kernel from kernel.org and exit')
+    parser.add_argument("--noload", dest="rteval___noload",
+                        action="store_true", default=False,
+                        help="only run the measurements (don't run loads)")
 
 
     if not cmdargs:
@@ -273,6 +276,12 @@  if __name__ == '__main__':
         measuremods.SetupModuleOptions(parser)
         cmd_args = parse_options(config, parser, sys.argv[1:])
 
+        if rtevcfg.noload:
+            if rtevcfg.onlyload:
+                # Make up your mind!
+                raise RuntimeError('The --noload and --onlyload options are incompatible.')
+            loadmods = None
+
         # download kernel tarball
         if rtevcfg.srcdownload:
             logger.log(Log.DEBUG, f"Kernel Version to download = {rtevcfg.srcdownload}")
diff --git a/rteval/__init__.py b/rteval/__init__.py
index 226d14f80f48..4d3e0c23e5ab 100644
--- a/rteval/__init__.py
+++ b/rteval/__init__.py
@@ -46,9 +46,6 @@  class RtEval(rtevalReport):
         if not isinstance(config, rtevalConfig.rtevalConfig):
             raise TypeError("config variable is not an rtevalConfig object")
 
-        if not isinstance(loadmods, LoadModules):
-            raise TypeError("loadmods variable is not a LoadModules object")
-
         if not isinstance(measuremods, MeasurementModules):
             raise TypeError("measuremods variable is not a MeasurementModules object")
 
@@ -111,20 +108,21 @@  class RtEval(rtevalReport):
         except Exception as err:
             raise RuntimeError(f"Cannot create report directory (NFS with rootsquash on?) [{err}]]")
 
+        params = {'workdir':self.__rtevcfg.workdir,
+                  'reportdir':self.__reportdir and self.__reportdir or "",
+                  'builddir':builddir,
+                  'srcdir':self.__rtevcfg.srcdir,
+                  'verbose': self.__rtevcfg.verbose,
+                  'debugging': self.__rtevcfg.debugging,
+                  'numcores':self._sysinfo.cpu_getCores(True),
+                  'logging':self.__rtevcfg.logging,
+                  'memsize':self._sysinfo.mem_get_size(),
+                  'numanodes':self._sysinfo.mem_get_numa_nodes(),
+                  'duration': float(self.__rtevcfg.duration),
+                  }
+
         if self._loadmods:
             self.__logger.log(Log.INFO, "Preparing load modules")
-            params = {'workdir':self.__rtevcfg.workdir,
-                      'reportdir':self.__reportdir and self.__reportdir or "",
-                      'builddir':builddir,
-                      'srcdir':self.__rtevcfg.srcdir,
-                      'verbose': self.__rtevcfg.verbose,
-                      'debugging': self.__rtevcfg.debugging,
-                      'numcores':self._sysinfo.cpu_getCores(True),
-                      'logging':self.__rtevcfg.logging,
-                      'memsize':self._sysinfo.mem_get_size(),
-                      'numanodes':self._sysinfo.mem_get_numa_nodes(),
-                      'duration': float(self.__rtevcfg.duration),
-                      }
             self._loadmods.Setup(params)
 
         self.__logger.log(Log.INFO, "Preparing measurement modules")
@@ -144,15 +142,18 @@  class RtEval(rtevalReport):
 
             print(f"rteval run on {os.uname()[2]} started at {time.asctime()}")
             onlinecpus = self._sysinfo.cpu_getCores(True)
-            cpulist = self._loadmods._cfg.GetSection("loads").cpulist
-            if cpulist:
-                print(f"started {self._loadmods.ModulesLoaded()} loads on cores {cpulist}", end=' ')
-            else:
-                print(f"started {self._loadmods.ModulesLoaded()} loads on {onlinecpus} cores", end=' ')
-            if self._sysinfo.mem_get_numa_nodes() > 1:
-                print(f" with {self._sysinfo.mem_get_numa_nodes()} numa nodes")
-            else:
-                print("")
+            if self._loadmods:
+                cpulist = self._loadmods._cfg.GetSection("loads").cpulist
+                if cpulist:
+                    print(f"started {self._loadmods.ModulesLoaded()} loads on cores {cpulist}",
+                          end=' ')
+                else:
+                    print(f"started {self._loadmods.ModulesLoaded()} loads on {onlinecpus} cores",
+                          end=' ')
+                if self._sysinfo.mem_get_numa_nodes() > 1:
+                    print(f" with {self._sysinfo.mem_get_numa_nodes()} numa nodes")
+                else:
+                    print("")
             cpulist = self._measuremods._cfg.GetSection("measurement").cpulist
             if cpulist:
                 print(f"started measurement threads on cores {cpulist}")
@@ -192,7 +193,7 @@  class RtEval(rtevalReport):
                     if threading.active_count() < nthreads:
                         raise RuntimeError("load thread died!")
 
-                if not load_avg_checked:
+                if self._loadmods and not load_avg_checked:
                     self._loadmods.SaveLoadAvg()
                     load_avg_checked = 5
                 else:
@@ -202,7 +203,8 @@  class RtEval(rtevalReport):
                     left_to_run = stoptime - currtime
                     self.__show_remaining_time(left_to_run)
                     rpttime = currtime + report_interval
-                    print(f"load average: {self._loadmods.GetLoadAvg():.2f}")
+                    if self._loadmods:
+                        print(f"load average: {self._loadmods.GetLoadAvg():.2f}")
                 currtime = time.time()
 
             self.__logger.log(Log.DEBUG, "out of measurement loop")
diff --git a/rteval/rtevalReport.py b/rteval/rtevalReport.py
index 57d99f520f50..7379a7904f3f 100644
--- a/rteval/rtevalReport.py
+++ b/rteval/rtevalReport.py
@@ -57,7 +57,8 @@  class rtevalReport:
         self.__xmlreport.AppendXMLnodes(self._sysinfo.MakeReport())
 
         # Add load info
-        self.__xmlreport.AppendXMLnodes(self._loadmods.MakeReport())
+        if self._loadmods:
+            self.__xmlreport.AppendXMLnodes(self._loadmods.MakeReport())
 
         # Add measurement data
         self.__xmlreport.AppendXMLnodes(self._measuremods.MakeReport())