Merge
This commit is contained in:
commit
a235f9f6ef
@ -30,11 +30,21 @@
|
||||
#include "runtime/atomic.hpp"
|
||||
#include "runtime/thread.inline.hpp"
|
||||
|
||||
MutableNUMASpace::MutableNUMASpace(size_t alignment) : MutableSpace(alignment) {
|
||||
MutableNUMASpace::MutableNUMASpace(size_t alignment) : MutableSpace(alignment), _must_use_large_pages(false) {
|
||||
_lgrp_spaces = new (ResourceObj::C_HEAP, mtGC) GrowableArray<LGRPSpace*>(0, true);
|
||||
_page_size = os::vm_page_size();
|
||||
_adaptation_cycles = 0;
|
||||
_samples_count = 0;
|
||||
|
||||
#ifdef LINUX
|
||||
// Changing the page size can lead to freeing of memory. When using large pages
|
||||
// and the memory has been both reserved and committed, Linux does not support
|
||||
// freeing parts of it.
|
||||
if (UseLargePages && !os::can_commit_large_page_memory()) {
|
||||
_must_use_large_pages = true;
|
||||
}
|
||||
#endif // LINUX
|
||||
|
||||
update_layout(true);
|
||||
}
|
||||
|
||||
@ -578,6 +588,10 @@ void MutableNUMASpace::initialize(MemRegion mr,
|
||||
// Try small pages if the chunk size is too small
|
||||
if (base_space_size_pages / lgrp_spaces()->length() == 0
|
||||
&& page_size() > (size_t)os::vm_page_size()) {
|
||||
// Changing the page size below can lead to freeing of memory. So we fail initialization.
|
||||
if (_must_use_large_pages) {
|
||||
vm_exit_during_initialization("Failed initializing NUMA with large pages. Too small heap size");
|
||||
}
|
||||
set_page_size(os::vm_page_size());
|
||||
rounded_bottom = (HeapWord*)round_to((intptr_t) bottom(), page_size());
|
||||
rounded_end = (HeapWord*)round_down((intptr_t) end(), page_size());
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 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
|
||||
@ -145,6 +145,8 @@ class MutableNUMASpace : public MutableSpace {
|
||||
size_t _page_size;
|
||||
unsigned _adaptation_cycles, _samples_count;
|
||||
|
||||
bool _must_use_large_pages;
|
||||
|
||||
void set_page_size(size_t psz) { _page_size = psz; }
|
||||
size_t page_size() const { return _page_size; }
|
||||
|
||||
|
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* 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 TestSmallInitialHeapWithLargePageAndNUMA
|
||||
* @bug 8023905
|
||||
* @requires os.family == "linux"
|
||||
* @requires vm.gc.Parallel
|
||||
* @summary Check large pages and NUMA are working together via the output message.
|
||||
* @library /testlibrary /test/lib /test/lib/share/classes
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* @modules java.management/sun.management
|
||||
* @build TestSmallInitialHeapWithLargePageAndNUMA
|
||||
* @run main ClassFileInstaller sun.hotspot.WhiteBox
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UseHugeTLBFS -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI TestSmallInitialHeapWithLargePageAndNUMA
|
||||
*/
|
||||
|
||||
import jdk.test.lib.ProcessTools;
|
||||
import jdk.test.lib.OutputAnalyzer;
|
||||
import sun.hotspot.WhiteBox;
|
||||
|
||||
public class TestSmallInitialHeapWithLargePageAndNUMA {
|
||||
|
||||
private static final String MSG_EXIT_TOO_SMALL_HEAP = "Failed initializing NUMA with large pages. Too small heap size";
|
||||
private static final String MSG_GC_TRIGGERED_BEFORE_INIT = "GC triggered before VM initialization completed.";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
WhiteBox wb = WhiteBox.getWhiteBox();
|
||||
long heapAlignment = wb.getHeapAlignment();
|
||||
|
||||
// When using large pages, Linux does not support freeing parts of reserved and committed memory.
|
||||
// And current Linux implementation uses page size as a condition to actually freeing memory.
|
||||
// If we allocate pages less than NUMA node, NUMA will try to use default page size and
|
||||
// this will free the memory which Linux does not support.
|
||||
// Assume the minimum NUMA node as 2.
|
||||
long initHeap = heapAlignment;
|
||||
long maxHeap = heapAlignment * 2;
|
||||
|
||||
String[] vmArgs = {"-XX:+UseParallelGC",
|
||||
"-Xms" + String.valueOf(initHeap),
|
||||
"-Xmx" + String.valueOf(maxHeap),
|
||||
"-XX:+UseNUMA",
|
||||
"-XX:+UseHugeTLBFS",
|
||||
"-XX:+PrintFlagsFinal",
|
||||
"-version"};
|
||||
|
||||
ProcessBuilder pb_enabled = ProcessTools.createJavaProcessBuilder(vmArgs);
|
||||
OutputAnalyzer analyzer = new OutputAnalyzer(pb_enabled.start());
|
||||
|
||||
if (largePageOrNumaEnabled(analyzer)) {
|
||||
// We reach here, if both NUMA and HugeTLB are supported.
|
||||
// However final flags will not be printed as NUMA initialization will be failed.
|
||||
checkAnalyzerValues(analyzer, 1, MSG_EXIT_TOO_SMALL_HEAP);
|
||||
}
|
||||
}
|
||||
|
||||
// If both NUMA and large pages are enabled, VM will exit during NUMA initialization
|
||||
// under the small heap configuration. So final flags will not be printed.
|
||||
private static boolean largePageOrNumaEnabled(OutputAnalyzer analyzer) {
|
||||
String output = analyzer.getOutput();
|
||||
|
||||
return !output.contains("[Global flags]");
|
||||
}
|
||||
|
||||
// We need to test with small heap but fastdebug binary fails to initialize because of the small heap.
|
||||
// So skip that case.
|
||||
private static void checkAnalyzerValues(OutputAnalyzer analyzer, int expectedExitValue, String expectedMessage) {
|
||||
String output = analyzer.getOutput();
|
||||
|
||||
// If the VM exits because of the small heap, skip checking the exit value.
|
||||
if (!output.contains(MSG_GC_TRIGGERED_BEFORE_INIT)) {
|
||||
analyzer.shouldHaveExitValue(expectedExitValue);
|
||||
}
|
||||
if (expectedMessage != null) {
|
||||
analyzer.shouldContain(expectedMessage);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user