8170655: [posix] Fix minimum stack size computations
Reviewed-by: dcubed, coleenp
This commit is contained in:
parent
c5a2c4af0e
commit
12aa0a8788
hotspot/src
cpu
os/posix/vm
os_cpu
aix_ppc/vm
bsd_x86/vm
linux_aarch64/vm
linux_ppc/vm
linux_s390/vm
linux_sparc/vm
linux_x86/vm
solaris_sparc/vm
solaris_x86/vm
share/vm/runtime
@ -42,6 +42,9 @@ define_pd_global(bool, UncommonNullCast, true); // Uncommon-trap NULLs pas
|
||||
|
||||
#define DEFAULT_STACK_YELLOW_PAGES (2)
|
||||
#define DEFAULT_STACK_RED_PAGES (1)
|
||||
// Java_java_net_SocketOutputStream_socketWrite0() uses a 64k buffer on the
|
||||
// stack if compiled for unix and LP64. To pass stack overflow tests we need
|
||||
// 20 shadow pages.
|
||||
#define DEFAULT_STACK_SHADOW_PAGES (20 DEBUG_ONLY(+2))
|
||||
#define DEFAULT_STACK_RESERVED_PAGES (1)
|
||||
|
||||
|
@ -63,9 +63,10 @@ define_pd_global(intx, InlineSmallCode, 1000);
|
||||
#define MIN_STACK_RED_PAGES DEFAULT_STACK_RED_PAGES
|
||||
#define MIN_STACK_RESERVED_PAGES (0)
|
||||
|
||||
#ifdef AMD64
|
||||
// Very large C++ stack frames using solaris-amd64 optimized builds
|
||||
// due to lack of optimization caused by C++ compiler bugs
|
||||
#ifdef _LP64
|
||||
// Java_java_net_SocketOutputStream_socketWrite0() uses a 64k buffer on the
|
||||
// stack if compiled for unix and LP64. To pass stack overflow tests we need
|
||||
// 20 shadow pages.
|
||||
#define DEFAULT_STACK_SHADOW_PAGES (NOT_WIN64(20) WIN64_ONLY(7) DEBUG_ONLY(+2))
|
||||
// For those clients that do not use write socket, we allow
|
||||
// the min range value to be below that of the default
|
||||
@ -73,7 +74,7 @@ define_pd_global(intx, InlineSmallCode, 1000);
|
||||
#else
|
||||
#define DEFAULT_STACK_SHADOW_PAGES (4 DEBUG_ONLY(+5))
|
||||
#define MIN_STACK_SHADOW_PAGES DEFAULT_STACK_SHADOW_PAGES
|
||||
#endif // AMD64
|
||||
#endif // _LP64
|
||||
|
||||
define_pd_global(intx, StackYellowPages, DEFAULT_STACK_YELLOW_PAGES);
|
||||
define_pd_global(intx, StackRedPages, DEFAULT_STACK_RED_PAGES);
|
||||
|
@ -1107,14 +1107,18 @@ char* os::Posix::describe_pthread_attr(char* buf, size_t buflen, const pthread_a
|
||||
|
||||
// Check minimum allowable stack sizes for thread creation and to initialize
|
||||
// the java system classes, including StackOverflowError - depends on page
|
||||
// size. Add two 4K pages for compiler2 recursion in main thread.
|
||||
// Add in 4*BytesPerWord 4K pages to account for VM stack during
|
||||
// class initialization depending on 32 or 64 bit VM.
|
||||
// size.
|
||||
// The space needed for frames during startup is platform dependent. It
|
||||
// depends on word size, platform calling conventions, C frame layout and
|
||||
// interpreter/C1/C2 design decisions. Therefore this is given in a
|
||||
// platform (os/cpu) dependent constant.
|
||||
// To this, space for guard mechanisms is added, which depends on the
|
||||
// page size which again depends on the concrete system the VM is running
|
||||
// on. Space for libc guard pages is not included in this size.
|
||||
jint os::Posix::set_minimum_stack_sizes() {
|
||||
_java_thread_min_stack_allowed = MAX2(_java_thread_min_stack_allowed,
|
||||
JavaThread::stack_guard_zone_size() +
|
||||
JavaThread::stack_shadow_zone_size() +
|
||||
(4 * BytesPerWord COMPILER2_PRESENT(+ 2)) * 4 * K);
|
||||
_java_thread_min_stack_allowed = _java_thread_min_stack_allowed +
|
||||
JavaThread::stack_guard_zone_size() +
|
||||
JavaThread::stack_shadow_zone_size();
|
||||
|
||||
_java_thread_min_stack_allowed = align_size_up(_java_thread_min_stack_allowed, vm_page_size());
|
||||
|
||||
@ -1130,28 +1134,14 @@ jint os::Posix::set_minimum_stack_sizes() {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
#ifdef SOLARIS
|
||||
// For 64kbps there will be a 64kb page size, which makes
|
||||
// the usable default stack size quite a bit less. Increase the
|
||||
// stack for 64kb (or any > than 8kb) pages, this increases
|
||||
// virtual memory fragmentation (since we're not creating the
|
||||
// stack on a power of 2 boundary. The real fix for this
|
||||
// should be to fix the guard page mechanism.
|
||||
|
||||
if (vm_page_size() > 8*K) {
|
||||
stack_size_in_bytes = (stack_size_in_bytes != 0)
|
||||
? stack_size_in_bytes +
|
||||
JavaThread::stack_red_zone_size() +
|
||||
JavaThread::stack_yellow_zone_size()
|
||||
: 0;
|
||||
ThreadStackSize = stack_size_in_bytes/K;
|
||||
}
|
||||
#endif // SOLARIS
|
||||
|
||||
// Make the stack size a multiple of the page size so that
|
||||
// the yellow/red zones can be guarded.
|
||||
JavaThread::set_stack_size_at_create(round_to(stack_size_in_bytes,
|
||||
vm_page_size()));
|
||||
JavaThread::set_stack_size_at_create(round_to(stack_size_in_bytes, vm_page_size()));
|
||||
|
||||
// Reminder: a compiler thread is a Java thread.
|
||||
_compiler_thread_min_stack_allowed = _compiler_thread_min_stack_allowed +
|
||||
JavaThread::stack_guard_zone_size() +
|
||||
JavaThread::stack_shadow_zone_size();
|
||||
|
||||
_compiler_thread_min_stack_allowed = align_size_up(_compiler_thread_min_stack_allowed, vm_page_size());
|
||||
|
||||
|
@ -43,7 +43,11 @@ protected:
|
||||
static void print_load_average(outputStream* st);
|
||||
|
||||
// Minimum stack size a thread can be created with (allowing
|
||||
// the VM to completely create the thread and enter user code)
|
||||
// the VM to completely create the thread and enter user code).
|
||||
// The initial values exclude any guard pages (by HotSpot or libc).
|
||||
// set_minimum_stack_sizes() will add the size required for
|
||||
// HotSpot guard pages depending on page size and flag settings.
|
||||
// Libc guard pages are never considered by these values.
|
||||
static size_t _compiler_thread_min_stack_allowed;
|
||||
static size_t _java_thread_min_stack_allowed;
|
||||
static size_t _vm_internal_thread_min_stack_allowed;
|
||||
|
@ -535,11 +535,11 @@ void os::Aix::init_thread_fpu_state(void) {
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// thread stack
|
||||
|
||||
// These sizes exclude libc stack guard pages, but include
|
||||
// the HotSpot guard pages.
|
||||
size_t os::Posix::_compiler_thread_min_stack_allowed = 512 * K;
|
||||
size_t os::Posix::_java_thread_min_stack_allowed = 512 * K;
|
||||
size_t os::Posix::_vm_internal_thread_min_stack_allowed = 128 * K;
|
||||
// Minimum usable stack sizes required to get to user code. Space for
|
||||
// HotSpot guard pages is added later.
|
||||
size_t os::Posix::_compiler_thread_min_stack_allowed = 192 * K;
|
||||
size_t os::Posix::_java_thread_min_stack_allowed = 64 * K;
|
||||
size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K;
|
||||
|
||||
// Return default stack size for thr_type.
|
||||
size_t os::Posix::default_stack_size(os::ThreadType thr_type) {
|
||||
|
@ -839,19 +839,20 @@ bool os::is_allocatable(size_t bytes) {
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// thread stack
|
||||
|
||||
#ifdef AMD64
|
||||
size_t os::Posix::_compiler_thread_min_stack_allowed = 64 * K;
|
||||
size_t os::Posix::_java_thread_min_stack_allowed = 64 * K;
|
||||
// Minimum usable stack sizes required to get to user code. Space for
|
||||
// HotSpot guard pages is added later.
|
||||
size_t os::Posix::_compiler_thread_min_stack_allowed = 48 * K;
|
||||
size_t os::Posix::_java_thread_min_stack_allowed = 48 * K;
|
||||
#ifdef _LP64
|
||||
size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K;
|
||||
#else
|
||||
size_t os::Posix::_compiler_thread_min_stack_allowed = (48 DEBUG_ONLY(+ 4)) * K;
|
||||
size_t os::Posix::_java_thread_min_stack_allowed = (48 DEBUG_ONLY(+ 4)) * K;
|
||||
size_t os::Posix::_vm_internal_thread_min_stack_allowed = (48 DEBUG_ONLY(+ 4)) * K;
|
||||
#endif // _LP64
|
||||
|
||||
#ifndef AMD64
|
||||
#ifdef __GNUC__
|
||||
#define GET_GS() ({int gs; __asm__ volatile("movw %%gs, %w0":"=q"(gs)); gs&0xffff;})
|
||||
#endif
|
||||
|
||||
#endif // AMD64
|
||||
|
||||
// return default stack size for thr_type
|
||||
|
@ -473,8 +473,10 @@ bool os::is_allocatable(size_t bytes) {
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// thread stack
|
||||
|
||||
size_t os::Posix::_compiler_thread_min_stack_allowed = 64 * K;
|
||||
size_t os::Posix::_java_thread_min_stack_allowed = 64 * K;
|
||||
// Minimum usable stack sizes required to get to user code. Space for
|
||||
// HotSpot guard pages is added later.
|
||||
size_t os::Posix::_compiler_thread_min_stack_allowed = 32 * K;
|
||||
size_t os::Posix::_java_thread_min_stack_allowed = 32 * K;
|
||||
size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K;
|
||||
|
||||
// return default stack size for thr_type
|
||||
|
@ -535,15 +535,15 @@ void os::Linux::set_fpu_control_word(int fpu_control) {
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// thread stack
|
||||
|
||||
// These sizes exclude libc stack guard pages, but include
|
||||
// the HotSpot guard pages.
|
||||
size_t os::Posix::_compiler_thread_min_stack_allowed = 384 * K;
|
||||
size_t os::Posix::_java_thread_min_stack_allowed = 384 * K;
|
||||
size_t os::Posix::_vm_internal_thread_min_stack_allowed = 128 * K;
|
||||
// Minimum usable stack sizes required to get to user code. Space for
|
||||
// HotSpot guard pages is added later.
|
||||
size_t os::Posix::_compiler_thread_min_stack_allowed = 64 * K;
|
||||
size_t os::Posix::_java_thread_min_stack_allowed = 64 * K;
|
||||
size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K;
|
||||
|
||||
// return default stack size for thr_type
|
||||
// Return default stack size for thr_type.
|
||||
size_t os::Posix::default_stack_size(os::ThreadType thr_type) {
|
||||
// default stack size (compiler thread needs larger stack)
|
||||
// Default stack size (compiler thread needs larger stack).
|
||||
size_t s = (thr_type == os::compiler_thread ? 4 * M : 1024 * K);
|
||||
return s;
|
||||
}
|
||||
|
@ -473,11 +473,11 @@ void os::Linux::set_fpu_control_word(int fpu_control) {
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// thread stack
|
||||
|
||||
// These sizes exclude libc stack guard pages, but include
|
||||
// the HotSpot guard pages.
|
||||
size_t os::Posix::_compiler_thread_min_stack_allowed = 128 * K;
|
||||
size_t os::Posix::_java_thread_min_stack_allowed = 236 * K;
|
||||
size_t os::Posix::_vm_internal_thread_min_stack_allowed = 128 * K;
|
||||
// Minimum usable stack sizes required to get to user code. Space for
|
||||
// HotSpot guard pages is added later.
|
||||
size_t os::Posix::_compiler_thread_min_stack_allowed = (52 DEBUG_ONLY(+ 32)) * K;
|
||||
size_t os::Posix::_java_thread_min_stack_allowed = (32 DEBUG_ONLY(+ 8)) * K;
|
||||
size_t os::Posix::_vm_internal_thread_min_stack_allowed = 32 * K;
|
||||
|
||||
// Return default stack size for thr_type.
|
||||
size_t os::Posix::default_stack_size(os::ThreadType thr_type) {
|
||||
|
@ -681,8 +681,10 @@ bool os::is_allocatable(size_t bytes) {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// thread stack
|
||||
|
||||
size_t os::Posix::_compiler_thread_min_stack_allowed = 128 * K;
|
||||
size_t os::Posix::_java_thread_min_stack_allowed = 128 * K;
|
||||
// Minimum usable stack sizes required to get to user code. Space for
|
||||
// HotSpot guard pages is added later.
|
||||
size_t os::Posix::_compiler_thread_min_stack_allowed = 64 * K;
|
||||
size_t os::Posix::_java_thread_min_stack_allowed = 64 * K;
|
||||
size_t os::Posix::_vm_internal_thread_min_stack_allowed = 128 * K;
|
||||
|
||||
// return default stack size for thr_type
|
||||
|
@ -677,15 +677,15 @@ bool os::is_allocatable(size_t bytes) {
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// thread stack
|
||||
|
||||
#ifdef AMD64
|
||||
size_t os::Posix::_compiler_thread_min_stack_allowed = 64 * K;
|
||||
size_t os::Posix::_java_thread_min_stack_allowed = 64 * K;
|
||||
// Minimum usable stack sizes required to get to user code. Space for
|
||||
// HotSpot guard pages is added later.
|
||||
size_t os::Posix::_compiler_thread_min_stack_allowed = 48 * K;
|
||||
size_t os::Posix::_java_thread_min_stack_allowed = 40 * K;
|
||||
#ifdef _LP64
|
||||
size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K;
|
||||
#else
|
||||
size_t os::Posix::_compiler_thread_min_stack_allowed = (48 DEBUG_ONLY(+ 4)) * K;
|
||||
size_t os::Posix::_java_thread_min_stack_allowed = (48 DEBUG_ONLY(+ 4)) * K;
|
||||
size_t os::Posix::_vm_internal_thread_min_stack_allowed = (48 DEBUG_ONLY(+ 4)) * K;
|
||||
#endif // AMD64
|
||||
#endif // _LP64
|
||||
|
||||
// return default stack size for thr_type
|
||||
size_t os::Posix::default_stack_size(os::ThreadType thr_type) {
|
||||
|
@ -81,15 +81,13 @@
|
||||
|
||||
#define MAX_PATH (2 * K)
|
||||
|
||||
// Minimum stack size for the VM. It's easier to document a constant
|
||||
// but it's different for x86 and sparc because the page sizes are different.
|
||||
// Minimum usable stack sizes required to get to user code. Space for
|
||||
// HotSpot guard pages is added later.
|
||||
size_t os::Posix::_compiler_thread_min_stack_allowed = 104 * K;
|
||||
size_t os::Posix::_java_thread_min_stack_allowed = 86 * K;
|
||||
#ifdef _LP64
|
||||
size_t os::Posix::_compiler_thread_min_stack_allowed = 128 * K;
|
||||
size_t os::Posix::_java_thread_min_stack_allowed = 128 * K;
|
||||
size_t os::Posix::_vm_internal_thread_min_stack_allowed = 128 * K;
|
||||
#else
|
||||
size_t os::Posix::_compiler_thread_min_stack_allowed = 96 * K;
|
||||
size_t os::Posix::_java_thread_min_stack_allowed = 96 * K;
|
||||
size_t os::Posix::_vm_internal_thread_min_stack_allowed = 96 * K;
|
||||
#endif
|
||||
|
||||
|
@ -86,19 +86,23 @@
|
||||
|
||||
#define MAX_PATH (2 * K)
|
||||
|
||||
// Minimum stack sizes for the VM. It's easier to document a constant value
|
||||
// but it's different for x86 and sparc because the page sizes are different.
|
||||
#ifdef AMD64
|
||||
size_t os::Posix::_compiler_thread_min_stack_allowed = 394 * K;
|
||||
size_t os::Posix::_java_thread_min_stack_allowed = 224 * K;
|
||||
// Minimum usable stack sizes required to get to user code. Space for
|
||||
// HotSpot guard pages is added later.
|
||||
#ifdef _LP64
|
||||
size_t os::Posix::_compiler_thread_min_stack_allowed = 202 * K;
|
||||
size_t os::Posix::_java_thread_min_stack_allowed = 48 * K;
|
||||
size_t os::Posix::_vm_internal_thread_min_stack_allowed = 224 * K;
|
||||
#else
|
||||
size_t os::Posix::_compiler_thread_min_stack_allowed = 32 * K;
|
||||
size_t os::Posix::_java_thread_min_stack_allowed = 32 * K;
|
||||
size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K;
|
||||
#endif // _LP64
|
||||
|
||||
#ifdef AMD64
|
||||
#define REG_SP REG_RSP
|
||||
#define REG_PC REG_RIP
|
||||
#define REG_FP REG_RBP
|
||||
#else
|
||||
size_t os::Posix::_compiler_thread_min_stack_allowed = 64 * K;
|
||||
size_t os::Posix::_java_thread_min_stack_allowed = 64 * K;
|
||||
size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K;
|
||||
#define REG_SP UESP
|
||||
#define REG_PC EIP
|
||||
#define REG_FP EBP
|
||||
|
@ -436,7 +436,7 @@ class os: AllStatic {
|
||||
vm_thread,
|
||||
cgc_thread, // Concurrent GC thread
|
||||
pgc_thread, // Parallel GC thread
|
||||
java_thread,
|
||||
java_thread, // Java, CodeCacheSweeper, JVMTIAgent and Service threads.
|
||||
compiler_thread,
|
||||
watcher_thread,
|
||||
os_thread
|
||||
|
Loading…
x
Reference in New Issue
Block a user