I need to benchmark the performance of every core in an Android phone, so I need to run a program exclusively on a core. Fortunately, I'm dealing with a dynamIQ chip from Qualcomm, so I think I would be able to pin a process to any core I like.
My set-up is as follows,
- OS: ArchLinux container on Termux app on an Android 11 phone
- SoC: QC 865, 855 and 845
sched_setaffinityto set the cpu-affinity
- Long-running computationally-intensive python program
- Wake-lock, keeping the screen on and ensuring that my app is at foreground so that its priority won't be downgraded.
To test the reliability of this set-up to ensure that an app is pinned to a core, I keep open a Python prompt and modify its affinity through
taskset. While it is straighforward to pin the process to the low-power cores (0,1,2,3), it is less likely to be able to pin to the mid-range cores (4,5,6) and almost impossible to pin it to the prime core (7).
A convoluted approach I have taken to widen the affinity is by running an infinite loop in the prompt, which then widens the scheduler-set affinity to 0-7, letting me pin the process to core 7. The process is then "unpinned" from core 7 when the infinite loop is stopped. I need a sure-shot way that ensures that the app is running on a particular core always.
How can I reliably and programmatically pin the process to the prime and mid-range cores?