Re: [PATCH RFC v2 02/25] stackdepot: prevent Clang from optimizing away stackdepot_memcmp()

0 views
Skip to first unread message

Arnd Bergmann

unread,
Nov 7, 2019, 5:00:39 AM11/7/19
to Andrey Ryabinin, Alexander Potapenko, Sergey Senozhatsky, Vegard Nossum, Dmitry Vyukov, Linux Memory Management List, Al Viro, Andrew Morton, Andy Lutomirski, Ard Biesheuvel, Christoph Hellwig, Dmitry Torokhov, Eric Dumazet, Eric Van Hensbergen, Greg Kroah-Hartman, Harry Wentland, Herbert Xu, Ingo Molnar, Jens Axboe, Martin K . Petersen, Martin Schwidefsky, Michael S. Tsirkin, Michal Simek, Petr Mladek, Sergey Senozhatsky, Steven Rostedt, Takashi Iwai, Theodore Ts'o, Thomas Gleixner, Wolfram Sang, Vasily Gorbik, Ilya Leoshkevich, Mark Rutland, Matthew Wilcox, Randy Dunlap, Andrey Konovalov, Marco Elver, Nick Desaulniers, clang-built-linux
On Thu, Nov 7, 2019 at 10:46 AM Andrey Ryabinin <arya...@virtuozzo.com> wrote:
> On 11/7/19 12:22 PM, Alexander Potapenko wrote:
> > On Thu, Nov 7, 2019 at 10:04 AM Arnd Bergmann <ar...@arndb.de> wrote:
> >> On Thu, Nov 7, 2019 at 7:08 AM Sergey Senozhatsky
> >> <sergey.seno...@gmail.com> wrote:
> >> The normal way to do a volatile access would be
> >> READ_ONCE()/WRITE_ONCE(), but that seems stronger than
> >> the barrier() here. I'd just stick to adding a barrier.
> > I actually like the READ_ONCE idea more, as READ_ONCE is really a
> > documented way to prevent the compiler from merging reads, which is
> > what we want here.
>
> I would rather go with -fno-builtin-bcmp or maybe even -fno-builtin if that works.

The commit message for 5f074f3e192f ("lib/string.c: implement a basic bcmp")
mentions that -fno-builtin-bcmp did not work for LTO when the global bcmp()
help was added. I don't know whether the same applies here, but my guess is
that it's the same issue.

Arnd

Andrey Ryabinin

unread,
Nov 7, 2019, 5:19:42 AM11/7/19
to Arnd Bergmann, Alexander Potapenko, Sergey Senozhatsky, Vegard Nossum, Dmitry Vyukov, Linux Memory Management List, Al Viro, Andrew Morton, Andy Lutomirski, Ard Biesheuvel, Christoph Hellwig, Dmitry Torokhov, Eric Dumazet, Eric Van Hensbergen, Greg Kroah-Hartman, Harry Wentland, Herbert Xu, Ingo Molnar, Jens Axboe, Martin K . Petersen, Martin Schwidefsky, Michael S. Tsirkin, Michal Simek, Petr Mladek, Sergey Senozhatsky, Steven Rostedt, Takashi Iwai, Theodore Ts'o, Thomas Gleixner, Wolfram Sang, Vasily Gorbik, Ilya Leoshkevich, Mark Rutland, Matthew Wilcox, Randy Dunlap, Andrey Konovalov, Marco Elver, Nick Desaulniers, clang-built-linux
But we don't do LTO.

Alexander Potapenko

unread,
Nov 7, 2019, 5:30:51 AM11/7/19
to Andrey Ryabinin, Arnd Bergmann, Sergey Senozhatsky, Vegard Nossum, Dmitry Vyukov, Linux Memory Management List, Al Viro, Andrew Morton, Andy Lutomirski, Ard Biesheuvel, Christoph Hellwig, Dmitry Torokhov, Eric Dumazet, Eric Van Hensbergen, Greg Kroah-Hartman, Harry Wentland, Herbert Xu, Ingo Molnar, Jens Axboe, Martin K . Petersen, Martin Schwidefsky, Michael S. Tsirkin, Michal Simek, Petr Mladek, Sergey Senozhatsky, Steven Rostedt, Takashi Iwai, Theodore Ts'o, Thomas Gleixner, Wolfram Sang, Vasily Gorbik, Ilya Leoshkevich, Mark Rutland, Matthew Wilcox, Randy Dunlap, Andrey Konovalov, Marco Elver, Nick Desaulniers, clang-built-linux
I don't think not doing LTO now is a valid argument, as some
distributions may start doing LTO in the future.
(Android already does LTO, by the way)

Regarding this particular case, -fno-builtin-bcmp is insufficient, as
Clang falls back to memcmp() in that case.
Building with -fno-builtin-bcmp -fno-builtin-memcmp does the trick,
but we'd probably better use -fno-builtin just to avoid future
surprises.
> --
> You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-li...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/6875c6e6-2f1f-f8e6-e5d7-d451c48397ff%40virtuozzo.com.



--
Alexander Potapenko
Software Engineer

Google Germany GmbH
Erika-Mann-Straße, 33
80636 München

Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Reply all
Reply to author
Forward
0 new messages