The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Steven Noonan <steven@uplinklabs.net>,
	Linus Torvalds <torvalds@linux-foundation.org>
Cc: Jiri Kosina <jkosina@suse.cz>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Martin Jambor <mjambor@suse.cz>, Petr Mladek <pmladek@suse.cz>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	"gcc@gcc.gnu.org" <gcc@gcc.gnu.org>
Subject: Re: [PATCH] tell gcc optimizer to never introduce new data races
Date: Tue, 10 Jun 2014 20:54:09 +0200	[thread overview]
Message-ID: <fb599019-daba-4d09-8524-fa692bd1f3a4@email.android.com> (raw)
In-Reply-To: <CAKbGBLi1hRxe03EB70HOYRTuVhHkAyTnhfv8HFXEwatP6Qn8tA@mail.gmail.com>

On June 10, 2014 8:04:13 PM CEST, Steven Noonan <steven@uplinklabs.net> wrote:
>On Tue, Jun 10, 2014 at 10:46 AM, Linus Torvalds
><torvalds@linux-foundation.org> wrote:
>> On Tue, Jun 10, 2014 at 6:23 AM, Jiri Kosina <jkosina@suse.cz> wrote:
>>> We have been chasing a memory corruption bug, which turned out to be
>>> caused by very old gcc (4.3.4), which happily turned conditional
>load into
>>> a non-conditional one, and that broke correctness (the condition was
>met
>>> only if lock was held) and corrupted memory.
>>
>> Just out of interest, can you point to the particular kernel code
>that
>> caused this? I think that's more interesting than the example program
>> you show - which I'm sure is really nice for gcc developers as an
>> example, but from a kernel standpoint I think it's more important to
>> show the particular problems this caused for the kernel?
>>
>
>Jiri, is there a workaround for compilers that don't support '--param
>allow-store-data-races=0'? For example:

The optimization that purposely performs the undesired transform is loop store motion which is part of the tree loop invariant motion optimization. You can disable that with -fno-tree-loop-im.

That the bug didn't appear with newer compilers was due to lucky decisions to not inline a particular function.

Richard.

>$ gcc-4.5 -O2 -o cond_store cond_store.c && ./cond_store
>Segmentation fault (core dumped)
>
>$ gcc-4.5 -O2 --param allow-store-data-races=0 -o cond_store
>cond_store.c && ./cond_store
>cc1: error: invalid parameter ‘allow-store-data-races’
>
>$ gcc-4.5 -v
>Using built-in specs.
>COLLECT_GCC=gcc-4.5
>COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.5.4/lto-wrapper
>Target: x86_64-unknown-linux-gnu
>Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
>--infodir=/usr/share/info --libdir=/usr/lib --libexecdir=/usr/lib
>--program-suffix=-4.5 --enable-shared
>--enable-languages=c,c++,fortran,objc,obj-c++ --enable-__cxa_atexit
>--disable-libstdcxx-pch --disable-multilib --disable-libgomp
>--disable-libmudflap --disable-libssp --enable-clocale=gnu
>--with-tune=generic --with-cloog --with-ppl --with-system-zlib
>Thread model: posix
>gcc version 4.5.4 (GCC)



  reply	other threads:[~2014-06-10 18:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-10 13:23 [PATCH] tell gcc optimizer to never introduce new data races Jiri Kosina
2014-06-10 14:53 ` Peter Zijlstra
2014-06-10 15:04   ` Marek Polacek
2014-06-10 15:13     ` Peter Zijlstra
2014-06-10 15:17       ` Jakub Jelinek
2014-06-10 17:46 ` Linus Torvalds
2014-06-10 18:04   ` Steven Noonan
2014-06-10 18:54     ` Richard Biener [this message]
2014-06-10 18:10   ` Jiri Kosina
2014-06-16 10:29 ` Dan Carpenter
2014-06-16 10:52   ` Andreas Schwab
2014-06-16 11:20     ` Jiri Kosina
2014-06-16 14:37     ` Mark Brown
2014-06-17  7:58   ` Jiri Kosina
2014-08-20 23:27 ` Jiri Kosina

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=fb599019-daba-4d09-8524-fa692bd1f3a4@email.android.com \
    --to=richard.guenther@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=gcc@gcc.gnu.org \
    --cc=jkosina@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjambor@suse.cz \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=pmladek@suse.cz \
    --cc=steven@uplinklabs.net \
    --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