From: Andi Kleen Using -mregparm=3 shrinks the kernel further: (compiled with gcc 3.4, without -funit-at-a-time, using the later and together with -Os shrinks .text even more, making over 700KB difference) 4129346 708629 207240 5045215 4cfbdf vmlinux 3892905 708629 207240 4808774 496046 vmlinux-regparm This one helps even more, >236KB .text difference. Clearly worth the effort. This patch adds an option to use -mregparm=3 while compiling the kernel. I did an LTP run and it showed no additional failures over an non regparm kernel. According to some gcc developers it should be safe to use in all gccs that are still supports (2.95 and up) I didn't make it the default because it will break all binary only modules (although they can be fixed by adding a wrapper that calls them with "asmlinkage"). Actually it may be a good idea to make this default with 2.7.1 or somesuch. --- arch/i386/Kconfig | 8 ++++++++ arch/i386/Makefile | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff -puN arch/i386/Kconfig~add-config-for-mregparm-3 arch/i386/Kconfig --- 25/arch/i386/Kconfig~add-config-for-mregparm-3 2004-01-19 16:45:57.000000000 -0800 +++ 25-akpm/arch/i386/Kconfig 2004-01-19 17:20:36.000000000 -0800 @@ -832,6 +832,14 @@ config BOOT_IOREMAP depends on (((X86_SUMMIT || X86_GENERICARCH) && NUMA) || (X86 && EFI)) default y +config REGPARM + bool "Use register arguments (EXPERIMENTAL)" + default n + help + Compile the kernel with -mregparm=3. This uses an different ABI + and passes the first three arguments of a function call in registers. + This will probably break binary only modules. + endmenu diff -puN arch/i386/Makefile~add-config-for-mregparm-3 arch/i386/Makefile --- 25/arch/i386/Makefile~add-config-for-mregparm-3 2004-01-19 16:45:57.000000000 -0800 +++ 25-akpm/arch/i386/Makefile 2004-01-19 17:22:25.000000000 -0800 @@ -68,7 +68,9 @@ cpuflags-$(CONFIG_CPU_386) := -march=i38 # AMD Elan support cpuflags-$(CONFIG_X86_ELAN) := -march=i486 -CFLAGS += $(cpuflags-y) +cflags-$(CONFIG_REGPARM) += -mregparm=3 + +CFLAGS += $(cpuflags-y) $(cflags-y) # Default subarch .c files mcore-y := mach-default _