changeset 55877:f48d3bec75ba

8225418: G1: region attribute remembered set state disagrees with actual remembered set state Summary: Keep remembered set update information when updating region attributes when abandoning the remaining collection set after mixed gc. Reviewed-by: kbarrett, mdoerr
author tschatzl
date Thu, 13 Jun 2019 11:54:55 +0200
parents 0f38ab93a53c
children bd613b97c7c8
files src/hotspot/share/gc/g1/g1CollectedHeap.cpp src/hotspot/share/gc/g1/g1CollectedHeap.hpp src/hotspot/share/gc/g1/g1CollectionSet.cpp
diffstat 3 files changed, 30 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp	Thu Jun 13 11:12:23 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp	Thu Jun 13 11:54:55 2019 +0200
@@ -2780,6 +2780,23 @@
   cl.flush_rem_set_entries();
 }
 
+#ifndef PRODUCT
+void G1CollectedHeap::verify_region_attr_remset_update() {
+  class VerifyRegionAttrRemSet : public HeapRegionClosure {
+  public:
+    virtual bool do_heap_region(HeapRegion* r) {
+      G1CollectedHeap* g1h = G1CollectedHeap::heap();
+      bool const needs_remset_update = g1h->region_attr(r->bottom()).needs_remset_update();
+      assert(r->rem_set()->is_tracked() == needs_remset_update,
+             "Region %u remset tracking status (%s) different to region attribute (%s)",
+             r->hrm_index(), BOOL_TO_STR(r->rem_set()->is_tracked()), BOOL_TO_STR(needs_remset_update));
+      return false;
+    }
+  } cl;
+  heap_region_iterate(&cl);
+}
+#endif
+
 class VerifyRegionRemSetClosure : public HeapRegionClosure {
   public:
     bool do_heap_region(HeapRegion* hr) {
@@ -3059,6 +3076,7 @@
 
         // Actually do the work...
         evacuate_initial_collection_set(&per_thread_states);
+
         if (_collection_set.optional_region_length() != 0) {
           evacuate_optional_collection_set(&per_thread_states);
         }
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp	Thu Jun 13 11:12:23 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp	Thu Jun 13 11:54:55 2019 +0200
@@ -593,6 +593,10 @@
     _region_attr.clear();
   }
 
+  // Verify that the G1RegionAttr remset tracking corresponds to actual remset tracking
+  // for all regions.
+  void verify_region_attr_remset_update() PRODUCT_RETURN;
+
   bool is_user_requested_concurrent_full_gc(GCCause::Cause cause);
 
   // This is called at the start of either a concurrent cycle or a Full
--- a/src/hotspot/share/gc/g1/g1CollectionSet.cpp	Thu Jun 13 11:12:23 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1CollectionSet.cpp	Thu Jun 13 11:54:55 2019 +0200
@@ -519,6 +519,9 @@
   _num_optional_regions -= num_selected_regions;
 
   stop_incremental_building();
+
+  _g1h->verify_region_attr_remset_update();
+
   return num_selected_regions > 0;
 }
 
@@ -526,10 +529,15 @@
   for (uint i = 0; i < _num_optional_regions; i++) {
     HeapRegion* r = candidates()->at(candidates()->cur_idx() + i);
     pss->record_unused_optional_region(r);
+    // Clear collection set marker and make sure that the remembered set information
+    // is correct as we still need it later.
     _g1h->clear_region_attr(r);
+    _g1h->register_region_with_region_attr(r);
     r->clear_index_in_opt_cset();
   }
   free_optional_regions();
+
+  _g1h->verify_region_attr_remset_update();
 }
 
 #ifdef ASSERT