[PATCH 5/5] rteval: kcompile.py: Gracefully handle missing affinity information

Punit Agrawal
2021-09-01T08:08:53Z

From: Punit Agrawal <punit1.agrawal@toshiba.co.jp>

kcompile either sets the affinity of the workload threads to a user
specified list of cpus (using taskset) or binds the threads to the
local numa node (using numactl). In the absence of both the following
hard to parse error is thrown -

Exception in thread kcompile:
Traceback (most recent call last):
...
File "...rteval/rteval/modules/loads/kcompile.py", line 55, in __init__
self.binder = 'taskset -c %s' % compress_cpulist(cpulist)
File "...rteval/rteval/misc.py", line 62, in compress_cpulist
if isinstance(cpulist[0], int):
TypeError: 'NoneType' object is not subscriptable

Instead, add a warning to report the missing affinity information /
tools and continue executing the workload with no affinity - relying
on the affinity settings being set by the kernel.

Signed-off-by: Punit Agrawal <punit1.agrawal@toshiba.co.jp>
---
rteval/modules/loads/kcompile.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/rteval/modules/loads/kcompile.py b/rteval/modules/loads/kcompile.py
index d1955c7aee3d..5c83b78525e5 100644
--- a/rteval/modules/loads/kcompile.py
+++ b/rteval/modules/loads/kcompile.py
@@ -51,8 +51,12 @@ class KBuildJob:
os.mkdir(self.objdir)
if os.path.exists('/usr/bin/numactl') and not cpulist:
self.binder = 'numactl --cpunodebind %d' % int(self.node)
- else:
+ elif cpulist is not None:
self.binder = 'taskset -c %s' % compress_cpulist(cpulist)
+ else:
+ self.log(Log.WARN, 'Unable to set job affinity - please install "numactl" or pass "cpulist"')
+ self.log(Log.WARN, 'Running with default OS decided affinity')
+ self.binder = ''
if cpulist:
self.jobs = self.calc_jobs_per_cpu() * len(cpulist)
else:
--
2.32.0