[PATCH 1/2] rteval: Make donotrun work correctly in load modules

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hackbench and kcompile don't correctly adhere to the donotrun variable
which is inherited class rtevalModulePrototype. If the variable is set
after the modules are loaded, although the modules do not run, some
threading accounting still occurs which causes problems on shutdown of
rteval.

Fix in the methods in hackbench and kcompile where this is relevant, by
checking the variable before the method runs.

While we are at it fix a few other things
- change len(threading.enumerate()) to threading.active_count()
- Fix a spelling typo

This patch is in preparation for a patch to allow stress-ng to run as a
load module without running other modules.

Signed-off-by: John Kacur <jkacur@xxxxxxxxxx>
---
 rteval/__init__.py                | 4 ++--
 rteval/modules/loads/__init__.py  | 2 +-
 rteval/modules/loads/hackbench.py | 3 +++
 rteval/modules/loads/kcompile.py  | 9 +++++++++
 4 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/rteval/__init__.py b/rteval/__init__.py
index 5faed23bc927..22af8e85d5aa 100644
--- a/rteval/__init__.py
+++ b/rteval/__init__.py
@@ -208,7 +208,7 @@ class RtEval(rtevalReport):
             report_interval = int(self.__rtevcfg.report_interval)
             if with_loads:
                 self._loadmods.Unleash()
-                nthreads = len(threading.enumerate())
+                nthreads = threading.active_count()
             else:
                 nthreads = None
             self.__logger.log(Log.INFO, "Waiting 30 seconds to let load modules settle down")
@@ -233,7 +233,7 @@ class RtEval(rtevalReport):
                                       "Measurement threads did not use the full time slot. Doing a controlled stop.")
 
                 if with_loads:
-                    if len(threading.enumerate()) < nthreads:
+                    if threading.active_count() < nthreads:
                         raise RuntimeError("load thread died!")
 
                 if not load_avg_checked:
diff --git a/rteval/modules/loads/__init__.py b/rteval/modules/loads/__init__.py
index 9a942f454536..2c2105efa964 100644
--- a/rteval/modules/loads/__init__.py
+++ b/rteval/modules/loads/__init__.py
@@ -106,7 +106,7 @@ class LoadModules(RtEvalModules):
         "Loads and imports all the configured modules"
 
         for m in modcfg:
-            # hope to eventually have different kinds but module is only on
+            # hope to eventually have different kinds but module is only one
             # for now (jcw)
             if m[1].lower() == 'module':
                 self._LoadModule(m[0])
diff --git a/rteval/modules/loads/hackbench.py b/rteval/modules/loads/hackbench.py
index 2fb90c1946a5..21a803b8a3cd 100644
--- a/rteval/modules/loads/hackbench.py
+++ b/rteval/modules/loads/hackbench.py
@@ -42,6 +42,9 @@ class Hackbench(CommandLineLoad):
         CommandLineLoad.__init__(self, "hackbench", config, logger)
 
     def _WorkloadSetup(self):
+        if self._donotrun:
+            return
+
         'calculate arguments based on input parameters'
         (mem, units) = self.memsize
         if units == 'KB':
diff --git a/rteval/modules/loads/kcompile.py b/rteval/modules/loads/kcompile.py
index 8d08a3d44302..ec85b75f38b5 100644
--- a/rteval/modules/loads/kcompile.py
+++ b/rteval/modules/loads/kcompile.py
@@ -158,6 +158,9 @@ class Kcompile(CommandLineLoad):
                 "error removing builddir (%s) (ret=%d)" % (self.builddir, ret))
 
     def _WorkloadSetup(self):
+        if self._donotrun:
+            return
+
         # find our source tarball
         if 'tarball' in self._cfg:
             tarfile = os.path.join(self.srcdir, self._cfg.tarfile)
@@ -219,6 +222,9 @@ class Kcompile(CommandLineLoad):
 
 
     def _WorkloadBuild(self):
+        if self._donotrun:
+            return
+
         null = os.open("/dev/null", os.O_RDWR)
         if self._logging:
             out = self.open_logfile("kcompile-build.stdout")
@@ -293,6 +299,9 @@ class Kcompile(CommandLineLoad):
 
 
     def _WorkloadCleanup(self):
+        if self._donotrun:
+            return
+
         self._log(Log.DEBUG, "out of stopevent loop")
         for n in self.buildjobs:
             if self.buildjobs[n].jobid.poll() is None:
-- 
2.31.1




[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux