From 03038d802cc43b7694f554978ac9de8edca8a954 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Thu, 22 Jan 2026 08:35:32 +0000 Subject: [PATCH] 8375978: G1: Convert G1Policy to use Atomic Reviewed-by: kbarrett --- src/hotspot/share/gc/g1/g1Policy.cpp | 4 ++-- src/hotspot/share/gc/g1/g1Policy.hpp | 13 +++++-------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/hotspot/share/gc/g1/g1Policy.cpp b/src/hotspot/share/gc/g1/g1Policy.cpp index 2847a25c5b4..8818b477aae 100644 --- a/src/hotspot/share/gc/g1/g1Policy.cpp +++ b/src/hotspot/share/gc/g1/g1Policy.cpp @@ -203,8 +203,8 @@ void G1Policy::update_young_length_bounds(size_t pending_cards, size_t card_rs_l // allocation. // That is "fine" - at most this will schedule a GC (hopefully only a little) too // early or too late. - AtomicAccess::store(&_young_list_desired_length, new_young_list_desired_length); - AtomicAccess::store(&_young_list_target_length, new_young_list_target_length); + _young_list_desired_length.store_relaxed(new_young_list_desired_length); + _young_list_target_length.store_relaxed(new_young_list_target_length); } // Calculates desired young gen length. It is calculated from: diff --git a/src/hotspot/share/gc/g1/g1Policy.hpp b/src/hotspot/share/gc/g1/g1Policy.hpp index cf12a7a8027..9513c79869e 100644 --- a/src/hotspot/share/gc/g1/g1Policy.hpp +++ b/src/hotspot/share/gc/g1/g1Policy.hpp @@ -35,7 +35,7 @@ #include "gc/g1/g1RemSetTrackingPolicy.hpp" #include "gc/g1/g1YoungGenSizer.hpp" #include "gc/shared/gcCause.hpp" -#include "runtime/atomicAccess.hpp" +#include "runtime/atomic.hpp" #include "utilities/pair.hpp" #include "utilities/ticks.hpp" @@ -81,12 +81,9 @@ class G1Policy: public CHeapObj { // Desired young gen length without taking actually available free regions into // account. - volatile uint _young_list_desired_length; + Atomic _young_list_desired_length; // Actual target length given available free memory. - volatile uint _young_list_target_length; - // The max number of regions we can extend the eden by while the GC - // locker is active. This should be >= _young_list_target_length; - volatile uint _young_list_max_length; + Atomic _young_list_target_length; // The survivor rate groups below must be initialized after the predictor because they // indirectly use it through the "this" object passed to their constructor. @@ -362,8 +359,8 @@ public: // This must be called at the very beginning of an evacuation pause. void decide_on_concurrent_start_pause(); - uint young_list_desired_length() const { return AtomicAccess::load(&_young_list_desired_length); } - uint young_list_target_length() const { return AtomicAccess::load(&_young_list_target_length); } + uint young_list_desired_length() const { return _young_list_desired_length.load_relaxed(); } + uint young_list_target_length() const { return _young_list_target_length.load_relaxed(); } bool should_allocate_mutator_region() const; bool should_expand_on_mutator_allocation() const;