diff mbox series

[v2] rteval: Add relative cpulists for loads

Message ID 20240404081438.252394-1-tglozar@redhat.com
State New
Headers show
Series [v2] rteval: Add relative cpulists for loads | expand

Commit Message

Tomas Glozar April 4, 2024, 8:14 a.m. UTC
From: Tomas Glozar <tglozar@redhat.com>

Relative cpulists were added for measurements in 64ce7848 ("rteval: Add
relative cpulists for measurements"). It was observed since that this
feature would also be useful for load cpulists, for example when the
measurements are performed externally and rteval is only used to run
loads.

Add support for relative cpulists also for loads. This works the same
way as for measurements using parse_cpulist_from_config, only difference
is there is no --loads-run-on-isolcpus option. That is, --loads-cpulist
now also takes lists with addition (+) and removal (-) of CPUs against
the default list, e.g. +0,1,-7,8.

Signed-off-by: Tomas Glozar <tglozar@redhat.com>
---
 rteval-cmd | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

Comments

John Kacur April 5, 2024, 9:16 p.m. UTC | #1
On Thu, 4 Apr 2024, tglozar@redhat.com wrote:

> From: Tomas Glozar <tglozar@redhat.com>
> 
> Relative cpulists were added for measurements in 64ce7848 ("rteval: Add
> relative cpulists for measurements"). It was observed since that this
> feature would also be useful for load cpulists, for example when the
> measurements are performed externally and rteval is only used to run
> loads.
> 
> Add support for relative cpulists also for loads. This works the same
> way as for measurements using parse_cpulist_from_config, only difference
> is there is no --loads-run-on-isolcpus option. That is, --loads-cpulist
> now also takes lists with addition (+) and removal (-) of CPUs against
> the default list, e.g. +0,1,-7,8.
> 
> Signed-off-by: Tomas Glozar <tglozar@redhat.com>
> ---
>  rteval-cmd | 17 ++++++++++-------
>  1 file changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/rteval-cmd b/rteval-cmd
> index a5e8746..2ef6cf4 100755
> --- a/rteval-cmd
> +++ b/rteval-cmd
> @@ -339,29 +339,32 @@ if __name__ == '__main__':
>  
>          ldcfg = config.GetSection('loads')
>          msrcfg = config.GetSection('measurement')
> +        # Remember if cpulists were explicitly set by the user before running
> +        # parse_cpulist_from_config, which generates default value for them
>          msrcfg_cpulist_present = msrcfg.cpulist != ""
> -        # Parse measurement cpulist using parse_cpulist_from_config to account for run-on-isolcpus
> -        # and relative cpusets
> +        ldcfg_cpulist_present = ldcfg.cpulist != ""
> +        # Parse cpulists using parse_cpulist_from_config to account for
> +        # run-on-isolcpus and relative cpusets
>          cpulist = parse_cpulist_from_config(msrcfg.cpulist, msrcfg.run_on_isolcpus)
>          if msrcfg_cpulist_present and not cpulist_utils.is_relative(msrcfg.cpulist) and msrcfg.run_on_isolcpus:
>              logger.log(Log.WARN, "ignoring --measurement-run-on-isolcpus, since cpulist is specified")
>          msrcfg.cpulist = collapse_cpulist(cpulist)
> -        if ldcfg.cpulist:
> -            ldcfg.cpulist = remove_offline(ldcfg.cpulist)
> +        cpulist = parse_cpulist_from_config(ldcfg.cpulist)
> +        ldcfg.cpulist = collapse_cpulist(cpulist)
>          # if we only specified one set of cpus (loads or measurement)
>          # default the other to the inverse of the specified list
> -        if not ldcfg.cpulist and msrcfg_cpulist_present:
> +        if not ldcfg_cpulist_present and msrcfg_cpulist_present:
>              tmplist = expand_cpulist(msrcfg.cpulist)
>              tmplist = SysTopology().invert_cpulist(tmplist)
>              tmplist = cpulist_utils.online_cpulist(tmplist)
>              ldcfg.cpulist = collapse_cpulist(tmplist)
> -        if not msrcfg_cpulist_present and ldcfg.cpulist:
> +        if not msrcfg_cpulist_present and ldcfg_cpulist_present:
>              tmplist = expand_cpulist(ldcfg.cpulist)
>              tmplist = SysTopology().invert_cpulist(tmplist)
>              tmplist = cpulist_utils.online_cpulist(tmplist)
>              msrcfg.cpulist = collapse_cpulist(tmplist)
>  
> -        if ldcfg.cpulist:
> +        if ldcfg_cpulist_present:
>              logger.log(Log.DEBUG, f"loads cpulist: {ldcfg.cpulist}")
>          # if --onlyload is specified msrcfg.cpulist is unused
>          if msrcfg_cpulist_present and not rtevcfg.onlyload:
> -- 

Signed-off-by: John Kacur <jkacur@redhat.com>
diff mbox series

Patch

diff --git a/rteval-cmd b/rteval-cmd
index a5e8746..2ef6cf4 100755
--- a/rteval-cmd
+++ b/rteval-cmd
@@ -339,29 +339,32 @@  if __name__ == '__main__':
 
         ldcfg = config.GetSection('loads')
         msrcfg = config.GetSection('measurement')
+        # Remember if cpulists were explicitly set by the user before running
+        # parse_cpulist_from_config, which generates default value for them
         msrcfg_cpulist_present = msrcfg.cpulist != ""
-        # Parse measurement cpulist using parse_cpulist_from_config to account for run-on-isolcpus
-        # and relative cpusets
+        ldcfg_cpulist_present = ldcfg.cpulist != ""
+        # Parse cpulists using parse_cpulist_from_config to account for
+        # run-on-isolcpus and relative cpusets
         cpulist = parse_cpulist_from_config(msrcfg.cpulist, msrcfg.run_on_isolcpus)
         if msrcfg_cpulist_present and not cpulist_utils.is_relative(msrcfg.cpulist) and msrcfg.run_on_isolcpus:
             logger.log(Log.WARN, "ignoring --measurement-run-on-isolcpus, since cpulist is specified")
         msrcfg.cpulist = collapse_cpulist(cpulist)
-        if ldcfg.cpulist:
-            ldcfg.cpulist = remove_offline(ldcfg.cpulist)
+        cpulist = parse_cpulist_from_config(ldcfg.cpulist)
+        ldcfg.cpulist = collapse_cpulist(cpulist)
         # if we only specified one set of cpus (loads or measurement)
         # default the other to the inverse of the specified list
-        if not ldcfg.cpulist and msrcfg_cpulist_present:
+        if not ldcfg_cpulist_present and msrcfg_cpulist_present:
             tmplist = expand_cpulist(msrcfg.cpulist)
             tmplist = SysTopology().invert_cpulist(tmplist)
             tmplist = cpulist_utils.online_cpulist(tmplist)
             ldcfg.cpulist = collapse_cpulist(tmplist)
-        if not msrcfg_cpulist_present and ldcfg.cpulist:
+        if not msrcfg_cpulist_present and ldcfg_cpulist_present:
             tmplist = expand_cpulist(ldcfg.cpulist)
             tmplist = SysTopology().invert_cpulist(tmplist)
             tmplist = cpulist_utils.online_cpulist(tmplist)
             msrcfg.cpulist = collapse_cpulist(tmplist)
 
-        if ldcfg.cpulist:
+        if ldcfg_cpulist_present:
             logger.log(Log.DEBUG, f"loads cpulist: {ldcfg.cpulist}")
         # if --onlyload is specified msrcfg.cpulist is unused
         if msrcfg_cpulist_present and not rtevcfg.onlyload: