From: Denys Vlasenko <dvlasenk@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Thomas Graf <tgraf@suug.ch>,
"David S. Miller" <davem@davemloft.net>,
Bart Van Assche <bvanassche@acm.org>,
Peter Zijlstra <peterz@infradead.org>,
David Rientjes <rientjes@google.com>,
Oleg Nesterov <oleg@redhat.com>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Ingo Molnar <mingo@kernel.org>,
linux-kernel@vger.kernel.org, Hagen Paul Pfeifer <hagen@jauu.net>
Subject: Re: [PATCH] force inlining of spinlock ops
Date: Tue, 12 May 2015 11:44:43 +0200 [thread overview]
Message-ID: <5551CB8B.6060007@redhat.com> (raw)
In-Reply-To: <20150511151913.86c37cde9294700b4b0e26c4@linux-foundation.org>
On 05/12/2015 12:19 AM, Andrew Morton wrote:
> On Mon, 11 May 2015 19:57:22 +0200 Denys Vlasenko <dvlasenk@redhat.com> wrote:
>
>> With both gcc 4.7.2 and 4.9.2, sometimes gcc mysteriously doesn't inline
>> very small functions we expect to be inlined. In particular,
>> with this config: http://busybox.net/~vda/kernel_config
>> there are more than a thousand copies of tiny spinlock-related functions:
>>
>> $ nm --size-sort vmlinux | grep -iF ' t ' | uniq -c | grep -v '^ *1 ' | sort -rn | grep ' spin'
>> 473 000000000000000b t spin_unlock_irqrestore
>> 292 000000000000000b t spin_unlock
>> 215 000000000000000b t spin_lock
>> 134 000000000000000b t spin_unlock_irq
>> 130 000000000000000b t spin_unlock_bh
>> 120 000000000000000b t spin_lock_irq
>> 106 000000000000000b t spin_lock_bh
>>
>> Disassembly:
>>
>> ffffffff81004720 <spin_lock>:
>> ffffffff81004720: 55 push %rbp
>> ffffffff81004721: 48 89 e5 mov %rsp,%rbp
>> ffffffff81004724: e8 f8 4e e2 02 callq <_raw_spin_lock>
>> ffffffff81004729: 5d pop %rbp
>> ffffffff8100472a: c3 retq
>>
>> This patch fixes this via s/inline/__always_inline/ in spinlock.h.
>> This decreases vmlinux by about 30k:
>>
>> text data bss dec hex filename
>> 82375570 22255544 20627456 125258570 7774b4a vmlinux.before
>> 82335059 22255416 20627456 125217931 776ac8b vmlinux
>
> See also https://lkml.org/lkml/2015/4/23/598 ("enforce function
> inlining for hot functions").
>
> Presumably Hagen didn't see the issue with spinlock functions. I
> wonder why not.
>
> I suppose we should get both these consolidated into a coherent whole.
>
> It's a bit irritating to have to do this: presumably gcc will get fixed
> and the huge sprinkling of __always_inline will become less and less
> relevant over time and people will have trouble distinguishing "real
> __always_inline which was put here for a purpose" from "dopey
> __always_inline to work around a short-term gcc glitch".
In my patches, I put __always_inline *only* on functions
where my measurements show a large size decrease from doing so.
*Not* on functions where "I think it may be a good idea".
So far, all such functions were so trivial that inlining decision there
is a no-brainer.
> and then use inline_for_broken_gcc everywhere. That way, the reason
> for the marker is self-explanatory and we can later hunt all these
> things down and remvoe them.
>
> Also, the inline_for_broken_gcc definition can be made dependent on
> particular gcc versions, which will allow us to easily keep an eye on
> the behaviour of later gcc versions.
I've seen it on gcc-4.7.2 and gcc-4.9.2, so this behavior is not
limited to a narrow range of gcc versions. I'd say by now about half
of running kernels can easily be affected.
--
vda
next prev parent reply other threads:[~2015-05-12 9:45 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-11 17:57 [PATCH] force inlining of spinlock ops Denys Vlasenko
2015-05-11 18:53 ` Josh Triplett
2015-05-11 22:19 ` Andrew Morton
2015-05-12 8:16 ` Hagen Paul Pfeifer
2015-05-12 9:44 ` Denys Vlasenko [this message]
2015-05-12 9:48 ` Ingo Molnar
2015-05-12 7:44 ` Ingo Molnar
2015-05-12 11:02 ` Denys Vlasenko
2015-05-12 11:43 ` Ingo Molnar
2015-05-12 13:13 ` Denys Vlasenko
2015-05-13 10:17 ` Ingo Molnar
2015-05-13 10:28 ` Denys Vlasenko
2015-05-13 10:43 ` Ingo Molnar
2015-05-13 14:09 ` Denys Vlasenko
2015-05-15 7:20 ` Heiko Carstens
-- strict thread matches above, loose matches on Subject: below --
2015-07-13 18:31 Denys Vlasenko
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=5551CB8B.6060007@redhat.com \
--to=dvlasenk@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=bvanassche@acm.org \
--cc=davem@davemloft.net \
--cc=hagen@jauu.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=rientjes@google.com \
--cc=tgraf@suug.ch \
--cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.