LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   The contrary effect taken by using taskset command to set processor affinity (https://www.linuxquestions.org/questions/linux-kernel-70/the-contrary-effect-taken-by-using-taskset-command-to-set-processor-affinity-821967/)

sobrier 07-24-2010 09:19 PM

The contrary effect taken by using taskset command to set processor affinity
 
Hi,
I have tried to set processor affinity for a certain task with "taskset" command
,but it takes contrary effect .
Here is my operations:
#taskset -p 0x00000001 9440 ;binding process qemu-system-x86_64 to run on #cpu0
but the cpu utilizaion from seeing "top": #cpu 1 is much busier than #cpu 0.
And,I do this:
#taskset -p 0x00000002 9440 ;binding process to run on #cpu1
from "top",see #cpu 0 is much busier than #cpu 1.
However,From "htop",I see two qemu processes:pid 9440 and pid 9441,but i have launched only one qemu process.I do it again:
#taskset -p 0x00000001 9441 ;
#taskset -p 0x00000002 9441
this time,it works right effect.
OH....I am so puzzled,so,i do these on the another computer which has the same hardware and Debian Lenny OS.Another problem happens:
After install htop,it works opposite effect as the first computer,so,i remove the htop command,and then set processor affinity,it works right.so,i think htop may be something wrong.
But,i remove the htop command on the fist computer,it still works contrary.so,htop may be not the only problem.
i can't solve this,any help can be appreciated!

smoker 07-24-2010 11:50 PM

What happens when you start the process using taskset ?
You can see whether the affinity has been applied by using
Code:

taskset -p <pid>

Also, it is much easier and clearer to use the -c option for the cpu numbers
Code:

taskset -p -c 0 <pid>
or
Code:

taskset -p -c 1 <pid>

syg00 07-25-2010 01:59 AM

Poor option if there is the possibility of child processes. Have a look at cgroups where they can all be contained without having to know pid or process name in advance.


All times are GMT -5. The time now is 12:33 AM.