From: Nick Desaulniers <ndesaulniers@google.com>
To: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Cc: Will Deacon <will@kernel.org>,
Masahiro Yamada <yamada.masahiro@socionext.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Nicolas Saenz Julienne <nsaenzjulienne@suse.de>,
Andrew Morton <akpm@linux-foundation.org>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
linux-arch <linux-arch@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Russell King <rmk+kernel@arm.linux.org.uk>,
Stefan Wahren <wahrenst@gmx.net>, Kees Cook <keescook@google.com>
Subject: Re: [PATCH] compiler: enable CONFIG_OPTIMIZE_INLINING forcibly
Date: Mon, 30 Sep 2019 15:34:41 -0700 [thread overview]
Message-ID: <CAKwvOdm_GoUeDjAYXTqCTuvdL+9vwvfeofhv06MLMYVA75CnEg@mail.gmail.com> (raw)
In-Reply-To: <CANiq72kbZVB4vdyQonMQzuRHdh=BnD6F=sv5NQsFey5_xAB-Zg@mail.gmail.com>
On Mon, Sep 30, 2019 at 3:08 PM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> On Mon, Sep 30, 2019 at 11:50 PM Nick Desaulniers
> <ndesaulniers@google.com> wrote:
> >
> > So __attribute__((always_inline)) doesn't guarantee that code will be
> > inlined. [...] inline and __attribute__((always_inline))
> > are a heuristic laden mess and should not be relied upon.
>
> Small note: in GCC, __attribute__((always_inline)) is documented as
> actually guaranteeing to either inline or error otherwise (although
> see the remark for indirect calls):
>
> "Failure to inline such a function is diagnosed as an error. Note
Not an error, but a warning at least: https://godbolt.org/z/_V5im1.
That's interesting, so it has multiple semantics, because it's also
documented to inline even when no optimizations are specified. So
when someone uses __attribute__((always_inline)) without a comment,
it's not clear whether they mean for there to be a warning when this
is not inlined, or for it to be inlined at -O0 (guess not for the
kernel), or both. If the kernel wants to enforce the former, why not
set `-Werror=attributes`? Maybe that warning is too broad? Seems
like a recipe for subtly broken code found at runtime, when we'd
rather have stronger compile time guarantees.
> that if such a function is called indirectly the compiler may or may
> not inline it depending on optimization level and a failure to inline
> an indirect call may or may not be diagnosed."
>
> As for LLVM/Clang, no idea, since it does not say anything about it in
> the docs -- but from what you say, it is a weaker guarantee.
Filed https://bugs.llvm.org/show_bug.cgi?id=43517
--
Thanks,
~Nick Desaulniers
next prev parent reply other threads:[~2019-09-30 22:34 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-30 3:43 [PATCH] compiler: enable CONFIG_OPTIMIZE_INLINING forcibly Masahiro Yamada
2019-08-30 20:54 ` Nick Desaulniers
2019-09-26 8:54 ` Geert Uytterhoeven
2019-09-26 9:02 ` Masahiro Yamada
2019-09-26 9:26 ` Geert Uytterhoeven
2019-09-26 9:46 ` Masahiro Yamada
2019-09-27 10:43 ` Nicolas Saenz Julienne
2019-09-27 10:59 ` Charles Keepax
2019-09-27 22:08 ` Nick Desaulniers
2019-09-27 22:38 ` Linus Torvalds
2019-09-30 11:26 ` Will Deacon
2019-09-30 12:05 ` Masahiro Yamada
2019-09-30 12:18 ` Will Deacon
2019-09-30 21:50 ` Nick Desaulniers
2019-09-30 22:08 ` Miguel Ojeda
2019-09-30 22:34 ` Nick Desaulniers [this message]
2019-10-01 9:28 ` Will Deacon
2019-10-01 16:32 ` Nick Desaulniers
2019-10-01 17:01 ` Will Deacon
2019-10-01 17:44 ` Nick Desaulniers
2019-10-01 17:55 ` Russell King - ARM Linux admin
2019-10-01 18:00 ` Nick Desaulniers
2019-10-01 18:14 ` Russell King - ARM Linux admin
2019-10-01 20:21 ` Nick Desaulniers
2019-10-01 20:53 ` Arnd Bergmann
2019-10-01 21:06 ` Miguel Ojeda
2019-10-01 21:14 ` Nick Desaulniers
2019-10-01 20:59 ` Russell King - ARM Linux admin
2019-10-01 21:26 ` Russell King - ARM Linux admin
2019-10-01 21:32 ` Nick Desaulniers
2019-10-01 21:58 ` Russell King - ARM Linux admin
2019-10-02 12:55 ` Geert Uytterhoeven
2019-10-02 18:51 ` Will Deacon
2019-10-02 20:39 ` Linus Torvalds
2019-10-03 2:10 ` Masahiro Yamada
2019-10-03 17:01 ` Linus Torvalds
2019-10-03 17:08 ` Linus Torvalds
2019-10-03 17:23 ` Masahiro Yamada
2019-10-03 17:29 ` Linus Torvalds
2019-10-03 20:21 ` Miguel Ojeda
2019-10-04 7:37 ` Geert Uytterhoeven
2019-10-03 16:36 ` Will Deacon
2019-10-12 10:15 ` Stefan Wahren
2019-10-12 11:12 ` Masahiro Yamada
2019-10-12 14:45 ` Russell King - ARM Linux admin
2019-10-01 9:39 ` Masahiro Yamada
2019-10-01 10:40 ` Will Deacon
2019-09-27 10:58 ` Nicolas Saenz Julienne
2019-09-30 6:04 ` Masahiro Yamada
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=CAKwvOdm_GoUeDjAYXTqCTuvdL+9vwvfeofhv06MLMYVA75CnEg@mail.gmail.com \
--to=ndesaulniers@google.com \
--cc=akpm@linux-foundation.org \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=keescook@google.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=mingo@redhat.com \
--cc=nsaenzjulienne@suse.de \
--cc=rmk+kernel@arm.linux.org.uk \
--cc=torvalds@linux-foundation.org \
--cc=wahrenst@gmx.net \
--cc=will@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).