6978641: Fix for 6929067 introduces additional overhead in thread creation/termination paths

Wed, 25 Aug 2010 21:29:05 -0400

author
dholmes
date
Wed, 25 Aug 2010 21:29:05 -0400
changeset 2105
c7004d700b49
parent 2100
ebfb7c68865e
child 2106
2528b5bd749c

6978641: Fix for 6929067 introduces additional overhead in thread creation/termination paths
Summary: Disable stack bounds checks in product mode other than for the initial thread
Reviewed-by: coleenp, jcoomes, aph

src/os/linux/vm/os_linux.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/os/linux/vm/os_linux.cpp	Mon Aug 23 08:44:03 2010 -0700
     1.2 +++ b/src/os/linux/vm/os_linux.cpp	Wed Aug 25 21:29:05 2010 -0400
     1.3 @@ -2597,10 +2597,14 @@
     1.4  // where we're going to put our guard pages, truncate the mapping at
     1.5  // that point by munmap()ping it.  This ensures that when we later
     1.6  // munmap() the guard pages we don't leave a hole in the stack
     1.7 -// mapping.
     1.8 +// mapping. This only affects the main/initial thread, but guard
     1.9 +// against future OS changes
    1.10  bool os::create_stack_guard_pages(char* addr, size_t size) {
    1.11    uintptr_t stack_extent, stack_base;
    1.12 -  if (get_stack_bounds(&stack_extent, &stack_base)) {
    1.13 +  bool chk_bounds = NOT_DEBUG(os::Linux::is_initial_thread()) DEBUG_ONLY(true);
    1.14 +  if (chk_bounds && get_stack_bounds(&stack_extent, &stack_base)) {
    1.15 +      assert(os::Linux::is_initial_thread(),
    1.16 +           "growable stack in non-initial thread");
    1.17      if (stack_extent < (uintptr_t)addr)
    1.18        ::munmap((void*)stack_extent, (uintptr_t)addr - stack_extent);
    1.19    }
    1.20 @@ -2609,10 +2613,15 @@
    1.21  }
    1.22  
    1.23  // If this is a growable mapping, remove the guard pages entirely by
    1.24 -// munmap()ping them.  If not, just call uncommit_memory().
    1.25 +// munmap()ping them.  If not, just call uncommit_memory(). This only
    1.26 +// affects the main/initial thread, but guard against future OS changes
    1.27  bool os::remove_stack_guard_pages(char* addr, size_t size) {
    1.28    uintptr_t stack_extent, stack_base;
    1.29 -  if (get_stack_bounds(&stack_extent, &stack_base)) {
    1.30 +  bool chk_bounds = NOT_DEBUG(os::Linux::is_initial_thread()) DEBUG_ONLY(true);
    1.31 +  if (chk_bounds && get_stack_bounds(&stack_extent, &stack_base)) {
    1.32 +      assert(os::Linux::is_initial_thread(),
    1.33 +           "growable stack in non-initial thread");
    1.34 +
    1.35      return ::munmap(addr, size) == 0;
    1.36    }
    1.37  

mercurial