rteval/rteval-Allow-user-to-enter-...

134 lines
5.2 KiB
Diff

From 3bfd38808c1caeec5844984d4c85bf430f85f470 Mon Sep 17 00:00:00 2001
From: John Kacur <jkacur@redhat.com>
Date: Tue, 9 Aug 2022 17:32:44 -0400
Subject: [PATCH 14/19] rteval: Allow user to enter compressed cpu-lists, fix
reporting
Allow user to enter compressed cpu-lists (short form),
that is 0-4 instead of 0,1,2,3,4
Fix reporting, make sure that early reports consider offline cpus
For example
If the user specifies
su -c './rteval-cmd -d5s --loads-cpulist=2-4 --measurement-cpulist=0,9-11'
but cpu3 has been turned off, then we should see the following
started 3 loads on cores 2,4
started measurement threads on cores 0,9-11
and not
started 3 loads on cores 2-4
So, to summarize the changes here
1. Allow user to input compressed cpulists
2. Fix reporting using the shortened form of the cpulists as well
3. Adds the method online_cpulist(self, cpulist) to SysTopology that
returns the same list after removing offline cpus
4. converts one print to an f-string for --only-loads
5. Adds some more DEBUG messages
Signed-off-by: John Kacur <jkacur@redhat.com>
---
rteval-cmd | 37 +++++++++++++++++++++++++++----------
rteval/systopology.py | 6 +++++-
2 files changed, 32 insertions(+), 11 deletions(-)
diff --git a/rteval-cmd b/rteval-cmd
index 13fd5c6950b9..6a928362828f 100755
--- a/rteval-cmd
+++ b/rteval-cmd
@@ -49,10 +49,11 @@ from rteval import RtEval, rtevalConfig
from rteval.modules.loads import LoadModules
from rteval.modules.measurement import MeasurementModules
from rteval.version import RTEVAL_VERSION
-from rteval.systopology import CpuList, SysTopology
+from rteval.systopology import CpuList, SysTopology, collapse_cpulist
from rteval.modules.loads.kcompile import ModuleParameters
compress_cpulist = CpuList.compress_cpulist
+expand_cpulist = CpuList.expand_cpulist
def summarize(repfile, xslt):
""" Summarize an already existing XML report """
@@ -199,6 +200,11 @@ def parse_options(cfg, parser, cmdargs):
return cmd_args
+def remove_offline(cpulist):
+ """ return cpulist in collapsed compressed form with only online cpus """
+ tmplist = expand_cpulist(cpulist)
+ tmplist = SysTopology().online_cpulist(tmplist)
+ return collapse_cpulist(tmplist)
if __name__ == '__main__':
@@ -322,17 +328,29 @@ if __name__ == '__main__':
sys.exit(0)
- # if we only specified one set of cpus (loads or measurement)
- # default the other to the inverse of the specified list
ldcfg = config.GetSection('loads')
msrcfg = config.GetSection('measurement')
+ if ldcfg.cpulist and msrcfg.cpulist:
+ ldcfg.cpulist = remove_offline(ldcfg.cpulist)
+ msrcfg.cpulist = remove_offline(msrcfg.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:
- invlist = SysTopology().invert_cpulist(msrcfg.cpulist)
- ldcfg.cpulist = compress_cpulist(invlist)
+ tmplist = expand_cpulist(msrcfg.cpulist)
+ tmplist = SysTopology().invert_cpulist(tmplist)
+ ldcfg.cpulist = compress_cpulist(tmplist)
+ msrcfg.cpulist = remove_offline(msrcfg.cpulist)
if not msrcfg.cpulist and ldcfg.cpulist:
- invlist = SysTopology().invert_cpulist(ldcfg.cpulist)
- msrcfg.cpulist = compress_cpulist(invlist)
-
+ tmplist = expand_cpulist(ldcfg.cpulist)
+ tmplist = SysTopology().invert_cpulist(tmplist)
+ msrcfg.cpulist = compress_cpulist(tmplist)
+ ldcfg.cpulist = remove_offline(ldcfg.cpulist)
+
+ if ldcfg.cpulist:
+ logger.log(Log.DEBUG, f"loads cpulist: {ldcfg.cpulist}")
+ # if --onlyload is specified msrcfg.cpulist is unused
+ if msrcfg.cpulist and not rtevcfg.onlyload:
+ logger.log(Log.DEBUG, f"measurement cpulist: {msrcfg.cpulist}")
logger.log(Log.DEBUG, f"workdir: {rtevcfg.workdir}")
# if --summarize was specified then just parse the XML, print it and exit
@@ -374,8 +392,7 @@ if __name__ == '__main__':
# No reports will be created.
loadmods.Start()
nthreads = loadmods.Unleash()
- logger.log(Log.INFO, "Started %i load threads - will run for %f seconds" % (
- nthreads, rtevcfg.duration))
+ logger.log(Log.INFO, f"Started {nthreads} load threads - will run for {rtevcfg.duration} seconds")
logger.log(Log.INFO, "No measurements will be performed, due to the --onlyload option")
time.sleep(rtevcfg.duration)
loadmods.Stop()
diff --git a/rteval/systopology.py b/rteval/systopology.py
index ce8d02cf7318..26332c30bb0e 100644
--- a/rteval/systopology.py
+++ b/rteval/systopology.py
@@ -329,7 +329,11 @@ class SysTopology:
def invert_cpulist(self, cpulist):
""" return a list of online cpus not in cpulist """
- return [c for c in self.online_cpus_str() if c not in cpulist]
+ return [c for c in self.online_cpus() if c not in cpulist]
+
+ def online_cpulist(self, cpulist):
+ """ return a list of online cpus in cpulist """
+ return [c for c in self.online_cpus() if c in cpulist]
if __name__ == "__main__":
--
2.37.3