From: Adrian Bunk <bunk@kernel.org>
To: Andi Kleen <andi@firstfloor.org>
Cc: Ingo Molnar <mingo@elte.hu>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Sam Ravnborg <sam@ravnborg.org>,
Alexander Viro <viro@ftp.linux.org.uk>,
"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [rfc] the kernel workflow & trivial "global -> static" patches
Date: Tue, 6 May 2008 09:18:25 +0300 [thread overview]
Message-ID: <20080506061825.GF1544@cs181133002.pp.htv.fi> (raw)
In-Reply-To: <874p9ccmes.fsf@basil.nowhere.org>
On Tue, May 06, 2008 at 02:21:31AM +0200, Andi Kleen wrote:
>
> I don't think the code changes actually with current gcc for integer
> code if you change something from global to static (unless it causes
> gcc to inline the function, but then it might be well larger if you're
> unlucky)
It's a common case that a function has only one caller. It should always
be an (at least tiny) space win to get them inlined.
> The only file size change you'll see will be from a smaller symbol
> table in the vmlinux ELF file, but that is not even loaded at run time
> or included into the bzImage (and the kallsyms table has statics too)
>...
I'm not attaching size change information to these patches since
whatever change one sees anyway also depends on other factors like
the exact kernel configuration, so it's non-trivial to get numbers
that could be taken seriously.
There are many small aspects, e.g. both gcc with -Wmissing-prototypes
and sparse give warnings, and the problem might either be needlessly
global code or the fact that a function prototype is either not in a
header or the header not #include'd by the file. Although I've only
2 or 3 times catched such bugs in the kernel that is a nasty to debug
class of bugs and gcc can find such problems at compile time.
> I could see some advantage from static in future compiler versions
> though from better optimization, but it's quite remote.
>...
The best case I've actually seen in practice was a variable I made
static, and with CONFIG_DEBUG_FOOBAR=n gcc was now able to prove that
the value never changed resulting in the variable plus quite a chunk
of code no longer emitted.
> -Andi
cu
Adrian
--
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed
next prev parent reply other threads:[~2008-05-06 6:19 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-05 18:29 [2.6 patch] make sched_feat_{names,open} static Adrian Bunk
2008-05-05 20:19 ` [rfc] the kernel workflow & trivial "global -> static" patches (was: Re: [2.6 patch] make sched_feat_{names,open} static) Ingo Molnar
2008-05-05 20:40 ` Randy.Dunlap
2008-05-05 21:51 ` Arjan van de Ven
2008-05-05 23:19 ` david
2008-05-05 23:40 ` Arjan van de Ven
2008-05-05 23:45 ` Theodore Tso
2008-05-06 3:23 ` Arjan van de Ven
2008-05-06 5:48 ` Arjan van de Ven
2008-05-05 20:42 ` Andrew Morton
2008-05-05 21:07 ` Adrian Bunk
2008-05-05 21:26 ` Andrew Morton
2008-05-05 21:45 ` Adrian Bunk
2008-05-05 21:46 ` Arjan van de Ven
2008-05-06 7:46 ` Andy Whitcroft
2008-05-05 21:02 ` Adrian Bunk
2008-05-06 0:21 ` [rfc] the kernel workflow & trivial "global -> static" patches Andi Kleen
2008-05-06 6:18 ` Adrian Bunk [this message]
2008-05-06 11:13 ` Andi Kleen
2008-05-06 11:25 ` Adrian Bunk
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=20080506061825.GF1544@cs181133002.pp.htv.fi \
--to=bunk@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=sam@ravnborg.org \
--cc=torvalds@linux-foundation.org \
--cc=viro@ftp.linux.org.uk \
/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
all inboxes | Powered by JetHome®