Changes to supply a customer kernel
cover Changes to supply a customer kernel
rteval compiles the linux kernel as a load for measuring real-time performance.
If you need to supply a custom kernel for kcompile, these patches allow you to do so with a "-rteval", for example linux-6.10.5-rteval
These patches allow you to do this by adding the ability to parse kernels with that naming scheme. They also fix a problem in which a kcompile would not always compile the correct kernel. For example, if you requested a 6.10.5, kcompile could end up compiling 6.10.5-rteval instead.
If you are using an up-to-date distro, with a newer tool chain, the kernel that was the default in rteval could fail to compile, so I updated it to linux-6.10.5 as the default as well.
When testing these changes, I noticed that the --kcompile-source option had disappeared, so I fixed this as well.
John Kacur (3):
rteval: restore all load module options
rteval: Upgrade load kernel to linux-6.10.5
rteval: Fix parsing in kcompile of the kernel to compile
Dockerfile | 2 +- Makefile | 2 +- rteval/modules/__init__.py | 22 +++++++++++++---- rteval/modules/loads/kcompile.py | 34 ++++++++++++++++---------- rteval/modules/measurement/__init__.py | 12 +-------- rteval/rteval.conf | 2 +- 6 files changed, 42 insertions(+), 32 deletions(-)
Signature · 1 line
2.46.0
PATCH 1/3 rteval: restore all load module options
Commit 56c7cf63942d rteval: Allow arguments specific to module group
intended to allow group options to the overall measurement modules without applying to the load modules. It inadvertently disabled options for most load modules such as hackbench and kcompile.
This patch reworks the overall group mechanism a little bit to restore these menus.
--- rteval/modules/__init__.py | 22 +++++++++++++++++----- rteval/modules/measurement/__init__.py | 12 +----------- 2 files changed, 18 insertions(+), 16 deletions(-)
rteval/modules/__init__.py +17 -5
@@ -280,10 +280,24 @@ reference from the first import""" grparser = parser.add_argument_group(f"Group Options for {self.__modtype} modules") grparser.add_argument(f'--{self.__modtype}-cpulist', - dest=f'{self.__modtype}___cpulist', action='store', default="", + dest=f'{self.__modtype}___cpulist', action='store', + default="", help=f'CPU list where {self.__modtype} modules will run', metavar='CPULIST') + # Set up options for measurement modules only + if self.__modtype == 'measurement': + grparser.add_argument(f'--{self.__modtype}-run-on-isolcpus', + dest = f'{self.__modtype}___run_on_isolcpus', + action = "store_true", + default = config.GetSection("measurement").setdefault("run-on-isolcpus", "false").lower() == "true", + help = "Include isolated CPUs in default cpulist") + grparser.add_argument('--idle-set', + dest='measurement___idlestate', + metavar='IDLESTATE', + default=None, + help='Idle state depth to set on cpus running measurement modules') + for (modname, mod) in list(self.__modsloaded.items()): opts = mod.ModuleParameters() if len(opts) == 0:
@@ -296,7 +310,7 @@ reference from the first import""" # Ignore if a section is not found cfg = None - modgrparser = parser.add_argument_group(f"Options for the {shortmod} module") + grparser = parser.add_argument_group(f"Options for the {shortmod} module") for (o, s) in list(opts.items()): descr = 'descr' in s and s['descr'] or "" metavar = 'metavar' in s and s['metavar'] or None
@@ -311,7 +325,7 @@ reference from the first import""" default = 'default' in s and s['default'] or None - modgrparser.add_argument(f'--{shortmod}-{o}', + grparser.add_argument(f'--{shortmod}-{o}', dest=f"{shortmod}___{o}", action='store', help='%s%s' % (descr,
@@ -319,8 +333,6 @@ reference from the first import""" default=default, metavar=metavar) - return grparser - def InstantiateModule(self, modname, modcfg, modroot=None): """Imports a module and instantiates an object from the modules create() function.
rteval/modules/measurement/__init__.py +1 -11
@@ -29,17 +29,7 @@ class MeasurementModules(RtEvalModules): def SetupModuleOptions(self, parser): "Sets up all the measurement modules' parameters for the option parser" - grparser = super().SetupModuleOptions(parser) - - # 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") - grparser.add_argument('--idle-set', dest='measurement___idlestate', metavar='IDLESTATE', - default=None, help='Idle state depth to set on cpus running measurement modules') + super().SetupModuleOptions(parser) def Setup(self, modparams):
Signature · 1 line
2.46.0
Re: [PATCH 1/3] rteval: restore all load module options
Quoted 5 lines · John Kacur
Commit 56c7cf63942d rteval: Allow arguments specific to module group
intended to allow group options to the overall measurement modules without applying to the load modules. It inadvertently disabled options for most load modules such as hackbench and kcompile.
How did that happen and how does this fix it?
(not saying it doesn't, just that clarifying that would help with reviewing and not introducing something similar in the future)
Quoted 3 lines
This patch reworks the overall group mechanism a little bit to restore these menus.
Menus?
Quoted 11 lines
+ # Set up options for measurement modules only
+ if self.__modtype == 'measurement':
+ grparser.add_argument(f'--{self.__modtype}-run-on-isolcpus', + dest = f'{self.__modtype}___run_on_isolcpus',
+ action = "store_true",
+ default = config.GetSection("measurement").setdefault("run-on-isolcpus", "false").lower() == "true",
+ help = "Include isolated CPUs in default cpulist")
You already know it's measurement in this section, so why {self.__modtype}?
Why does this need to be here rather than in rteval/modules/measurement.py?
Quoted 24 lines
for (modname, mod) in list(self.__modsloaded.items()):
opts =mod.ModuleParameters()
if len(opts) == 0:rteval/modules/__init__.py +0
-0@@ -296,7 +310,7 @@ reference from the first import""" # Ignore if a section is not foundcfg = None
- modgrparser =parser.add_argument_group(f"Options for the {shortmod} module")
+ grparser =parser.add_argument_group(f"Options for the {shortmod} module")
for (o, s) in list(opts.items()):
descr = 'descr' in s and s['descr'] or "" metavar = 'metavar' in s and s['metavar'] or None(quoted diff) +0
-0@@ -311,7 +325,7 @@ reference from the first import"""default = 'default' in s and s['default'] or None
- modgrparser.add_argument(f'--{shortmod}-{o}', + grparser.add_argument(f'--{shortmod}-{o}', dest=f"{shortmod}___{o}", action='store', help='%s%s' % (descr,
rteval/modules/__init__.py reference from the first import""" · line 334
Quoted 2 lines
rteval/modules/__init__.py +0
-0@@ -319,8 +333,6 @@ reference from the first import""" default=default, metavar=metavar)
Wouldn't "modparser" be more accurate, since this isn't for the entire group?
Or we could reuse the mechanism for both group and module level (maybe s/ModuleParameters/Parameters/) if it's not introducing more complexity than it eliminates.
Quoted 19 lines
rteval/modules/measurement/__init__.py +0
-0@@ -29,17 +29,7 @@ class MeasurementModules(RtEvalModules):
defSetupModuleOptions(self, parser):
"Sets up all the measurement modules' parameters for the option parser"
- grparser = super().SetupModuleOptions(parser)
-
- # 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()
Quoted 8 lines
- == "true",
- help="Include isolated CPUs in default cpulist")
- grparser.add_argument('--idle-set', dest='measurement___idlestate', metavar='IDLESTATE',
- default=None, help='Idle state depth to set on cpus running measurement modules')
+ super().SetupModuleOptions(parser)
Why is this method still here if all it does is call super?
-Crystal
Re: [PATCH 1/3] rteval: restore all load module options
po 19. 8. 2024 v 22:40 odesílatel Crystal Wood <[email protected]> napsal:
Quoted 12 lines · John Kacur
Quoted 5 lines
Commit
56c7cf63942drteval: Allow arguments specific to module groupintended to allow group options to the overall measurement modules without applying to the load modules. It inadvertently disabled options for most load modules such as hackbench and kcompile.
How did that happen and how does this fix it?
(not saying it doesn't, just that clarifying that would help with reviewing and not introducing something similar in the future)
The bug in commit 56c7cf63942d is that the "return grparser" command is indented one tab more than intended (no pun intended), putting it inside the for loop iterating over list(opts.items()). This leads to only the first module's arguments to be applied in the case of both measurements and loads, since the return exists from the loop before the rest can be processed.
Quoted 6 lines
Quoted 3 lines
This patch reworks the overall group mechanism a little bit to restore these menus.
Menus?
The module command-line options, as defined by ModuleParameters() module-level functions e.g. in rteval/modules/loads/hackbench.py.
Quoted 80 lines
Quoted 11 lines
rteval/modules/__init__.py +4
-0+ # Set up options for measurement modules only + if self.__modtype == 'measurement': + grparser.add_argument(f'--{self.__modtype}-run-on-isolcpus', + dest =f'{self.__modtype}___run_on_isolcpus',
(quoted diff) +2
-0+ action = "store_true", + default =config.GetSection("measurement").setdefault("run-on-isolcpus", "false").lower() == "true",
+ help = "Include isolated CPUs in
default cpulist")You already know it's measurement in this section, so why {self.__modtype}?
Why does this need to be here rather than in
rteval/modules/measurement.py?Quoted 24 lines
for (modname, mod) in list(self.__modsloaded.items()):
opts =mod.ModuleParameters()
if len(opts) == 0:rteval/modules/__init__.py +1
-1@@ -296,7 +310,7 @@ reference from the first import""" # Ignore if a section is not found cfg = None - modgrparser = parser.add_argument_group(f"Options for the {shortmod} module") + grparser = parser.add_argument_group(f"Options for the {shortmod} module") for (o, s) in list(opts.items()):descr = 'descr' in s and s['descr'] or "" metavar = 'metavar' in s and s['metavar'] or None
rteval/modules/__init__.py +1
-1@@ -311,7 +325,7 @@ reference from the first import""" default = 'default' in s and s['default'] or None - modgrparser.add_argument(f'--{shortmod}-{o}', + grparser.add_argument(f'--{shortmod}-{o}', dest=f"{shortmod}___{o}", action='store', help='%s%s' % (descr,rteval/modules/__init__.py reference from the first import""" · line 334
Quoted 2 lines
rteval/modules/__init__.py +0
-0@@ -319,8 +333,6 @@ reference from the first import""" default=default, metavar=metavar)Wouldn't "modparser" be more accurate, since this isn't for the entire group?
Or we could reuse the mechanism for both group and module level (maybe s/ModuleParameters/Parameters/) if it's not introducing more complexity than it eliminates.
Quoted 21 lines
rteval/modules/measurement/__init__.py +0
-0@@ -29,17 +29,7 @@ class MeasurementModules(RtEvalModules): def SetupModuleOptions(self, parser): "Sets up all the measurement modules' parameters for the optionparser"
rteval/modules/measurement/__init__.py +0
-7- grparser = super().SetupModuleOptions(parser) - - # 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()
rteval/modules/measurement/__init__.py +0
-2- == "true", - help="Include isolated CPUs in defaultQuoted 6 lines
cpulist")
- grparser.add_argument('--idle-set',
dest='measurement___idlestate', metavar='IDLESTATE',
- default=None, help='Idle state depth to set on
cpus running measurement modules')
+ super().SetupModuleOptions(parser)Why is this method still here if all it does is call super?
Quoted 2 lines
-Crystal
The super() call is there to get the parent class. It should rather be RtEvalModules.SetupModuleOptions(self, parser) so that the parent constructor does not get called again redundantly.
I suggest reverting this commit and going back to my original implementation, which does not have the issues you are pointing out here (measurement options outside of measurement modules and overriding the grparser variable). We will discuss this offline and give an update soon.
Tomas
PATCH 2/3 rteval: Upgrade load kernel to linux-6.10.5
In reply to John KacurThe older kernel fails to compile on newer tool chains, so upgrade the kernel that kcompile compiles as a load to linux-6.10.5
--- Dockerfile | 2 +- Makefile | 2 +- rteval/modules/loads/kcompile.py | 4 ++-- rteval/rteval.conf | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-)
Dockerfile +1 -1
@@ -1,7 +1,7 @@ # Use CentOS Stream 9 as base image FROM centos:stream9 -ARG KERNEL_VERSION=linux-6.6.1.tar.xz +ARG KERNEL_VERSION=linux-6.10.5.tar.xz # Copy current directory to /opt/rteval/
Makefile +1 -1
@@ -14,7 +14,7 @@ PREFIX := /usr DATADIR := $(DESTDIR)/$(PREFIX)/share LOADDIR := loadsource -KLOAD := $(LOADDIR)/linux-6.6.1.tar.xz +KLOAD := $(LOADDIR)/linux-6.10.5.tar.xz BLOAD := $(LOADDIR)/dbench-4.0.tar.gz LOADS := $(KLOAD) $(BLOAD)
rteval/modules/loads/kcompile.py +2 -2
@@ -21,7 +21,7 @@ expand_cpulist = cpulist_utils.expand_cpulist compress_cpulist = cpulist_utils.compress_cpulist nonisolated_cpulist = cpulist_utils.nonisolated_cpulist -DEFAULT_KERNEL_PREFIX = "linux-6.6" +DEFAULT_KERNEL_PREFIX = "linux-6.10.5" class KBuildJob: '''Class to manage a build job bound to a particular node'''
@@ -334,7 +334,7 @@ class Kcompile(CommandLineLoad): def ModuleParameters(): return {"source": {"descr": "Source tar ball", - "default": "linux-6.6.1.tar.xz", + "default": "linux-6.10.5.tar.xz", "metavar": "TARBALL"}, "jobspercore": {"descr": "Number of working threads per core", "default": 2,
rteval/rteval.conf +1 -1
@@ -18,7 +18,7 @@ dbench: external stressng: module [kcompile] -source: linux-6.6.1.xz +source: linux-6.10.5.xz jobspercore: 2 [hackbench]
Signature · 1 line
2.46.0
Re: [PATCH 2/3] rteval: Upgrade load kernel to linux-6.10.5
Quoted 10 lines · John Kacur
The older kernel fails to compile on newer tool chains, so upgrade the kernel that kcompile compiles as a load to linux-6.10.5
Signed-off-by John Kacur <[email protected]>---
Dockerfile | 2 +-
Makefile | 2 +-
rteval/modules/loads/kcompile.py | 4 ++--
rteval/rteval.conf | 2 +-4 files changed, 5 insertions(+), 5 deletions(-)
Should we add a make target to fetch the tarball if it's not there, rather than make the user look up the url to fetch from and figure out where to stick it?
-Crystal
Re: [PATCH 2/3] rteval: Upgrade load kernel to linux-6.10.5
In reply to John KacurQuoted 9 lines · John Kacur
The older kernel fails to compile on newer tool chains, so upgrade the kernel that kcompile compiles as a load to linux-6.10.5
Signed-off-by John Kacur <[email protected]>---
Dockerfile | 2 +-
Makefile | 2 +-
rteval/modules/loads/kcompile.py | 4 ++--
rteval/rteval.conf | 2 +-
Wait, there's both an rteval.conf and an rteval/rteval.conf?
Quoted 33 lines
rteval/modules/loads/kcompile.py +0
-0@@ -21,7 +21,7 @@ expand_cpulist = cpulist_utils.expand_cpulistcompress_cpulist = cpulist_utils.compress_cpulist
nonisolated_cpulist= cpulist_utils.nonisolated_cpulistrteval/modules/loads/kcompile.py +1
-1-DEFAULT_KERNEL_PREFIX = "linux-6.6" +DEFAULT_KERNEL_PREFIX = "linux-6.10.5"
class KBuildJob:
'''Class to manage a build job bound to a particular node'''rteval/modules/loads/kcompile.py +0
-0@@ -334,7 +334,7 @@ class Kcompile(CommandLineLoad):
defModuleParameters():
return {"source": {"descr": "Source tar ball",
- "default": "linux-6.6.1.tar.xz", + "default": "linux-6.10.5.tar.xz", "metavar": "TARBALL"}, "jobspercore": {"descr": "Number of working threads per core",
"default": 2,rteval/rteval.conf +0
-0@@ -18,7 +18,7 @@ dbench: externalstressng: module
[kcompile]
rteval/rteval.conf dbench: external · line 21
Quoted 2 lines
rteval/rteval.conf +1
-1-source: linux-6.6.1.xz +source: linux-6.10.5.xz
Why does this not have .tar in the name, while both the default and the actual filename do?
-Crystal
PATCH 3/3 rteval: Fix parsing in kcompile of the kernel to compile
In reply to John KacurThis patch does two things.
1. It allows you to create your own customer kernel with a dash -rteval in the name, eg, linux-6.10.5-rteval
2. It fixes parsing of the kernel name so that if the user requests linux-6.10.5 it doesn't use linux-6.10.6-rteval instead
--- rteval/modules/loads/kcompile.py | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-)
rteval/modules/loads/kcompile.py +19 -11
@@ -122,6 +122,8 @@ class Kcompile(CommandLineLoad): self.cpulist = config.cpulist CommandLineLoad.__init__(self, "kcompile", config, logger) self.logger = logger + self._kernel_prefix = "" + self._log(Log.DEBUG, f'self._cfg.source = {self._cfg.source}') def _extract_tarball(self): if self.source is None:
@@ -152,22 +154,29 @@ class Kcompile(CommandLineLoad): f"error removing builddir ({self.builddir}) (ret={ret})") def _find_tarball(self): - # If the user specifies the full kernel name, check if available - tarfile = os.path.join(self.srcdir, self._cfg.source) - if os.path.exists(tarfile): - return tarfile + """ Find the tarball and self._kernel_prefix """ if 'rc' in self._cfg.source: - tarfile_prefix = re.search(r"\d{1,2}\.\d{1,3}\-[a-z]*\d{1,2}", self._cfg.source).group(0) + tarfile_prefix = re.search(r"\d{1,2}\.\d{1,3}\-rc\d{1,2}", self._cfg.source).group(0) + elif 'rteval' in self._cfg.source: + tarfile_prefix = re.search(r"(\d{1,2}\.\d{1,3}\.\d{1,3}\-rteval)|(\d{1,2}\.\d{1,3}\-rteval)", self._cfg.source).group(0) else: tarfile_prefix = re.search(r"(\d{1,2}\.\d{1,3}\.\d{1,3})|(\d{1,2}\.\d{1,3})", self._cfg.source).group(0) + # Save the kernel prefix + self._kernel_prefix = "linux-" + tarfile_prefix + + # If the user specifies the full kernel name, check if available + tarfile = os.path.join(self.srcdir, self._cfg.source) + if os.path.exists(tarfile): + return tarfile + # either a tar.xz or tar.gz might exist. Check for both. xz_file = os.path.join(self.srcdir,"linux-" + tarfile_prefix + ".tar.xz" ) gz_file = os.path.join(self.srcdir,"linux-" + tarfile_prefix + ".tar.gz" ) if os.path.exists(xz_file): return xz_file - elif os.path.exists(gz_file): + if os.path.exists(gz_file): return gz_file raise rtevalRuntimeError(self, f"tarfile {tarfile} does not exist!")
@@ -178,21 +187,20 @@ class Kcompile(CommandLineLoad): # find our source tarball if self._cfg.source: self.source = self._find_tarball() - kernel_prefix = re.search(r"(linux-\d{1,2}\.\d{1,3}\.\d{1,3})|(linux-\d{1,2}\.\d{1,3})", self.source).group(0) else: tarfiles = glob.glob(os.path.join(self.srcdir, f"{DEFAULT_KERNEL_PREFIX}*")) if tarfiles: self.source = tarfiles[0] else: raise rtevalRuntimeError(self, f" no kernel tarballs found in {self.srcdir}") - kernel_prefix = DEFAULT_KERNEL_PREFIX - self._log(Log.DEBUG, f"kernel_prefix = {kernel_prefix}") + self._kernel_prefix = DEFAULT_KERNEL_PREFIX + self._log(Log.DEBUG, f"self._kernel_prefix = {self._kernel_prefix}") # check for existing directory kdir = None names = os.listdir(self.builddir) for d in names: - if d.startswith(kernel_prefix): + if d == self._kernel_prefix: kdir = d break if kdir is None:
@@ -200,7 +208,7 @@ class Kcompile(CommandLineLoad): names = os.listdir(self.builddir) for d in names: self._log(Log.DEBUG, f"checking {d}") - if d.startswith(kernel_prefix): + if d == self._kernel_prefix: kdir = d break if kdir is None:
Signature · 1 line
2.46.0
Re: [PATCH 3/3] rteval: Fix parsing in kcompile of the kernel to compile
Quoted 3 lines · John Kacur
This patch does two things.
1. It allows you to create your own customer kernel with a dash -rteval in the name, eg, linux-6.10.5-rteval
s/customer/custom/
Quoted 33 lines
def_find_tarball(self):
- # If the user specifies the full kernel name, check if available - tarfile =os.path.join(self.srcdir, self._cfg.source)- ifos.path.exists(tarfile):
- return tarfile
+ """ Find the tarball and self._kernel_prefix """
if 'rc' in self._cfg.source:
-tarfile_prefix=re.search(r"\d{1,2}\.\d{1,3}\-[a- z]*\d{1,2}", self._cfg.source).group(0)
+tarfile_prefix=re.search(r"\d{1,2}\.\d{1,3}\-rc\d{1,2}", self._cfg.source).group(0)
+ elif 'rteval' in self._cfg.source:
+tarfile_prefix=re.search(r"(\d{1,2}\.\d{1,3}\.\d{1,3}\- rteval)|(\d{1,2}\.\d{1,3}\-rteval)", self._cfg.source).group(0) else:
tarfile_prefix=re.search(r"(\d{1,2}\.\d{1,3}\.\d{1,3})|(\d{1,2}\.\d{1,3})", self._cfg.source).group(0)
+ # Save the kernel prefix
+ self._kernel_prefix = "linux-" +tarfile_prefixrteval/modules/loads/kcompile.py +6
-0+ + # If the user specifies the full kernel name, check if available + tarfile = os.path.join(self.srcdir, self._cfg.source) + if os.path.exists(tarfile): + return tarfile +# either a tar.xz or tar.gz might exist. Check for both. xz_file = os.path.join(self.srcdir,"linux-" + tarfile_prefix + ".tar.xz" ) gz_file = os.path.join(self.srcdir,"linux-" + tarfile_prefix +
Quoted 8 lines
".tar.gz" )
if os.path.exists(xz_file):
return xz_file
- elif os.path.exists(gz_file):
+ if os.path.exists(gz_file):
return gz_file
raise rtevalRuntimeError(self, f"tarfile {tarfile} does not
exist!")Why do we have any of this instead of just having the user point at the specific file (which I assume is mainly of interest for working around problems building the default one)?
-Crystal