Messages in this thread | | | Date | Thu, 18 Jun 2015 11:15:05 +0200 | From | Peter Zijlstra <> | Subject | Re: [PATCH 11/18] seqcount: Introduce raw_write_seqcount_barrier() |
| |
On Wed, Jun 17, 2015 at 11:02:14AM -0700, Paul E. McKenney wrote: > On Wed, Jun 17, 2015 at 07:11:40PM +0200, Peter Zijlstra wrote: > > On Wed, Jun 17, 2015 at 09:37:31AM -0700, Paul E. McKenney wrote: > > > The point of std::atomic<> (and of the equivalent C11 syntax) is to > > > force the compiler to suppress optimizations that are unsafe for shared > > > variables. We get more or less the same effect with volatile, protests > > > from compiler people notwithstanding. > > > > > > I often tell the compiler guys that they have to expect make -some- > > > concessions for being 30 years late to the concurrency party, but > > > it nevertheless makes sense to future-proof our code where it is > > > reasonable to do so. > > > > Right, so in that regards I would request the compiler option (and or > > #pragma) that disables all the out-of-thin-air nonsense. > > OK. What is the form of the #pragma? If it focuses on a specific > access, we are likely to get a lot of pushback.
I didn't have anything specific in mind; other than
#pragma no_speculative_stores_ever
Which would forbid all these retarded 'optimizations' for the entire translation unit.
> > Because while they hide behind their undefined behaviour, the fact is > > that all of their machines for the past 30 odd years have been relying > > on this 'undefined' behaviour to work. This being the machines they've > > been typing their useless specs on :-) > > Maybe I can scare them into doing all their work on UP systems. ;-) > > Interestingly enough, LLVM is taking a slightly different approach. > Rather than invoke undefined behavior, they say that data races result > in random bits being loaded. Not that it makes much difference to the > health and well-being of the software, mind you...
I'm not sure I follow that argument.
> > I doubt there's a single OS kernel (that supports SMP configurations) > > that does not rely on a whole host of 'undefined' behaviour. > > An alternative approach would be a compiler switch (or similar) that > changed the default atomic access from SC to relaxed. Then shared > variables could be marked atomic, and normal C code could be used to > access them, but without the compiler emitting memory barriers all over > the place (yes, even on x86).
See, I don;'t think that is a realistic approach. Who is going to audit our ~16 million lines of code to mark all shared variables? Or all the other existing code bases that rely on this behaviour?
| |