linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Andi Kleen <andi@firstfloor.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Allow linker to eliminate unused functions in lib/*
Date: Fri, 8 Jan 2010 16:29:30 -0800	[thread overview]
Message-ID: <20100108162930.a011749a.akpm@linux-foundation.org> (raw)
In-Reply-To: <20100105145917.GA25570@basil.fritz.box>

On Tue, 5 Jan 2010 15:59:18 +0100
Andi Kleen <andi@firstfloor.org> wrote:

> Allow linker to eliminate unused functions in lib/*
> 
> Right now a lot of code in lib/* is obj-y and always linked
> in. The reason is that there is no other way to ensure the EXPORT_SYMBOLs
> get included.
> 
> This patch moves the EXPORT_SYMBOLs into separate files instead. This
> way the files actually implementing the code can be made lib-y again,
> and the separate export symbols pull them in for modular kernels.
> 
> For non modular kernels the linker can decide whether to use them
> or not. 
> 
> This shrinks a allnoconfig+CONFIG_EMBEDDED=y+all options disabled
> kernel by about 1k on x86. Not much, but also not too shabby.
> 
> In some ways that's similar to the old ksyms.c files, but
> not as centralized.
> 
> I didn't do this for the functions in lib/* which already have 
> Kconfig symbol. Presumably that is usually only set on demand
> when they are actually needed (although I'm not sure it's true
> for all cases).
> 

Sneaky.

It's a bit sad to reduce the code cleanliness and maintainability in
this way, but 1k is 1k.

Removing the module.h include from the .c files will hopefully help
people realise that new exports shouldn't be added to the .c files.

> --- linux-2.6.33-rc2-ak.orig/lib/lib-syms.c
> +++ linux-2.6.33-rc2-ak/lib/lib-syms.c
> @@ -5,9 +5,13 @@
>   * On modular kernels it keeps a reference to all the lib files with
>   * exports so that they can be used by modules.  On non modular
>   * kernels it does nothing and the linker can decide whether a lib
> - * object file is needed or not.
> + * object file is needed or not. This way unneeded library functions
> + * can be eliminated.
>   */

The patch assumes a pre-existing lib-syms.c.  Confused.

  reply	other threads:[~2010-01-09  0:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-05 14:59 [PATCH] Allow linker to eliminate unused functions in lib/* Andi Kleen
2010-01-09  0:29 ` Andrew Morton [this message]
2010-01-09 16:51   ` Andi Kleen
2010-01-10 23:17     ` Dave Chinner
2010-01-11 10:51       ` Christoph Hellwig
2010-01-11 14:24       ` Andi Kleen
2010-01-11 22:49         ` Dave Chinner
2010-01-15 23:44     ` Andrew Morton
2010-01-16 11:07       ` Andi Kleen

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=20100108162930.a011749a.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=andi@firstfloor.org \
    --cc=linux-kernel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).