changeset 56547:8b60ae8a2569

8231947: Shenandoah: cleanup ShenandoahHumongousMoves flag treatment Reviewed-by: rkennke
author shade
date Thu, 10 Oct 2019 21:54:54 +0200
parents a7a606f6311c
children 725244418646
files src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.hpp src/hotspot/share/gc/shenandoah/shenandoahMarkCompact.cpp src/hotspot/share/gc/shenandoah/shenandoah_globals.hpp test/hotspot/jtreg/gc/shenandoah/options/TestHumongousMoves.java
diffstat 5 files changed, 72 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp	Thu Oct 10 21:54:53 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp	Thu Oct 10 21:54:54 2019 +0200
@@ -963,7 +963,8 @@
     ShenandoahConcurrentEvacuateRegionObjectClosure cl(_sh);
     ShenandoahHeapRegion* r;
     while ((r =_cs->claim_next()) != NULL) {
-      assert(r->has_live(), "all-garbage regions are reclaimed early");
+      assert(r->has_live(), "Region " SIZE_FORMAT " should have been reclaimed early", r->region_number());
+      assert(r->is_conc_move_allowed(), "Region " SIZE_FORMAT " should be movable", r->region_number());
       _sh->marked_object_iterate(r, &cl);
 
       if (ShenandoahPacing) {
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.hpp	Thu Oct 10 21:54:53 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.hpp	Thu Oct 10 21:54:54 2019 +0200
@@ -198,7 +198,8 @@
 
   // Macro-properties:
   bool is_alloc_allowed()          const { return is_empty() || is_regular() || _state == _pinned; }
-  bool is_move_allowed()           const { return is_regular() || _state == _cset || (ShenandoahHumongousMoves && _state == _humongous_start); }
+  bool is_conc_move_allowed()      const { return is_regular() || _state == _cset; }
+  bool is_stw_move_allowed()       const { return is_conc_move_allowed() || (ShenandoahHumongousMoves && _state == _humongous_start); }
 
   RegionState state()              const { return _state; }
   int  state_ordinal()             const { return region_state_to_ordinal(_state); }
--- a/src/hotspot/share/gc/shenandoah/shenandoahMarkCompact.cpp	Thu Oct 10 21:54:53 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahMarkCompact.cpp	Thu Oct 10 21:54:54 2019 +0200
@@ -337,7 +337,7 @@
 
       // Can move the region, and this is not the humongous region. Humongous
       // moves are special cased here, because their moves are handled separately.
-      if (from_region->is_move_allowed() && !from_region->is_humongous()) break;
+      if (from_region->is_stw_move_allowed() && !from_region->is_humongous()) break;
 
       from_region = _heap_regions.next();
     }
@@ -345,7 +345,7 @@
     if (from_region != NULL) {
       assert(slice != NULL, "sanity");
       assert(!from_region->is_humongous(), "this path cannot handle humongous regions");
-      assert(from_region->is_empty() || from_region->is_move_allowed(), "only regions that can be moved in mark-compact");
+      assert(from_region->is_empty() || from_region->is_stw_move_allowed(), "only regions that can be moved in mark-compact");
       slice->add_region(from_region);
     }
 
@@ -419,7 +419,7 @@
       continue;
     }
 
-    if (r->is_humongous_start() && r->is_move_allowed()) {
+    if (r->is_humongous_start() && r->is_stw_move_allowed()) {
       // From-region candidate: movable humongous region
       oop old_obj = oop(r->bottom());
       size_t words_size = old_obj->size();
@@ -761,7 +761,7 @@
       size_t new_start = heap->heap_region_index_containing(old_obj->forwardee());
       size_t new_end   = new_start + num_regions - 1;
       assert(old_start != new_start, "must be real move");
-      assert (r->is_move_allowed(), "should be movable");
+      assert(r->is_stw_move_allowed(), "Region " SIZE_FORMAT " should be movable", r->region_number());
 
       Copy::aligned_conjoint_words(heap->get_region(old_start)->bottom(),
                                    heap->get_region(new_start)->bottom(),
--- a/src/hotspot/share/gc/shenandoah/shenandoah_globals.hpp	Thu Oct 10 21:54:53 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoah_globals.hpp	Thu Oct 10 21:54:54 2019 +0200
@@ -299,11 +299,11 @@
           "Should internally-caused GCs invoke concurrent cycles, or go to" \
           "stop-the-world (degenerated/full)?")                             \
                                                                             \
-  experimental(bool, ShenandoahHumongousMoves, true,                        \
+  diagnostic(bool, ShenandoahHumongousMoves, true,                          \
           "Allow moving humongous regions. This makes GC more resistant "   \
           "to external fragmentation that may otherwise fail other "        \
           "humongous allocations, at the expense of higher GC copying "     \
-          "costs.")                                                         \
+          "costs. Currently affects stop-the-world (full) cycle only.")     \
                                                                             \
   diagnostic(bool, ShenandoahOOMDuringEvacALot, false,                      \
           "Simulate OOM during evacuation frequently.")                     \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/gc/shenandoah/options/TestHumongousMoves.java	Thu Oct 10 21:54:54 2019 +0200
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2016, 2018, Red Hat, Inc. All rights reserved.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+/*
+ * @test TestHumongousMoves
+ * @summary Check Shenandoah reacts on setting humongous moves correctly
+ * @key gc
+ * @requires vm.gc.Shenandoah & !vm.graal.enabled
+ *
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
+ *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
+ *      -XX:-ShenandoahHumongousMoves
+ *      -XX:-ShenandoahDegeneratedGC -XX:+ShenandoahVerify
+ *      TestHumongousMoves
+ *
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
+ *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
+ *      -XX:+ShenandoahHumongousMoves
+ *      -XX:-ShenandoahDegeneratedGC -XX:+ShenandoahVerify
+ *      TestHumongousMoves
+ */
+
+import java.util.Random;
+
+public class TestHumongousMoves {
+
+    static final long TARGET_MB = Long.getLong("target", 10_000); // 10 Gb allocation
+
+    static volatile Object sink;
+
+    public static void main(String[] args) throws Exception {
+        final int min = 0;
+        final int max = 384 * 1024;
+        long count = TARGET_MB * 1024 * 1024 / (16 + 4 * (min + (max - min) / 2));
+
+        Random r = new Random();
+        for (long c = 0; c < count; c++) {
+            sink = new int[min + r.nextInt(max - min)];
+        }
+    }
+
+}