Good morning everyone,
I am trying to set up an environment on some specific CPUs on my Jetson nano.
The first thing I am doing is setting up a runner by assigning the affinity with taskset as follows with terraform:
echo ${var.password} | sudo -S taskset -c ${var.cpu_affinity} gitlab-runner register --non-interactive --url \"${var.gitlab_url}\" --registration-token \"${var.gitlab_project_token}\" --tag-list \"${var.tag_list_runner_container}\" --executor 'shell'",
This seems to work and I thought that the jobs I am running on my CI/CD would inherit the affinity. However, I wanted to check it and I build the next jobs stage:
check-jobs:
tags:
- runner-tag
needs: [check-reboot-job]
script:
- |
while true; do
echo "Process ID of current script $$"
awk '{print "Running on CPU core: " $39}' /proc/self/stat
sleep 0.003 # Sleep
done
then, I have seen that the affinity it's not inherit:
Running on CPU core: 0
Process ID of current script 2575940
Running on CPU core: 2
Process ID of current script 2575940
Running on CPU core: 2
Process ID of current script 2575940
Running on CPU core: 1
Process ID of current script 2575940
Running on CPU core: 3
Process ID of current script 2575940
I've tried changing the affinity in different places like gitlab-runner.service, and in the same job directly with taskset to the $$ and $PPID, but it doesn't work within jobs:
awk '{print "Running on CPU core: " $39}' /proc/self/stat
- taskset -cp 4,5 $$
- echo "Process ID of current script $$, PID $PPID"
- |
awk '{print "Running on CPU core: " $39}' /proc/self/stat
- taskset -cp 4,5 $PPID
but it either has no effect or gives me an error. The only thing that has worked for me is to enter the platform, check the process id in htop and change it manually in the terminal.
Does anyone know how I can do what I'm trying to do, and what is the reason for the lack of affinity in these processes?
Also, I'm afraid that maybe I'm putting a lot of stuff on a couple of CPUs as a result of the scheduler removing some of my affinity.
Thanks in advance and I'll give update if I'll figure out how to do it.