Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 26822 - $CPUS is never changed from 1 in genkernel
Summary: $CPUS is never changed from 1 in genkernel
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Daniel Robbins (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-08-17 13:38 UTC by James Hiscock
Modified: 2003-09-03 21:38 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description James Hiscock 2003-08-17 13:38:19 UTC
In the following snippet from genkernel, the value for CPUS is never changed
from 1, but the value is used to set MAKEOPTS:

MAKEOPTS="-j2"
CPUS="1"
get_number_of_jobs() {
        local jobs
        if [ ! -r /proc/cpuinfo ]
        then
                einfo "/proc not mounted; optimizing for uniprocessor compile..$
       fi
                                                                                
        jobs="`grep -c ^[Pp]rocessor /proc/cpuinfo`"
        # Make sure the number is valid ...
        if [ "${jobs}" -lt 1 ]
        then
                CPUS=1
        fi
                                                                                
        MAKEOPTS="-j$(( $CPUS * 2 ))"
                                                                                
}

Reproducible: Always
Steps to Reproduce:
1. emerge genkernel
2. run genkernel on a multi-processor system (or a system where 'grep -c
^[Pp]rocessor /proc/cpuinfo' returns a value > 1)
3. Watch the "compile optimization" setting

Actual Results:  
compile optimization: 1 processor(s)

on a P4/2.4GHz hyperthreaded system (where 'grep -c ^[Pp]rocessor /proc/cpuinfo'
returns 2)

Expected Results:  
compile optimization: 2 processor(s)

Here's a patch:

--- genkernel   2003-08-17 16:34:30.000000000 -0400
+++ /usr/sbin/genkernel 2003-08-17 16:35:22.000000000 -0400
@@ -47,6 +47,8 @@
        if [ "${jobs}" -lt 1 ]
        then
                CPUS=1
+       else
+               CPUS=${jobs}
        fi
  
        MAKEOPTS="-j$(( $CPUS * 2 ))"

Portage 2.0.48-r5 (default-x86-1.4, gcc-3.2.3, glibc-2.3.2-r1)
=================================================================
System uname: 2.4.20-win4lin-r1 i686 Intel(R) Pentium(R) 4 CPU 2.40GHz
GENTOO_MIRRORS="ftp://ftp.ussg.iu.edu/pub/linux/gentoo
ftp://cs.ubishops.ca/pub/gentoo ftp://gentoo.noved.org/ http://gentoo.noved.org/
http://adelie.polymtl.ca/"
CONFIG_PROTECT="/etc /var/qmail/control /usr/kde/2/share/config
/usr/kde/3/share/config /usr/X11R6/lib/X11/xkb /usr/kde/3.1/share/config
/usr/share/config"
CONFIG_PROTECT_MASK="/etc/gconf /etc/env.d"
PORTDIR="/usr/portage"
DISTDIR="/usr/portage/distfiles"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR_OVERLAY="/custom/portage"
USE="x86 oss 3dnow apm avi crypt encode foomaticdb gif jpeg libg++ mad mikmod
mmx mpeg ncurses nls pdflib png quicktime spell truetype xml2 xmms xv zlib
directfb gtkhtml alsa gdbm berkdb slang readline arts aalib nas bonobo svga ggi
tcltk guile ruby mysql postgres X sdl tcpd pam libwww ssl perl python esd imlib
oggvorbis gtk qt motif mozilla gphoto2 cdr acpi acpi4linux apache2 curl dga dvd
fbcon gd gd-external gtk2 i8x0 imap maildir moznocompose moznoirc moznomail mpi
pda pic sse tiff usb wmf gnome xinerama xml opengl -cups -java -gpm -kde"
COMPILER="gcc3"
CHOST="i686-pc-linux-gnu"
CFLAGS="-O3 -march=pentium3 -pipe"
CXXFLAGS="-O2 -mcpu=i686 -pipe"
ACCEPT_KEYWORDS="x86"
MAKEOPTS="-j2"
AUTOCLEAN="yes"
SYNC="rsync://rsync.namerica.gentoo.org/gentoo-portage"
FEATURES="sandbox buildpkg ccache"
Comment 1 James Hiscock 2003-08-17 13:41:24 UTC
Forgot to mention (and now I feel like a dolt): this was found in sys-kernel/genkernel-1.5
Comment 2 Daniel Robbins (RETIRED) gentoo-dev 2003-09-03 21:38:33 UTC
Thanks for the bug report; I was rushing. This will be fixed in 1.6 (working on it now, should be online tonight.)