Re: [PATCH] Generic dead function optimisation

From: Andrew Morton (andrewm@uow.edu.au)
Date: Thu Apr 20 2000 - 08:10:59 EST


Graham Stoney wrote:
>
> Andrew Morton writes:
> > x86/SMP: Patch applies cleanly against 2.2.14-pre9. vmlinux ends
> > up with ~300 bytes less text, from one meg.
>
> A huge and compelling saving indeed! Seriously though, you aren't going to see
> large savings unless you are turing off config options you don't need, like
> CONFIG_PROC and CONFIG_SYSCTL. There will be even bigger benefits once I post
> my CONFIG_MESSAGES patch, hopefully later today.

Sorry, Graham. I screwed up - got the compiler versions tangled, ended
up compiling with 2.7.2.3. You very sneakily determine whether the
compiler supports -ffunction-sections and if not, fall back to the old
behaviour.

The size diff I saw was due to compiling with and without '-g' which, of
course, should make no difference but does...

Here are the sizes _with_ CONFIG_PROC_FS:

   text data bss dec hex filename
1117557 137720 119428 1374705 14f9f1 vmlinux

   text data bss dec hex filename
1075327 132240 119428 1326995 143f93 vmlinux

3.5% decrease in toto.

Without CONFIG_PROC_FS:

   text data bss dec hex filename
1058180 124440 119396 1302016 13de00 vmlinux

   text data bss dec hex filename
1011806 120196 119396 1251398 131846 vmlinux

4% decrease.

I'm including netfilter and scsi. The kernel without /proc hangs during
boot just after enabling swap space. This is with or without your patch,
so we need to talk to our pals at Mandrake about that :-) With /proc it
comes up fine.

An added bonus from this patch is that it allows ifdefs to be removed so
that code can be always compiled, even if it's not required. This is a
maintenance plus, preventing trivial mistakes from propagating.

Interesting that 'ld --gc-sections' takes about 15x longer than normal.

I would suggest that you make '-ffunction-sections/--gc-sections' _not_
be the default behaviour - it's a concern that you're treading rarely
travelled code paths through the compiler and linker. Perhaps add an
experimental CONFIG_GC_FUNCTIONS?

Regarding your string elimination patch:

I'm not sure that doing:

#ifdef CONFIG_MESSAGES
..
#else
#define printk(fmt, args...)
#endif

is the best approach. After all, printk() _does_ return an int,
although you've proven that a lot of the kernel doesn't use this return
value. But if someone does, they'll get a syntax error without
CONFIG_MESSAGES. Perhaps:

#else
extern inline int printk(const char *s, ...)
{
        return 0;
}
#endif

-- 
-akpm-

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Apr 23 2000 - 21:00:17 EST