8312620: WSL Linux build crashes after JDK-8310233
Reviewed-by: dholmes, djelinski
This commit is contained in:
parent
8661b8e115
commit
25058cd23a
@ -36,7 +36,7 @@
|
||||
#include <dirent.h>
|
||||
|
||||
StaticHugePageSupport::StaticHugePageSupport() :
|
||||
_initialized(false), _pagesizes(), _default_hugepage_size(SIZE_MAX) {}
|
||||
_initialized(false), _pagesizes(), _default_hugepage_size(SIZE_MAX), _inconsistent(false) {}
|
||||
|
||||
os::PageSizes StaticHugePageSupport::pagesizes() const {
|
||||
assert(_initialized, "Not initialized");
|
||||
@ -141,15 +141,24 @@ void StaticHugePageSupport::print_on(outputStream* os) {
|
||||
} else {
|
||||
os->print_cr(" unknown.");
|
||||
}
|
||||
if (_inconsistent) {
|
||||
os->print_cr(" Support inconsistent. JVM will not use static hugepages.");
|
||||
}
|
||||
}
|
||||
|
||||
void StaticHugePageSupport::scan_os() {
|
||||
_default_hugepage_size = scan_default_hugepagesize();
|
||||
if (_default_hugepage_size > 0) {
|
||||
_pagesizes = scan_hugepages();
|
||||
assert(_pagesizes.contains(_default_hugepage_size),
|
||||
"Unexpected configuration: default pagesize (" SIZE_FORMAT ") "
|
||||
"has no associated directory in /sys/kernel/mm/hugepages..", _default_hugepage_size);
|
||||
// See https://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt: /proc/meminfo should match
|
||||
// /sys/kernel/mm/hugepages/hugepages-xxxx. However, we may run on a broken kernel (e.g. on WSL)
|
||||
// that only exposes /proc/meminfo but not /sys/kernel/mm/hugepages. In that case, we are not
|
||||
// sure about the state of hugepage support by the kernel, so we won't use static hugepages.
|
||||
if (!_pagesizes.contains(_default_hugepage_size)) {
|
||||
log_info(pagesize)("Unexpected configuration: default pagesize (" SIZE_FORMAT ") "
|
||||
"has no associated directory in /sys/kernel/mm/hugepages..", _default_hugepage_size);
|
||||
_inconsistent = true;
|
||||
}
|
||||
}
|
||||
_initialized = true;
|
||||
LogTarget(Info, pagesize) lt;
|
||||
|
@ -52,6 +52,9 @@ class StaticHugePageSupport {
|
||||
// - is the size one gets when using mmap(MAP_HUGETLB) when omitting size specifiers like MAP_HUGE_SHIFT)
|
||||
size_t _default_hugepage_size;
|
||||
|
||||
// If true, the kernel support for hugepages is inconsistent
|
||||
bool _inconsistent;
|
||||
|
||||
public:
|
||||
StaticHugePageSupport();
|
||||
|
||||
@ -60,6 +63,8 @@ public:
|
||||
os::PageSizes pagesizes() const;
|
||||
size_t default_hugepage_size() const;
|
||||
void print_on(outputStream* os);
|
||||
|
||||
bool inconsistent() const { return _inconsistent; }
|
||||
};
|
||||
|
||||
enum class THPMode { always, never, madvise };
|
||||
@ -98,7 +103,7 @@ public:
|
||||
static const THPSupport& thp_info() { return _thp_support; }
|
||||
|
||||
static size_t default_static_hugepage_size() { return _static_hugepage_support.default_hugepage_size(); }
|
||||
static bool supports_static_hugepages() { return default_static_hugepage_size() > 0; }
|
||||
static bool supports_static_hugepages() { return default_static_hugepage_size() > 0 && !_static_hugepage_support.inconsistent(); }
|
||||
static THPMode thp_mode() { return _thp_support.mode(); }
|
||||
static bool supports_thp() { return thp_mode() == THPMode::madvise || thp_mode() == THPMode::always; }
|
||||
static size_t thp_pagesize() { return _thp_support.pagesize(); }
|
||||
|
@ -29,14 +29,14 @@
|
||||
* @requires os.family == "linux"
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* java.management
|
||||
* @run driver HugePageDetection
|
||||
* @run driver TestHugePageDetection
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
|
||||
public class HugePageDetection {
|
||||
public class TestHugePageDetection {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
Loading…
Reference in New Issue
Block a user