linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [2.6 patch] add an -Os config option
@ 2003-08-11 21:11 Adrian Bunk
  2003-08-11 21:19 ` Michael Buesch
                   ` (3 more replies)
  0 siblings, 4 replies; 22+ messages in thread
From: Adrian Bunk @ 2003-08-11 21:11 UTC (permalink / raw)
  To: linux-kernel

The patch below adds an option OPTIMIZE_FOR_SIZE (depending on EMBEDDED) 
that changes the optimization from -O2 to -Os.

cu
Adrian

--- linux-2.6.0-test3/init/Kconfig.old	2003-08-11 01:33:31.000000000 +0200
+++ linux-2.6.0-test3/init/Kconfig	2003-08-11 01:46:48.000000000 +0200
@@ -118,6 +118,17 @@
 	  a "non-standard" kernel.  Only use this if you really know what you
 	  are doing.
 
+config OPTIMIZE_FOR_SIZE
+	bool "Optimize for size" if EMBEDDED
+	default n
+	help
+	  Enabling this option will pass "-Os" instead of "-O2" to gcc
+	  resulting in a smaller kernel.
+
+	  The resulting kernel might be significantly slower.
+
+	  If unsure, say N.
+
 config KALLSYMS
 	 bool "Load all symbols for debugging/kksymoops" if EMBEDDED
 	 default y
--- linux-2.6.0-test3/Makefile.old	2003-08-11 01:34:41.000000000 +0200
+++ linux-2.6.0-test3/Makefile	2003-08-11 01:37:16.000000000 +0200
@@ -223,7 +223,7 @@
 NOSTDINC_FLAGS  = -nostdinc -iwithprefix include
 
 CPPFLAGS	:= -D__KERNEL__ -Iinclude
-CFLAGS 		:= -Wall -Wstrict-prototypes -Wno-trigraphs -O2 \
+CFLAGS 		:= -Wall -Wstrict-prototypes -Wno-trigraphs \
 	  	   -fno-strict-aliasing -fno-common
 AFLAGS		:= -D__ASSEMBLY__
 
@@ -318,6 +318,12 @@
 
 -include .config.cmd
 
+ifdef CONFIG_OPTIMIZE_FOR_SIZE
+CFLAGS		+= -Os
+else
+CFLAGS		+= -O2
+endif
+
 ifndef CONFIG_FRAME_POINTER
 CFLAGS		+= -fomit-frame-pointer
 endif

^ permalink raw reply	[flat|nested] 22+ messages in thread
* Re: [2.6 patch] add an -Os config option
@ 2003-08-12 19:43 John Bradford
  0 siblings, 0 replies; 22+ messages in thread
From: John Bradford @ 2003-08-12 19:43 UTC (permalink / raw)
  To: alan, miller; +Cc: bunk, linux-kernel

> >>+config OPTIMIZE_FOR_SIZE
> >>+	bool "Optimize for size" if EMBEDDED
> >>+	default n
> >>+	help
> >>+	  Enabling this option will pass "-Os" instead of "-O2" to gcc
> >>+	  resulting in a smaller kernel.
> >>+
> >>+	  The resulting kernel might be significantly slower.
> > 
> > 
> > With most of the gcc's I tried -Os was faster.
>
>
> Why is -Os faster?  Fewer cache misses?
>
> Wouldn't that make -O2 kinda pointless?  It seems kinda futile to 
> optimize for speed just to have it come out slower.

See the comments Linus made earlier this year on the same subject:

http://marc.theaimsgroup.com/?l=linux-kernel&m=104457390406050&w=2

Alan, could Valgrind help us to profile cache hits/misses in different
parts of the kernel?

John.

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2003-08-12 19:32 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-11 21:11 [2.6 patch] add an -Os config option Adrian Bunk
2003-08-11 21:19 ` Michael Buesch
2003-08-11 21:37   ` Mike Fedyk
2003-08-11 21:39   ` Christophe Saout
2003-08-11 21:41   ` Dagfinn Ilmari Mannsåker
2003-08-12  1:29   ` Gene Heskett
2003-08-12  2:51     ` Thomas Molina
2003-08-12  4:14       ` [OT] " Steven Cole
2003-08-12 15:25         ` Timothy Miller
2003-08-12 14:48       ` Gene Heskett
2003-08-12 10:11     ` Michael Buesch
2003-08-12 14:42       ` Gene Heskett
2003-08-12  1:45   ` Warren Turkal
2003-08-11 22:20 ` Russell King
2003-08-12  7:06 ` Christoph Hellwig
2003-08-12 15:43   ` Timothy Miller
2003-08-12 15:58     ` Adrian Bunk
2003-08-12 16:03     ` Kevin P. Fleming
2003-08-12 13:35 ` Alan Cox
2003-08-12 15:45   ` Joe Korty
2003-08-12 18:03   ` Timothy Miller
2003-08-12 19:43 John Bradford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).