From: James Y Knight <jyknight@google.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: mka@chromium.org, Linus Torvalds <torvalds@linux-foundation.org>,
arnd@arndb.de, Ingo Molnar <mingo@kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
tglx@linutronix.de, Andrew Morton <akpm@linux-foundation.org>,
Chandler Carruth <chandlerc@google.com>,
Stephen Hines <srhines@google.com>,
Nick Desaulniers <ndesaulniers@google.com>,
Kees Cook <keescook@google.com>,
groeck@chromium.org, Greg Hackmann <ghackmann@google.com>,
gregkh@linuxfoundation.org
Subject: Re: [GIT PULL] x86/build changes for v4.17
Date: Thu, 05 Apr 2018 17:46:58 +0000 [thread overview]
Message-ID: <CAA2zVHraWtmmW1yFvVH+kUbih5wxiDLuM=wArnQanrWN9NF=Xw@mail.gmail.com> (raw)
In-Reply-To: <20180405072017.GN4043@hirez.programming.kicks-ass.net>
[-- Attachment #1: Type: text/plain, Size: 1480 bytes --]
On Thu, Apr 5, 2018 at 3:20 AM Peter Zijlstra <peterz@infradead.org> wrote:
> On Wed, Apr 04, 2018 at 04:31:11PM -0700, Matthias Kaehlcke wrote:
>
> > From some experiments it looks like clang, in difference to gcc, does
> > not treat constant values passed as parameters to inline function as
> > constants.
>
> Then you're also missing a heap of optimizations in code like
> rb_erase_augmented() which is specifically constructed to take advantage
> of constant propagation like that.
>
> Other sites where we expect that to happen is __mutex_lock_common(),
> __update_load_sum() and a bunch of others. There isn't strictly a bug
> here, but not doing that constant propagation will still result in shit
> code gen.
>
I think maybe you're confused; those functions do not appear to use
__builtin_constant_p, which is the issue at hand. Clang's optimizer is of
course not a complete joke...it can perfectly well optimize functions after
inlining in order to not generate "shit code gen".
GCC, however, mixes up the concept of a C "constant expression" with the
results of running optimization passes such as inlining for its
definition/implementation of __builtin_constant_p. Clang does not, and
quite likely will not ever, do that.
That said, I do believe there are ongoing discussions as to how to best
provide a useful alternative which is less semantically strange, and not
too difficult for to conditionally adopt for a gcc/clang-compatible
codebase such as the kernel.
[-- Attachment #2: Type: text/html, Size: 1882 bytes --]
next prev parent reply other threads:[~2018-04-05 17:46 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-02 9:50 [GIT PULL] x86/build changes for v4.17 Ingo Molnar
2018-04-02 21:44 ` Linus Torvalds
2018-04-02 22:38 ` Matthias Kaehlcke
2018-04-03 1:26 ` Matthias Kaehlcke
2018-04-03 8:59 ` Peter Zijlstra
2018-04-03 9:51 ` Ingo Molnar
2018-04-03 12:09 ` Peter Zijlstra
2018-04-03 18:06 ` Matthias Kaehlcke
2018-04-03 21:58 ` Nick Desaulniers
2018-04-04 9:19 ` Peter Zijlstra
2018-04-04 9:38 ` Greg KH
2018-04-04 16:49 ` Nick Desaulniers
2018-04-04 17:13 ` Linus Torvalds
2018-04-04 17:46 ` Nick Desaulniers
2018-04-04 23:10 ` Nick Desaulniers
2018-04-04 16:53 ` Nick Desaulniers
2018-04-04 16:59 ` Greg KH
2018-04-04 19:26 ` James Y Knight
2018-04-04 19:42 ` Linus Torvalds
2018-04-04 22:21 ` James Y Knight
2018-04-04 22:29 ` Linus Torvalds
2018-04-05 7:08 ` Peter Zijlstra
2018-04-05 16:21 ` James Y Knight
2018-04-04 19:32 ` Josh Poimboeuf
2018-06-07 19:23 ` Nick Desaulniers
2018-06-07 20:11 ` Greg KH
2018-04-04 9:30 ` Peter Zijlstra
2018-04-04 19:17 ` Matthias Kaehlcke
2018-04-04 20:33 ` Arnd Bergmann
2018-04-04 20:58 ` Matthias Kaehlcke
2018-04-04 21:11 ` Arnd Bergmann
2018-04-04 21:46 ` Matthias Kaehlcke
2018-04-04 21:59 ` Linus Torvalds
2018-04-04 22:17 ` Matthias Kaehlcke
2018-04-04 22:39 ` Linus Torvalds
2018-04-04 23:31 ` Matthias Kaehlcke
2018-04-05 0:05 ` Linus Torvalds
2018-04-05 0:20 ` Kees Cook
2018-04-05 7:24 ` Peter Zijlstra
2018-04-05 8:04 ` Ingo Molnar
2018-04-05 8:24 ` Peter Zijlstra
2018-04-05 16:43 ` Linus Torvalds
2018-04-05 7:20 ` Peter Zijlstra
2018-04-05 17:46 ` James Y Knight [this message]
2018-04-05 18:06 ` Linus Torvalds
2018-04-05 20:51 ` James Y Knight
2018-04-05 21:13 ` Linus Torvalds
2018-04-05 22:51 ` James Y Knight
2018-04-06 2:02 ` Linus Torvalds
2018-04-05 17:47 ` James Y Knight
2018-04-04 23:04 ` Nick Desaulniers
2018-04-03 17:36 ` Linus Torvalds
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='CAA2zVHraWtmmW1yFvVH+kUbih5wxiDLuM=wArnQanrWN9NF=Xw@mail.gmail.com' \
--to=jyknight@google.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=chandlerc@google.com \
--cc=ghackmann@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=groeck@chromium.org \
--cc=keescook@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=mka@chromium.org \
--cc=ndesaulniers@google.com \
--cc=peterz@infradead.org \
--cc=srhines@google.com \
--cc=tglx@linutronix.de \
--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 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).