--- a/hotspot/src/os/aix/vm/os_aix.cpp Mon Dec 12 21:56:45 2016 -0800
+++ b/hotspot/src/os/aix/vm/os_aix.cpp Tue Nov 08 16:30:36 2016 +0100
@@ -848,13 +848,13 @@
assert(thread->osthread() == NULL, "caller responsible");
- // Allocate the OSThread object
+ // Allocate the OSThread object.
OSThread* osthread = new OSThread(NULL, NULL);
if (osthread == NULL) {
return false;
}
- // set the correct thread state
+ // Set the correct thread state.
osthread->set_thread_type(thr_type);
// Initial state is ALLOCATED but not INITIALIZED
@@ -862,7 +862,7 @@
thread->set_osthread(osthread);
- // init thread attributes
+ // Init thread attributes.
pthread_attr_t attr;
pthread_attr_init(&attr);
guarantee(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) == 0, "???");
@@ -871,15 +871,18 @@
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
+ // 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);
+ // Configure 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);
@@ -895,7 +898,7 @@
pthread_attr_destroy(&attr);
if (ret != 0) {
- // Need to clean up stuff we've allocated so far
+ // Need to clean up stuff we've allocated so far.
thread->set_osthread(NULL);
delete osthread;
return false;
@@ -3032,6 +3035,19 @@
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];