提交 b1575360 编写于 作者: I iveresov

7040485: Use transparent huge page on linux by default

Summary: Turn on UseLargePages by default but try only HugeTLBFS method if it is not explicitly specified on the command line.
Reviewed-by: ysr
上级 3f7b044b
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2011, 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
......@@ -47,7 +47,7 @@
// Defines Linux-specific default values. The flags are available on all
// platforms, but they may have different default values on other platforms.
//
define_pd_global(bool, UseLargePages, false);
define_pd_global(bool, UseLargePages, true);
define_pd_global(bool, UseLargePagesIndividualAllocation, false);
define_pd_global(bool, UseOSErrorReporting, false);
define_pd_global(bool, UseThreadPriorities, true) ;
......
......@@ -2914,16 +2914,21 @@ static void set_coredump_filter(void) {
static size_t _large_page_size = 0;
bool os::large_page_init() {
void os::large_page_init() {
if (!UseLargePages) {
UseHugeTLBFS = false;
UseSHM = false;
return false;
return;
}
if (FLAG_IS_DEFAULT(UseHugeTLBFS) && FLAG_IS_DEFAULT(UseSHM)) {
// Our user has not expressed a preference, so we'll try both.
UseHugeTLBFS = UseSHM = true;
// If UseLargePages is specified on the command line try both methods,
// if it's default, then try only HugeTLBFS.
if (FLAG_IS_DEFAULT(UseLargePages)) {
UseHugeTLBFS = true;
} else {
UseHugeTLBFS = UseSHM = true;
}
}
if (LargePageSizeInBytes) {
......@@ -2978,7 +2983,6 @@ bool os::large_page_init() {
_page_sizes[1] = default_page_size;
_page_sizes[2] = 0;
}
UseHugeTLBFS = UseHugeTLBFS &&
Linux::hugetlbfs_sanity_check(warn_on_failure, _large_page_size);
......@@ -2988,12 +2992,6 @@ bool os::large_page_init() {
UseLargePages = UseHugeTLBFS || UseSHM;
set_coredump_filter();
// Large page support is available on 2.6 or newer kernel, some vendors
// (e.g. Redhat) have backported it to their 2.4 based distributions.
// We optimistically assume the support is available. If later it turns out
// not true, VM will automatically switch to use regular page size.
return true;
}
#ifndef SHM_HUGETLB
......@@ -4118,7 +4116,7 @@ jint os::init_2(void)
#endif
}
FLAG_SET_DEFAULT(UseLargePages, os::large_page_init());
os::large_page_init();
// initialize suspend/resume support - must do this before signal_sets_init()
if (SR_initialize() != 0) {
......
......@@ -3336,11 +3336,11 @@ bool os::Solaris::mpss_sanity_check(bool warn, size_t * page_size) {
return true;
}
bool os::large_page_init() {
void os::large_page_init() {
if (!UseLargePages) {
UseISM = false;
UseMPSS = false;
return false;
return;
}
// print a warning if any large page related flag is specified on command line
......@@ -3361,7 +3361,6 @@ bool os::large_page_init() {
Solaris::mpss_sanity_check(warn_on_failure, &_large_page_size);
UseLargePages = UseISM || UseMPSS;
return UseLargePages;
}
bool os::Solaris::set_mpss_range(caddr_t start, size_t bytes, size_t align) {
......@@ -4992,7 +4991,7 @@ jint os::init_2(void) {
#endif
}
FLAG_SET_DEFAULT(UseLargePages, os::large_page_init());
os::large_page_init();
// Check minimum allowable stack size for thread creation and to initialize
// the java system classes, including StackOverflowError - depends on page
......
......@@ -2762,8 +2762,8 @@ static void cleanup_after_large_page_init() {
_hToken = NULL;
}
bool os::large_page_init() {
if (!UseLargePages) return false;
void os::large_page_init() {
if (!UseLargePages) return;
// print a warning if any large page related flag is specified on command line
bool warn_on_failure = !FLAG_IS_DEFAULT(UseLargePages) ||
......@@ -2808,7 +2808,7 @@ bool os::large_page_init() {
}
cleanup_after_large_page_init();
return success;
UseLargePages = success;
}
// On win32, one cannot release just a part of reserved memory, it's an
......@@ -3561,7 +3561,7 @@ jint os::init_2(void) {
#endif
}
FLAG_SET_DEFAULT(UseLargePages, os::large_page_init());
os::large_page_init();
// Setup Windows Exceptions
......
......@@ -274,7 +274,7 @@ class os: AllStatic {
static char* reserve_memory_special(size_t size, char* addr = NULL,
bool executable = false);
static bool release_memory_special(char* addr, size_t bytes);
static bool large_page_init();
static void large_page_init();
static size_t large_page_size();
static bool can_commit_large_page_memory();
static bool can_execute_large_page_memory();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册