Print this page
rev 4531 : 8013398: Adjust number of stack guard pages on systems with large memory page size
Summary: Auto adjust number of stack guard pages on systems with large memory page size
Reviewed-by: bobv, coleenp

Split Split Close
Expand all
Collapse all
          --- old/src/os/linux/vm/os_linux.cpp
          +++ new/src/os/linux/vm/os_linux.cpp
↓ open down ↓ 130 lines elided ↑ open up ↑
 131  131  julong os::Linux::_physical_memory = 0;
 132  132  
 133  133  address   os::Linux::_initial_thread_stack_bottom = NULL;
 134  134  uintptr_t os::Linux::_initial_thread_stack_size   = 0;
 135  135  
 136  136  int (*os::Linux::_clock_gettime)(clockid_t, struct timespec *) = NULL;
 137  137  int (*os::Linux::_pthread_getcpuclockid)(pthread_t, clockid_t *) = NULL;
 138  138  Mutex* os::Linux::_createThread_lock = NULL;
 139  139  pthread_t os::Linux::_main_thread;
 140  140  int os::Linux::_page_size = -1;
      141 +const int os::Linux::_vm_default_page_size = (8 * K);
 141  142  bool os::Linux::_is_floating_stack = false;
 142  143  bool os::Linux::_is_NPTL = false;
 143  144  bool os::Linux::_supports_fast_thread_cpu_time = false;
 144  145  const char * os::Linux::_glibc_version = NULL;
 145  146  const char * os::Linux::_libpthread_version = NULL;
 146  147  
 147  148  static jlong initial_time_count=0;
 148  149  
 149  150  static int clock_tics_per_sec = 100;
 150  151  
↓ open down ↓ 4227 lines elided ↑ open up ↑
4378 4379    init_page_sizes((size_t) Linux::page_size());
4379 4380  
4380 4381    Linux::initialize_system_info();
4381 4382  
4382 4383    // main_thread points to the aboriginal thread
4383 4384    Linux::_main_thread = pthread_self();
4384 4385  
4385 4386    Linux::clock_init();
4386 4387    initial_time_count = os::elapsed_counter();
4387 4388    pthread_mutex_init(&dl_mutex, NULL);
     4389 +
     4390 +  // If the pagesize of the VM is greater than 8K determine the appropriate
     4391 +  // number of initial guard pages.  The user can change this with the
     4392 +  // command line arguments, if needed.
     4393 +  if (vm_page_size() > (int)Linux::vm_default_page_size()) {
     4394 +    StackYellowPages = 1;
     4395 +    StackRedPages = 1;
     4396 +    StackShadowPages = round_to((StackShadowPages*Linux::vm_default_page_size()), vm_page_size()) / vm_page_size();
     4397 +  }
4388 4398  }
4389 4399  
4390 4400  // To install functions for atexit system call
4391 4401  extern "C" {
4392 4402    static void perfMemory_exit_helper() {
4393 4403      perfMemory_exit();
4394 4404    }
4395 4405  }
4396 4406  
4397 4407  // this is called _after_ the global arguments have been parsed
↓ open down ↓ 33 lines elided ↑ open up ↑
4431 4441  
4432 4442    Linux::signal_sets_init();
4433 4443    Linux::install_signal_handlers();
4434 4444  
4435 4445    // Check minimum allowable stack size for thread creation and to initialize
4436 4446    // the java system classes, including StackOverflowError - depends on page
4437 4447    // size.  Add a page for compiler2 recursion in main thread.
4438 4448    // Add in 2*BytesPerWord times page size to account for VM stack during
4439 4449    // class initialization depending on 32 or 64 bit VM.
4440 4450    os::Linux::min_stack_allowed = MAX2(os::Linux::min_stack_allowed,
4441      -            (size_t)(StackYellowPages+StackRedPages+StackShadowPages+
4442      -                    2*BytesPerWord COMPILER2_PRESENT(+1)) * Linux::page_size());
     4451 +            (size_t)(StackYellowPages+StackRedPages+StackShadowPages) * Linux::page_size() +
     4452 +                    (2*BytesPerWord COMPILER2_PRESENT(+1)) * Linux::vm_default_page_size());
4443 4453  
4444 4454    size_t threadStackSizeInBytes = ThreadStackSize * K;
4445 4455    if (threadStackSizeInBytes != 0 &&
4446 4456        threadStackSizeInBytes < os::Linux::min_stack_allowed) {
4447 4457          tty->print_cr("\nThe stack size specified is too small, "
4448 4458                        "Specify at least %dk",
4449 4459                        os::Linux::min_stack_allowed/ K);
4450 4460          return JNI_ERR;
4451 4461    }
4452 4462  
↓ open down ↓ 1346 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX