Skip to content

Commit e4aed95

Browse files
author
Thomas Schatzl
committed
8370682: G1: Survivor regions not in young gen cset group
Reviewed-by: iwalulya, ayang
1 parent c1476fc commit e4aed95

File tree

4 files changed

+32
-20
lines changed

4 files changed

+32
-20
lines changed

src/hotspot/share/gc/g1/g1CollectedHeap.cpp

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2563,10 +2563,12 @@ void G1CollectedHeap::verify_region_attr_is_remset_tracked() {
25632563
public:
25642564
virtual bool do_heap_region(G1HeapRegion* r) {
25652565
G1CollectedHeap* g1h = G1CollectedHeap::heap();
2566-
const bool is_remset_tracked = g1h->region_attr(r->bottom()).is_remset_tracked();
2567-
assert(r->rem_set()->is_tracked() == is_remset_tracked,
2568-
"Region %u remset tracking status (%s) different to region attribute (%s)",
2569-
r->hrm_index(), BOOL_TO_STR(r->rem_set()->is_tracked()), BOOL_TO_STR(is_remset_tracked));
2566+
G1HeapRegionAttr attr = g1h->region_attr(r->bottom());
2567+
bool const is_remset_tracked = attr.is_remset_tracked();
2568+
assert((r->rem_set()->is_tracked() == is_remset_tracked) ||
2569+
(attr.is_new_survivor() && is_remset_tracked),
2570+
"Region %u (%s) remset tracking status (%s) different to region attribute (%s)",
2571+
r->hrm_index(), r->get_type_str(), BOOL_TO_STR(r->rem_set()->is_tracked()), BOOL_TO_STR(is_remset_tracked));
25702572
return false;
25712573
}
25722574
} cl;
@@ -3105,9 +3107,8 @@ G1HeapRegion* G1CollectedHeap::new_mutator_alloc_region(size_t word_size,
31053107
new_alloc_region->set_eden();
31063108
_eden.add(new_alloc_region);
31073109
_policy->set_region_eden(new_alloc_region);
3108-
_policy->remset_tracker()->update_at_allocate(new_alloc_region);
3109-
// Install the group cardset.
3110-
young_regions_cset_group()->add(new_alloc_region);
3110+
3111+
collection_set()->add_eden_region(new_alloc_region);
31113112
G1HeapRegionPrinter::alloc(new_alloc_region);
31123113
return new_alloc_region;
31133114
}
@@ -3120,7 +3121,6 @@ void G1CollectedHeap::retire_mutator_alloc_region(G1HeapRegion* alloc_region,
31203121
assert_heap_locked_or_at_safepoint(true /* should_be_vm_thread */);
31213122
assert(alloc_region->is_eden(), "all mutator alloc regions should be eden");
31223123

3123-
collection_set()->add_eden_region(alloc_region);
31243124
increase_used(allocated_bytes);
31253125
_eden.add_used_bytes(allocated_bytes);
31263126
G1HeapRegionPrinter::retire(alloc_region);
@@ -3164,14 +3164,20 @@ G1HeapRegion* G1CollectedHeap::new_gc_alloc_region(size_t word_size, G1HeapRegio
31643164
if (type.is_survivor()) {
31653165
new_alloc_region->set_survivor();
31663166
_survivor.add(new_alloc_region);
3167+
// The remembered set/group cardset for this region will be installed at the
3168+
// end of GC. Cannot do that right now because we still need the current young
3169+
// gen cardset group.
3170+
// However, register with the attribute table to collect remembered set entries
3171+
// immediately as it is the only source for determining the need for remembered
3172+
// set tracking during GC.
31673173
register_new_survivor_region_with_region_attr(new_alloc_region);
3168-
// Install the group cardset.
3169-
young_regions_cset_group()->add(new_alloc_region);
31703174
} else {
31713175
new_alloc_region->set_old();
3176+
// Update remembered set/cardset.
3177+
_policy->remset_tracker()->update_at_allocate(new_alloc_region);
3178+
// Synchronize with region attribute table.
31723179
update_region_attr(new_alloc_region);
31733180
}
3174-
_policy->remset_tracker()->update_at_allocate(new_alloc_region);
31753181
G1HeapRegionPrinter::alloc(new_alloc_region);
31763182
return new_alloc_region;
31773183
}

src/hotspot/share/gc/g1/g1CollectionSet.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ void G1CollectionSet::clear() {
163163
assert_at_safepoint_on_vm_thread();
164164
_regions_cur_length = 0;
165165
_groups.clear();
166+
assert(_optional_groups.length() == 0, "must be");
166167
}
167168

168169
void G1CollectionSet::iterate(G1HeapRegionClosure* cl) const {
@@ -216,7 +217,11 @@ void G1CollectionSet::add_young_region_common(G1HeapRegion* hr) {
216217
assert(hr->is_young(), "invariant");
217218
assert(_inc_build_state == CSetBuildType::Active, "Precondition");
218219

219-
assert(!hr->in_collection_set(), "invariant");
220+
// Add to remembered set/cardset group.
221+
_g1h->policy()->remset_tracker()->update_at_allocate(hr);
222+
_g1h->young_regions_cset_group()->add(hr);
223+
224+
// Synchronize with the region attribute table.
220225
_g1h->register_young_region_with_region_attr(hr);
221226

222227
// We use UINT_MAX as "invalid" marker in verification.
@@ -233,11 +238,13 @@ void G1CollectionSet::add_young_region_common(G1HeapRegion* hr) {
233238
}
234239

235240
void G1CollectionSet::add_survivor_regions(G1HeapRegion* hr) {
241+
assert_at_safepoint_on_vm_thread();
236242
assert(hr->is_survivor(), "Must only add survivor regions, but is %s", hr->get_type_str());
237243
add_young_region_common(hr);
238244
}
239245

240246
void G1CollectionSet::add_eden_region(G1HeapRegion* hr) {
247+
assert_heap_locked_or_at_safepoint(true /* should_be_vm_thread */);
241248
assert(hr->is_eden(), "Must only add eden regions, but is %s", hr->get_type_str());
242249
add_young_region_common(hr);
243250
}

src/hotspot/share/gc/g1/g1FullGCResetMetadataTask.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,13 @@ G1FullGCResetMetadataTask::G1ResetMetadataClosure::G1ResetMetadataClosure(G1Full
3131
_collector(collector) { }
3232

3333
void G1FullGCResetMetadataTask::G1ResetMetadataClosure::reset_region_metadata(G1HeapRegion* hr) {
34+
assert(hr->is_humongous() || !hr->rem_set()->has_cset_group(),
35+
"Non-humongous regions must not have cset group");
3436
hr->rem_set()->clear();
3537
hr->clear_both_card_tables();
3638
}
3739

3840
bool G1FullGCResetMetadataTask::G1ResetMetadataClosure::do_heap_region(G1HeapRegion* hr) {
39-
if (!hr->is_humongous()) {
40-
hr->uninstall_cset_group();
41-
}
42-
43-
4441
uint const region_idx = hr->hrm_index();
4542
if (!_collector->is_compaction_target(region_idx)) {
4643
assert(!hr->is_free(), "all free regions should be compaction targets");

src/hotspot/share/gc/g1/g1ParScanThreadState.inline.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,13 @@ template <class T> void G1ParScanThreadState::mark_card_if_tracked(G1HeapRegionA
151151

152152
#ifdef ASSERT
153153
G1HeapRegion* const hr_obj = _g1h->heap_region_containing(o);
154-
assert(region_attr.is_remset_tracked() == hr_obj->rem_set()->is_tracked(),
155-
"State flag indicating remset tracking disagrees (%s) with actual remembered set (%s) for region %u",
154+
assert((region_attr.is_remset_tracked() == hr_obj->rem_set()->is_tracked()) ||
155+
(region_attr.is_new_survivor() && region_attr.is_remset_tracked()),
156+
"State flag indicating remset tracking disagrees (%s) with actual remembered set (%s) for region %u (%s)",
156157
BOOL_TO_STR(region_attr.is_remset_tracked()),
157158
BOOL_TO_STR(hr_obj->rem_set()->is_tracked()),
158-
hr_obj->hrm_index());
159+
hr_obj->hrm_index(),
160+
hr_obj->get_type_str());
159161
#endif
160162
if (!region_attr.is_remset_tracked()) {
161163
return;

0 commit comments

Comments
 (0)