1090 #endif
1091 }
1092
1093 char* os::Posix::describe_pthread_attr(char* buf, size_t buflen, const pthread_attr_t* attr) {
1094 size_t stack_size = 0;
1095 size_t guard_size = 0;
1096 int detachstate = 0;
1097 pthread_attr_getstacksize(attr, &stack_size);
1098 pthread_attr_getguardsize(attr, &guard_size);
1099 // Work around linux NPTL implementation error, see also os::create_thread() in os_linux.cpp.
1100 LINUX_ONLY(stack_size -= guard_size);
1101 pthread_attr_getdetachstate(attr, &detachstate);
1102 jio_snprintf(buf, buflen, "stacksize: " SIZE_FORMAT "k, guardsize: " SIZE_FORMAT "k, %s",
1103 stack_size / 1024, guard_size / 1024,
1104 (detachstate == PTHREAD_CREATE_DETACHED ? "detached" : "joinable"));
1105 return buf;
1106 }
1107
1108 // Check minimum allowable stack sizes for thread creation and to initialize
1109 // the java system classes, including StackOverflowError - depends on page
1110 // size. Add two 4K pages for compiler2 recursion in main thread.
1111 // Add in 4*BytesPerWord 4K pages to account for VM stack during
1112 // class initialization depending on 32 or 64 bit VM.
1113 jint os::Posix::set_minimum_stack_sizes() {
1114 _java_thread_min_stack_allowed = MAX2(_java_thread_min_stack_allowed,
1115 JavaThread::stack_guard_zone_size() +
1116 JavaThread::stack_shadow_zone_size() +
1117 (4 * BytesPerWord COMPILER2_PRESENT(+ 2)) * 4 * K);
1118
1119 _java_thread_min_stack_allowed = align_size_up(_java_thread_min_stack_allowed, vm_page_size());
1120
1121 size_t stack_size_in_bytes = ThreadStackSize * K;
1122 if (stack_size_in_bytes != 0 &&
1123 stack_size_in_bytes < _java_thread_min_stack_allowed) {
1124 // The '-Xss' and '-XX:ThreadStackSize=N' options both set
1125 // ThreadStackSize so we go with "Java thread stack size" instead
1126 // of "ThreadStackSize" to be more friendly.
1127 tty->print_cr("\nThe Java thread stack size specified is too small. "
1128 "Specify at least " SIZE_FORMAT "k",
1129 _java_thread_min_stack_allowed / K);
1130 return JNI_ERR;
1131 }
1132
1133 #ifdef SOLARIS
1134 // For 64kbps there will be a 64kb page size, which makes
1135 // the usable default stack size quite a bit less. Increase the
1136 // stack for 64kb (or any > than 8kb) pages, this increases
1137 // virtual memory fragmentation (since we're not creating the
1138 // stack on a power of 2 boundary. The real fix for this
1139 // should be to fix the guard page mechanism.
1140
1141 if (vm_page_size() > 8*K) {
1142 stack_size_in_bytes = (stack_size_in_bytes != 0)
1143 ? stack_size_in_bytes +
1144 JavaThread::stack_red_zone_size() +
1145 JavaThread::stack_yellow_zone_size()
1146 : 0;
1147 ThreadStackSize = stack_size_in_bytes/K;
1148 }
1149 #endif // SOLARIS
1150
1151 // Make the stack size a multiple of the page size so that
1152 // the yellow/red zones can be guarded.
1153 JavaThread::set_stack_size_at_create(round_to(stack_size_in_bytes,
1154 vm_page_size()));
1155
1156 _compiler_thread_min_stack_allowed = align_size_up(_compiler_thread_min_stack_allowed, vm_page_size());
1157
1158 stack_size_in_bytes = CompilerThreadStackSize * K;
1159 if (stack_size_in_bytes != 0 &&
1160 stack_size_in_bytes < _compiler_thread_min_stack_allowed) {
1161 tty->print_cr("\nThe CompilerThreadStackSize specified is too small. "
1162 "Specify at least " SIZE_FORMAT "k",
1163 _compiler_thread_min_stack_allowed / K);
1164 return JNI_ERR;
1165 }
1166
1167 _vm_internal_thread_min_stack_allowed = align_size_up(_vm_internal_thread_min_stack_allowed, vm_page_size());
1168
1169 stack_size_in_bytes = VMThreadStackSize * K;
1170 if (stack_size_in_bytes != 0 &&
1171 stack_size_in_bytes < _vm_internal_thread_min_stack_allowed) {
1172 tty->print_cr("\nThe VMThreadStackSize specified is too small. "
1173 "Specify at least " SIZE_FORMAT "k",
1174 _vm_internal_thread_min_stack_allowed / K);
|
1090 #endif
1091 }
1092
1093 char* os::Posix::describe_pthread_attr(char* buf, size_t buflen, const pthread_attr_t* attr) {
1094 size_t stack_size = 0;
1095 size_t guard_size = 0;
1096 int detachstate = 0;
1097 pthread_attr_getstacksize(attr, &stack_size);
1098 pthread_attr_getguardsize(attr, &guard_size);
1099 // Work around linux NPTL implementation error, see also os::create_thread() in os_linux.cpp.
1100 LINUX_ONLY(stack_size -= guard_size);
1101 pthread_attr_getdetachstate(attr, &detachstate);
1102 jio_snprintf(buf, buflen, "stacksize: " SIZE_FORMAT "k, guardsize: " SIZE_FORMAT "k, %s",
1103 stack_size / 1024, guard_size / 1024,
1104 (detachstate == PTHREAD_CREATE_DETACHED ? "detached" : "joinable"));
1105 return buf;
1106 }
1107
1108 // Check minimum allowable stack sizes for thread creation and to initialize
1109 // the java system classes, including StackOverflowError - depends on page
1110 // size.
1111 // The space needed for frames during startup is platform dependent.
1112 // It dependes on word size, platform calling conventions, C frame layout and
1113 // interpreter/C1/C2 design decisions. Therefore this is given in a
1114 // platform (os/cpu) dependent constant.
1115 // To this, space for guard mechanisms is added, which depends on the
1116 // page size which again depends on the concrete system the VM is running
1117 // on. Space for libc guard pages is not included in this size.
1118 jint os::Posix::set_minimum_stack_sizes() {
1119 _java_thread_min_stack_allowed = _java_thread_min_stack_allowed +
1120 JavaThread::stack_guard_zone_size() +
1121 JavaThread::stack_shadow_zone_size();
1122
1123 _java_thread_min_stack_allowed = align_size_up(_java_thread_min_stack_allowed, vm_page_size());
1124
1125 size_t stack_size_in_bytes = ThreadStackSize * K;
1126 if (stack_size_in_bytes != 0 &&
1127 stack_size_in_bytes < _java_thread_min_stack_allowed) {
1128 // The '-Xss' and '-XX:ThreadStackSize=N' options both set
1129 // ThreadStackSize so we go with "Java thread stack size" instead
1130 // of "ThreadStackSize" to be more friendly.
1131 tty->print_cr("\nThe Java thread stack size specified is too small. "
1132 "Specify at least " SIZE_FORMAT "k",
1133 _java_thread_min_stack_allowed / K);
1134 return JNI_ERR;
1135 }
1136
1137 // Make the stack size a multiple of the page size so that
1138 // the yellow/red zones can be guarded.
1139 JavaThread::set_stack_size_at_create(round_to(stack_size_in_bytes, vm_page_size()));
1140
1141 // Reminder: a compiler thread is a Java thread.
1142 _compiler_thread_min_stack_allowed = _compiler_thread_min_stack_allowed +
1143 JavaThread::stack_guard_zone_size() +
1144 JavaThread::stack_shadow_zone_size();
1145
1146 _compiler_thread_min_stack_allowed = align_size_up(_compiler_thread_min_stack_allowed, vm_page_size());
1147
1148 stack_size_in_bytes = CompilerThreadStackSize * K;
1149 if (stack_size_in_bytes != 0 &&
1150 stack_size_in_bytes < _compiler_thread_min_stack_allowed) {
1151 tty->print_cr("\nThe CompilerThreadStackSize specified is too small. "
1152 "Specify at least " SIZE_FORMAT "k",
1153 _compiler_thread_min_stack_allowed / K);
1154 return JNI_ERR;
1155 }
1156
1157 _vm_internal_thread_min_stack_allowed = align_size_up(_vm_internal_thread_min_stack_allowed, vm_page_size());
1158
1159 stack_size_in_bytes = VMThreadStackSize * K;
1160 if (stack_size_in_bytes != 0 &&
1161 stack_size_in_bytes < _vm_internal_thread_min_stack_allowed) {
1162 tty->print_cr("\nThe VMThreadStackSize specified is too small. "
1163 "Specify at least " SIZE_FORMAT "k",
1164 _vm_internal_thread_min_stack_allowed / K);
|