LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Taskset on multicore cpu (https://www.linuxquestions.org/questions/linux-general-1/taskset-on-multicore-cpu-765548/)

DinoFly 10-30-2009 07:18 AM

Taskset on multicore cpu
 
Hi all I wanted to ask is there a way to migrate a proces from one core of cpu to another core of the same cpu with taskset.

Regards

AlucardZero 10-30-2009 01:25 PM

man taskset

DinoFly 10-31-2009 03:33 PM

Hi again and thanks for your reply.

I read the man and info pages. Let me first make my situation a bit clearer.

I installed the squid as a web-cache server. When runing in testing envoriment I had great performances. I had 2* dual core cpu and I created 2 instances of squid and set afinity for each on a single cpu. Worked great.

Now in real life I am using 2* quad core cpu processor server and I can do the same but when I reach 300MB traffic my server responds slowely. I am curious can I make 2 or even 3 instances of squid per cpu like 1 instance run on cpu 1 core 1, second on cpu 1 core 2, third cpu 1 core 3, fourth cpu2 core 1, fifth cpu 2 core 2 and six on cpu2 core 3. Is somethink like this possible since I have 3 cores on each cpu's sleeping while a core is working on 100%.

I know that on non intensive proceses the taskset is helpful on isolating proceses on one cpu or even a core, but in my cause I want to balance the usage of procesors since squid uses only 1 process not create child processes (can not say if it is a bad idea or not - limited knowledge on computing arcitecture :) ).

Thanks in advance.

p.s. sorry my bad english.

AlucardZero 10-31-2009 04:50 PM

Quote:

a way to migrate a proces from one core of cpu to another core of the same cpu
Use taskset. What it refers to as CPUs means cores.

I have four cores:
Code:

alucard@karrde:~$ cat /proc/cpuinfo | grep "model name"
model name      : Intel(R) Xeon(R) CPU          L5420  @ 2.50GHz
model name      : Intel(R) Xeon(R) CPU          L5420  @ 2.50GHz
model name      : Intel(R) Xeon(R) CPU          L5420  @ 2.50GHz
model name      : Intel(R) Xeon(R) CPU          L5420  @ 2.50GHz

Code:

alucard@karrde:~$ sudo taskset -c -p 3 32039
[sudo] password for alucard:
pid 32039's current affinity list: 0-3
pid 32039's new affinity list: 3
alucard@karrde:~$ sudo taskset -c -p 4 32039
pid 32039's current affinity list: 3
sched_setaffinity: Invalid argument
failed to set pid 32039's affinity.
alucard@karrde:~$ sudo taskset -c -p 0-3 32039
pid 32039's current affinity list: 3
pid 32039's new affinity list: 0-3


syg00 10-31-2009 05:03 PM

Quote:

Originally Posted by DinoFly (Post 3739438)
I have 3 cores on each cpu's sleeping while a core is working on 100%.

I would consider that very unusual. Normally I would expect the scheduler to dispatch tasks evenly across the cores - certainly not just one per substrate.
As for forcing particular instances of a program onto a particular core, that can sometimes be beneficial - usually not worth the hassle, but certainly might be worth a try in your case. You could use taskset when starting each instance, but I generally use cgroups when I want/need to isolate workloads - usually for testing in my case. It's really designed to isolate a group of workloads to a group of processors, but you could use it to do what you want.
Can be a bit fiddly to setup, but have a look at ../Documentation/cgroups in your kernel source tree (used to be called cpusets).


All times are GMT -5. The time now is 03:00 PM.