提交 4bdc3b7f 编写于 作者: A Arjan van de Ven 提交者: Linus Torvalds

[PATCH] x86_64: Basic reorder infrastructure

This patch puts the infrastructure in place to allow for a reordering of
functions based inside the vmlinux. The general idea is that it is possible
to put all "common" functions into the first 2Mb of the code, so that they
are covered by one TLB entry. This as opposed to the current situation where
a typical vmlinux covers about 3.5Mb (on x86-64) and thus 2 TLB entries.

This is done by enabling the -ffunction-sections flag in gcc, which puts
each function in its own ELF section, so that the linker can then order them
in a way defined by the linker script.

As per previous discussions, Linus said he wanted a "static" list for this,
eg a list provided by the kernel tarbal, so that most people have the same
ordering at least. A script is provided to create this list based on
readprofile(1) output. The included list is provisional, and entirely biased
on my own testbox and me running a few kernel compiles and some other
things.

I think that to get to a better list we need to invite people to submit
their own profiles, and somehow add those all up and base the final list on
that. I'm willing to do that effort if this is ends up being the prefered
approach. Such an effort probably needs to be repeated like once a year or
so to adopt to the changing nature of the kernel.

Made it a CONFIG with default n because it increases link times
dramatically.
Signed-off-by: NAndi Kleen <ak@suse.de>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 9b2a13b9
...@@ -464,6 +464,14 @@ config SECCOMP ...@@ -464,6 +464,14 @@ config SECCOMP
source kernel/Kconfig.hz source kernel/Kconfig.hz
config REORDER
bool "Function reordering"
default n
help
This option enables the toolchain to reorder functions for a more
optimal TLB usage. If you have pretty much any version of binutils,
this can increase your kernel build time by roughly one minute.
endmenu endmenu
# #
......
...@@ -36,6 +36,7 @@ CFLAGS += -m64 ...@@ -36,6 +36,7 @@ CFLAGS += -m64
CFLAGS += -mno-red-zone CFLAGS += -mno-red-zone
CFLAGS += -mcmodel=kernel CFLAGS += -mcmodel=kernel
CFLAGS += -pipe CFLAGS += -pipe
cflags-$(CONFIG_REORDER) += -ffunction-sections
# this makes reading assembly source easier, but produces worse code # this makes reading assembly source easier, but produces worse code
# actually it makes the kernel smaller too. # actually it makes the kernel smaller too.
CFLAGS += -fno-reorder-blocks CFLAGS += -fno-reorder-blocks
......
此差异已折叠。
...@@ -20,7 +20,12 @@ SECTIONS ...@@ -20,7 +20,12 @@ SECTIONS
phys_startup_64 = startup_64 - LOAD_OFFSET; phys_startup_64 = startup_64 - LOAD_OFFSET;
_text = .; /* Text and read-only data */ _text = .; /* Text and read-only data */
.text : AT(ADDR(.text) - LOAD_OFFSET) { .text : AT(ADDR(.text) - LOAD_OFFSET) {
/* First the code that has to be first for bootstrapping */
*(.bootstrap.text) *(.bootstrap.text)
/* Then all the functions that are "hot" in profiles, to group them
onto the same hugetlb entry */
#include "functionlist"
/* Then the rest */
*(.text) *(.text)
SCHED_TEXT SCHED_TEXT
LOCK_TEXT LOCK_TEXT
......
#!/usr/bin/perl
#
# Takes a (sorted) output of readprofile and turns it into a list suitable for
# linker scripts
#
# usage:
# readprofile | sort -rn | perl profile2linkerlist.pl > functionlist
#
while (<>) {
my $line = $_;
$_ =~ /\W*[0-9]+\W*([a-zA-Z\_0-9]+)\W*[0-9]+/;
if ( ($line =~ /unknown/) || ($line =~ /total/)) {
} else {
print "*(.text.$1)\n";
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册