Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Linux - Kernel This forum is for all discussion relating to the Linux kernel.


  Search this Thread
Old 07-24-2010, 10:19 PM   #1
LQ Newbie
Registered: Jul 2010
Posts: 4

Rep: Reputation: 0
The contrary effect taken by using taskset command to set processor affinity

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 processesid 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,i think htop may be something wrong.
But,i remove the htop command on the fist computer,it still works,htop may be not the only problem.
i can't solve this,any help can be appreciated!
Old 07-25-2010, 12:50 AM   #2
Senior Member
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 249Reputation: 249Reputation: 249
What happens when you start the process using taskset ?
You can see whether the affinity has been applied by using
taskset -p <pid>
Also, it is much easier and clearer to use the -c option for the cpu numbers
taskset -p -c 0 <pid>
taskset -p -c 1 <pid>
Old 07-25-2010, 02:59 AM   #3
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 15,991

Rep: Reputation: 2218Reputation: 2218Reputation: 2218Reputation: 2218Reputation: 2218Reputation: 2218Reputation: 2218Reputation: 2218Reputation: 2218Reputation: 2218Reputation: 2218
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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] problems with cpu affinity, wine and Mass Effect 2 gimli01 Linux - Games 2 07-17-2010 03:49 AM
CPU affinity / taskset does not always work. lwi Ubuntu 3 03-01-2010 01:49 PM
taskset and affinity masks tethysgods Linux - Software 1 01-16-2010 01:29 PM
Using taskset to set process affinity on multi-core/hyperthreading lennyk Linux - Software 0 04-06-2009 10:29 AM
Can you set processor affinity on Linux? Thaidog Linux - General 1 02-27-2008 10:31 AM > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 11:13 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration