8200385: Eagerly reclaimed humongous objects leave mark in prev bitmap
authortschatzl
Tue, 10 Apr 2018 09:12:23 +0200
changeset 49727 2bbd5117d91a
parent 49726 4ae63fcabe2e
child 49728 a1617a75c231
8200385: Eagerly reclaimed humongous objects leave mark in prev bitmap Summary: Also clear marks on prev bitmap on eager reclaim Reviewed-by: sangheki, sjohanss
src/hotspot/share/gc/g1/g1CollectedHeap.cpp
src/hotspot/share/gc/g1/g1ConcurrentMark.cpp
src/hotspot/share/gc/g1/g1ConcurrentMark.hpp
src/hotspot/share/gc/g1/g1ConcurrentMark.inline.hpp
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp	Mon Apr 09 10:09:38 2018 +0200
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp	Tue Apr 10 09:12:23 2018 +0200
@@ -4691,7 +4691,13 @@
                              obj->is_typeArray()
                             );
 
-    g1h->concurrent_mark()->humongous_object_eagerly_reclaimed(r);
+    G1ConcurrentMark* const cm = g1h->concurrent_mark();
+    cm->humongous_object_eagerly_reclaimed(r);
+    assert(!cm->is_marked_in_prev_bitmap(obj) && !cm->is_marked_in_next_bitmap(obj),
+           "Eagerly reclaimed humongous region %u should not be marked at all but is in prev %s next %s",
+           region_idx,
+           BOOL_TO_STR(cm->is_marked_in_prev_bitmap(obj)),
+           BOOL_TO_STR(cm->is_marked_in_next_bitmap(obj)));
     _humongous_objects_reclaimed++;
     do {
       HeapRegion* next = g1h->next_region_in_humongous(r);
--- a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp	Mon Apr 09 10:09:38 2018 +0200
+++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp	Tue Apr 10 09:12:23 2018 +0200
@@ -530,13 +530,18 @@
   }
 }
 
+static void clear_mark_if_set(G1CMBitMap* bitmap, HeapWord* addr) {
+  if (bitmap->is_marked(addr)) {
+    bitmap->clear(addr);
+  }
+}
+
 void G1ConcurrentMark::humongous_object_eagerly_reclaimed(HeapRegion* r) {
   assert_at_safepoint_on_vm_thread();
 
-  // Need to clear mark bit of the humongous object.
-  if (_next_mark_bitmap->is_marked(r->bottom())) {
-    _next_mark_bitmap->clear(r->bottom());
-  }
+  // Need to clear all mark bits of the humongous object.
+  clear_mark_if_set(_prev_mark_bitmap, r->bottom());
+  clear_mark_if_set(_next_mark_bitmap, r->bottom());
 
   if (!_g1h->collector_state()->mark_or_rebuild_in_progress()) {
     return;
--- a/src/hotspot/share/gc/g1/g1ConcurrentMark.hpp	Mon Apr 09 10:09:38 2018 +0200
+++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.hpp	Tue Apr 10 09:12:23 2018 +0200
@@ -589,6 +589,8 @@
   inline bool mark_in_next_bitmap(uint worker_id, HeapRegion* const hr, oop const obj, size_t const obj_size = 0);
   inline bool mark_in_next_bitmap(uint worker_id, oop const obj, size_t const obj_size = 0);
 
+  inline bool is_marked_in_next_bitmap(oop p) const;
+
   // Returns true if initialization was successfully completed.
   bool completed_initialization() const {
     return _completed_initialization;
--- a/src/hotspot/share/gc/g1/g1ConcurrentMark.inline.hpp	Mon Apr 09 10:09:38 2018 +0200
+++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.inline.hpp	Tue Apr 10 09:12:23 2018 +0200
@@ -255,6 +255,11 @@
   return _prev_mark_bitmap->is_marked((HeapWord*)p);
 }
 
+bool G1ConcurrentMark::is_marked_in_next_bitmap(oop p) const {
+  assert(p != NULL && oopDesc::is_oop(p), "expected an oop");
+  return _next_mark_bitmap->is_marked((HeapWord*)p);
+}
+
 inline bool G1ConcurrentMark::do_yield_check() {
   if (SuspendibleThreadSet::should_yield()) {
     SuspendibleThreadSet::yield();