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

Unified Diff: base/metrics/persistent_memory_allocator.cc

Issue 1619983004: Restrict volatile section of block header. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
Index: base/metrics/persistent_memory_allocator.cc
diff --git a/base/metrics/persistent_memory_allocator.cc b/base/metrics/persistent_memory_allocator.cc
index 8b4c4a4cd759758d64623d19e36f1067f24adeb8..4ab8f8c8c3f72cdeee6526318ca2c948715f0ddc 100644
--- a/base/metrics/persistent_memory_allocator.cc
+++ b/base/metrics/persistent_memory_allocator.cc
@@ -90,15 +90,23 @@ struct PersistentMemoryAllocator::SharedMetadata {
uint32_t size; // Total size of memory segment.
uint32_t page_size; // Paging size within memory segment.
uint32_t version; // Version code so upgrades don't break.
- std::atomic<uint32_t> freeptr; // Offset/ref to first free space in segment.
- std::atomic<uint32_t> flags; // Bitfield of information flags.
uint64_t id; // Arbitrary ID number given by creator.
uint32_t name; // Reference to stored name string.
+ // Above is read-only after first construction. Below may be changed and
+ // so must be marked "volatile" to provide correct inter-process behavior.
+
+ // Bitfield of information flags. Access to this should be done through
+ // the CheckFlag() and SetFlag() methods defined above.
+ volatile std::atomic<uint32_t> flags;
+
+ // Offset/reference to first free space in segment.
+ volatile std::atomic<uint32_t> freeptr;
+
// The "iterable" queue is an M&S Queue as described here, append-only:
// https://www.research.ibm.com/people/m/michael/podc-1996.pdf
- std::atomic<uint32_t> tailptr; // Last block available for iteration.
- BlockHeader queue; // Empty block for linked-list head/tail. (must be last)
+ volatile std::atomic<uint32_t> tailptr; // Last block of iteration queue.
+ volatile BlockHeader queue; // Empty block for linked-list head/tail.
};
// The "queue" block header is used to detect "last node" so that zero/null
« base/metrics/persistent_memory_allocator.h ('K') | « base/metrics/persistent_memory_allocator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698