Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1407167

Re: [RFC][PATCH 1/3] locking: Introduce smp_acquire__after_ctrl_dep

From "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Newsgroups linux.kernel
Subject Re: [RFC][PATCH 1/3] locking: Introduce smp_acquire__after_ctrl_dep
Date 2016-05-25 21:00 +0200
Message-ID <rCMca-4qa-11@gated-at.bofh.it> (permalink)
References (3 earlier) <rCz5g-53m-39@gated-at.bofh.it> <rCIUW-2Ao-15@gated-at.bofh.it> <rCJnX-2Kq-3@gated-at.bofh.it> <rCJR0-39l-21@gated-at.bofh.it> <rCKk2-3j5-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed, May 25, 2016 at 09:54:55AM -0700, Linus Torvalds wrote:
> On Wed, May 25, 2016 at 9:28 AM, Peter Zijlstra <peterz@infradead.org> wrote:
> >
> > I would consider any architecture that allows speculative stores as
> > broken. They are values out of thin air and would make any kind of
> > concurrency extremely 'interesting'.
> 
> It's worth noting that the same is true of compilers too. You will
> find compiler people who argue that speculative stores are valid
> because the spec doesn't explicitly forbid them. Same is true of
> compiler-generated value speculation.

Thankfully, this has improved.  There was a time when compiler writers
were happy to overwrite adjacent variables and fix them up later,
believe it or not.  Not so good if the variables are shared variables,
possibly protected by different locks.  Most compiler writers now
understand that this sort of thing is not permitted, and recent
versions of the standard explicitly forbid it.

But there are still any number of optimizations that can cause trouble
for concurrent code.  Common subexpresssion elimination, for example...
Which is one reason for my heavy use of READ_ONCE() and WRITE_ONCE().

> Both are cases of "yeah, the C standard may not explicitly disallow
> it, but sanity in a threaded environment does". Sadly, I've seen
> compiler people who dismiss "sanity" as an argument, since that also
> isn't defined in the C standard. There are people who think that paper
> is the most precious resource in the universe.
> 
> I'm not actually aware of anybody doing speculative stores or value
> speculation in a compiler we care about, but if those kinds of things
> are the kinds of things where we'd just go "that compiler is shit" and
> not use it (possibly with a command line option to disable the
> particular broken optimization, like we do for the broken type-based
> aliasing and some other code generation things that just don't work in
> the kernel).
> 
> So we definitely have the option to just say "theory is just theory".
> We'll never make design decisions based on insane things being
> possible in theory, whether it be crazy architectures or crazy
> compilers.

There has been some discussion of adding "-std=kernel" to tell the
compiler to follow Linux-kernel rules, but not sure whether this is
really going anywhere.

							Thanx, Paul

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[RFC][PATCH 0/3] spin_unlock_wait and assorted borkage Peter Zijlstra <peterz@infradead.org> - 2016-05-24 16:40 +0200
  [RFC][PATCH 2/3] locking: Annotate spin_unlock_wait() users Peter Zijlstra <peterz@infradead.org> - 2016-05-24 16:40 +0200
    Re: [RFC][PATCH 2/3] locking: Annotate spin_unlock_wait() users Linus Torvalds <torvalds@linux-foundation.org> - 2016-05-24 18:20 +0200
      Re: [RFC][PATCH 2/3] locking: Annotate spin_unlock_wait() users Tejun Heo <tj@kernel.org> - 2016-05-24 18:30 +0200
        Re: [RFC][PATCH 2/3] locking: Annotate spin_unlock_wait() users Peter Zijlstra <peterz@infradead.org> - 2016-05-24 19:00 +0200
          Re: [RFC][PATCH 2/3] locking: Annotate spin_unlock_wait() users Tejun Heo <tj@kernel.org> - 2016-05-25 21:30 +0200
      Re: [RFC][PATCH 2/3] locking: Annotate spin_unlock_wait() users Peter Zijlstra <peterz@infradead.org> - 2016-05-24 19:00 +0200
  [RFC][PATCH 1/3] locking: Introduce smp_acquire__after_ctrl_dep Peter Zijlstra <peterz@infradead.org> - 2016-05-24 16:50 +0200
    Re: [RFC][PATCH 1/3] locking: Introduce smp_acquire__after_ctrl_dep "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-05-25 07:00 +0200
      Re: [RFC][PATCH 1/3] locking: Introduce smp_acquire__after_ctrl_dep Boqun Feng <boqun.feng@gmail.com> - 2016-05-25 07:40 +0200
        Re: [RFC][PATCH 1/3] locking: Introduce smp_acquire__after_ctrl_dep "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-05-25 16:30 +0200
      Re: [RFC][PATCH 1/3] locking: Introduce smp_acquire__after_ctrl_dep Waiman Long <waiman.long@hpe.com> - 2016-05-25 17:30 +0200
        Re: [RFC][PATCH 1/3] locking: Introduce smp_acquire__after_ctrl_dep "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-05-25 18:00 +0200
          Re: [RFC][PATCH 1/3] locking: Introduce smp_acquire__after_ctrl_dep Peter Zijlstra <peterz@infradead.org> - 2016-05-25 18:30 +0200
            Re: [RFC][PATCH 1/3] locking: Introduce smp_acquire__after_ctrl_dep Linus Torvalds <torvalds@linux-foundation.org> - 2016-05-25 19:00 +0200
              Re: [RFC][PATCH 1/3] locking: Introduce smp_acquire__after_ctrl_dep "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-05-25 21:00 +0200

csiph-web