From: Nadav Amit <namit@vmware.com>
To: Nick Desaulniers <ndesaulniers@google.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Linus Torvalds <torvalds@linux-foundation.org>,
"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
<x86@kernel.org>, LKML <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>,
Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>,
Masahiro Yamada <yamada.masahiro@socionext.com>,
clang-built-linux <clang-built-linux@googlegroups.com>,
Joe Perches <joe@perches.com>
Subject: Re: [RFC PATCH 0/5] make use of gcc 9's "asm inline()"
Date: Thu, 29 Aug 2019 18:26:07 +0000 [thread overview]
Message-ID: <6C70DE15-0F83-4CBB-B25B-EFF50BC34DD3@vmware.com> (raw)
In-Reply-To: <CAHk-=wgZ7Ge8QUkkSZLCfJBsHRsre65DkfTyZ2Kt5VPwa=dkuA@mail.gmail.com>
> On Aug 29, 2019, at 11:15 AM, Linus Torvalds <torvalds@linux-foundation.org> wrote:
>
> On Thu, Aug 29, 2019 at 10:36 AM Nick Desaulniers
> <ndesaulniers@google.com> wrote:
>> I'm curious what "the size of the asm" means, and how it differs
>> precisely from "how many instructions GCC thinks it is." I would
>> think those are one and the same? Or maybe "the size of the asm"
>> means the size in bytes when assembled to machine code, as opposed to
>> the count of assembly instructions?
>
> The problem is that we do different sections in the inline asm, and
> the instruction counts are completely bogus as a result.
>
> The actual instruction in the code stream may be just a single
> instruction. But the out-of-line sections can be multiple instructions
> and/or a data section that contains exception information.
>
> So we want the asm inlined, because the _inline_ part (and the hot
> instruction) is small, even though the asm technically maybe generates
> many more bytes of additional data.
>
> The worst offenders for this tend to be
>
> - various exception tables for user accesses etc
>
> - "alternatives" where we list two or more different asm alternatives
> and then pick the right one at boot time depending on CPU ID flags
>
> - "BUG_ON()" instructions where there's a "ud2" instruction and
> various data annotations going with it
>
> so gcc may be "technically correct" that the inline asm statement
> contains ten instructions or more, but the actual instruction _code_
> footprint in the asm is likely just a single instruction or two.
>
> The statement counting is also completely off by the fact that some of
> the "statements" are assembler directives (ie the
> ".pushsection"/".popsection" lines etc). So some of it is that the
> instruction counting is off, but the largest part is that it's just
> not relevant to the code footprint in that function.
>
> Un-inlining a function because it contains a single inline asm
> instruction is not productive. Yes, it might result in a smaller
> binary over-all (because all those other non-code sections do take up
> some space), but it actually results in a bigger code footprint.
For the record, here is my failing attempt to address the issue without GCC
support:
https://lore.kernel.org/lkml/20181003213100.189959-9-namit@vmware.com/T/
next prev parent reply other threads:[~2019-08-29 18:26 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-29 8:32 [RFC PATCH 0/5] make use of gcc 9's "asm inline()" Rasmus Villemoes
2019-08-29 8:32 ` [RFC PATCH 1/5] treewide: replace __inline__ by inline Rasmus Villemoes
2019-08-29 16:29 ` Joe Perches
2019-08-29 8:32 ` [RFC PATCH 2/5] compiler_types.h: don't #define __inline__ Rasmus Villemoes
2019-08-29 8:32 ` [RFC PATCH 3/5] compiler-gcc.h: add asm_inline definition Rasmus Villemoes
2019-08-29 8:32 ` [RFC PATCH 4/5] x86: alternative.h: use asm_inline for all alternative variants Rasmus Villemoes
2019-08-29 8:32 ` [RFC PATCH 5/5] x86: bug.h: use asm_inline in _BUG_FLAGS definitions Rasmus Villemoes
2019-08-29 16:05 ` [RFC PATCH 0/5] make use of gcc 9's "asm inline()" Linus Torvalds
2019-08-30 7:45 ` Rasmus Villemoes
2019-08-29 17:36 ` Nick Desaulniers
2019-08-29 18:15 ` Linus Torvalds
2019-08-29 18:26 ` Nadav Amit [this message]
2019-08-29 18:42 ` Borislav Petkov
2019-08-29 19:41 ` Masahiro Yamada
2019-08-30 23:15 ` [PATCH v2 0/6] " Rasmus Villemoes
2019-08-30 23:15 ` [PATCH v2 1/6] staging: rtl8723bs: replace __inline by inline Rasmus Villemoes
2019-09-04 23:54 ` Nick Desaulniers
2019-08-30 23:15 ` [PATCH v2 2/6] lib/zstd/mem.h: " Rasmus Villemoes
2019-09-04 23:59 ` Nick Desaulniers
2019-09-05 0:07 ` Miguel Ojeda
2019-09-05 9:28 ` Rasmus Villemoes
2019-08-30 23:15 ` [PATCH v2 3/6] compiler_types.h: don't #define __inline Rasmus Villemoes
2019-09-05 0:13 ` Nick Desaulniers
2019-09-05 9:45 ` Rasmus Villemoes
2019-08-30 23:15 ` [PATCH v2 4/6] compiler-gcc.h: add asm_inline definition Rasmus Villemoes
2019-09-05 0:18 ` Nick Desaulniers
2019-09-05 5:43 ` Nadav Amit
2019-09-05 11:07 ` Rasmus Villemoes
2019-09-05 13:45 ` Segher Boessenkool
2019-09-05 14:23 ` Rasmus Villemoes
2019-09-05 14:47 ` Segher Boessenkool
2019-09-05 15:52 ` Miguel Ojeda
2019-09-05 16:13 ` Miguel Ojeda
2019-09-06 12:23 ` Segher Boessenkool
2019-09-06 15:13 ` Miguel Ojeda
2019-09-06 16:30 ` Segher Boessenkool
2019-09-06 16:39 ` Jakub Jelinek
2019-09-06 18:14 ` Nick Desaulniers
2019-09-06 22:03 ` Segher Boessenkool
2019-09-06 22:35 ` Nick Desaulniers
2019-09-06 22:56 ` Segher Boessenkool
2019-09-06 23:42 ` Nick Desaulniers
2019-09-07 0:14 ` Segher Boessenkool
2019-09-07 1:04 ` Nick Desaulniers
2019-09-07 13:11 ` Segher Boessenkool
2019-09-08 13:55 ` Miguel Ojeda
2019-09-12 21:54 ` Nick Desaulniers
2019-09-12 22:12 ` Rasmus Villemoes
2019-09-20 0:50 ` Segher Boessenkool
2019-09-06 16:47 ` Miguel Ojeda
2019-08-30 23:15 ` [PATCH v2 5/6] x86: alternative.h: use asm_inline for all alternative variants Rasmus Villemoes
2019-08-30 23:15 ` [PATCH v2 6/6] x86: bug.h: use asm_inline in _BUG_FLAGS definitions Rasmus Villemoes
2019-09-12 22:19 ` [PATCH v3 0/6] make use of gcc 9's "asm inline()" Rasmus Villemoes
2019-09-12 22:19 ` [PATCH v3 1/6] staging: rtl8723bs: replace __inline by inline Rasmus Villemoes
2019-09-29 10:40 ` Greg Kroah-Hartman
2019-09-12 22:19 ` [PATCH v3 2/6] lib/zstd/mem.h: " Rasmus Villemoes
2019-09-12 22:19 ` [PATCH v3 3/6] compiler_types.h: don't #define __inline Rasmus Villemoes
2019-09-12 22:19 ` [PATCH v3 4/6] compiler-types.h: add asm_inline definition Rasmus Villemoes
2019-09-12 22:19 ` [PATCH v3 5/6] x86: alternative.h: use asm_inline for all alternative variants Rasmus Villemoes
2019-09-13 5:41 ` Ingo Molnar
2019-09-12 22:19 ` [PATCH v3 6/6] x86: bug.h: use asm_inline in _BUG_FLAGS definitions Rasmus Villemoes
2019-09-13 5:42 ` Ingo Molnar
2019-09-12 22:30 ` [PATCH v3 0/6] make use of gcc 9's "asm inline()" Miguel Ojeda
2019-09-13 6:11 ` Rasmus Villemoes
2019-09-13 15:21 ` Greg Kroah-Hartman
2019-09-15 18:20 ` Miguel Ojeda
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=6C70DE15-0F83-4CBB-B25B-EFF50BC34DD3@vmware.com \
--to=namit@vmware.com \
--cc=clang-built-linux@googlegroups.com \
--cc=hpa@zytor.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=mingo@redhat.com \
--cc=ndesaulniers@google.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=x86@kernel.org \
--cc=yamada.masahiro@socionext.com \
/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).