mirror of
https://github.com/openjdk/jdk.git
synced 2026-04-04 03:58:42 +00:00
8261496: Shenandoah: reconsider pacing updates memory ordering
Reviewed-by: zgu
This commit is contained in:
parent
7c93159169
commit
4642730b05
@ -100,7 +100,7 @@ void ShenandoahControlThread::run_service() {
|
||||
bool implicit_gc_requested = _gc_requested.is_set() && !is_explicit_gc(_requested_gc_cause);
|
||||
|
||||
// This control loop iteration have seen this much allocations.
|
||||
size_t allocs_seen = Atomic::xchg(&_allocs_seen, (size_t)0);
|
||||
size_t allocs_seen = Atomic::xchg(&_allocs_seen, (size_t)0, memory_order_relaxed);
|
||||
|
||||
// Check if we have seen a new target for soft max heap size.
|
||||
bool soft_max_changed = check_soft_max_changed();
|
||||
@ -595,7 +595,7 @@ void ShenandoahControlThread::notify_heap_changed() {
|
||||
|
||||
void ShenandoahControlThread::pacing_notify_alloc(size_t words) {
|
||||
assert(ShenandoahPacing, "should only call when pacing is enabled");
|
||||
Atomic::add(&_allocs_seen, words);
|
||||
Atomic::add(&_allocs_seen, words, memory_order_relaxed);
|
||||
}
|
||||
|
||||
void ShenandoahControlThread::set_forced_counters_update(bool value) {
|
||||
|
||||
@ -179,7 +179,7 @@ size_t ShenandoahPacer::update_and_get_progress_history() {
|
||||
void ShenandoahPacer::restart_with(size_t non_taxable_bytes, double tax_rate) {
|
||||
size_t initial = (size_t)(non_taxable_bytes * tax_rate) >> LogHeapWordSize;
|
||||
STATIC_ASSERT(sizeof(size_t) <= sizeof(intptr_t));
|
||||
Atomic::xchg(&_budget, (intptr_t)initial);
|
||||
Atomic::xchg(&_budget, (intptr_t)initial, memory_order_relaxed);
|
||||
Atomic::store(&_tax_rate, tax_rate);
|
||||
Atomic::inc(&_epoch);
|
||||
|
||||
@ -201,14 +201,14 @@ bool ShenandoahPacer::claim_for_alloc(size_t words, bool force) {
|
||||
return false;
|
||||
}
|
||||
new_val = cur - tax;
|
||||
} while (Atomic::cmpxchg(&_budget, cur, new_val) != cur);
|
||||
} while (Atomic::cmpxchg(&_budget, cur, new_val, memory_order_relaxed) != cur);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ShenandoahPacer::unpace_for_alloc(intptr_t epoch, size_t words) {
|
||||
assert(ShenandoahPacing, "Only be here when pacing is enabled");
|
||||
|
||||
if (_epoch != epoch) {
|
||||
if (Atomic::load(&_epoch) != epoch) {
|
||||
// Stale ticket, no need to unpace.
|
||||
return;
|
||||
}
|
||||
|
||||
@ -53,13 +53,13 @@ inline void ShenandoahPacer::report_internal(size_t words) {
|
||||
inline void ShenandoahPacer::report_progress_internal(size_t words) {
|
||||
assert(ShenandoahPacing, "Only be here when pacing is enabled");
|
||||
STATIC_ASSERT(sizeof(size_t) <= sizeof(intptr_t));
|
||||
Atomic::add(&_progress, (intptr_t)words);
|
||||
Atomic::add(&_progress, (intptr_t)words, memory_order_relaxed);
|
||||
}
|
||||
|
||||
inline void ShenandoahPacer::add_budget(size_t words) {
|
||||
STATIC_ASSERT(sizeof(size_t) <= sizeof(intptr_t));
|
||||
intptr_t inc = (intptr_t) words;
|
||||
intptr_t new_budget = Atomic::add(&_budget, inc);
|
||||
intptr_t new_budget = Atomic::add(&_budget, inc, memory_order_relaxed);
|
||||
|
||||
// Was the budget replenished beyond zero? Then all pacing claims
|
||||
// are satisfied, notify the waiters. Avoid taking any locks here,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user