diff mbox series

rteval: kcompile: Fix for no numactl and no cpulist

Message ID 20210909193240.438891-1-jkacur@redhat.com
State New
Headers show
Series rteval: kcompile: Fix for no numactl and no cpulist | expand

Commit Message

John Kacur Sept. 9, 2021, 7:32 p.m. UTC
Constructing a command to compile the kernel as a load can fail
in certain cases such as when numactl is not available and the user
doesn't pass a cpulist.

Fix this for both the runcmd and the cleancmd by not assuming that
numactl is available or that taskset will be used.

Reported-by: Punit Agrawal <punit1.agrawal@toshiba.co.jp>
Signed-off-by: John Kacur <jkacur@redhat.com>
---
 rteval/modules/loads/kcompile.py | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/rteval/modules/loads/kcompile.py b/rteval/modules/loads/kcompile.py
index d1955c7aee3d..8d08a3d44302 100644
--- a/rteval/modules/loads/kcompile.py
+++ b/rteval/modules/loads/kcompile.py
@@ -45,23 +45,33 @@  class KBuildJob:
         self.jobid = None
         self.node = node
         self.logger = logger
+        self.binder = None
         self.builddir = os.path.dirname(kdir)
         self.objdir = "%s/node%d" % (self.builddir, int(node))
+
         if not os.path.isdir(self.objdir):
             os.mkdir(self.objdir)
+
         if os.path.exists('/usr/bin/numactl') and not cpulist:
+            """ Use numactl """
             self.binder = 'numactl --cpunodebind %d' % int(self.node)
-        else:
-            self.binder = 'taskset -c %s' % compress_cpulist(cpulist)
-        if cpulist:
+            self.jobs = self.calc_jobs_per_cpu() * len(self.node)
+        elif cpulist:
+            """ Use taskset """
             self.jobs = self.calc_jobs_per_cpu() * len(cpulist)
+            self.binder = 'taskset -c %s' % compress_cpulist(cpulist)
         else:
+            """ Without numactl calculate number of jobs from the node """
             self.jobs = self.calc_jobs_per_cpu() * len(self.node)
+
+        self.runcmd = f"make O={self.objdir} -C {self.kdir} -j{self.jobs}"
+        self.cleancmd = f"make O={self.objdir} -C {self.kdir} clean allmodconfig"
+        if self.binder:
+            self.runcmd = self.binder + " " + self.runcmd
+            self.cleancmd = self.binder + " " + self.cleancmd
+
         self.log(Log.DEBUG, "node %d: jobs == %d" % (int(node), self.jobs))
-        self.runcmd = "%s make O=%s -C %s -j%d" \
-                % (self.binder, self.objdir, self.kdir, self.jobs)
-        self.cleancmd = "%s make O=%s -C %s clean allmodconfig" \
-                % (self.binder, self.objdir, self.kdir)
+        self.log(Log.DEBUG, f"cleancmd = {self.cleancmd}")
         self.log(Log.DEBUG, "node%d kcompile command: %s" \
                 % (int(node), self.runcmd))