[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[debian-knoppix] Possible kernel size tweak



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

	I don't know if Klaus has tried this already, but I think I found a way
to squeeze the kernel a bit more. I've been a fan of WOLK
(http://wolk.sf.net/) for some time now, and while compiling another
kernel with it I noticed this option:


CONFIG_GCC_OPTIMIZATION1:

If you select this, the whole kernel/modules will be build with -Os
instead of -O2. This "may" give you a performance gain on AMD
architectures. You can also select this for other architectures, the
kernel will be smaller than a kernel compiled with -O2 (usually ~ 100kb
smaller).

It would be nice if you can provide your experience with these settings
so we can probably make them default for some configurations/arches.

If you get hangs/reboots/panics with this option, try without it and if
it still occurs, report it.

If unsure, say N.


	A quick test confirmed that it shrunk my bzImage from 1.4MB to 1.3MB.
As for stability, I've had that option enabled on my webserver and
workstation with no problems. Not the best test, I know.

	I'm attaching a diff file that adds just that option to the stock
kernel. I haven't done much testing of it, but it's not an extensive patch.

HJ Hornbeck


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE+pc76bYQU8p5saQIRAliDAJ94FtdnvZQvYygfhhjgTN3GN/RTKwCfStrT
ZknCwnwgjhWe+lb3YzaUa+g=
=L5dh
-----END PGP SIGNATURE-----
--- linux-2.4.20/Makefile	2002-11-28 16:53:16.000000000 -0700
+++ linux-2.4.20_gccopt/Makefile	2003-04-22 15:53:10.000000000 -0600
@@ -17,7 +17,12 @@
 FINDHPATH	= $(HPATH)/asm $(HPATH)/linux $(HPATH)/scsi $(HPATH)/net $(HPATH)/math-emu
 
 HOSTCC  	= gcc
-HOSTCFLAGS	= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
+
+ifeq ($(CONFIG_GCC_OPTIMIZATION1),y)
+  HOSTCFLAGS   = -Wall -Wstrict-prototypes -Os -fomit-frame-pointer -pipe
+else
+  HOSTCFLAGS   = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -pipe
+endif
 
 CROSS_COMPILE 	=
 
@@ -88,8 +93,15 @@
 
 CPPFLAGS := -D__KERNEL__ -I$(HPATH)
 
-CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wno-trigraphs -O2 \
+CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wno-trigraphs \
 	  -fno-strict-aliasing -fno-common
+
+ifeq ($(CONFIG_GCC_OPTIMIZATION1),y)
+  CFLAGS += -Os
+else
+  CFLAGS += -O2
+endif
+
 ifndef CONFIG_FRAME_POINTER
 CFLAGS += -fomit-frame-pointer
 endif
--- linux-2.4.20/Documentation/Configure.help	2002-11-28 16:53:08.000000000 -0700
+++ linux-2.4.20_gccopt/Documentation/Configure.help	2003-04-22 15:49:40.000000000 -0600
@@ -266,6 +266,21 @@
   If you have a system with several CPUs, you do not need to say Y
   here: the IO-APIC will be used automatically.
 
+Compile the kernel with -Os instead of -O2
+CONFIG_GCC_OPTIMIZATION1
+  If you select this, the whole kernel/modules will be build with -Os instead
+  of -O2. This "may" give you a performance gain on AMD architectures. You
+  can also select this for other architectures, the kernel will be smaller than
+  a kernel compiled with -O2 (usually ~ 100kb smaller).
+  
+  It would be nice if you can provide your experience with these settings so
+  we can probably make them default for some configurations/arches.
+
+  If you get hangs/reboots/panics with this option, try without it and if it
+  still occurs, report it.
+  
+  If unsure, say N.
+
 Local APIC Support on Uniprocessors
 CONFIG_X86_UP_APIC
   A local APIC (Advanced Programmable Interrupt Controller) is an
--- linux-2.4.20/arch/i386/config.in	2002-11-28 16:53:09.000000000 -0700
+++ linux-2.4.20_gccopt/arch/i386/config.in	2003-04-22 16:31:17.000000000 -0600
@@ -227,6 +227,10 @@
 if [ "$CONFIG_SMP" = "y" -a "$CONFIG_X86_CMPXCHG" = "y" ]; then
    define_bool CONFIG_HAVE_DEC_LOCK y
 fi
+
+# Compiler option tweaks
+bool 'Compile the kernel with -Os instead of -O2' CONFIG_GCC_OPTIMIZATION1
+
 endmenu
 
 mainmenu_option next_comment



Reply to: