Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions src/hotspot/share/runtime/cpuTimeCounters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,9 @@ void CPUTimeCounters::inc_gc_total_cpu_time(jlong diff) {

void CPUTimeCounters::publish_gc_total_cpu_time() {
CPUTimeCounters* instance = CPUTimeCounters::get_instance();
// Ensure that we are only incrementing atomically by using Atomic::cmpxchg
// to set the value to zero after we obtain the new CPU time difference.
jlong old_value;
jlong fetched_value = Atomic::load(&(instance->_gc_total_cpu_time_diff));
// Atomically fetch the current _gc_total_cpu_time_diff and reset it to zero.
jlong new_value = 0;
do {
old_value = fetched_value;
fetched_value = Atomic::cmpxchg(&(instance->_gc_total_cpu_time_diff), old_value, new_value);
} while (old_value != fetched_value);
jlong fetched_value = Atomic::xchg(&(instance->_gc_total_cpu_time_diff), new_value);
get_counter(CPUTimeGroups::CPUTimeType::gc_total)->inc(fetched_value);
}

Expand Down