Skip to content

Commit e7a7070

Browse files
committed
concurrent_set: change CAS memory order
1 parent ebf3453 commit e7a7070

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

concurrent_set.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ rb_concurrent_set_find_or_insert(VALUE *set_obj_ptr, VALUE key, void *data)
519519
VALUE curr_hash = raw_hash & CONCURRENT_SET_HASH_MASK;
520520
if (raw_hash == 0) {
521521
// Reserve this slot for our hash value
522-
raw_hash = rbimpl_atomic_value_cas(&entry->hash, 0, hash, RBIMPL_ATOMIC_RELEASE, RBIMPL_ATOMIC_ACQUIRE);
522+
raw_hash = rbimpl_atomic_value_cas(&entry->hash, 0, hash, RBIMPL_ATOMIC_RELEASE, RBIMPL_ATOMIC_RELAXED);
523523
if (raw_hash != 0) {
524524
// Lost race, retry same slot to check winner's hash
525525
continue;
@@ -537,7 +537,7 @@ rb_concurrent_set_find_or_insert(VALUE *set_obj_ptr, VALUE key, void *data)
537537
case CONCURRENT_SET_EMPTY: {
538538
if ((raw_hash & CONCURRENT_SET_HASH_RECLAIMABLE_BIT) && !continuation) {
539539
// Reclaim this reclaimable slot by clearing the reclaimable bit
540-
VALUE prev_hash = rbimpl_atomic_value_cas(&entry->hash, raw_hash, hash, RBIMPL_ATOMIC_RELEASE, RBIMPL_ATOMIC_ACQUIRE);
540+
VALUE prev_hash = rbimpl_atomic_value_cas(&entry->hash, raw_hash, hash, RBIMPL_ATOMIC_RELEASE, RBIMPL_ATOMIC_RELAXED);
541541
if (prev_hash != raw_hash) {
542542
// Lost race, retry same slot
543543
continue;
@@ -558,7 +558,7 @@ rb_concurrent_set_find_or_insert(VALUE *set_obj_ptr, VALUE key, void *data)
558558
goto retry;
559559
}
560560

561-
VALUE prev_raw_key = rbimpl_atomic_value_cas(&entry->key, raw_key, key | (continuation ? CONCURRENT_SET_CONTINUATION_BIT : 0), RBIMPL_ATOMIC_RELEASE, RBIMPL_ATOMIC_ACQUIRE);
561+
VALUE prev_raw_key = rbimpl_atomic_value_cas(&entry->key, raw_key, key | (continuation ? CONCURRENT_SET_CONTINUATION_BIT : 0), RBIMPL_ATOMIC_RELEASE, RBIMPL_ATOMIC_RELAXED);
562562
if (prev_raw_key == raw_key) {
563563
#if CONCURRENT_SET_DEBUG_STATS
564564
rbimpl_atomic_fetch_add(&set->insert_count, 1, RBIMPL_ATOMIC_RELAXED);
@@ -715,7 +715,7 @@ rb_concurrent_set_delete_by_identity_locked(VALUE set_obj, VALUE key)
715715

716716
if (!hash_cleared) {
717717
// Hashes only change here and they get reclaimed in find_or_insert
718-
prev_hash = rbimpl_atomic_value_cas(&entry->hash, loaded_hash_raw, hash | CONCURRENT_SET_HASH_RECLAIMABLE_BIT, RBIMPL_ATOMIC_RELEASE, RBIMPL_ATOMIC_ACQUIRE);
718+
prev_hash = rbimpl_atomic_value_cas(&entry->hash, loaded_hash_raw, hash | CONCURRENT_SET_HASH_RECLAIMABLE_BIT, RBIMPL_ATOMIC_RELEASE, RBIMPL_ATOMIC_RELAXED);
719719
RUBY_ASSERT(prev_hash == hash || prev_hash == (hash | CONCURRENT_SET_HASH_RECLAIMABLE_BIT));
720720
hash_cleared = true;
721721
}

0 commit comments

Comments
 (0)