diff mbox series

[3/3] rteval: Support run-on-isolcpus in cyclictest

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

Commit Message

Tomas Glozar Aug. 10, 2023, 9:01 a.m. UTC
If --measurement-run-on-isolcpus is enabled, add isolated CPUs to the
cpumask for the case when --measurement-cpulist is not specified. If
both options are specified, display a warning.

Signed-off-by: Tomas Glozar <tglozar@redhat.com>
---
 rteval/modules/measurement/cyclictest.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/rteval/modules/measurement/cyclictest.py b/rteval/modules/measurement/cyclictest.py
index ace8db4..4d7fcf2 100644
--- a/rteval/modules/measurement/cyclictest.py
+++ b/rteval/modules/measurement/cyclictest.py
@@ -214,6 +214,7 @@  class Cyclictest(rtevalModulePrototype):
         self.__cpus = []
         self.__cyclicdata = {}
         self.__sparse = False
+        self.__run_on_isolcpus = bool(self.__cfg.setdefault('run-on-isolcpus', False))
 
         if self.__cfg.cpulist:
             self.__cpulist = self.__cfg.cpulist
@@ -224,14 +225,21 @@  class Cyclictest(rtevalModulePrototype):
             self.__cpulist = collapse_cpulist(self.__cpus)
             self.__cpus = [str(c) for c in self.__cpus]
             self.__sparse = True
+            if self.__run_on_isolcpus:
+                self._log(Log.WARN, "ignoring --measurement-run-on-isolcpus, since cpulist is specified")
         else:
             self.__cpus = SysTopology().online_cpus_str()
             # Get the cpuset from the environment
             cpuset = os.sched_getaffinity(0)
             # Convert the elements to strings
             cpuset = [str(c) for c in cpuset]
-            # Only include cpus that are in the cpuset
-            self.__cpus = [c for c in self.__cpus if c in cpuset]
+            # Get isolated CPU list
+            isolcpus = [str(c) for c in SysTopology().isolated_cpus()]
+            # Only include cpus that are in the cpuset and isolated CPUs if run_on_isolcpus is enabled
+            self.__cpus = [c for c in self.__cpus if c in cpuset or self.__run_on_isolcpus and c in isolcpus]
+            if self.__run_on_isolcpus:
+                self.__sparse = True
+                self.__cpulist = collapse_cpulist(self.__cpus)
 
         # Sort the list of cpus to align with the order reported by cyclictest
         self.__cpus.sort(key=int)