Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
0372026
Card table as DCQ
tschatzl Feb 11, 2025
7782295
* remove some commented out debug code
tschatzl Feb 24, 2025
9e26abb
* remove mention of "enqueue" or "enqueuing" for actions related to p…
tschatzl Feb 24, 2025
3004a96
* fix crash when writing dirty cards for memory regions during card t…
tschatzl Feb 24, 2025
b8100b9
* mdoerr review: fix comments in ppc code
tschatzl Feb 24, 2025
0100d8e
* only provide byte map base for JavaThreads
tschatzl Feb 25, 2025
9ef9c5f
* remove unnecessarily added logging
tschatzl Feb 25, 2025
e51eec8
* ayang review 1
tschatzl Feb 28, 2025
7d361fc
* ayang review 1 (ctd)
tschatzl Feb 28, 2025
d87935a
* fix assert
tschatzl Feb 28, 2025
810bf2d
* fix comment (trailing whitespace)
tschatzl Mar 3, 2025
b3dd008
ayang review 2
tschatzl Mar 3, 2025
8f46dc9
* iwalulya initial comments
tschatzl Mar 4, 2025
9e2ee54
* do not change card table base for gc threads during swapping
tschatzl Mar 4, 2025
442d9ea
* iwalulya review 2
tschatzl Mar 4, 2025
fc674f0
* ayang review - fix comment
tschatzl Mar 4, 2025
b4d19d9
iwalulya review
tschatzl Mar 4, 2025
4a97811
ayang review
tschatzl Mar 4, 2025
a457e6e
* fix whitespace
tschatzl Mar 5, 2025
350a4fa
* iwalulya review
tschatzl Mar 6, 2025
c994000
* ayang review 3
tschatzl Mar 7, 2025
93b884f
* fix card table verification crashes: in the first refinement phase,…
tschatzl Mar 8, 2025
758fac0
* optimized RISCV gen_write_ref_array_post_barrier() implementation c…
tschatzl Mar 11, 2025
aec9505
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Mar 12, 2025
3766b76
* ayang review
tschatzl Mar 12, 2025
7861117
* when aborting refinement during full collection, the global card ta…
tschatzl Mar 13, 2025
51a9eed
* ayang review
tschatzl Mar 14, 2025
b073017
Merge branch 'master' into 8342381-card-table-instead-of-dcq
tschatzl Mar 14, 2025
447fe39
* more documentation on why we need to rendezvous the gc threads
tschatzl Mar 15, 2025
4d0afd5
* obsolete G1UpdateBufferSize
tschatzl Mar 17, 2025
ff9eb26
Merge branch 'master' into 8342382-card-table-instead-of-dcq3
tschatzl Mar 18, 2025
c833bc8
* factor out card table and refinement table merging into a single
tschatzl Mar 18, 2025
f419556
* fix IR code generation tests that change due to barrier cost changes
tschatzl Mar 19, 2025
5e76a51
* make young gen length revising independent of refinement thread
tschatzl Mar 20, 2025
d931104
Merge branch 'master' into submit/8342382-card-table-instead-of-dcq
tschatzl Mar 21, 2025
6d574da
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Mar 26, 2025
51fb6e6
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Apr 1, 2025
27b3dd6
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Apr 4, 2025
1c5a669
* missing file from merge
tschatzl Apr 4, 2025
c5d5f3a
Reorder includes
robcasloz Apr 9, 2025
9481821
Refine needs_liveness_data
robcasloz Apr 9, 2025
855ec8d
Do not unnecessarily pass around tmp2 in x86
robcasloz Apr 9, 2025
d4649ed
* ayang review: revising young gen length
tschatzl Apr 9, 2025
63b1de8
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Apr 10, 2025
39aa903
* fixes after merge related to 32 bit x86 removal
tschatzl Apr 10, 2025
fcf96a2
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Apr 10, 2025
fd77531
* remove support for 32 bit x86 in the barrier generation code, follo…
tschatzl Apr 10, 2025
068d2a3
* indentation fix
tschatzl Apr 10, 2025
e683152
* ayang review (part 1)
tschatzl Apr 11, 2025
a3b2386
* ayang review (part 2 - yield duration changes)
tschatzl Apr 11, 2025
e4bf1ac
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Apr 23, 2025
51dfbe5
Merge branch 'master' into card-table-as-dcq-merge
tschatzl Apr 29, 2025
8b56880
* ayang review: remove sweep_epoch
tschatzl Apr 29, 2025
1def83a
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl May 15, 2025
c07a73d
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Jun 10, 2025
750ed2d
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Jun 27, 2025
441c234
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Jul 7, 2025
5ab928e
Merge branch 'master' into pull/23739
tschatzl Jul 14, 2025
4b21868
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Jul 17, 2025
cea0e1b
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Jul 23, 2025
dd83638
* remove unused G1DetachedRefinementStats_lock
tschatzl Jul 23, 2025
23aa2c8
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Jul 28, 2025
188fc81
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Aug 5, 2025
7fe518e
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Aug 12, 2025
6c88f1d
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Aug 22, 2025
e8a8282
* forgot to actually save the files
tschatzl Aug 22, 2025
cc4b7a0
* fix merge error
tschatzl Aug 22, 2025
4a41b40
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Sep 1, 2025
b3873d6
* commit merge changes
tschatzl Sep 1, 2025
104d506
* improve logging for refinement, making it similar to marking logging
tschatzl Sep 3, 2025
2a614a2
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Sep 4, 2025
4601bf8
* sort includes
tschatzl Sep 8, 2025
87b4136
* iwalulya: remove confusing comment
tschatzl Sep 10, 2025
e7c3a06
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Sep 10, 2025
de1469d
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Sep 10, 2025
d0ca906
* aph review, fix some comment
tschatzl Sep 10, 2025
b47c7b0
* walulyai review
tschatzl Sep 10, 2025
c469c13
* walulyai review
tschatzl Sep 10, 2025
74e9240
* therealaph suggestion for avoiding the register aliasin in gen_writ…
tschatzl Sep 12, 2025
1ced9f9
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Sep 12, 2025
bf8cab3
* iwalulya review
tschatzl Sep 12, 2025
b5d22d5
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Sep 22, 2025
53ef008
* improved gen_write_ref_array_post_barrier() for riscv, contributed …
tschatzl Sep 22, 2025
6e37f8d
* iwalulya: "Amount of" -> "Number of" in new flag description
tschatzl Sep 22, 2025
311bb3e
* walulyai: remove cost_per_pending_card_ms_default array since we on…
tschatzl Sep 22, 2025
d80d690
* walulyai: remove unnecessarily introduced newline
tschatzl Sep 22, 2025
3c889e9
* walulyai: bufferNodeList can be removed
tschatzl Sep 22, 2025
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
Prev Previous commit
Next Next commit
* when aborting refinement during full collection, the global card ta…
…ble and the per-thread card table might not be in sync. Roll forward during abort of the refinement in these situations.

* additional verification
* added some missing ResourceMarks in asserts
* added variant of ArrayJuggle2 that crashes fairly quickly without these changes
  • Loading branch information
tschatzl committed Mar 13, 2025
commit 786111735c306583af5bc75f7653f0da67d52adb
13 changes: 12 additions & 1 deletion src/hotspot/share/gc/g1/g1BarrierSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ void G1BarrierSet::swap_global_card_table() {
_refinement_table = temp;
}

void G1BarrierSet::update_card_table_base(Thread* thread) {
#ifdef ASSERT
{
ResourceMark rm;
assert(thread->is_Java_thread(), "may only update card table base of JavaThreads, not %s", thread->name());
}
#endif
G1ThreadLocalData::set_byte_map_base(thread, _card_table->byte_map_base());
}

template <class T> void
G1BarrierSet::write_ref_array_pre_work(T* dst, size_t count) {
G1SATBMarkQueueSet& queue_set = G1BarrierSet::satb_mark_queue_set();
Expand Down Expand Up @@ -161,7 +171,8 @@ void G1BarrierSet::on_thread_attach(Thread* thread) {
satbq.set_active(_satb_mark_queue_set.is_active());

if (thread->is_Java_thread()) {
G1ThreadLocalData::set_byte_map_base(thread, G1CollectedHeap::heap()->card_table_base());
assert(Threads_lock->is_locked(), "must be, synchronization with refinement.");
update_card_table_base(thread);
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/share/gc/g1/g1BarrierSet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "gc/shared/bufferNode.hpp"

class G1CardTable;
class Thread;

// This barrier set is specialized to manage two card tables:
// * one the mutator is currently working on ("card table")
Expand Down Expand Up @@ -81,6 +82,9 @@ class G1BarrierSet: public CardTableBarrierSet {
// Swap the global card table references, without synchronization.
void swap_global_card_table();

// Update the given thread's card table (byte map) base to the current card table's.
void update_card_table_base(Thread* thread);

virtual bool card_mark_must_follow_store() const {
return true;
}
Expand Down
16 changes: 16 additions & 0 deletions src/hotspot/share/gc/g1/g1CollectedHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
#include "runtime/init.hpp"
#include "runtime/java.hpp"
#include "runtime/orderAccess.hpp"
#include "runtime/threads.hpp"
#include "runtime/threadSMR.hpp"
#include "runtime/vmThread.hpp"
#include "utilities/align.hpp"
Expand Down Expand Up @@ -800,6 +801,20 @@ void G1CollectedHeap::prepare_for_mutator_after_full_collection() {
void G1CollectedHeap::abort_refinement() {
G1ConcurrentRefineSweepState& sweep_state = concurrent_refine()->sweep_state();
if (sweep_state.is_in_progress()) {

if (!sweep_state.are_java_threads_synched()) {
// Synchronize Java threads with global card table that has already been swapped.
class SwapThreadCardTableClosure : public ThreadClosure {
public:

virtual void do_thread(Thread* t) {
G1BarrierSet* bs = G1BarrierSet::g1_barrier_set();
bs->update_card_table_base(t);
}
} cl;
Threads::java_threads_do(&cl);
}

// Record any available refinement statistics.
policy()->record_refinement_stats(sweep_state.stats());
sweep_state.complete_work(false /* concurrent */, false /* print_log */);
Expand All @@ -816,6 +831,7 @@ void G1CollectedHeap::verify_after_full_collection() {
}
_hrm.verify_optional();
_verifier->verify_region_sets_optional();
_verifier->verify_card_tables_clean(true /* both_card_tables */);
_verifier->verify_after_gc();
_verifier->verify_bitmap_clear(false /* above_tams_only */);

Expand Down
8 changes: 6 additions & 2 deletions src/hotspot/share/gc/g1/g1ConcurrentRefine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ bool G1ConcurrentRefineSweepState::swap_java_threads_ct() {
public:
G1SwapThreadCardTableClosure() : HandshakeClosure("G1 Swap JT card table") { }

virtual void do_thread(Thread* t) {
virtual void do_thread(Thread* thread) {
G1BarrierSet* bs = G1BarrierSet::g1_barrier_set();
G1ThreadLocalData::set_byte_map_base(t, bs->card_table()->byte_map_base());
bs->update_card_table_base(thread);
}
} cl;
Handshake::execute(&cl);
Expand Down Expand Up @@ -374,6 +374,10 @@ bool G1ConcurrentRefineSweepState::is_in_progress() const {
return _state != State::Idle;
}

bool G1ConcurrentRefineSweepState::are_java_threads_synched() const {
return _state > State::SwapJavaThreadsCT || !is_in_progress();
}

uint64_t G1ConcurrentRefine::adjust_threads_period_ms() const {
// Instead of a fixed value, this could be a command line option. But then
// we might also want to allow configuration of adjust_threads_wait_ms().
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/gc/g1/g1ConcurrentRefine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ class G1ConcurrentRefineSweepState {
void add_yield_duration(jlong duration);

bool is_in_progress() const;
bool are_java_threads_synched() const;
};

// Controls concurrent refinement.
Expand Down
54 changes: 46 additions & 8 deletions src/hotspot/share/gc/g1/g1HeapVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "oops/compressedOops.inline.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/threads.hpp"

int G1HeapVerifier::_enabled_verification_types = G1HeapVerifier::G1VerifyAll;

Expand Down Expand Up @@ -527,6 +528,7 @@ void G1HeapVerifier::verify_before_gc() {

void G1HeapVerifier::verify_after_gc() {
verify(VerifyOption::G1UseConcMarking, "After GC");
verify_card_tables_in_sync();
}

void G1HeapVerifier::verify_bitmap_clear(bool from_tams) {
Expand Down Expand Up @@ -578,23 +580,25 @@ void G1HeapVerifier::verify_card_table_cleanup() {
}
}

class G1VerifyRefinementTableClean: public G1HeapRegionClosure {
class G1VerifyCardTablesClean: public G1HeapRegionClosure {
G1HeapVerifier* _verifier;
bool _both_card_tables;

public:
G1VerifyRefinementTableClean(G1HeapVerifier* verifier)
: _verifier(verifier) { }
G1VerifyCardTablesClean(G1HeapVerifier* verifier, bool both_card_tables = true)
: _verifier(verifier), _both_card_tables(both_card_tables) { }

virtual bool do_heap_region(G1HeapRegion* r) {
G1CardTable* ct = G1CollectedHeap::heap()->refinement_table();
MemRegion mr(r->bottom(), r->end());
ct->verify_region(mr, G1CardTable::clean_card_val(), true); // Must be all Clean from bottom -> end.
_verifier->verify_rt_clean_region(r); // Must be all Clean from bottom -> end.
if (_both_card_tables) {
_verifier->verify_ct_clean_region(r);
}
return false;
}
};

void G1HeapVerifier::verify_refinement_table_clean() {
G1VerifyRefinementTableClean cl(this);
void G1HeapVerifier::verify_card_tables_clean(bool both_card_tables) {
G1VerifyCardTablesClean cl(this, both_card_tables);
_g1h->heap_region_iterate(&cl);
}

Expand Down Expand Up @@ -630,6 +634,40 @@ void G1HeapVerifier::verify_rt_clean_region(G1HeapRegion* hr) {
}

#ifndef PRODUCT

void G1HeapVerifier::verify_card_tables_in_sync() {

// Non-Java thread card tables must be null.
class AssertCardTableBaseNull : public ThreadClosure {
public:

void do_thread(Thread* thread) {
ResourceMark rm;
assert(G1ThreadLocalData::get_byte_map_base(thread) == nullptr, "thread " PTR_FORMAT " (%s) has non-null card table base",
p2i(thread), thread->name());
}
} check_null_cl;

Threads::non_java_threads_do(&check_null_cl);

// Java thread card tables must be the same as the global card table.
class AssertSameCardTableClosure : public ThreadClosure {
public:

void do_thread(Thread* thread) {
G1CardTable::CardValue* global_ct_base = G1CollectedHeap::heap()->card_table_base();
G1CardTable::CardValue* cur_ct_base = G1ThreadLocalData::get_byte_map_base(thread);

ResourceMark rm;
assert(cur_ct_base == global_ct_base,
"thread " PTR_FORMAT " (%s) has wrong card table base, should be " PTR_FORMAT " is " PTR_FORMAT,
p2i(thread), thread->name(), p2i(global_ct_base), p2i(cur_ct_base));
}
} check_same_cl;

Threads::java_threads_do(&check_same_cl);
}

class G1CheckRegionAttrTableClosure : public G1HeapRegionClosure {
private:
bool _failures;
Expand Down
5 changes: 4 additions & 1 deletion src/hotspot/share/gc/g1/g1HeapVerifier.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,15 @@ class G1HeapVerifier : public CHeapObj<mtGC> {
bool check_region_attr_table() PRODUCT_RETURN_( return true; );

void verify_card_table_cleanup();
void verify_refinement_table_clean();
void verify_card_tables_clean(bool both_card_tables);

void verify_ct_clean_region(G1HeapRegion* hr);
void verify_rt_dirty_to_dummy_top(G1HeapRegion* hr);
void verify_rt_clean_from_top(G1HeapRegion* hr);
void verify_rt_clean_region(G1HeapRegion* hr);

// Verify that the global card table and the thread's card tables are in sync.
void verify_card_tables_in_sync() PRODUCT_RETURN;
};

#endif // SHARE_GC_G1_G1HEAPVERIFIER_HPP
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/g1RemSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,7 @@ void G1RemSet::merge_heap_roots(bool initial_evacuation) {
}

if (VerifyDuringGC && initial_evacuation) {
g1h->verifier()->verify_refinement_table_clean();
g1h->verifier()->verify_card_tables_clean(false /* both_card_tables */);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/g1ThreadLocalData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class G1ThreadLocalData {
data(thread)->_byte_map_base = new_byte_map_base;
}

#ifdef ASSERT
#ifndef PRODUCT
static G1CardTable::CardValue* get_byte_map_base(Thread* thread) {
return data(thread)->_byte_map_base;
}
Expand Down
15 changes: 1 addition & 14 deletions src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -839,17 +839,6 @@ class G1PostEvacuateCollectionSetCleanupTask2::ResizeTLABsAndSwapCardTableTask :
: G1AbstractSubTask(G1GCPhaseTimes::ResizeThreadLABs), _claimer(ThreadsPerWorker)
{
G1BarrierSet::g1_barrier_set()->swap_global_card_table();

#ifdef ASSERT
class AssertCardTableBaseNull : public ThreadClosure {
public:

void do_thread(Thread* thread) {
assert(G1ThreadLocalData::get_byte_map_base(thread) == nullptr, "thread " PTR_FORMAT " (%s) has non-null card table base", p2i(thread), thread->name());
}
} assert_cl;
Threads::non_java_threads_do(&assert_cl);
#endif
}

void do_work(uint worker_id) override {
Expand All @@ -862,9 +851,7 @@ class G1PostEvacuateCollectionSetCleanupTask2::ResizeTLABsAndSwapCardTableTask :
static_cast<JavaThread*>(thread)->tlab().resize();
}

// The global card table references have already been swapped.
G1CardTable::CardValue* new_card_table_base = G1CollectedHeap::heap()->card_table_base();
G1ThreadLocalData::set_byte_map_base(thread, new_card_table_base);
G1BarrierSet::g1_barrier_set()->update_card_table_base(thread);
}
} resize_and_swap_cl;

Expand Down
7 changes: 6 additions & 1 deletion test/hotspot/jtreg/vmTestbase/gc/ArrayJuggle/Juggle2.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -30,6 +30,11 @@
/* @test @key stress randomness @library /vmTestbase /test/lib @run main/othervm -Xlog:gc=debug:gc.log gc.ArrayJuggle.Juggle2 */
/* @test @key stress randomness @library /vmTestbase /test/lib @run main/othervm -Xlog:gc=debug:gc.log gc.ArrayJuggle.Juggle2 -tg */

/*
* The next test stresses the interaction between (mostly) full garbage collections and refinement.
*/
/* @test @key stress randomness @library /vmTestbase /test/lib @run main/othervm -XX:-G1UseAdaptiveIHOP -XX:InitiatingHeapOccupancyPercent=0 -XX:G1HeapRegionSize=1m -XX:G1RSetUpdatingPauseTimePercent=0 -XX:G1UpdateBufferSize=1 -XX:+UnlockDiagnosticVMOptions -XX:+VerifyAfterGC -Xlog:gc=debug,gc+refine=debug:gc.log gc.ArrayJuggle.Juggle2 -tg */

package gc.ArrayJuggle;

import nsk.share.test.*;
Expand Down