[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKwvOdm_GoUeDjAYXTqCTuvdL+9vwvfeofhv06MLMYVA75CnEg@mail.gmail.com>
Date: Mon, 30 Sep 2019 15:34:41 -0700
From: Nick Desaulniers <ndesaulniers@...gle.com>
To: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
Cc: Will Deacon <will@...nel.org>,
Masahiro Yamada <yamada.masahiro@...ionext.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Nicolas Saenz Julienne <nsaenzjulienne@...e.de>,
Andrew Morton <akpm@...ux-foundation.org>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
linux-arch <linux-arch@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>,
Catalin Marinas <catalin.marinas@....com>,
Russell King <rmk+kernel@....linux.org.uk>,
Stefan Wahren <wahrenst@....net>,
Kees Cook <keescook@...gle.com>
Subject: Re: [PATCH] compiler: enable CONFIG_OPTIMIZE_INLINING forcibly
On Mon, Sep 30, 2019 at 3:08 PM Miguel Ojeda
<miguel.ojeda.sandonis@...il.com> wrote:
>
> On Mon, Sep 30, 2019 at 11:50 PM Nick Desaulniers
> <ndesaulniers@...gle.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
Powered by blists - more mailing lists