@@ -113,7 +113,7 @@ increment_reader(std::atomic<uint64_t> *p)
113113{
114114 uint64_t d;
115115 while (true ) {
116- uint64_t data = p->load (std::memory_order_acquire );
116+ uint64_t data = p->load ();
117117 if ((data & LOCK) == LOCK) { // Max count, just spin.
118118 continue ;
119119 }
@@ -129,7 +129,7 @@ decrement_reader(std::atomic<uint64_t> *p)
129129{
130130 uint64_t d;
131131 while (true ) {
132- uint64_t data = p->load (std::memory_order_acquire );
132+ uint64_t data = p->load ();
133133 d = data - 1 ;
134134 if (p->compare_exchange_weak (data, d)) {
135135 return d;
@@ -141,7 +141,7 @@ static void
141141update_lru (int i, RamCacheLocklessLRUTags *t)
142142{
143143 while (true ) {
144- uint64_t lru = t->lru .load (std::memory_order_acquire);
144+ uint64_t lru = t->lru .load (std::memory_order_relaxed); // Handled at a higher level.
145145 uint64_t new_lru = lru;
146146 // Update the row so that there is a zero for i and 1 for all others.
147147 // Set row to all ones.
@@ -160,7 +160,7 @@ static void
160160update_tag (int i, RamCacheLocklessLRUTags *t, CryptoHash *key)
161161{
162162 while (true ) {
163- uint64_t tags = t->tags .load (std::memory_order_acquire);
163+ uint64_t tags = t->tags .load (std::memory_order_relaxed); // Handled at a higher level.
164164 uint64_t new_tags = tags;
165165 uint64_t m = 0xFF << i;
166166 new_tags &= ~m;
@@ -356,9 +356,9 @@ RamCacheLocklessLRU::put(CryptoHash *key, IOBufferData *data, uint32_t len, bool
356356
357357 // Update the key and auxkey.
358358 e->key = *key;
359- e->auxkey .store (auxkey);
360359 update_lru (empty, t);
361360 update_tag (empty, t, key);
361+ e->auxkey .store (auxkey, std::memory_order_release);
362362
363363 decrement_reader (&e->data );
364364
@@ -392,8 +392,8 @@ RamCacheLocklessLRU::fixup(const CryptoHash *key, uint64_t old_auxkey, uint64_t
392392 continue ;
393393 }
394394 if (e->key == *key && e->auxkey .load () == old_auxkey) {
395- e->auxkey .store (new_auxkey);
396395 decrement_reader (&e->data );
396+ e->auxkey .store (new_auxkey, std::memory_order_release);
397397 return 1 ;
398398 }
399399 }
0 commit comments