Re: [patch 00/2] improve .text size on gcc 4.0 and newer compilers

Andrew Morton
2006-01-02T19:07:33Z

Krzysztof Halasa <khc@pm.waw.pl> wrote:
>
> Ingo Molnar <mingo@elte.hu> writes:
>
> > what is the 'deeper problem'? I believe it is a combination of two
> > (well-known) things:
> >
> > 1) people add 'inline' too easily
> > 2) we default to 'always inline'
>
> For example, I add "inline" for static functions which are only called
> from one place.
>
> If I'm able to say "this is static function which is called from one
> place" I'd do so instead of saying "inline". But omitting the "inline"
> with hope that some new gcc probably will inline it anyway (on some
> platform?) doesn't seem like a best idea.
>
> But what _is_ the best idea?

Just use `inline'. With gcc-3 it'll be inlined.

With gcc-4 and Ingo's patch it _might_ be inlined. And it _might_ be
uninlined by the compiler if someone adds a second callsite later on.
Maybe. We just don't know. That's a problem. Use of __always_inline will
remove this uncertainty.

So our options appear to be:

a) Go fix up stupid inlinings (again) or

b) Apply Ingo's patch, then go add __always_inline to places which we
care about.

Either way, we need to go all over the tree. In practice, we'll only
bother going over the bits which we most care about (core kernel, core
networking, a handful of net and block drivers). I suspect many of the bad
inlining decisions are in poorly-maintained code - we've been pretty
careful about this for several years.