utilising multi-core/-processor support in linux

  • Follow


Hi

I recently bought a centrino dual core machine, and compiled a kernel 
2.6.17.8 with support for kernel threading and 2 processors/cores.

When I tried utilising both cores, I had a look at top/ps to see if 
linux distributed the processes/tasks to both processors, but according 
to it it only used one of the cores.

Looking at the web for information on how to control and utilise 
multi-processors/cores in linux only yield information about linux 
supporting in 2.2/2.4 kernels and some odd information on how to 
programm for it. Not how to verify it is beeing utilised, in what way or 
if there are things that need to be configured for it to work properly.

So my question is, how can i verify its use and is there anything that 
needs to be done to existing programs or the linux distro to utilise it.

Any information, pointers or good articles explaining system 
administration of smp functionality is highly appreciated.

regards

tom
0
Reply spam225 (180) 8/28/2006 9:01:27 AM

On Monday 28 August 2006 11:01, Tom Forsmo stood up and addressed the masses
in /comp.os.linux.misc/ as follows...:

> Hi
> 
> I recently bought a centrino dual core machine, and compiled a kernel
> 2.6.17.8 with support for kernel threading and 2 processors/cores.

Perhaps you should have set it up for 4 processors, because if those cores
are hyperthreaded - and provided that hyperthreading is enabled in the BIOS
_and_ that you're running an ACPI interpreter - then you have 4 logical
CPU's.

> When I tried utilising both cores, I had a look at top/ps to see if
> linux distributed the processes/tasks to both processors, but according
> to it it only used one of the cores.

/top/ normally defaults to showing a non-SMP view.  You should press "1" to
enable an SMP view.

> Looking at the web for information on how to control and utilise
> multi-processors/cores in linux only yield information about linux
> supporting in 2.2/2.4 kernels and some odd information on how to
> programm for it. Not how to verify it is beeing utilised, in what way or
> if there are things that need to be configured for it to work properly.

2.2 and 2.4 Linux kernel generations are by default not good choices for
hyperthreaded or multi-core CPU's in physical SMP set-ups because they
don't normally distinguish between a physical CPU and a hyperthreaded
sibling or an on-chip second core, which leads to poor load balancing and
may cause one physical CPU to generate more heat and do all the work when
another physical CPU is completely idle.

I would advise sticking to a 2.6 kernel for such a machine.

> So my question is, how can i verify its use and is there anything that
> needs to be done to existing programs or the linux distro to utilise it.

The kernel will dispatch processes across the available CPU
cores/hyperthreads as it sees fit, but in order to take advantage of true
multi-threading, your application software itself has to support it.

If it doesn't, then the kernel can run process abc on one CPU and process
xyz on another one, but those will then be the entire processes.  Threads
are also being used but are only implemented at the kernel level, i.e. for
kernelspace processes.

If you want your userspace processes to support threads - and to thus
execute faster on a multi-threaded machine - you'll have to compile them
with thread support.  Older GNU/Linux distributions make use of the
so-called Linux Threads (LT), while newer distributions make use of the
Native POSIX Threads for Linux (NPTL), with or without support for the
older Linux Threads.

An example of an application that usually supports threads is The Gimp, and
KVIrc - an excellent Qt-based IRC client - also supports threads.

> Any information, pointers or good articles explaining system
> administration of smp functionality is highly appreciated.

Your Google's as good as mine... ;-)

-- 
With kind regards,

*Aragorn*
(registered GNU/Linux user #223157)
0
Reply stryder (1498) 8/28/2006 9:19:50 AM


Tom Forsmo =E3=81=AE=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8:

> Hi
>
> I recently bought a centrino dual core machine, and compiled a kernel
> 2.6.17.8 with support for kernel threading and 2 processors/cores.
>
> When I tried utilising both cores, I had a look at top/ps to see if
> linux distributed the processes/tasks to both processors, but according
> to it it only used one of the cores.
>
> Looking at the web for information on how to control and utilise
> multi-processors/cores in linux only yield information about linux
> supporting in 2.2/2.4 kernels and some odd information on how to
> programm for it. Not how to verify it is beeing utilised, in what way or
> if there are things that need to be configured for it to work properly.
>
> So my question is, how can i verify its use and is there anything that
> needs to be done to existing programs or the linux distro to utilise it.
>
> Any information, pointers or good articles explaining system
> administration of smp functionality is highly appreciated.
>
> regards
>
> tom
Write a multi-threaded Java program and use it as your test program.

0
Reply HGA03630 (500) 8/28/2006 10:22:55 AM

Tom Forsmo wrote:
> Hi
> 
> I recently bought a centrino dual core machine, and compiled a kernel
> 2.6.17.8 with support for kernel threading and 2 processors/cores.

Something funny here. You compile the kernel for either uniprocessor (one
processor with one core), or symmetric multiprocessor (more than one
processor with possibly more than one core). Unless kernels have changed
lately, those are the only two option.
> 
> When I tried utilising both cores, I had a look at top/ps to see if
> linux distributed the processes/tasks to both processors, but according
> to it it only used one of the cores.

To use more than one processor, be it a single hyperthreaded processor, a
single multi-cored processor, or multiple processors, it suffices to boot a
SMP kernel.
> 
> Looking at the web for information on how to control and utilise
> multi-processors/cores in linux only yield information about linux
> supporting in 2.2/2.4 kernels and some odd information on how to
> programm for it. Not how to verify it is beeing utilised, in what way or
> if there are things that need to be configured for it to work properly.

My old machine has two Pentium III processors (not hyperthreaded, not
multicore), and it runs CentOS 4 with a 2.6 kernel, called

kernel-smp-2.6.9-34.0.2.EL

by rpm. In /boot, the actual kernel used is called

vmlinuz-2.6.9-34.0.2.ELsmp
> 
> So my question is, how can i verify its use and is there anything that
> needs to be done to existing programs or the linux distro to utilise it.

I would just run top. When it is multiprocessing, the top of that looks like
this:

top - 06:54:16 up 16 days, 21:37,  1 user,  load average: 2.78, 2.26, 2.09
Tasks:  85 total,   3 running,  82 sleeping,   0 stopped,   0 zombie
Cpu0  :  1.0% us,  0.5% sy, 98.2% ni,  0.0% id,  0.0% wa,  0.3% hi,  0.0% si
Cpu1  :  0.0% us,  0.0% sy, 99.7% ni,  0.0% id,  0.0% wa,  0.3% hi,  0.0% si
Mem:    514516k total,   496960k used,    17556k free,    17692k buffers
Swap:  1052216k total,      192k used,  1052024k free,   210328k cached

> 
> Any information, pointers or good articles explaining system
> administration of smp functionality is highly appreciated.
> 
> regards
> 
> tom


-- 
  .~.  Jean-David Beyer          Registered Linux User 85642.
  /V\  PGP-Key: 9A2FC99A         Registered Machine   241939.
 /( )\ Shrewsbury, New Jersey    http://counter.li.org
 ^^-^^ 06:45:01 up 14 days, 15:53, 3 users, load average: 4.12, 4.16, 4.07
0
Reply jeandavid8 (968) 8/28/2006 10:54:53 AM

Tom Forsmo wrote:

> So my question is, how can i verify its use and is there anything that
> needs to be done to existing programs or the linux distro to utilise it.

top and ps aux work.

Like aragorn said, press '1' after typing top. (Useful tip, Aragorn!)

Otherwise, the default display of top shows "Cpu(s)"

If you have a dual core machine and you are using one core only, Cpu(s)
will be ~50.0%.
The task running would show %CPU as ~99.9

If you are using both cores, Cpu(s) will be ~99.9% and you would see
_two_ processes with %CPU ~99.9

Similarly for ps aux. You will see two 99.9's if you are using both
cores.

For reference, one of the SuSE 10.0 x86-64 kernels on my dual core
Intel D 805 machine:
Linux linux 2.6.13-15.11-smp #1 Mon Jul 17 09:43:01 UTC 2006 x86_64
GNU/Linux

0
Reply altcomphardware (64) 8/28/2006 11:58:05 AM

Jean-David Beyer <jeandavid8@verizon.net> writes:

> Something funny here. You compile the kernel for either uniprocessor (one
> processor with one core), or symmetric multiprocessor (more than one
> processor with possibly more than one core). Unless kernels have changed
> lately, those are the only two option.

That is basically true, but when you select SMP then you also get the
option to optimise for Hyperthreading and/or Multi-core processors. 
0
Reply newspost3823 (17) 8/28/2006 12:27:26 PM

Aragorn wrote:
> On Monday 28 August 2006 11:01, Tom Forsmo stood up and addressed the masses
> in /comp.os.linux.misc/ as follows...:
> 
>> Hi
>>
>> I recently bought a centrino dual core machine, and compiled a kernel
>> 2.6.17.8 with support for kernel threading and 2 processors/cores.
> 
> Perhaps you should have set it up for 4 processors, because if those cores
> are hyperthreaded - and provided that hyperthreading is enabled in the BIOS
> _and_ that you're running an ACPI interpreter - then you have 4 logical
> CPU's.

Perhaps I shall have a look at it, but I dont think this processor 
supports hyperhtreading. I think I read somewhere that they disabled it 
for this processor type because you didnt gain much by it.

>> When I tried utilising both cores, I had a look at top/ps to see if
>> linux distributed the processes/tasks to both processors, but according
>> to it it only used one of the cores.
> 
> /top/ normally defaults to showing a non-SMP view.  You should press "1" to
> enable an SMP view.

Thanks for the tip, I also found that adding the P column show which 
processor the process is running on. (and some other columns can be 
added to get thread information.)

>> Looking at the web for information on how to control and utilise
>> multi-processors/cores in linux only yield information about linux
>> supporting in 2.2/2.4 kernels and some odd information on how to
>> programm for it. Not how to verify it is beeing utilised, in what way or
>> if there are things that need to be configured for it to work properly.
> 
> I would advise sticking to a 2.6 kernel for such a machine.

I have to use 2.6 because the machine wont run on anything pre 2.6.7

> 
>> So my question is, how can i verify its use and is there anything that
>> needs to be done to existing programs or the linux distro to utilise it.
> 
> The kernel will dispatch processes across the available CPU
> cores/hyperthreads as it sees fit, 

Thats what everybody says, but what I was looking for was hard facts, a 
top/ps output showing me that this was the case on my machine, 
fortunately I found parts of it.

> If you want your userspace processes to support threads - and to thus
> execute faster on a multi-threaded machine - you'll have to compile them
> with thread support.  Older GNU/Linux distributions make use of the
> so-called Linux Threads (LT), while newer distributions make use of the
> Native POSIX Threads for Linux (NPTL), with or without support for the
> older Linux Threads.

Thanks for the tip, I think for most userapps multiprocessing is fine, 
but for some I might consider recompiling with threading support.

>> Any information, pointers or good articles explaining system
>> administration of smp functionality is highly appreciated.
> 
> Your Google's as good as mine... ;-)

Only if we use the same search expression ;)

Ive tried searching for things like "linux smp administration", ".. 
multicore.." "...multiprocessing..." and so forth but all I get are a 
couple of year old articles saying how wonderful linux is now that it 
supports smp systems and so forth. I cant seem to find anything about 
how to use sysadm tools to get an overview of or controlling the smp 
operations of the linux kernel, f.ex what tools can be used for such 
status info, are there any special tools, how to get smp/threading 
information from /proc etc.

Any hints?

regards

tom

0
Reply spam225 (180) 8/28/2006 1:50:06 PM

Tom Forsmo wrote:
> Any information, pointers or good articles explaining system 
> administration of smp functionality is highly appreciated.

$cat /proc/cpuinfo

to see the number of CPU's the kernel actually sees / uses/



	Igmar
0
Reply igmar2 (50) 8/28/2006 2:05:58 PM

On Monday 28 August 2006 13:58, composlinuxmisc stood up and addressed the
masses in /comp.os.linux.misc/ as follows...:

> Like aragorn said, press '1' after typing top. (Useful tip, Aragorn!)

You can also toggle between an IRIX-style view or a Solaris-style view. 
Just press "h" for instructions on the various viewmodes.  

And most importantly, if you press "W" - i.e. uppercase! - the current view
will be saved to *~/.toprc* and will be invoked again the next time you
bring up /top/ again. ;-)

I have mine also set up to highlight running processes and the column on
which the table is sorted, and I use a colored view. ;-)

-- 
With kind regards,

*Aragorn*
(registered GNU/Linux user #223157)
0
Reply stryder (1498) 8/29/2006 3:08:40 AM

8 Replies
33 Views

(page loaded in 0.208 seconds)


Reply: