From 9c9bd97f35920752e99f471becb8e0cda7e5bd36 Mon Sep 17 00:00:00 2001 From: "glider@chromium.org" Date: Thu, 24 Jan 2013 22:58:28 +0000 Subject: Add two MemoryBarrier calls and transform the Acquire_Store() calls to Release_Store() ones so that ThreadSanitizer doesn't report a false positive. Changing Acquire_Store() to a pair of Release_Store(); MemoryBarrier() is more restrictive on the memory access ordering, but does not introduce synchronization errors. On the other hand, using Release_Store() allows ThreadSanitizer to observe the happens-before relation, which it can't understand otherwise. BUG=171660 Review URL: https://chromiumcodereview.appspot.com/11896063 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178683 0039d316-1c4b-4281-b951-d872f2087c98 --- gpu/command_buffer/common/command_buffer_shared.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'gpu/command_buffer/common/command_buffer_shared.h') diff --git a/gpu/command_buffer/common/command_buffer_shared.h b/gpu/command_buffer/common/command_buffer_shared.h index 017a644..fafe767 100644 --- a/gpu/command_buffer/common/command_buffer_shared.h +++ b/gpu/command_buffer/common/command_buffer_shared.h @@ -30,16 +30,17 @@ public: base::subtle::NoBarrier_Store(&reading_, 0); base::subtle::NoBarrier_Store(&latest_, 0); base::subtle::NoBarrier_Store(&slots_[0], 0); - base::subtle::Acquire_Store(&slots_[1], 0); + base::subtle::Release_Store(&slots_[1], 0); + base::subtle::MemoryBarrier(); } void Write(const T& state) { int towrite = !base::subtle::Acquire_Load(&reading_); int index = !base::subtle::Acquire_Load(&slots_[towrite]); states_[towrite][index] = state; + base::subtle::Release_Store(&slots_[towrite], index); + base::subtle::Release_Store(&latest_, towrite); base::subtle::MemoryBarrier(); - base::subtle::Acquire_Store(&slots_[towrite], index); - base::subtle::Acquire_Store(&latest_, towrite); } // Attempt to update the state, updating only if the generation counter is @@ -47,7 +48,8 @@ public: void Read(T* state) { base::subtle::MemoryBarrier(); int toread = !!base::subtle::Acquire_Load(&latest_); - base::subtle::Acquire_Store(&reading_, toread); + base::subtle::Release_Store(&reading_, toread); + base::subtle::MemoryBarrier(); int index = !!base::subtle::Acquire_Load(&slots_[toread]); if (states_[toread][index].generation - state->generation < 0x80000000U) *state = states_[toread][index]; -- cgit v1.1