1.1 --- a/src/share/vm/runtime/os.cpp Thu Jan 31 14:56:50 2008 -0500 1.2 +++ b/src/share/vm/runtime/os.cpp Tue Feb 05 23:21:57 2008 -0800 1.3 @@ -956,7 +956,6 @@ 1.4 return true; 1.5 } 1.6 1.7 - 1.8 void os::set_memory_serialize_page(address page) { 1.9 int count = log2_intptr(sizeof(class JavaThread)) - log2_intptr(64); 1.10 _mem_serialize_page = (volatile int32_t *)page; 1.11 @@ -967,6 +966,8 @@ 1.12 set_serialize_page_mask((uintptr_t)(vm_page_size() - sizeof(int32_t))); 1.13 } 1.14 1.15 +static volatile intptr_t SerializePageLock = 0; 1.16 + 1.17 // This method is called from signal handler when SIGSEGV occurs while the current 1.18 // thread tries to store to the "read-only" memory serialize page during state 1.19 // transition. 1.20 @@ -974,15 +975,14 @@ 1.21 if (TraceSafepoint) { 1.22 tty->print_cr("Block until the serialize page permission restored"); 1.23 } 1.24 - // When VMThread is holding the SerializePage_lock during modifying the 1.25 + // When VMThread is holding the SerializePageLock during modifying the 1.26 // access permission of the memory serialize page, the following call 1.27 // will block until the permission of that page is restored to rw. 1.28 // Generally, it is unsafe to manipulate locks in signal handlers, but in 1.29 // this case, it's OK as the signal is synchronous and we know precisely when 1.30 - // it can occur. SerializePage_lock is a transiently-held leaf lock, so 1.31 - // lock_without_safepoint_check should be safe. 1.32 - SerializePage_lock->lock_without_safepoint_check(); 1.33 - SerializePage_lock->unlock(); 1.34 + // it can occur. 1.35 + Thread::muxAcquire(&SerializePageLock, "set_memory_serialize_page"); 1.36 + Thread::muxRelease(&SerializePageLock); 1.37 } 1.38 1.39 // Serialize all thread state variables 1.40 @@ -990,14 +990,12 @@ 1.41 // On some platforms such as Solaris & Linux, the time duration of the page 1.42 // permission restoration is observed to be much longer than expected due to 1.43 // scheduler starvation problem etc. To avoid the long synchronization 1.44 - // time and expensive page trap spinning, 'SerializePage_lock' is used to block 1.45 - // the mutator thread if such case is encountered. Since this method is always 1.46 - // called by VMThread during safepoint, lock_without_safepoint_check is used 1.47 - // instead. See bug 6546278. 1.48 - SerializePage_lock->lock_without_safepoint_check(); 1.49 + // time and expensive page trap spinning, 'SerializePageLock' is used to block 1.50 + // the mutator thread if such case is encountered. See bug 6546278 for details. 1.51 + Thread::muxAcquire(&SerializePageLock, "serialize_thread_states"); 1.52 os::protect_memory( (char *)os::get_memory_serialize_page(), os::vm_page_size() ); 1.53 os::unguard_memory( (char *)os::get_memory_serialize_page(), os::vm_page_size() ); 1.54 - SerializePage_lock->unlock(); 1.55 + Thread::muxRelease(&SerializePageLock); 1.56 } 1.57 1.58 // Returns true if the current stack pointer is above the stack shadow