In case of a machine having mulitple processor like NUMA processes generally perform better on one processor when compared to other processors. So its necessary to attach process to that particular processor so as to maximize performance. For such reasons, a tool named taskset can be used. The linux scheduler then acts according to processor affinity set by taskset command. But generally scheduler tries to keep process on same CPU as long as it supports natural affinity. So this taskset command may not work in all cases.
Command to check affinity of process with pid
# taskset -p pid
This command tells which cores have been assigned to the process with taht pid.
Command to set affinity of process
# taskset -p mask pid
This command is used to assign process with pid to cores given by that mask.
Mask is defined as follows:
It is a bitmap of processors present in the system. For example if there are 4 cores then 4 bits will be used in bitmap and if there are 8 cores then 8 bits will be used in bitmap.LSB indicates first core and MSB indicates last core. So to assign process with pid 1111 to cores 0,2,4,6 we will give following command
# taskset -p 0X55 1111
To assign it to cores 1,3,5,7 we will give following command
# taskset -p 0Xaa 1111
Command to check affinity of process with pid
# taskset -p pid
This command tells which cores have been assigned to the process with taht pid.
Command to set affinity of process
# taskset -p mask pid
This command is used to assign process with pid to cores given by that mask.
Mask is defined as follows:
It is a bitmap of processors present in the system. For example if there are 4 cores then 4 bits will be used in bitmap and if there are 8 cores then 8 bits will be used in bitmap.LSB indicates first core and MSB indicates last core. So to assign process with pid 1111 to cores 0,2,4,6 we will give following command
# taskset -p 0X55 1111
To assign it to cores 1,3,5,7 we will give following command
# taskset -p 0Xaa 1111
No comments:
Post a Comment