Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8291725: Leftover marks when VM shutdown aborts bitmap clearing make …
…mixed gc fail

Reviewed-by: iwalulya, ayang
  • Loading branch information
Thomas Schatzl committed Sep 6, 2022
1 parent 6a1e98c commit b2067e6
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/hotspot/share/gc/g1/g1RemSet.cpp
Expand Up @@ -1271,6 +1271,22 @@ class G1MergeHeapRootsTask : public WorkerTask {
"Bitmap should have no mark for region %u", hr->hrm_index());
}

bool should_clear_region(HeapRegion* hr) const {
// The bitmap for young regions must obviously be clear as we never mark through them;
// old regions are only in the collection set after the concurrent cycle completed,
// so their bitmaps must also be clear except when the pause occurs during the
// Concurrent Cleanup for Next Mark phase. Only at that point the region's bitmap may
// contain marks while being in the collection set at the same time.
//
// There is one exception: shutdown might have aborted the Concurrent Cleanup for Next
// Mark phase midway, which might have also left stale marks in old generation regions.
// There might actually have been scheduled multiple collections, but at that point we do
// not care that much about performance and just do the work multiple times if needed.
return (_g1h->collector_state()->clearing_bitmap() ||
_g1h->concurrent_mark_is_terminating()) &&
hr->is_old();
}

public:
G1ClearBitmapClosure(G1CollectedHeap* g1h) : _g1h(g1h) { }

Expand All @@ -1279,13 +1295,7 @@ class G1MergeHeapRootsTask : public WorkerTask {

// Evacuation failure uses the bitmap to record evacuation failed objects,
// so the bitmap for the regions in the collection set must be cleared if not already.
//
// A clear bitmap is obvious for young regions as we never mark through them;
// old regions are only in the collection set after the concurrent cycle completed,
// so their bitmaps must also be clear except when the pause occurs during the
// concurrent bitmap clear. At that point the region's bitmap may contain marks
// while being in the collection set at the same time.
if (_g1h->collector_state()->clearing_bitmap() && hr->is_old()) {
if (should_clear_region(hr)) {
_g1h->clear_bitmap_for_region(hr);
} else {
assert_bitmap_clear(hr, _g1h->concurrent_mark()->mark_bitmap());
Expand Down

1 comment on commit b2067e6

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.