LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-30-2009, 07:18 AM   #1
DinoFly
Member
 
Registered: Nov 2007
Distribution: Fedora, CentOS,
Posts: 72

Rep: Reputation: Disabled
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
 
Old 10-30-2009, 01:25 PM   #2
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
man taskset
 
Old 10-31-2009, 03:33 PM   #3
DinoFly
Member
 
Registered: Nov 2007
Distribution: Fedora, CentOS,
Posts: 72

Original Poster
Rep: Reputation: Disabled
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.
 
Old 10-31-2009, 04:50 PM   #4
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
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
 
Old 10-31-2009, 05:03 PM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,131

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
Quote:
Originally Posted by DinoFly View Post
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).
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Single cpu-core used on multicore system when processes communicate with pipe merijnv Linux - Kernel 3 04-10-2009 09:17 PM
Using taskset to set process affinity on multi-core/hyperthreading lennyk Linux - Software 0 04-06-2009 09:29 AM
multicore cpus question mokku Linux - Server 8 09-04-2008 12:45 AM
Wine and multicore CPU's... z3r0.0v3rrid3 Linux - Software 2 06-25-2007 12:06 AM
amd multicore inspiredbymetal Linux - Hardware 1 07-12-2005 09:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:19 PM.

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