Skip to content

Commit

Permalink
8275226: Shenandoah: Relax memory constraint for worker claiming task…
Browse files Browse the repository at this point in the history
…s/ranges

Reviewed-by: shade
  • Loading branch information
zhengyu123 committed Oct 14, 2021
1 parent 8d9004b commit 3b0b6ad
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void ShenandoahParallelCodeHeapIterator::parallel_blobs_do(CodeBlobClosure* f) {
int current = count++;
if ((current & stride_mask) == 0) {
process_block = (current >= _claimed_idx) &&
(Atomic::cmpxchg(&_claimed_idx, current, current + stride) == current);
(Atomic::cmpxchg(&_claimed_idx, current, current + stride, memory_order_relaxed) == current);
}
if (process_block) {
if (cb->is_alive()) {
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/gc/shenandoah/shenandoahNMethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ void ShenandoahNMethodTableSnapshot::parallel_blobs_do(CodeBlobClosure *f) {

size_t max = (size_t)_limit;
while (_claimed < max) {
size_t cur = Atomic::fetch_and_add(&_claimed, stride);
size_t cur = Atomic::fetch_and_add(&_claimed, stride, memory_order_relaxed);
size_t start = cur;
size_t end = MIN2(cur + stride, max);
if (start >= max) break;
Expand All @@ -520,7 +520,7 @@ void ShenandoahNMethodTableSnapshot::concurrent_nmethods_do(NMethodClosure* cl)
ShenandoahNMethod** list = _list->list();
size_t max = (size_t)_limit;
while (_claimed < max) {
size_t cur = Atomic::fetch_and_add(&_claimed, stride);
size_t cur = Atomic::fetch_and_add(&_claimed, stride, memory_order_relaxed);
size_t start = cur;
size_t end = MIN2(cur + stride, max);
if (start >= max) break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,14 +453,14 @@ void ShenandoahReferenceProcessor::process_references(ShenandoahRefProcThreadLoc
void ShenandoahReferenceProcessor::work() {
// Process discovered references
uint max_workers = ShenandoahHeap::heap()->max_workers();
uint worker_id = Atomic::add(&_iterate_discovered_list_id, 1U) - 1;
uint worker_id = Atomic::add(&_iterate_discovered_list_id, 1U, memory_order_relaxed) - 1;
while (worker_id < max_workers) {
if (UseCompressedOops) {
process_references<narrowOop>(_ref_proc_thread_locals[worker_id], worker_id);
} else {
process_references<oop>(_ref_proc_thread_locals[worker_id], worker_id);
}
worker_id = Atomic::add(&_iterate_discovered_list_id, 1U) - 1;
worker_id = Atomic::add(&_iterate_discovered_list_id, 1U, memory_order_relaxed) - 1;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ T* ParallelClaimableQueueSet<T, F>::claim_next() {
return NULL;
}

jint index = Atomic::add(&_claimed_index, 1);
jint index = Atomic::add(&_claimed_index, 1, memory_order_relaxed);

if (index <= size) {
return GenericTaskQueueSet<T, F>::queue((uint)index - 1);
Expand Down

1 comment on commit 3b0b6ad

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.