I have quad core CPU with hyper threading enabled. So I have 8 logical cores. I want to limit my application to use only 4 cores and I want this 4 cores to be different physical cores. Which taskset options (core numbers) should I use? :
- taskset -c 0,1,2,3 command or
- taskset -c 0,2,4,6 command
Thank you.
You can see which cores are on which processors by taking at look at
/proc/cpuinfo
. For example, you will see on a machine with a dual core cpu:for the first core on the processor and:
on the second.
So, generally speaking, I think you would want:
or:
You may want to take a look at CPU Set (cset) to create a CPU shield group for your application. This way you can ensure that real cores are being used for the important work. I typically disable hyperthreading (on Nehalem systems) for my realtime and low-latency applications.
Here's a tutorial for creating groups of CPUs for specific applications/processes using cset, which is a little more organized than taskset. https://rt.wiki.kernel.org/index.php/Cpuset_management_utility/tutorial
As far as determining the core count and location assignments, take a look at: http://dag.wieers.com/blog/is-hyper-threading-enabled-on-a-linux-system
A quick run of the utility linked on a quad-core Nehalem with hyperthreading enabled shows:
You can use like:
taskset -c -p 0-3 pid