Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1071)

Unified Diff: base/metrics/persistent_memory_allocator.cc

Issue 2634093002: Revert simplification of memory ordering that is causing TSAN errors. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/persistent_memory_allocator.cc
diff --git a/base/metrics/persistent_memory_allocator.cc b/base/metrics/persistent_memory_allocator.cc
index eecd19a9767d82223c24f71dd7095ffb805391c1..f32e9a3e2bd581a8f88774ba6d462ac02ae1ed6f 100644
--- a/base/metrics/persistent_memory_allocator.cc
+++ b/base/metrics/persistent_memory_allocator.cc
@@ -218,11 +218,9 @@ PersistentMemoryAllocator::Iterator::GetNext(uint32_t* type_return) {
// again. Failing will also load the existing value into "last" so there
// is no need to do another such load when the while-loop restarts. A
// "strong" compare-exchange is used because failing unnecessarily would
- // mean repeating some fairly costly validations above. This operation
- // is "relaxed" because the iterator has no other values to protect and
- // the referenced object will be accessed via an "acquire" in GetAsObject.
+ // mean repeating some fairly costly validations above.
if (last_record_.compare_exchange_strong(
- last, next, std::memory_order_relaxed, std::memory_order_relaxed)) {
+ last, next, std::memory_order_acq_rel, std::memory_order_acquire)) {
*type_return = block->type_id.load(std::memory_order_relaxed);
break;
}
@@ -638,6 +636,10 @@ PersistentMemoryAllocator::Reference PersistentMemoryAllocator::AllocateImpl(
return kReferenceNull;
}
+ // Load information into the block header. There is no "release" of the
+ // data here because this memory can, currently, be seen only by the thread
+ // performing the allocation. When it comes time to share this, the thread
+ // will call MakeIterable() which does the release operation.
block->size = size;
block->cookie = kBlockCookieAllocated;
block->type_id.store(type_id, std::memory_order_relaxed);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698