On 4 October 2016 at 15:14, Nicolai Hähnle <nhaeh...@gmail.com> wrote: > From: Nicolai Hähnle <nicolai.haeh...@amd.com> > > This is motivated by the fact that p_atomic_read and p_atomic_set may > somewhat surprisingly not do the right thing in the old version: while > stores and loads are de facto atomic at least on x86, the compiler may > apply re-ordering and speculation quite liberally. Basically, the old > version uses the "relaxed" memory ordering. > > The new ordering always uses acquire/release ordering. This is the > strongest possible memory ordering that doesn't require additional > fence instructions on x86. (And the only stronger ordering is > "sequentially consistent", which is usually more than you need anyway.) > > I would feel more comfortable if p_atomic_set/read in the old > implementation were at least using volatile loads and stores, but I > don't see a way to get there without typeof (which we cannot use here > since the code is compiled with -std=c99). > > Eventually, we should really just move to something that is based on > the atomics in C11 / C++11. > --- > configure.ac | 11 +++++++++++ > src/util/u_atomic.h | 21 +++++++++++++++++++++ > 2 files changed, 32 insertions(+) > On the build side the patch looks great, I haven't looked at the atomic specifics. Reviewed-by: Emil Velikov <emil.veli...@collabora.com>
-Emil _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev