LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Linux and processor affinity (https://www.linuxquestions.org/questions/linux-hardware-18/linux-and-processor-affinity-4175416020/)

ilesterg 07-10-2012 10:02 PM

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

ilesterg 07-10-2012 10:07 PM

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?

syg00 07-10-2012 10:20 PM

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.

ilesterg 07-10-2012 10:30 PM

Quote:

Originally Posted by syg00 (Post 4724526)
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!


All times are GMT -5. The time now is 08:14 PM.