diff mbox series

[v2,2/3] rteval: Add run_on_isolcpus option to measurements

Message ID 20230811095228.200772-3-tglozar@redhat.com
State New
Headers show
Series rteval: Add cmdline option to run measurements on isolcpus by default | expand

Commit Message

Tomas Glozar Aug. 11, 2023, 9:52 a.m. UTC
Add option --measurement-run-on-isolcpus for the user to specify to
include isolcpus in the default cpulist (without --measurement-cpulist).

A default value might also be specified in rteval.conf:
[measurement]
run-on-isolcpus: true

Note that values different from true evaluate as false.

Signed-off-by: Tomas Glozar <tglozar@redhat.com>
---
 rteval/modules/measurement/__init__.py | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

Comments

John Kacur Sept. 15, 2023, 7:01 p.m. UTC | #1
On Fri, 11 Aug 2023, Tomas Glozar wrote:

> Add option --measurement-run-on-isolcpus for the user to specify to
> include isolcpus in the default cpulist (without --measurement-cpulist).
> 
> A default value might also be specified in rteval.conf:
> [measurement]
> run-on-isolcpus: true
> 
> Note that values different from true evaluate as false.
> 
> Signed-off-by: Tomas Glozar <tglozar@redhat.com>
> ---
>  rteval/modules/measurement/__init__.py | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/rteval/modules/measurement/__init__.py b/rteval/modules/measurement/__init__.py
> index 0e395be..5258dd7 100644
> --- a/rteval/modules/measurement/__init__.py
> +++ b/rteval/modules/measurement/__init__.py
> @@ -146,7 +146,15 @@ measurement profiles, based on their characteristics"""
>  
>      def SetupModuleOptions(self, parser):
>          "Sets up all the measurement modules' parameters for the option parser"
> -        self.__container.SetupModuleOptions(parser, self.__cfg)
> +        grparser = self.__container.SetupModuleOptions(parser, self.__cfg)
> +
> +        # Set up options specific for measurement module group
> +        grparser.add_argument("--measurement-run-on-isolcpus",
> +                              dest="measurement___run_on_isolcpus",
> +                              action="store_true",
> +                              default=self.__cfg.GetSection("measurement").setdefault("run-on-isolcpus", "false").lower()
> +                                      == "true",
> +                              help="Include isolated CPUs in default cpulist")
>  
>  
>      def Setup(self, modparams):
> @@ -157,9 +165,10 @@ measurement profiles, based on their characteristics"""
>  
>          modcfg = self.__cfg.GetSection("measurement")
>          cpulist = modcfg.cpulist
> +        run_on_isolcpus = modcfg.run_on_isolcpus
>  
>          for (modname, modtype) in modcfg:
> -            if modtype.lower() == 'module':  # Only 'module' will be supported (ds)
> +            if isinstance(modtype, str) and modtype.lower() == 'module':  # Only 'module' will be supported (ds)
>                  # Extract the measurement modules info
>                  modinfo = self.__container.ModuleInfo(modname)
>  
> @@ -179,6 +188,7 @@ measurement profiles, based on their characteristics"""
>                  # Setup this imported module inside the appropriate measurement profile
>                  self.__cfg.AppendConfig(modname, modparams)
>                  self.__cfg.AppendConfig(modname, {'cpulist':cpulist})
> +                self.__cfg.AppendConfig(modname, {'run-on-isolcpus':run_on_isolcpus})
>                  mp.Setup(modname)
>  
>          del self.__container
> @@ -190,11 +200,12 @@ measurement profiles, based on their characteristics"""
>          # Get the reports from all meaurement modules in all measurement profiles
>          rep_n = libxml2.newNode("Measurements")
>          cpulist = self.__cfg.GetSection("measurement").cpulist
> +        run_on_isolcpus = self.__cfg.GetSection("measurement").run_on_isolcpus
>          if cpulist:
>              # Convert str to list and remove offline cpus
>              cpulist = CpuList(cpulist).cpulist
>          else:
> -            cpulist = SysTop().default_cpus()
> +            cpulist = SysTop().online_cpus() if run_on_isolcpus else SysTop().default_cpus()
>          rep_n.newProp("measurecpus", collapse_cpulist(cpulist))
>  
>          for mp in self.__measureprofiles:
> -- 
> 2.41.0
> 
> 
Signed-off-by: John Kacur <jkacur@redhat.com>
John Kacur Sept. 15, 2023, 7:06 p.m. UTC | #2
On Fri, 11 Aug 2023, Tomas Glozar wrote:

> Add option --measurement-run-on-isolcpus for the user to specify to
> include isolcpus in the default cpulist (without --measurement-cpulist).
> 
> A default value might also be specified in rteval.conf:
> [measurement]
> run-on-isolcpus: true
> 
> Note that values different from true evaluate as false.
> 
> Signed-off-by: Tomas Glozar <tglozar@redhat.com>
> ---
>  rteval/modules/measurement/__init__.py | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/rteval/modules/measurement/__init__.py b/rteval/modules/measurement/__init__.py
> index 0e395be..5258dd7 100644
> --- a/rteval/modules/measurement/__init__.py
> +++ b/rteval/modules/measurement/__init__.py
> @@ -146,7 +146,15 @@ measurement profiles, based on their characteristics"""
>  
>      def SetupModuleOptions(self, parser):
>          "Sets up all the measurement modules' parameters for the option parser"
> -        self.__container.SetupModuleOptions(parser, self.__cfg)
> +        grparser = self.__container.SetupModuleOptions(parser, self.__cfg)
> +
> +        # Set up options specific for measurement module group
> +        grparser.add_argument("--measurement-run-on-isolcpus",
> +                              dest="measurement___run_on_isolcpus",
> +                              action="store_true",
> +                              default=self.__cfg.GetSection("measurement").setdefault("run-on-isolcpus", "false").lower()
> +                                      == "true",
> +                              help="Include isolated CPUs in default cpulist")
>  
>  
>      def Setup(self, modparams):
> @@ -157,9 +165,10 @@ measurement profiles, based on their characteristics"""
>  
>          modcfg = self.__cfg.GetSection("measurement")
>          cpulist = modcfg.cpulist
> +        run_on_isolcpus = modcfg.run_on_isolcpus
>  
>          for (modname, modtype) in modcfg:
> -            if modtype.lower() == 'module':  # Only 'module' will be supported (ds)
> +            if isinstance(modtype, str) and modtype.lower() == 'module':  # Only 'module' will be supported (ds)
>                  # Extract the measurement modules info
>                  modinfo = self.__container.ModuleInfo(modname)
>  
> @@ -179,6 +188,7 @@ measurement profiles, based on their characteristics"""
>                  # Setup this imported module inside the appropriate measurement profile
>                  self.__cfg.AppendConfig(modname, modparams)
>                  self.__cfg.AppendConfig(modname, {'cpulist':cpulist})
> +                self.__cfg.AppendConfig(modname, {'run-on-isolcpus':run_on_isolcpus})
>                  mp.Setup(modname)
>  
>          del self.__container
> @@ -190,11 +200,12 @@ measurement profiles, based on their characteristics"""
>          # Get the reports from all meaurement modules in all measurement profiles
>          rep_n = libxml2.newNode("Measurements")
>          cpulist = self.__cfg.GetSection("measurement").cpulist
> +        run_on_isolcpus = self.__cfg.GetSection("measurement").run_on_isolcpus
>          if cpulist:
>              # Convert str to list and remove offline cpus
>              cpulist = CpuList(cpulist).cpulist
>          else:
> -            cpulist = SysTop().default_cpus()
> +            cpulist = SysTop().online_cpus() if run_on_isolcpus else SysTop().default_cpus()
>          rep_n.newProp("measurecpus", collapse_cpulist(cpulist))
>  
>          for mp in self.__measureprofiles:
> -- 
> 2.41.0
> 
> 
Signed-off-by: John Kacur <jkacur@redhat.com>
diff mbox series

Patch

diff --git a/rteval/modules/measurement/__init__.py b/rteval/modules/measurement/__init__.py
index 0e395be..5258dd7 100644
--- a/rteval/modules/measurement/__init__.py
+++ b/rteval/modules/measurement/__init__.py
@@ -146,7 +146,15 @@  measurement profiles, based on their characteristics"""
 
     def SetupModuleOptions(self, parser):
         "Sets up all the measurement modules' parameters for the option parser"
-        self.__container.SetupModuleOptions(parser, self.__cfg)
+        grparser = self.__container.SetupModuleOptions(parser, self.__cfg)
+
+        # Set up options specific for measurement module group
+        grparser.add_argument("--measurement-run-on-isolcpus",
+                              dest="measurement___run_on_isolcpus",
+                              action="store_true",
+                              default=self.__cfg.GetSection("measurement").setdefault("run-on-isolcpus", "false").lower()
+                                      == "true",
+                              help="Include isolated CPUs in default cpulist")
 
 
     def Setup(self, modparams):
@@ -157,9 +165,10 @@  measurement profiles, based on their characteristics"""
 
         modcfg = self.__cfg.GetSection("measurement")
         cpulist = modcfg.cpulist
+        run_on_isolcpus = modcfg.run_on_isolcpus
 
         for (modname, modtype) in modcfg:
-            if modtype.lower() == 'module':  # Only 'module' will be supported (ds)
+            if isinstance(modtype, str) and modtype.lower() == 'module':  # Only 'module' will be supported (ds)
                 # Extract the measurement modules info
                 modinfo = self.__container.ModuleInfo(modname)
 
@@ -179,6 +188,7 @@  measurement profiles, based on their characteristics"""
                 # Setup this imported module inside the appropriate measurement profile
                 self.__cfg.AppendConfig(modname, modparams)
                 self.__cfg.AppendConfig(modname, {'cpulist':cpulist})
+                self.__cfg.AppendConfig(modname, {'run-on-isolcpus':run_on_isolcpus})
                 mp.Setup(modname)
 
         del self.__container
@@ -190,11 +200,12 @@  measurement profiles, based on their characteristics"""
         # Get the reports from all meaurement modules in all measurement profiles
         rep_n = libxml2.newNode("Measurements")
         cpulist = self.__cfg.GetSection("measurement").cpulist
+        run_on_isolcpus = self.__cfg.GetSection("measurement").run_on_isolcpus
         if cpulist:
             # Convert str to list and remove offline cpus
             cpulist = CpuList(cpulist).cpulist
         else:
-            cpulist = SysTop().default_cpus()
+            cpulist = SysTop().online_cpus() if run_on_isolcpus else SysTop().default_cpus()
         rep_n.newProp("measurecpus", collapse_cpulist(cpulist))
 
         for mp in self.__measureprofiles: