From: Andi Kleen <ak@colin2.muc.de>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Andi Kleen <ak@muc.de>, Andrew Morton <akpm@osdl.org>,
jh@suse.cz, Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] Add noinline attribute
Date: 16 Jan 2004 11:13:45 +0100
Date: Fri, 16 Jan 2004 11:13:45 +0100 [thread overview]
Message-ID: <20040116101345.GA96037@colin2.muc.de> (raw)
In-Reply-To: <Pine.LNX.4.58.0401151448200.2597@evo.osdl.org>
> Ugh. Can't we just make this be generic code (and that means calling it in
> the module loading code too..)?
Ok, here is a new patch that does the whole thing in generic code and for
modules too. I didn't bother to change the sort algorithm because the
existing one works well enough.
-Andi
------------------------------------------------------------------
Sort exception tables at runtime. This avoids problems with out of
order sections like __init. Needed for gcc 3.4 or 3.3-hammer with
-funit-at-a-time.
diff -u linux-34/init/main.c-o linux-34/init/main.c
--- linux-34/init/main.c-o 2004-01-09 09:27:20.000000000 +0100
+++ linux-34/init/main.c 2004-01-16 10:07:00.699618728 +0100
@@ -289,6 +289,32 @@
}
__setup("init=", init_setup);
+extern struct exception_table_entry __start___ex_table[];
+extern struct exception_table_entry __stop___ex_table[];
+
+/* When an exception handler is in an non standard section (like __init)
+ the fixup table can end up unordered. Fix that here. */
+__init void sort_extable(struct exception_table_entry *start,
+ struct exception_table_entry *end)
+{
+ struct exception_table_entry *e;
+ int change;
+
+ /* The input is near completely presorted, which makes bubble sort the
+ best (and simplest) sort algorithm. */
+ do {
+ change = 0;
+ for (e = start+1; e < end; e++) {
+ if (e->insn < e[-1].insn) {
+ struct exception_table_entry tmp = e[-1];
+ e[-1] = e[0];
+ e[0] = tmp;
+ change = 1;
+ }
+ }
+ } while (change != 0);
+}
+
extern void setup_arch(char **);
extern void cpu_idle(void);
@@ -394,6 +420,7 @@
lock_kernel();
printk(linux_banner);
setup_arch(&command_line);
+ sort_extable(__start___ex_table, __stop___ex_table);
setup_per_cpu_areas();
/*
diff -u linux-34/kernel/module.c-o linux-34/kernel/module.c
--- linux-34/kernel/module.c-o 2004-01-09 09:27:20.000000000 +0100
+++ linux-34/kernel/module.c 2004-01-16 10:06:14.945574400 +0100
@@ -37,6 +37,9 @@
#include <asm/pgalloc.h>
#include <asm/cacheflush.h>
+extern void sort_extable(const struct exception_table_entry *start,
+ const struct exception_table_entry *end);
+
#if 0
#define DEBUGP printk
#else
@@ -1614,6 +1617,7 @@
/* Set up exception table */
mod->num_exentries = sechdrs[exindex].sh_size / sizeof(*mod->extable);
mod->extable = (void *)sechdrs[exindex].sh_addr;
+ sort_extable(mod->extable, mod->extable+mod->num_exentries);
/* Now do relocations. */
for (i = 1; i < hdr->e_shnum; i++) {
next prev parent reply other threads:[~2004-01-16 10:12 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-14 8:31 [PATCH] Add noinline attribute Andi Kleen
2004-01-14 23:23 ` Linus Torvalds
2004-01-15 7:48 ` Andi Kleen
2004-01-15 22:55 ` Linus Torvalds
2004-01-16 0:26 ` Peter Osterlund
2004-01-16 10:13 ` Andi Kleen [this message]
2004-01-18 20:47 ` Richard Henderson
2004-01-18 20:58 ` Andi Kleen
2004-01-19 0:41 ` Richard Henderson
2004-01-18 23:07 ` [PATCH] Add noinline attribute - new extable sort patch Andi Kleen
2004-01-19 0:52 ` Richard Henderson
2004-01-19 1:01 ` Andi Kleen
2004-01-19 11:26 ` Rusty Russell
2004-01-15 0:35 ` [PATCH] Add noinline attribute Rusty Russell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040116101345.GA96037@colin2.muc.de \
--to=ak@colin2.muc.de \
--cc=ak@muc.de \
--cc=akpm@osdl.org \
--cc=jh@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.