< prev index next >

src/os/aix/vm/os_aix.cpp

Print this page
rev 12346 : 8169373: Work around linux NPTL stack guard error.
Summary: Also skip libc guard page for compiler thread, merge similar code on linux platforms, and streamline libc guard page handling on linuxs390, linuxppc, aixppc.
Reviewed-by: dholmes, dcubed

*** 850,891 **** bool os::create_thread(Thread* thread, ThreadType thr_type, size_t req_stack_size) { assert(thread->osthread() == NULL, "caller responsible"); ! // Allocate the OSThread object OSThread* osthread = new OSThread(NULL, NULL); if (osthread == NULL) { return false; } ! // set the correct thread state osthread->set_thread_type(thr_type); // Initial state is ALLOCATED but not INITIALIZED osthread->set_state(ALLOCATED); thread->set_osthread(osthread); ! // init thread attributes pthread_attr_t attr; pthread_attr_init(&attr); guarantee(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) == 0, "???"); // Make sure we run in 1:1 kernel-user-thread mode. if (os::Aix::on_aix()) { guarantee(pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM) == 0, "???"); guarantee(pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED) == 0, "???"); ! } // end: aix // Start in suspended state, and in os::thread_start, wake the thread up. guarantee(pthread_attr_setsuspendstate_np(&attr, PTHREAD_CREATE_SUSPENDED_NP) == 0, "???"); ! // calculate stack size if it's not specified by caller size_t stack_size = os::Posix::get_initial_stack_size(thr_type, req_stack_size); pthread_attr_setstacksize(&attr, stack_size); pthread_t tid; int ret = pthread_create(&tid, &attr, (void* (*)(void*)) thread_native_entry, thread); char buf[64]; if (ret == 0) { --- 850,894 ---- bool os::create_thread(Thread* thread, ThreadType thr_type, size_t req_stack_size) { assert(thread->osthread() == NULL, "caller responsible"); ! // Allocate the OSThread object. OSThread* osthread = new OSThread(NULL, NULL); if (osthread == NULL) { return false; } ! // Set the correct thread state. osthread->set_thread_type(thr_type); // Initial state is ALLOCATED but not INITIALIZED osthread->set_state(ALLOCATED); thread->set_osthread(osthread); ! // Init thread attributes. pthread_attr_t attr; pthread_attr_init(&attr); guarantee(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) == 0, "???"); // Make sure we run in 1:1 kernel-user-thread mode. if (os::Aix::on_aix()) { guarantee(pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM) == 0, "???"); guarantee(pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED) == 0, "???"); ! } // Start in suspended state, and in os::thread_start, wake the thread up. guarantee(pthread_attr_setsuspendstate_np(&attr, PTHREAD_CREATE_SUSPENDED_NP) == 0, "???"); ! // Calculate stack size if it's not specified by caller. size_t stack_size = os::Posix::get_initial_stack_size(thr_type, req_stack_size); pthread_attr_setstacksize(&attr, stack_size); + // libc guard page + pthread_attr_setguardsize(&attr, os::Aix::default_guard_size(thr_type)); + pthread_t tid; int ret = pthread_create(&tid, &attr, (void* (*)(void*)) thread_native_entry, thread); char buf[64]; if (ret == 0) {
*** 897,907 **** } pthread_attr_destroy(&attr); if (ret != 0) { ! // Need to clean up stuff we've allocated so far thread->set_osthread(NULL); delete osthread; return false; } --- 900,910 ---- } pthread_attr_destroy(&attr); if (ret != 0) { ! // Need to clean up stuff we've allocated so far. thread->set_osthread(NULL); delete osthread; return false; }
*** 3034,3043 **** --- 3037,3059 ---- } } return chained; } + size_t os::Aix::default_guard_size(os::ThreadType thr_type) { + // Creating guard page is very expensive. Java thread has HotSpot + // guard pages, only enable glibc guard page for non-Java threads. + // (Remember: compiler thread is a Java thread, too!) + // + // Aix can have different page sizes for stack (4K) and heap (64K). + // As Hotspot knows only one page size, we assume the stack has + // the same page size as the heap. Returning page_size() here can + // cause 16 guard pages which we want to avoid. Thus we return 4K + // which will be rounded to the real page size by the OS. + return ((thr_type == java_thread || thr_type == compiler_thread) ? 0 : 4 * K); + } + struct sigaction* os::Aix::get_preinstalled_handler(int sig) { if (sigismember(&sigs, sig)) { return &sigact[sig]; } return NULL;
< prev index next >