Linux – taskset core numbers question

central-processing-unithyperthreadinglinuxmulti-threadingunix

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.

Best Answer

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:

processor   : 0
(snip)
core id     : 0
cpu cores   : 2

for the first core on the processor and:

processor   : 1
(snip)
core id : 1
cpu cores   : 2

on the second.

So, generally speaking, I think you would want:

taskset -c 0,1,2,3

or:

taskset -c 4,5,6,7