LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
 
Search this Thread
Old 07-10-2012, 10:02 PM   #1
ilesterg
Member
 
Registered: Jul 2012
Location: Philippines
Distribution: CentOS, Oracle Linux, AIX
Posts: 355

Rep: Reputation: 46
Linux and processor affinity


I just encountered a new concept today, 'processor affinity', which is related to how the processes in a system utilizes the available sockets/cpus/cores of a hardware. This made me think about how Linux could utilize the available resources of a system.

Since I am not that much familiar with how the linux kernel works on hardware, I came up with the following questions:
1. As I add more CPUs or upgrade an existing CPU with more cores, would the kernel automatically recognize the changes and utilize all available resources?
2. If not, should I be making any tweaks, probably recompile the kernel?
3. Suppose my CPU utilization is 50% on only 1 core of 1 CPU, and I have 4 CPUs with 4 cores each, is it safe that i set the processor affinity of my OS to utilize all the CPUs and all their cores? Would this affect the processes owned by the applications running on my system?
4. Or is there any need to do #3?


Good day!
Lester
 
Old 07-10-2012, 10:07 PM   #2
ilesterg
Member
 
Registered: Jul 2012
Location: Philippines
Distribution: CentOS, Oracle Linux, AIX
Posts: 355

Original Poster
Rep: Reputation: 46
Please take the above concept from the context of an enterprise server.

Additionally, suppose I have a process (which typically runs for 1 hour), and it currently runs on only 1 core on 1 CPU, if I decide to distribute the processing on multiple cores, would the process run faster? or would the interprocess communication still result to a 1 hour processing?
 
Old 07-10-2012, 10:20 PM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,810

Rep: Reputation: 1156Reputation: 1156Reputation: 1156Reputation: 1156Reputation: 1156Reputation: 1156Reputation: 1156Reputation: 1156Reputation: 1156
1. Yes - if using a SMP-aware kernel. That is, almost every distros released in the last few years.
2. n/a
3. the kernel will handle it automatically. Much better than any of us could.
4. no

Properly constructed multi-processing (aka multi-threaded) code will run significantly faster in almost all cases. Poorly designed code may have race and/or locking issues that may not only slow things down, but make it (much) worse.
If it's your own code, the proper design is your responsibility.
 
Old 07-10-2012, 10:30 PM   #4
ilesterg
Member
 
Registered: Jul 2012
Location: Philippines
Distribution: CentOS, Oracle Linux, AIX
Posts: 355

Original Poster
Rep: Reputation: 46
Quote:
Originally Posted by syg00 View Post
1. Yes - if using a SMP-aware kernel. That is, almost every distros released in the last few years.
2. n/a
3. the kernel will handle it automatically. Much better than any of us could.
4. no

Properly constructed multi-processing (aka multi-threaded) code will run significantly faster in almost all cases. Poorly designed code may have race and/or locking issues that may not only slow things down, but make it (much) worse.
If it's your own code, the proper design is your responsibility.
I see, i see. Thanks!
 
  


Reply

Tags
cpuaffinity


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
program execution time & Processor affinity ghobad2005 Ubuntu 1 08-08-2010 02:24 PM
Setting Processor Affinity in application grubby23 Programming 1 01-28-2010 10:40 AM
Processor Affinity vikesh.u Linux - Kernel 1 09-07-2009 12:52 PM
Can you set processor affinity on Linux? Thaidog Linux - General 1 02-27-2008 09:31 AM
Processor affinity and cpu scheduling...? Thaidog Linux - Newbie 5 01-09-2003 07:08 PM


All times are GMT -5. The time now is 11:06 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration