# Core 2 Duo, but only one core works

## m.s.w

Hi !

I have a Core 2 Duo CPU (Intel E6600).  I have also gkrellm running. I realized, that during most of the work of gcc (compiling programs), or durig work of other software (like avidemux) only one core at a time is working (one core is doing 100% of the job, and the othre one is idle). I wonder if this is a matter of bad system, or bad hardware or bad programs. Is that mean, that only half of my CPU is used? 

Does it mean that it is better to have one core processor but operating at higher frequency?

I just don't get it...

----------

## NeddySeagoon

m.s.w,

Does uname -a say anything about SMP ? 

```
$ uname -a

Linux NeddySeagoon 2.6.29-gentoo-r1 #2 SMP PREEMPT Wed Apr 15 19:02:51 BST 2009 x86_64 AMD Phenom(tm) II X3 720 Processor AuthenticAMD GNU/Linux
```

If not, your kernel only supports one CPU.  Turn on SMP and select the number of cores you have in Number of CPUs

----------

## loki99

As far as I understand, this is a software problem. Most software is still written  for single cores so you do not see  too much of a difference unless you run more applications at once. So if you want to have top speed for certain single threaded applications a faster single core cpu is  the better choice. On the other hand, there are a couple of programs that run multi threaded like portage ie., which does quite a good job of utilizing both of my cores.

Plz post your emerge --info

----------

## krinn

 *NeddySeagoon wrote:*   

> 
> 
> If not, your kernel only supports one CPU...

 

and 

 *m.s.w wrote:*   

> (one core is doing 100% of the job, and the othre one is idle).

 

i love to quote neddyseagoon  :Razz: 

about the thread: it's just the program you are using only use 1 core, if the program have more than 1 thread the load balance will be made when possible.

you'll see that when you will emerge something, your cores will work.

but if you use a program that will busy one core, another version of that same program will busy the other one (because 2nd core is idle, kernel will give the task to it), as if you run 2x ffmepg

----------

## poly_poly-man

MAKEOPTS="-j3"

put that in your make.conf.

also add "threads" to your USE flags.

----------

## m.s.w

NeddySeagoon:

```
maniek@mkm-box ~ $ uname -a

Linux mkm-box 2.6.28-gentoo-r2-mkm #1 SMP PREEMPT Sat Mar 7 21:15:56 CET 2009 i686 Intel(R) Core(TM)2 CPU 6600 @ 2.40GHz GenuineIntel GNU/Linux
```

Well, I am surprised  how only the little number of apps is using dual cores. Emerging not always is using both cores. 

My emerge --info:

```

maniek@mkm-box ~ $ emerge --info

Portage 2.2_rc30 (default/linux/x86/2008.0, gcc-4.3.3, glibc-2.9_p20081201-r2, 2.6.28-gentoo-r2-mkm i686)

=================================================================

System uname: Linux-2.6.28-gentoo-r2-mkm-i686-Intel-R-_Core-TM-2_CPU_6600_@_2.40GHz-with-glibc2.0

Timestamp of tree: Fri, 17 Apr 2009 20:00:01 +0000

app-shells/bash:     3.2_p39

dev-java/java-config: 1.3.7-r1, 2.1.7

dev-lang/python:     2.4.4-r13, 2.5.2-r7

dev-python/pycrypto: 2.0.1-r6

dev-util/cmake:      2.6.3-r1

sys-apps/baselayout: 2.0.0

sys-apps/openrc:     0.4.3-r1

sys-apps/sandbox:    1.2.18.1-r2

sys-devel/autoconf:  2.13, 2.63

sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10.2

sys-devel/binutils:  2.19.1-r1

sys-devel/gcc-config: 1.4.1

sys-devel/libtool:   1.5.26

virtual/os-headers:  2.6.27-r2

ACCEPT_KEYWORDS="x86"

CBUILD="i686-pc-linux-gnu"

CFLAGS="-O2 -march=prescott -pipe -fomit-frame-pointer"

CHOST="i686-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/config /var/lib/hsqldb"

CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c /etc/udev/rules.d"

CXXFLAGS="-O2 -march=prescott -pipe"

DISTDIR="/usr/portage/distfiles"

FEATURES="collision-protect distlocks fixpackages parallel-fetch preserve-libs protect-owned sandbox sfperms strict unmerge-orphans"

GENTOO_MIRRORS="ftp://gentoo.inode.at/source/ http://194.117.143.70 http://gentoo.zie.pg.gda.pl http://src.gentoo.pl"

LANG="pl_PL.utf8"

LC_ALL="pl_PL.utf8"

LDFLAGS="-Wl,-O1"

LINGUAS="pl en_GB"

MAKEOPTS="-j3"

PKGDIR="/usr/portage/packages"

PORTAGE_CONFIGROOT="/"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

PORTDIR_OVERLAY="/usr/portage/local/layman/font-overlay /usr/portage/local/layman/font-overlay /usr/portage/local/layman/kadu-stable /usr/local/portage"

SYNC="rsync://rsync.gentoo.org/gentoo-portage"

USE="X acl alsa apache2 avi berkdb bzip2 cdr cli cracklib crypt cups doc dri dvd fam foomaticdb fortran gdbm gpm gtk2 iconv isdnlog java jpeg libv4l2 midi mozilla mudflap mysql ncurses nls nptl nptlonly nvidia opengl openmp pam pcre perl php png ppds pppd python qt readline reflection samba session spl sse sse2 ssl sysfs tcpd tiff truetype unicode usb x86 xml2 xorg zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1 emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic auth_digest authn_anon authn_dbd authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock dbd deflate dir disk_cache env expires ext_filter file_cache filter headers ident imagemap include info log_config logio mem_cache mime mime_magic negotiation proxy proxy_ajp proxy_balancer proxy_connect proxy_http rewrite setenvif so speling status unique_id userdir usertrack vhost_alias" CAMERAS="ptp2" ELIBC="glibc" INPUT_DEVICES="evdev keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="pl en_GB" USERLAND="GNU" VIDEO_CARDS="nvidia vesa v4l fbdev"

Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

```

Nothing unusuall. I was also surprised that avidemux is not using two cores - one of the most CPU-hungry applications. Dual cores (even quad cores) are not something new and yet, only few apps supports it. I understand, that the power of dual core is used when I am launching two or more applications at a time ? To be honest I don't see it in gkrellm, but this might be the gkrellm problem.

Anyway, thank you for your answers, they put some light at this subject.

----------

## pigeon768

A better way to get portage using multiple cores is to unmask -2.2 and run emerge with 'emerge --jobs 3 --load-average 3'.

And you're correct, most apps are single threaded.

----------

## Khumarahn

 *m.s.w wrote:*   

> Hi !
> 
> I have a Core 2 Duo CPU (Intel E6600).  I have also gkrellm running. I realized, that during most of the work of gcc (compiling programs), or durig work of other software (like avidemux) only one core at a time is working (one core is doing 100% of the job, and the othre one is idle). I wonder if this is a matter of bad system, or bad hardware or bad programs. Is that mean, that only half of my CPU is used? 
> 
> Does it mean that it is better to have one core processor but operating at higher frequency?
> ...

 

It's a good feature. One core does all the job, and then it becomes too hot, the other takes the job.

I don't remember exactly the advantages of this feature. May be, better cooling and power consumption.

Probably both will work when you have parallel tasks running.

----------

## Tekeli Li

Most apps are single threaded because their logic does not call for parallel processing. Number crunching applications that work on streams of data, of any sorts: images, video, audio, mathematical arrays, etc..., and applications that operate different subsystems at once, benefit a lot from and do use multiple threads (which system balances out on the cores), if written that way, and most modern apps usually are.

As for the portage, there are two solutions. MAKEOPTS="-jX" where X is more than 1 suggests portage to do parallel jobs within single package. Using --jobs as pigeon768 suggested is better solution because it tells portage to do more than one package in parallel. Of course, portage "knows" when it can't do that, for example, when single package is required before it can proceed with others (say a common dependency).

How many processes should be done in parallel? My opinion is that 2-4 per core works best. But that depends on what they're doing. If they're waiting on I/O, pushing more processes will only slow down because they will all choke on single serialized point: the I/O waiting. When it comes to portage, it is mostly CPU bound with exception of initial reading of the code and final writing of the compiled code. That's why I like to keep its temporary, compilation intermediate files in memory, and do more jobs in parallel.

However, parellel compilation makes sense, IMHO, only for initial or massive installations of sorts. Once you get your system running, doing gradual updates while you work on the computer at the same time, might call for less processing power, leaving the most for your job. That's why I keep MAKEOPTS="j1" and niceness at 5, and I don't notice at all when it compiles the updates in the background. I can always override this with temporary instructions on teh same command line with emerge, if I really need a burst of compilation power for something.

----------

## pappy_mcfae

m.s.w,

Please post /var/log/dmesg.

Blessed be!

Pappy

----------

## Erdie

You should post your kernel features section withing menuconfig as well

----------

## MaximeG

Hi,

A lot of applications are still mono threaded for different reasons.

1) Having these programs re-written for multi-threads is a lot of work, so sometimes developper don't bother doing it especially if the program isn't CPU bound

2) Having a program running with multi-threads is _hard_ (bugs risk increased, hard debugging, harder to design ...) to develop. So when the benefit isn't clear, it's better not to risk the multi thread.

3) When doing multi-threaded applications you have the so called overhead : the code lines used to manage the 2+ threads to gather results, to share efficiently the resources between the different threads .... In some occasion, this overhead is close or heavier than the benefit of the multi-thread (the more threads you have, the better chances you have this situation) which means that your multithreaded application is slower (or at least not clearly faster) than the normal one.

4) A real example of the latest is Python. Python allows virtual multithreads, but because of the tremendous work it would involve to make it really multithreaded, it's simply 'disabled', and every virtual threads (from the python virtual machine) run in a single real (from your machine point of view) thread. So, Python apps even if multithreaded will only use one core. Since portage is written in Python, you know why it uses only one core. (Now, you can do multiprocessing (multi-core) with python but not with base python and the threading library).

5) When emerging uses more than one core, it's because GCC is running, and it can be multi-threaded (with the -j compilation flag)

6) Even if only one core is used, it doesn't mean that your dual core processor isn't useful, this is the exact opposite. Actually it allows your computer to run 2 programs/threads at the same time, (almost) perfectly parallel, which a single core will never ever allow.

Conclusion :

Oh yes, multicore processors are way better than the others, especially when computers are used for different things at the same time. But no, it's not as easy as saying : "Hey I have two cores and now my computer is twice as fast as before."

To stay a bit more practical. Check whether your Linux kernel is configured to use mutli cores, and if you compiled/ran your software with the threads flag/option. Then, the multicore capable applications will use them and Linux will simply load balances your applications on the right/free core, that's the whole point of having an operating system isn't it ? 

Best Regards,

Maxime

----------

## alex.blackbit

 *Khumarahn wrote:*   

>  *m.s.w wrote:*   Hi !
> 
> I have a Core 2 Duo CPU (Intel E6600).  I have also gkrellm running. I realized, that during most of the work of gcc (compiling programs), or durig work of other software (like avidemux) only one core at a time is working (one core is doing 100% of the job, and the othre one is idle). I wonder if this is a matter of bad system, or bad hardware or bad programs. Is that mean, that only half of my CPU is used? 
> 
> Does it mean that it is better to have one core processor but operating at higher frequency?
> ...

 

you are joking, right?

----------

## MaximeG

I hope he does :p

----------

## Khumarahn

 *Quote:*   

> you are joking, right?

 

Just a bit   :Cool: 

Core 2 Duo (at least some  models) can put one core to sleep while the other is running at full capacity, and it appears to be more effective, even for power consumption.

And after a while cores exchange. And this is exactly how my system behaves when working with really hard continuous load.

Though, there is a small possibility that I'm wrong.

----------

## eccerr0r

 *alex.blackbit wrote:*   

>  *Khumarahn wrote:*   It's a good feature. One core does all the job, and then it becomes too hot, the other takes the job.
> 
> I don't remember exactly the advantages of this feature. May be, better cooling and power consumption.
> 
> Probably both will work when you have parallel tasks running. 
> ...

 

Some CPUs/OS's really do end up working like this if the cooling system failed.

However you shouldn't see this swapping between cpu/cores on a properly cooled system.  A process should stick to one core to run the fastest, swapping cores just slows it down.  However, random background processes waking up could affect the scheduler to swap the process between cores, and this is why single threaded apps tend to migrate cores once in a while.  Nothing to worry about, though it does hinder performance when the core swap happens...then again running background tasks also eats CPU time anyway...

----------

## rtomek

 *eccerr0r wrote:*   

> 
> 
> Some CPUs/OS's really do end up working like this if the cooling system failed.
> 
> However you shouldn't see this swapping between cpu/cores on a properly cooled system.  A process should stick to one core to run the fastest, swapping cores just slows it down.
> ...

 

My quad core runs most processes on core 0, then core 1.  Cores 2 and 3 seem to only get used when I'm running a bunch of threads.  My core 0/1 temps are about 2C-3C higher than my core 2/3 most of the time (it varies a lot), and still nothing gets sent to those cores.  Considering a core 2 duo is on a single die, I don't think there should be any difference in temps.  I think Intel slows down cores if they are getting too hot (I'm not sure how the scheduler handles that situation, but nowadays you would notice the slowdown first).

I really think that you are just running one job, and by default you will only compile one c file at a time, and that takes one core (one thread).  If you add -j2 (preferably -j3) to your MAKEOPTS (or emerge, or both...), gcc will compile more than one c file at a time and utilize both of your cores.

Personally, I have -j4 in my makeopts and I still run 'emerge -j4 <list of packages>' if I have a many packages to install.  configure scripts take up a lot of time and only use one thread so I want to make sure I'm utilizing everything I can.

The fact that he can see both cores means he's running an SMP system, otherwise it should only see core 0 (not see both and run jobs on one).

----------

## pappy_mcfae

If you truly want to track the action of both cores, you need to emerge -av xfce4 xfce4-extras...switching to XFCE on core-too...and install the CPU Graph applet in one of your panel bars. 

That applet not only gives a window with a graphical history, but it also shows two small bars. Each one represents one CPU core. Using it, you get an "instantaneous" reading of how much work each core is doing.

For instance, right now, since I'm looking for ET, BOINC is doing it's thing. The core bars alternate as to which one does more work. If you watch and you notice a trend toward favoring one core over the other, you might want to make sure you have IRQ balancing set in the kernel, and emerge -av irqbalance && rc-update add irqbalance default.

Blessed be!

Pappy

----------

## coolsnowmen

The kernel will move a task from one processor to another if it runs long and hard enough on my Dual processor Xeon(hyper threaded).

----------

## m.s.w

MaximeG, thanks a lot for your answer. I just don't know what do you mean by configuring kernel to use multi cores? Do you mean CONFIG_MCORE2=y ? I have it.

Does the scheduler have anything to do with it? CONFIG_DEFAULT_IOSCHED="cfq" thats what I have.

All of you describe more or less behavior of my processor so it looks like it acts as it should.

Thanks everybody for your input.

----------

## NeddySeagoon

m.s.w,

Check your kernel for

```
[*] Symmetric multi-processing support  

(4) Maximum number of CPUs   

[*] Multi-core scheduler support 
```

For Maximum number of CPUs read cores. Too high a number wastes memory but is otherwise harmless.

Too low a number prevents all your cores being used.

If you change any of these settings, rebuild the kernel starting with 

```
make clean
```

CONFIG_MCORE2=y is the type of CPU setting. The kernel does not use that to set up for multi CPU/Core support.

----------

