8060463: ParNew: SurvivorAlignmentInBytes greater then YoungPLABSize cause assert(obj != NULL || plab->words_remaining() < word_sz) failed: Else should have been able to allocate
Reviewed-by: sangheki, tschatzl, mchernov
--- a/hotspot/src/share/vm/gc/cms/parNewGeneration.cpp Thu Mar 24 15:19:06 2016 +0000
+++ b/hotspot/src/share/vm/gc/cms/parNewGeneration.cpp Wed Mar 16 14:47:55 2016 -0700
@@ -233,11 +233,15 @@
if (word_sz * 100 < ParallelGCBufferWastePct * plab->word_sz()) {
// Is small enough; abandon this buffer and start a new one.
plab->retire();
- size_t buf_size = plab->word_sz();
+ // The minimum size has to be twice SurvivorAlignmentInBytes to
+ // allow for padding used in the alignment of 1 word. A padding
+ // of 1 is too small for a filler word so the padding size will
+ // be increased by SurvivorAlignmentInBytes.
+ size_t min_usable_size = 2 * static_cast<size_t>(SurvivorAlignmentInBytes >> LogHeapWordSize);
+ size_t buf_size = MAX2(plab->word_sz(), min_usable_size);
HeapWord* buf_space = sp->par_allocate(buf_size);
if (buf_space == NULL) {
- const size_t min_bytes =
- PLAB::min_size() << LogHeapWordSize;
+ const size_t min_bytes = MAX2(PLAB::min_size(), min_usable_size) << LogHeapWordSize;
size_t free_bytes = sp->free();
while(buf_space == NULL && free_bytes >= min_bytes) {
buf_size = free_bytes >> LogHeapWordSize;
@@ -253,7 +257,10 @@
// Note that we cannot compare buf_size < word_sz below
// because of AlignmentReserve (see PLAB::allocate()).
assert(obj != NULL || plab->words_remaining() < word_sz,
- "Else should have been able to allocate");
+ "Else should have been able to allocate requested object size "
+ SIZE_FORMAT ", PLAB size " SIZE_FORMAT ", SurvivorAlignmentInBytes "
+ SIZE_FORMAT ", words_remaining " SIZE_FORMAT,
+ word_sz, buf_size, SurvivorAlignmentInBytes, plab->words_remaining());
// It's conceivable that we may be able to use the
// buffer we just grabbed for subsequent small requests
// even if not for this one.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/gc/survivorAlignment/TestPromotionLABLargeSurvivorAlignment.java Wed Mar 16 14:47:55 2016 -0700
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * 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
+ * @bug 8060463
+ * @summary Verify that objects promoted from eden space to survivor space
+ * with large values for SurvivorAlignmentInBytes succeed.
+ * @requires vm.opt.ExplicitGCInvokesConcurrent != true
+ * @run main/othervm -Xmx128m
+ * -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=8 -XX:SurvivorRatio=1
+ * -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB
+ * TestPromotionLABLargeSurvivorAlignment
+ * @run main/othervm -Xmx128m
+ * -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=16 -XX:SurvivorRatio=1
+ * -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB
+ * TestPromotionLABLargeSurvivorAlignment
+ * @run main/othervm -Xmx128m
+ * -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=512 -XX:SurvivorRatio=1
+ * -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB
+ * TestPromotionLABLargeSurvivorAlignment
+ * @run main/othervm -Xmx128m
+ * -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=1k -XX:SurvivorRatio=1
+ * -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB
+ * TestPromotionLABLargeSurvivorAlignment
+ * @run main/othervm -Xmx128m
+ * -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=4k -XX:SurvivorRatio=1
+ * -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB
+ * TestPromotionLABLargeSurvivorAlignment
+ * @run main/othervm -Xmx128m
+ * -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=16k -XX:SurvivorRatio=1
+ * -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB
+ * TestPromotionLABLargeSurvivorAlignment
+ */
+public class TestPromotionLABLargeSurvivorAlignment {
+ public static void main(String args[]) {
+ Object garbage[] = new Object[1000000];
+ for (int i = 0; i < garbage.length; i++) {
+ garbage[i] = new byte[0];
+ }
+ for (int i = 0; i < 2; i++) {
+ System.gc();
+ }
+ }
+}
+