# does SMP need to be on for makeopts=jX to work?

## rmbalfa

I searched with no luck . . . 

Do I need to turn on SMP in the kernel if I only have one CPU for the makeopts in make.conf to work properly?

I am asking because it seems to always be turned on by default when I emerge new sources. I thought maybe it was like that for a reason.

----------

## CriminalMastermind

no, if you only have one cpu then there is no point in enabling smp support in your kernel... at least none i know of.

the -j flag given to the make program tells make how many job's to run at the same time.  i think the rule of thumb is to make the number you put after j as the number of cpu's in your computer +1.

so if you have one cpu then you should have -j2.

this just makes the compile go faster.  it's not really required.

it's just like running more then one process on your computer at once.  smp is not required to do that.

i think the reasoning behind that is so one job is running you your cpu, while the other sits in the job que waiting to be next.

hope that helped.

----------

## secondshadow

I was under the impression that parallel makes meant that there would be that number of makes running at the same time not just that many waiting in the job que. If that were the case I'd probably use something like 8 or 9...

----------

## sumin k'adra

The idea here is that you max out CPU usage so there is no downtime, ie no wasted cycles. That is to say that when one process finishes and is transfering data to the HD and not using CPU cycles then the second process can be using the extra cycles. However, there is a level of overhead per parallel process. So setting it obsurdly high--8 or 9 processes/CPU--would more than likely slow things down rather then speed them up. Only one way to find out for sure though : )

-sk

----------

## secondshadow

Well...after watching top a few times while building things to -j1 and -j2 I've determined this: -j1=95% CPU load         -j2=97-99% CPU load. The problem I have with this is that the extra 2-4% probably doesn't justify having more than two things compiling at any given time. I've asked a head software engineer for a rather large company about it and he told me that from what he gathered from the -j option, you should probably have it equal to the number of CPU's you have because most of the time in a make is spent compiling, that is IF it indeed is actually running them in parallel. If its just queing them then I really don't see a benifit was more my point than anything else. I can't say that I've noticed any real speedup using -j2 vs. -j1 (which is what I use). If anything I'd say they typically exhibit fairly similar build times. But I have nothing concrete to back that up.

----------

## CriminalMastermind

there would only be one make running... make can call any other program it want's to.  the -j flag tell's it how many other programs to call at a time.

make is a program that with the help of a config file (the Makefile) knows how to make thinks... usually programs

so yes, it's the number of job's make will running at the same time.... but say you only have one processor.  if you think about it, only one program can be running on that processor at a time.  the cpu is shaired between all processes running on your computer.  they each get a specified time before they are booted off back into a que.  this is a que of program's waiting for there time on the processor.  processes with higher prioritys will cut ahead in the que.  that is the que i was talking about.

----------

## Luud

Hi all,

The rule of thumb to use number of CPUs + 1 is usually correct. I have an SMP system and make -j 3 gives the best results most of the time.

Make will start additional makes that are not dependent on each other.

For a single CPU machine, I'd suggest -j 2.

For a dual CPU machine, go for -j 3 or -j 4.

If it is still to slow for you and you have more than one machine, you could consider distcc.

Cheers.

----------

## rmbalfa

I turned of SMP and then this happened.

```
root@dogma linux # make bzImage

. scripts/mkversion > .tmpversion

gcc -D__KERNEL__ -I/usr/src/linux-2.4.22-gentoo-r4/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -finline-limit=2000 -fomit-frame-pointer -pipe -mpreferred-stack-boundary=2 -march=pentium3  -DUTS_MACHINE='"i386"' -DKBUILD_BASENAME=version -c -o init/version.o init/version.c

make CFLAGS="-D__KERNEL__ -I/usr/src/linux-2.4.22-gentoo-r4/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -finline-limit=2000 -fomit-frame-pointer -pipe -mpreferred-stack-boundary=2 -march=pentium3 " -C  kernel

make[1]: Entering directory `/usr/src/linux-2.4.22-gentoo-r4/kernel'

make all_targets

make[2]: Entering directory `/usr/src/linux-2.4.22-gentoo-r4/kernel'

gcc -D__KERNEL__ -I/usr/src/linux-2.4.22-gentoo-r4/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -finline-limit=2000 -fomit-frame-pointer -pipe -mpreferred-stack-boundary=2 -march=pentium3   -nostdinc -iwithprefix include -DKBUILD_BASENAME=ksyms  -DEXPORT_SYMTAB -c ksyms.c

In file included from /usr/src/linux-2.4.22-gentoo-r4/include/linux/modversions.h:145,

                 from /usr/src/linux-2.4.22-gentoo-r4/include/linux/module.h:21,

                 from ksyms.c:14:

/usr/src/linux-2.4.22-gentoo-r4/include/linux/modules/i386_ksyms.ver:84:1: warning: "cpu_data" redefined

In file included from /usr/src/linux-2.4.22-gentoo-r4/include/linux/prefetch.h:13,

                 from /usr/src/linux-2.4.22-gentoo-r4/include/linux/list.h:6,

                 from /usr/src/linux-2.4.22-gentoo-r4/include/linux/wait.h:14,

                 from /usr/src/linux-2.4.22-gentoo-r4/include/linux/fs.h:12,

                 from /usr/src/linux-2.4.22-gentoo-r4/include/linux/capability.h:17,

                 from /usr/src/linux-2.4.22-gentoo-r4/include/linux/binfmts.h:5,

                 from /usr/src/linux-2.4.22-gentoo-r4/include/linux/sched.h:9,

                 from /usr/src/linux-2.4.22-gentoo-r4/include/linux/mm.h:4,

                 from /usr/src/linux-2.4.22-gentoo-r4/include/linux/slab.h:14,

                 from ksyms.c:13:

/usr/src/linux-2.4.22-gentoo-r4/include/asm/processor.h:81:1: warning: this is the location of the previous definition

In file included from /usr/src/linux-2.4.22-gentoo-r4/include/linux/modversions.h:145,

                 from /usr/src/linux-2.4.22-gentoo-r4/include/linux/module.h:21,

                 from ksyms.c:14:

/usr/src/linux-2.4.22-gentoo-r4/include/linux/modules/i386_ksyms.ver:88:1: warning: "smp_num_cpus" redefined

In file included from /usr/src/linux-2.4.22-gentoo-r4/include/linux/sched.h:23,

                 from /usr/src/linux-2.4.22-gentoo-r4/include/linux/mm.h:4,

                 from /usr/src/linux-2.4.22-gentoo-r4/include/linux/slab.h:14,

                 from ksyms.c:13:

/usr/src/linux-2.4.22-gentoo-r4/include/linux/smp.h:80:1: warning: this is the location of the previous definition

In file included from /usr/src/linux-2.4.22-gentoo-r4/include/linux/modversions.h:145,

                 from /usr/src/linux-2.4.22-gentoo-r4/include/linux/module.h:21,

                 from ksyms.c:14:

/usr/src/linux-2.4.22-gentoo-r4/include/linux/modules/i386_ksyms.ver:90:1: warning: "cpu_online_map" redefined

In file included from /usr/src/linux-2.4.22-gentoo-r4/include/linux/sched.h:23,

                 from /usr/src/linux-2.4.22-gentoo-r4/include/linux/mm.h:4,

                 from /usr/src/linux-2.4.22-gentoo-r4/include/linux/slab.h:14,

                 from ksyms.c:13:

/usr/src/linux-2.4.22-gentoo-r4/include/linux/smp.h:90:1: warning: this is the location of the previous definition

In file included from /usr/src/linux-2.4.22-gentoo-r4/include/linux/modversions.h:145,

                 from /usr/src/linux-2.4.22-gentoo-r4/include/linux/module.h:21,

                 from ksyms.c:14:

/usr/src/linux-2.4.22-gentoo-r4/include/linux/modules/i386_ksyms.ver:104:1: warning: "smp_call_function" redefined

In file included from /usr/src/linux-2.4.22-gentoo-r4/include/linux/sched.h:23,

                 from /usr/src/linux-2.4.22-gentoo-r4/include/linux/mm.h:4,

                 from /usr/src/linux-2.4.22-gentoo-r4/include/linux/slab.h:14,

                 from ksyms.c:13:

/usr/src/linux-2.4.22-gentoo-r4/include/linux/smp.h:89:1: warning: this is the location of the previous definition

In file included from /usr/src/linux-2.4.22-gentoo-r4/include/linux/modversions.h:184,

                 from /usr/src/linux-2.4.22-gentoo-r4/include/linux/module.h:21,

                 from ksyms.c:14:

/usr/src/linux-2.4.22-gentoo-r4/include/linux/modules/ksyms.ver:590:1: warning: "del_timer_sync" redefined

In file included from /usr/src/linux-2.4.22-gentoo-r4/include/linux/ext3_fs_sb.h:20,

                 from /usr/src/linux-2.4.22-gentoo-r4/include/linux/fs.h:726,

                 from /usr/src/linux-2.4.22-gentoo-r4/include/linux/capability.h:17,

                 from /usr/src/linux-2.4.22-gentoo-r4/include/linux/binfmts.h:5,

                 from /usr/src/linux-2.4.22-gentoo-r4/include/linux/sched.h:9,

                 from /usr/src/linux-2.4.22-gentoo-r4/include/linux/mm.h:4,

                 from /usr/src/linux-2.4.22-gentoo-r4/include/linux/slab.h:14,

                 from ksyms.c:13:

/usr/src/linux-2.4.22-gentoo-r4/include/linux/timer.h:30:1: warning: this is the location of the previous definition

In file included from /usr/src/linux-2.4.22-gentoo-r4/include/linux/modversions.h:184,

                 from /usr/src/linux-2.4.22-gentoo-r4/include/linux/module.h:21,

                 from ksyms.c:14:

/usr/src/linux-2.4.22-gentoo-r4/include/linux/modules/ksyms.ver:674:1: warning: "set_cpus_allowed" redefined

In file included from /usr/src/linux-2.4.22-gentoo-r4/include/linux/mm.h:4,

                 from /usr/src/linux-2.4.22-gentoo-r4/include/linux/slab.h:14,

                 from ksyms.c:13:

/usr/src/linux-2.4.22-gentoo-r4/include/linux/sched.h:544:1: warning: this is the location of the previous definition

In file included from ksyms.c:17:

/usr/src/linux-2.4.22-gentoo-r4/include/linux/kernel_stat.h: In function `kstat_irqs':

/usr/src/linux-2.4.22-gentoo-r4/include/linux/kernel_stat.h:63: `smp_num_cpus' undeclared (first use in this function)

/usr/src/linux-2.4.22-gentoo-r4/include/linux/kernel_stat.h:63: (Each undeclared identifier is reported only once

/usr/src/linux-2.4.22-gentoo-r4/include/linux/kernel_stat.h:63: for each function it appears in.)

In file included from /usr/src/linux-2.4.22-gentoo-r4/include/linux/interrupt.h:52,

                 from ksyms.c:21:

/usr/src/linux-2.4.22-gentoo-r4/include/asm/hardirq.h:44:1: warning: "synchronize_irq" redefined

In file included from /usr/src/linux-2.4.22-gentoo-r4/include/linux/modversions.h:145,

                 from /usr/src/linux-2.4.22-gentoo-r4/include/linux/module.h:21,

                 from ksyms.c:14:

/usr/src/linux-2.4.22-gentoo-r4/include/linux/modules/i386_ksyms.ver:92:1: warning: this is the location of the previous definition

make[2]: *** [ksyms.o] Error 1

make[2]: Leaving directory `/usr/src/linux-2.4.22-gentoo-r4/kernel'

make[1]: *** [first_rule] Error 2

make[1]: Leaving directory `/usr/src/linux-2.4.22-gentoo-r4/kernel'

make: *** [_dir_kernel] Error 2

```

----------

## Luud

Try this:

```
cd /usr/src/linux

cp .config /root/dot-config

make mrproper

cp /root/dot-config .config

make oldconfig

make dep

make clean

make bzImage

... etc ...
```

If it still fails, verify if your kernel configuration is correct.

Good luck.

P.S. make mrproper cleans up your kernel source tree (also throwing away your configuration, that's why you need to copy the .config file).

----------

## rmbalfa

What exactly does make oldconfig do? It sounds obvious but why can't you just copy the dot-config file back to /usr/src/linux?

----------

## secondshadow

there are some things that only get done after make config/menuconfig/xconfig. I forget what the are, but without them the kernel won't build. 'make oldconfig' re-generates this information based on the current .config file the the source tree.

----------

## Luud

Make oldconfig also has another important function.

Say you have kernel version 2.4.22 and that configuration is working perfectly for your hardware. So you want to keep this configuration when you switch to a newer version, say 2.4.23.

Now it might be that some options disappeared or that new options are available. Just taking the .config of the first one and using it with the new kernel will (or might) not work. Make oldconfig will generate an appropriate .config file for the current kernel source tree and asks you to specify the configuration of new options. This is already present when you switch from gentoo-sources-2.4.22-r4 to gentoo-sources-2.4.22-r5. 

A list of some of the make target for the 2.4 series and older (honestly stolen from http://www.linuxdocs.org/HOWTOs/Kernel-HOWTO-5.html):

dep : `make clean'. This removes all of the object files and some other things that an old version leaves behind. In any case, do not forget this step before attempting to recompile a kernel

clean : This removes all of the object files and some other things that an old version leaves behind. In any case, do not forget this step before attempting to recompile a kernel

bzImage :: This will compile the kernel, and leave a file in arch/i386/boot called `bzImage' (among other things). This is the new compressed kernel (we are assuming x86 platform, of course on sparc for example it will not be in the i386 directory   :Wink:  ).

mrproper : This will do a more extensive cleaning. It is sometimes necessary; you may wish to do it at every patch. `make mrproper' will also delete your configuration file, so you might want to make a backup of it (.config) if you see it as valuable.

oldconfig : This will attempt to configure the kernel from an old configuration file; it will run through the `make config' process for you. If you haven't ever compiled a kernel before or don't have an old config file, then you probably shouldn't do this, as you will most likely want to change the default configuration.

Hope this helps.

----------

