Is there a way to know which cores currently have a process pinned
to them?
Even processes run by other users should be listed in the output.
Or, is it possible to try pinning a process to a core but
fail in case the required core already has a process pinned to it?
PS: processes of interest must have bin pinned to the given cores, not just
currently running on the given core
PS: this is not a duplicate, the other question is on how to ensure exclusive use of one CPU by one process. Here we are asking how to detect that a process was pinned to a given core (i.e. cpuset was used, not how to use it).
Best Answer
Under normal circumstances Linux processes are not explicitly pinned to a given core, there's typically no reason to do that, but is possible.
You can manage process affinity using
taskset
or view which process runs on which CPU in the present instant using ps with the field 'psr'.Check current CPU affinity of process 27395:
Check affinity list of process 27395:
Set affinity of process 27395 to CPU 3
Check current CPU affinity of process 27395:
To check if any process is pinned to any CPU, you can loop through your process identifiers and run
taskset -p
against them: