Messages in this thread Patch in this message | | | From | Denis Vlasenko <> | Subject | [PATCH] Controlling code alignment from kernel config | Date | Fri, 27 Feb 2004 18:05:36 +0200 |
| |
On Friday 27 February 2004 00:38, Sam Ravnborg wrote: > > Is there any hope for these options be settable > > in make *config? > > Hi, I see no problem in adding support for this from a build system > perspective. But I will request you to bring it up at lkml, people there > may have knowledge / opinions that shall be taken into account. > > Do you care to try implemting it yourself, or are you stuck with the > functionality of the build system?
Attached patch adds
(n) Function alignment (n) Label alignment (n) Loop alignment (n) Jump alignment
to "General setup".
I compiled kernel with all options set to 1 (no alignment):
# size vmlinux.old vmlinux text data bss dec hex filename 4641327 1115225 220804 5977356 5b350c vmlinux.old 4362115 1115184 220804 5698103 56f237 vmlinux
(Dunno why data have changed too)
Comments? -- vda diff -urN 2.6.3.orig/Makefile 2.6.3/Makefile --- 2.6.3.orig/Makefile Wed Feb 18 05:58:39 2004 +++ 2.6.3/Makefile Fri Feb 27 17:49:05 2004 @@ -438,6 +438,19 @@ CFLAGS += -O2 endif +ifneq ($(CONFIG_CC_ALIGN_FUNCTIONS),0) +CFLAGS += -falign-functions=$(CONFIG_CC_ALIGN_FUNCTIONS) +endif +ifneq ($(CONFIG_CC_ALIGN_LABELS),0) +CFLAGS += -falign-labels=$(CONFIG_CC_ALIGN_LABELS) +endif +ifneq ($(CONFIG_CC_ALIGN_LOOPS),0) +CFLAGS += -falign-loops=$(CONFIG_CC_ALIGN_LOOPS) +endif +ifneq ($(CONFIG_CC_ALIGN_JUMPS),0) +CFLAGS += -falign-jumps=$(CONFIG_CC_ALIGN_JUMPS) +endif + ifndef CONFIG_FRAME_POINTER CFLAGS += -fomit-frame-pointer endif diff -urN 2.6.3.orig/init/Kconfig 2.6.3/init/Kconfig --- 2.6.3.orig/init/Kconfig Wed Feb 18 05:59:12 2004 +++ 2.6.3/init/Kconfig Fri Feb 27 17:58:17 2004 @@ -209,6 +209,43 @@ If unsure, say N. +config CC_ALIGN_FUNCTIONS + int "Function alignment" + default 0 + help + Align the start of functions to the next power-of-two greater than n, + skipping up to n bytes. For instance, 32 aligns functions + to the next 32-byte boundary, but 24 would align to the next + 32-byte boundary only if this can be done by skipping 23 bytes or less. + Zero means use compiler's default. + +config CC_ALIGN_LABELS + int "Label alignment" + default 0 + help + Align all branch targets to a power-of-two boundary, skipping + up to n bytes like ALIGN_FUNCTIONS. This option can easily + make code slower, because it must insert dummy operations for + when the branch target is reached in the usual flow of the code. + Zero means use compiler's default. + +config CC_ALIGN_LOOPS + int "Loop alignment" + default 0 + help + Align loops to a power-of-two boundary, skipping up to n bytes. + Zero means use compiler's default. + +config CC_ALIGN_JUMPS + int "Jump alignment" + default 0 + help + Align branch targets to a power-of-two boundary, for branch + targets where the targets can only be reached by jumping, + skipping up to n bytes like ALIGN_FUNCTIONS. In this case, + no dummy operations need be executed. + Zero means use compiler's default. + endmenu # General setup | |