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

John Kacur
2021-09-09T19:23:38Z

On Wed, 1 Sep 2021, Punit Agrawal wrote:

> 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
>
>

Wow, that's some messy code! (Not yours, the original).

I think for embedded arm distros, numactl is not always available, so we
shouldn't tell users to install it, and just make the code work when it's
not there. Also, it should be perfectly fine to run without passing a
cpulist, so it's not something we should warn the users about.

You've got the right idea to just make the self.binder empty.
I've got a version that cleans-up a few more things,
I've tested with no numactl and no cpulist, no numactl and a cpulist
with numactl and no cpulist and with numactl and with a cpulist.

Could you give it a test on your arm system?
Sending in a separte mail

John