From ed260e8cae329a0c077e91ff76d104ee197fb7fd Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Thu, 21 Aug 2025 09:37:34 +0000 Subject: [PATCH] 8365026: G1: Initialization should start a "full" new collection set Reviewed-by: ayang, kbarrett --- src/hotspot/share/gc/g1/g1CollectedHeap.cpp | 2 ++ src/hotspot/share/gc/g1/g1ConcurrentMark.cpp | 3 ++- src/hotspot/share/gc/g1/g1Policy.cpp | 4 ---- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp index e964ecefb18..ed08d43bbbe 100644 --- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp +++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp @@ -1487,6 +1487,8 @@ jint G1CollectedHeap::initialize() { _collection_set.initialize(max_num_regions()); + start_new_collection_set(); + allocation_failure_injector()->reset(); CPUTimeCounters::create_counter(CPUTimeGroups::CPUTimeType::gc_parallel_workers); diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp index 210d78098b3..237704c12a8 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp @@ -1962,7 +1962,8 @@ public: }; void G1ConcurrentMark::verify_no_collection_set_oops() { - assert(SafepointSynchronize::is_at_safepoint(), "should be at a safepoint"); + assert(SafepointSynchronize::is_at_safepoint() || !is_init_completed(), + "should be at a safepoint or initializing"); if (!_g1h->collector_state()->mark_or_rebuild_in_progress()) { return; } diff --git a/src/hotspot/share/gc/g1/g1Policy.cpp b/src/hotspot/share/gc/g1/g1Policy.cpp index bb54d344ca0..53f0a7bf7a6 100644 --- a/src/hotspot/share/gc/g1/g1Policy.cpp +++ b/src/hotspot/share/gc/g1/g1Policy.cpp @@ -97,10 +97,6 @@ void G1Policy::init(G1CollectedHeap* g1h, G1CollectionSet* collection_set) { _free_regions_at_end_of_collection = _g1h->num_free_regions(); update_young_length_bounds(); - - // We immediately start allocating regions placing them in the collection set. - // Initialize the collection set info. - _collection_set->start_incremental_building(); } void G1Policy::record_young_gc_pause_start() {