public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Sort kallsyms in name order: kernel shrinks by 30k
@ 2004-05-11  5:08 Rusty Russell
  2004-05-11  5:23 ` Keith Owens
  2004-05-11  8:08 ` Andi Kleen
  0 siblings, 2 replies; 8+ messages in thread
From: Rusty Russell @ 2004-05-11  5:08 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Andi Kleen, randy.dunlap, Sam Ravnborg,
	lkml - Kernel Mailing List

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


^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: [PATCH] Sort kallsyms in name order: kernel shrinks by 30k
@ 2004-05-13  0:05 Albert Cahalan
  0 siblings, 0 replies; 8+ messages in thread
From: Albert Cahalan @ 2004-05-13  0:05 UTC (permalink / raw)
  To: linux-kernel mailing list; +Cc: rusty, kaos, ak

> 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.

That's nothing these days.

How does this change stand up to benchmarking?
Start up 12345 processes or more, then do this:

time ps -eo wchan >> /dev/null
time cat /proc/*/wchan >> /dev/null

As Keith Owens says, "top can consume a complete
cpu out of 128 cpus". (not that I can verify this)



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2004-05-13  2:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-11  5:08 [PATCH] Sort kallsyms in name order: kernel shrinks by 30k Rusty Russell
2004-05-11  5:23 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox