rteval: Added functionality to allow user to set the cstate of specified cpus when running rteval
PATCH v4 1/1 rteval: Added functionality to allow user to set the cstate of specified cpus when running rteval
We would like to be able to set the idle states of CPUs while running rteval.
This patch adds the file cpupower.py and option '--idle-set' within rteval to use cpupower. The set idle state is applied to the cpulist given by '--measurement-cpulist'.
cpupower.py provides the infrastructure to interface and execute the cpupower command, and the options in rteval-cmd let the user specify the idle state to be set and the CPUs to set it on.
--- rteval-cmd | 22 ++++++++- rteval/cpupower.py | 94 ++++++++++++++++++++++++++++++++++++++ rteval/modules/__init__.py | 2 +- 3 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 rteval/cpupower.py
rteval-cmd +21 -1
@@ -29,6 +29,7 @@ from rteval.Log import Log from rteval import RtEval, rtevalConfig from rteval.modules.loads import LoadModules from rteval.modules.measurement import MeasurementModules +from rteval import cpupower from rteval.version import RTEVAL_VERSION from rteval.systopology import SysTopology, parse_cpulist_from_config from rteval.modules.loads.kcompile import ModuleParameters
@@ -146,7 +147,8 @@ 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('--idle-set', dest='rteval___idlestate', metavar='IDLESTATE', + default=None, help='Idle state to enable for this rteval run') if not cmdargs: cmdargs = ["--help"]
@@ -169,6 +171,12 @@ def parse_options(cfg, parser, cmdargs): cmd_args = cmdargs[ind+1:] cmdargs = cmdargs[:ind+1] + # if --cpulist is specified, make sure --idle-set is too + if ((sys.argv.count('-c')+sys.argv.count('--cpulist')) > 0) and \ + (sys.argv.count('--idle-set') == 0): + print('--cpulist must be used with --idle-set') + cmdargs = ["--help"] + cmd_opts = parser.parse_args(args=cmdargs) # if no kernel version was provided for --source-download, set version to default
@@ -263,6 +271,9 @@ if __name__ == '__main__': | (rtevcfg.debugging and Log.DEBUG) logger.SetLogVerbosity(loglev) + # check if cpupower is being used + if sys.argv.count('--idle-set') > 0: + rtevcfg.update({'usingCpupower': True}) # Load modules loadmods = LoadModules(config, logger=logger) measuremods = MeasurementModules(config, logger=logger)
@@ -394,6 +405,11 @@ if __name__ == '__main__': if not os.path.isdir(rtevcfg.workdir): raise RuntimeError(f"work directory {rtevcfg.workdir} does not exist") + # if idle-set has been specified, enable idlestate in rtecfg.cpulist + cpupower_controller = None + if rtevcfg.idlestate: + cpupower_controller = cpupower.Cpupower(msrcfg.cpulist, rtevcfg.idlestate) + cpupower_controller.enable_idle_state() rteval = RtEval(config, loadmods, measuremods, logger) rteval.Prepare(rtevcfg.onlyload)
@@ -413,6 +429,10 @@ if __name__ == '__main__': ec = rteval.Measure() logger.log(Log.DEBUG, f"exiting with exit code: {ec}") + # reset idlestate + if rtevcfg.idlestate: + cpupower_controller.restore_cstate() + sys.exit(ec) except KeyboardInterrupt: sys.exit(0)
rteval/cpupower.py new file +94 -0
94 lines not on this page · raw message
rteval/modules/__init__.py +1 -1
@@ -284,7 +284,7 @@ the information provided by the module""" grparser.add_argument(f'--{self.__modtype}-cpulist', dest=f'{self.__modtype}___cpulist', action='store', default="", help=f'CPU list where {self.__modtype} modules will run', - metavar='LIST') + metavar='CPULIST') for (modname, mod) in list(self.__modsloaded.items()): opts = mod.ModuleParameters()
Signature · 1 line
2.45.2
PATCH v4 1/1 rteval: run cyclictest using '--default-system' when setting idle states
When running cyclictest in rteval, cyclictest automatically disables idle states. This means whenever the user sets the idle state of a cpu list using '--idle-set' it is overridden by cyclictest.
To fix this, the variable 'usingCpupower' is appended to the parameter dictionary that's passed to the Cyclictest measurement object which executes cyclictest in rteval.
If '--idle-set' is specified when running rteval, 'usingCpupower' is set to true and the '--default-system' option is appended to the cyclictest command, which will prevent cyclictest from disabling cstates.
--- rteval/__init__.py | 3 ++- rteval/modules/measurement/cyclictest.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-)
rteval/__init__.py +2 -1
@@ -124,7 +124,8 @@ class RtEval(rtevalReport): 'memsize':self._sysinfo.mem_get_size(), 'numanodes':self._sysinfo.mem_get_numa_nodes(), 'duration': float(self.__rtevcfg.duration), - } + 'usingCpupower': self.__rtevcfg.usingCpupower + } self._loadmods.Setup(params) self.__logger.log(Log.INFO, "Preparing measurement modules")
rteval/modules/measurement/cyclictest.py +3 -0
@@ -251,6 +251,9 @@ class Cyclictest(rtevalModulePrototype): self.__cmd.append(f'-t{self.__numcores}') self.__cmd.append(f'-a{self.__cpulist}') + if (self.__cfg.usingCpupower): + self.__cmd.append('--default-system') + if 'threads' in self.__cfg and self.__cfg.threads: self.__cmd.append(f"-t{int(self.__cfg.threads)}")
Signature · 1 line
2.45.2
Quoted 7 lines · Anubhav Shelat
We would like to be able to set the idle states of CPUs while running rteval.
This patch adds the file
cpupower.pyand option '--idle-set' within rteval to use cpupower. The set idle state is applied to the cpulist given by '--measurement-cpulist'.
Quoted 5 lines
cpupower.pyprovides the infrastructure to interface and execute the cpupower command, and the options in rteval-cmd let the user specify the idle state to be set and the CPUs to set it on.Signed-off-by Anubhav Shelat <[email protected]>
Hi Anubhav
Your patches are not applying, are you sure that you updated your local git repo to the latest before generating your patches?
Thanks
John Kacur