You can set affinity by range with other like a specify CPU
$ taskset -cp 1-3,12 14846
Or
$ taskset -cp 1-6:2 14846
The suffix ":N" specifies stride in the range, for example 0-10:3 is interpreted as 0,3,6,9 list.
You can set affinity by range with other like a specify CPU
$ taskset -cp 1-3,12 14846
Or
$ taskset -cp 1-6:2 14846
The suffix ":N" specifies stride in the range, for example 0-10:3 is interpreted as 0,3,6,9 list.
That mean new CPU affinity list is [0,1,2,3]
$ taskset -cp 0-3 14846
pid 14846's current affinity list: 1
pid 14846's new affinity list: 0-3
You can set single CPU with the following command:
$ taskset -cp 5,8,12 14846
pid 14846's current affinity list: 0-3
pid 14846's new affinity list: 5,8,12
That mean new CPU affinity list is [5,8,12]
Now let's try to set process in to a specify CPU. For example, we have a process has PID = 14846 Let's see the CPU affinity list of this process first:
$ taskset -cp 14846
pid 14846's current affinity list: 0-15
$ taskset -cp 1 14846
pid 14846's current affinity list: 0-15
pid 14846's new affinity list: 1
As we see, CPU affinity was changed
$ taskset -cp 29523
pid 29523's current affinity list: 0-15
That mean process with PID 29523
is active on CPU range from [0,1,...,15]
which means 16
total.
PID: Process Identifier - is a unique numerical identifier given to each running process, you can view PID of processes in top
or htop
tools
If you run the above command but get the message bad usage
, try with PID = 1
$ taskset -cp 1