LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 05-15-2010, 05:30 AM   #1
Josh000
Member
 
Registered: Aug 2009
Distribution: Slackware 13 64bit
Posts: 534

Rep: Reputation: 35
Multiple core CPU's and Linux


I have a Core 2 duo.

Whenever I monitor my CPU's, it seems only the first is ever utilized, with the second always being at 0%.

Does this mean it is not being used, or just not being reported as in use?

Is there anything I could do to improve the situation if it is not being used as much as it could be?


On Windows, I can assign processes to both cores, or either one. Is there a way to do something similar in Linux?
 
Old 05-15-2010, 05:59 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
The scheduler should handle things for you - unless you just have one big task. Try this twice from a terminal, and check your monitor (use "kill %1" and "kill %2" to get rid of them)
Code:
while true ; do a=1 ; done &
 
Old 05-15-2010, 06:01 AM   #3
camorri
LQ 5k Club
 
Registered: Nov 2002
Location: Somewhere inside 9.9 million sq. km. Canada
Distribution: Slackware 15.0, current, slackware-arm-currnet
Posts: 6,215

Rep: Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849
Have you got a SMP kernel loaded? Run the command 'uname -a' ( without the quotes ) and look for the SMP in the name. If it is not SMP, you probably are not using both cores.

Here is what I see on my system -

Quote:
uname -a
Linux duelie 2.6.31.13-desktop-1mnb #1 SMP Tue Apr 27 20:37:44 EDT 2010 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 5200+ GNU/Linux
 
Old 05-15-2010, 06:05 AM   #4
Josh000
Member
 
Registered: Aug 2009
Distribution: Slackware 13 64bit
Posts: 534

Original Poster
Rep: Reputation: 35
Yep, it's an SMP kernel.

I tried the loop command twice, and using powertop it shows only the first cpu running at 100%, the second still at 0.
 
Old 05-15-2010, 06:08 AM   #5
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018
How are you monitoring your CPUs. A single threaded process can only run on one cpu at a time (*) so it's quite possible that you could have one running at 100% and the other doing 0-5% but if your second cpu never shows any activity then that's certainly a little strange. Try running 2 loop commands at once.

The 'taskset' command will allow you to assign cpu affinity, but I suspect that unless you have a really good reason to use it, you're only likely to make your system run slower. The CPU Scheduler probably understands you system's workload far better than you do.


(*) That was part of the reason I decided to go for a dual 2.8Ghz box rather than a slower 2.4 quad box (plus the dual was much cheaper). The quad has more processing muscle in total, but a single task will complete faster on my faster clocked dual core.

Last edited by GazL; 05-15-2010 at 06:16 AM.
 
Old 05-15-2010, 06:13 AM   #6
Josh000
Member
 
Registered: Aug 2009
Distribution: Slackware 13 64bit
Posts: 534

Original Poster
Rep: Reputation: 35
I am just monitoring with the powertop program. I ran two loop commands, and the second cpu never shows any activity.

The only reason I ever used to set a processes affinity was to put firefox on it's own core if it started being to beastly, which resulted in a marked improvement.
 
Old 05-15-2010, 06:22 AM   #7
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018
try running the normal top program and press the "1" key to show individual cpus.

If firefox starts to hog cpu, then a better option would be to alter it's nice value to protect the other processes, setting a cpu-affinity in that sort of situation is not really what cpu-affinity is designed for, but it's your system and your choice.
 
Old 05-15-2010, 06:28 AM   #8
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
If there are two "processor" entries in /proc/cpuinfo, you should be using them both.
Simple as that.
 
Old 05-15-2010, 06:45 AM   #9
Josh000
Member
 
Registered: Aug 2009
Distribution: Slackware 13 64bit
Posts: 534

Original Poster
Rep: Reputation: 35
Quote:
Originally Posted by GazL View Post
try running the normal top program and press the "1" key to show individual cpus.

If firefox starts to hog cpu, then a better option would be to alter it's nice value to protect the other processes, setting a cpu-affinity in that sort of situation is not really what cpu-affinity is designed for, but it's your system and your choice.
Hmm, top shows them both in use, although neither one as being above 20% utilization even though it shows the loop command taking 99% of my cpu.

Obviously they areboth being used, I just thought it was odd it wasn't reported as such(or so I thought)

I just wanted to ask you about cpu affinity? You say it was not designed to be used the way I used it...what was it designed for? Why is it a bad idea to use it as I do, when I see a improvement by doing so?

Just curious, and would like to learn more.
 
Old 05-15-2010, 07:37 AM   #10
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018
By setting cpu affinity what you're doing is restricting the choices the cpu scheduler can make about where to run a program. This could potentially make overall performance worse rather than better depending on the situation.

System affinity was really designed for very specific situations where you want a task to stay on a single cpu to maximise cache hits and register usage. As soon as you introduce a multi-tasking/time-slicing system such as unix where the task on the cpu is regularly being swapped any advantages from cache hits and register use that setting cpu-affinity would bring are going to be lost anyway. Unless you tell everything else not to run on that cpu, setting the affinity really won't buy you that much in this sort of environment and will more likely hinder the scheduler in doing its job. A lot of thought tends to go into Scheduler algorithms, best to leave it to it.

Now if your problem is that firefox is too greedy at times and overall system responsiveness is suffering then tell the scheduler to give less priority to firefox with nice/renice. This will help the responsiveness/performance of other processes without artificially limiting where the scheduler can run things and overall performance should be better.

Last edited by GazL; 05-15-2010 at 07:39 AM.
 
1 members found this post helpful.
Old 05-15-2010, 07:38 AM   #11
Josh000
Member
 
Registered: Aug 2009
Distribution: Slackware 13 64bit
Posts: 534

Original Poster
Rep: Reputation: 35
Thanks for explaining that
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to run the linux process on multiple core saurin Linux - General 1 10-26-2009 02:01 PM
Mixing quad and dual core cpu's in the same machine sniff Linux - Hardware 12 09-26-2008 09:52 AM
Slackware 11 and shiny new dual core CPU's TL_CLD Slackware 8 01-02-2007 01:02 AM
Dual Core CPU's - What Kernel carlosinfl Linux - Hardware 1 08-21-2006 01:55 PM
CPU's on Linux zakl Linux - Hardware 1 06-12-2003 02:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 02:56 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