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);
|
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 = _java_thread_min_stack_allowed +
1115 JavaThread::stack_guard_zone_size() +
1116 JavaThread::stack_shadow_zone_size();
1117
1118 _java_thread_min_stack_allowed = align_size_up(_java_thread_min_stack_allowed, vm_page_size());
1119
1120 size_t stack_size_in_bytes = ThreadStackSize * K;
1121 if (stack_size_in_bytes != 0 &&
1122 stack_size_in_bytes < _java_thread_min_stack_allowed) {
1123 // The '-Xss' and '-XX:ThreadStackSize=N' options both set
1124 // ThreadStackSize so we go with "Java thread stack size" instead
1125 // of "ThreadStackSize" to be more friendly.
1126 tty->print_cr("\nThe Java thread stack size specified is too small. "
1127 "Specify at least " SIZE_FORMAT "k",
1128 _java_thread_min_stack_allowed / K);
1129 return JNI_ERR;
1130 }
1131
1132 #ifdef SOLARIS
1133 // For 64kbps there will be a 64kb page size, which makes
1134 // the usable default stack size quite a bit less. Increase the
1135 // stack for 64kb (or any > than 8kb) pages, this increases
1136 // virtual memory fragmentation (since we're not creating the
1137 // stack on a power of 2 boundary. The real fix for this
1138 // should be to fix the guard page mechanism.
1139
1140 if (vm_page_size() > 8*K) {
1141 stack_size_in_bytes = (stack_size_in_bytes != 0)
1142 ? stack_size_in_bytes +
1143 JavaThread::stack_red_zone_size() +
1144 JavaThread::stack_yellow_zone_size()
1145 : 0;
1146 ThreadStackSize = stack_size_in_bytes/K;
1147 }
1148 #endif // SOLARIS
1149
1150 // Make the stack size a multiple of the page size so that
1151 // the yellow/red zones can be guarded.
1152 JavaThread::set_stack_size_at_create(round_to(stack_size_in_bytes, vm_page_size()));
1153
1154 _compiler_thread_min_stack_allowed = _compiler_thread_min_stack_allowed +
1155 JavaThread::stack_guard_zone_size() +
1156 JavaThread::stack_shadow_zone_size();
1157
1158 _compiler_thread_min_stack_allowed = align_size_up(_compiler_thread_min_stack_allowed, vm_page_size());
1159
1160 stack_size_in_bytes = CompilerThreadStackSize * K;
1161 if (stack_size_in_bytes != 0 &&
1162 stack_size_in_bytes < _compiler_thread_min_stack_allowed) {
1163 tty->print_cr("\nThe CompilerThreadStackSize specified is too small. "
1164 "Specify at least " SIZE_FORMAT "k",
1165 _compiler_thread_min_stack_allowed / K);
1166 return JNI_ERR;
1167 }
1168
1169 _vm_internal_thread_min_stack_allowed = align_size_up(_vm_internal_thread_min_stack_allowed, vm_page_size());
1170
1171 stack_size_in_bytes = VMThreadStackSize * K;
1172 if (stack_size_in_bytes != 0 &&
1173 stack_size_in_bytes < _vm_internal_thread_min_stack_allowed) {
1174 tty->print_cr("\nThe VMThreadStackSize specified is too small. "
1175 "Specify at least " SIZE_FORMAT "k",
1176 _vm_internal_thread_min_stack_allowed / K);
|