From: Rusty Russell <rusty@rustcorp.com.au>
To: Andrew Morton <akpm@osdl.org>
Cc: Andi Kleen <ak@muc.de>,
randy.dunlap@osdl.org, Sam Ravnborg <sam@ravnborg.org>,
lkml - Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH] Sort kallsyms in name order: kernel shrinks by 30k
Date: Tue, 11 May 2004 15:08:55 +1000 [thread overview]
Message-ID: <1084252135.31802.312.camel@bach> (raw)
Admittedly, anyone who sets CONFIG_KALLSYMS doesn't care about space,
it's a fairly trivial change.
Name: Sort Kallsyms for Stem Compression
Status: Booted on 2.6.6
Depends: Misc/kallsyms-include-aliases.patch.gz
Leaving the symbols sorted by name rather than address, so stem
compression works more effectively. Saves a little over 30k here.
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .5923-linux-2.6.6/Makefile .5923-linux-2.6.6.updated/Makefile
--- .5923-linux-2.6.6/Makefile 2004-05-10 15:12:44.000000000 +1000
+++ .5923-linux-2.6.6.updated/Makefile 2004-05-11 14:45:37.000000000 +1000
@@ -567,7 +567,7 @@ ifdef CONFIG_KALLSYMS
kallsyms.o := .tmp_kallsyms2.o
quiet_cmd_kallsyms = KSYM $@
-cmd_kallsyms = $(NM) -n $< | $(KALLSYMS) > $@
+cmd_kallsyms = $(NM) $< | $(KALLSYMS) > $@
.tmp_kallsyms1.o .tmp_kallsyms2.o: %.o: %.S scripts FORCE
$(call if_changed_dep,as_o_S)
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .5923-linux-2.6.6/kernel/kallsyms.c .5923-linux-2.6.6.updated/kernel/kallsyms.c
--- .5923-linux-2.6.6/kernel/kallsyms.c 2004-05-11 14:45:36.000000000 +1000
+++ .5923-linux-2.6.6.updated/kernel/kallsyms.c 2004-05-11 14:49:45.000000000 +1000
@@ -62,7 +62,7 @@ const char *kallsyms_lookup(unsigned lon
unsigned long *offset,
char **modname, char *namebuf)
{
- unsigned long i, best = 0;
+ unsigned long i, best = -1UL;
/* This kernel should never had been booted. */
BUG_ON(!kallsyms_addresses);
@@ -74,10 +74,12 @@ const char *kallsyms_lookup(unsigned lon
unsigned long symbol_end;
char *name = kallsyms_names;
- /* They're sorted, we could be clever here, but who cares? */
+ /* Look for closest symbol <= address. */
for (i = 0; i < kallsyms_num_syms; i++) {
- if (kallsyms_addresses[i] > kallsyms_addresses[best] &&
- kallsyms_addresses[i] <= addr)
+ if (kallsyms_addresses[i] > addr)
+ continue;
+ if (best == -1UL
+ ||kallsyms_addresses[i] > kallsyms_addresses[best])
best = i;
}
@@ -94,12 +96,11 @@ const char *kallsyms_lookup(unsigned lon
else
symbol_end = (unsigned long)_etext;
- /* Search for next non-aliased symbol */
- for (i = best+1; i < kallsyms_num_syms; i++) {
- if (kallsyms_addresses[i] > kallsyms_addresses[best]) {
+ /* Search for next symbol */
+ for (i = 0; i < kallsyms_num_syms; i++) {
+ if (kallsyms_addresses[i] > kallsyms_addresses[best]
+ && kallsyms_addresses[i] < symbol_end)
symbol_end = kallsyms_addresses[i];
- break;
- }
}
*symbolsize = symbol_end - kallsyms_addresses[best];
--
Anyone who quotes me in their signature is an idiot -- Rusty Russell
next reply other threads:[~2004-05-11 5:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-11 5:08 Rusty Russell [this message]
2004-05-11 5:23 ` [PATCH] Sort kallsyms in name order: kernel shrinks by 30k Keith Owens
2004-05-11 8:08 ` Andi Kleen
2004-05-11 15:35 ` Randy.Dunlap
2004-05-11 23:16 ` Rusty Russell
2004-05-12 1:47 ` Matt Mackall
2004-05-12 6:00 ` Andi Kleen
-- strict thread matches above, loose matches on Subject: below --
2004-05-13 0:05 Albert Cahalan
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=1084252135.31802.312.camel@bach \
--to=rusty@rustcorp.com.au \
--cc=ak@muc.de \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=randy.dunlap@osdl.org \
--cc=sam@ravnborg.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox