diff src/share/vm/runtime/os.cpp @ 55:2a8eb116ebbe

6610420: Debug VM crashes during monitor lock rank checking Summary: Make SerializePage lock as raw lock and add name for mutex locks Reviewed-by: never, dice, dholmes
author xlu
date Tue, 05 Feb 2008 23:21:57 -0800
parents a61af66fc99e
children 5a76ab815e34
line wrap: on
line diff
--- a/src/share/vm/runtime/os.cpp	Thu Jan 31 14:56:50 2008 -0500
+++ b/src/share/vm/runtime/os.cpp	Tue Feb 05 23:21:57 2008 -0800
@@ -956,7 +956,6 @@
     return true;
 }
 
-
 void os::set_memory_serialize_page(address page) {
   int count = log2_intptr(sizeof(class JavaThread)) - log2_intptr(64);
   _mem_serialize_page = (volatile int32_t *)page;
@@ -967,6 +966,8 @@
   set_serialize_page_mask((uintptr_t)(vm_page_size() - sizeof(int32_t)));
 }
 
+static volatile intptr_t SerializePageLock = 0;
+
 // This method is called from signal handler when SIGSEGV occurs while the current
 // thread tries to store to the "read-only" memory serialize page during state
 // transition.
@@ -974,15 +975,14 @@
   if (TraceSafepoint) {
     tty->print_cr("Block until the serialize page permission restored");
   }
-  // When VMThread is holding the SerializePage_lock during modifying the
+  // When VMThread is holding the SerializePageLock during modifying the
   // access permission of the memory serialize page, the following call
   // will block until the permission of that page is restored to rw.
   // Generally, it is unsafe to manipulate locks in signal handlers, but in
   // this case, it's OK as the signal is synchronous and we know precisely when
-  // it can occur. SerializePage_lock is a transiently-held leaf lock, so
-  // lock_without_safepoint_check should be safe.
-  SerializePage_lock->lock_without_safepoint_check();
-  SerializePage_lock->unlock();
+  // it can occur.
+  Thread::muxAcquire(&SerializePageLock, "set_memory_serialize_page");
+  Thread::muxRelease(&SerializePageLock);
 }
 
 // Serialize all thread state variables
@@ -990,14 +990,12 @@
   // On some platforms such as Solaris & Linux, the time duration of the page
   // permission restoration is observed to be much longer than expected  due to
   // scheduler starvation problem etc. To avoid the long synchronization
-  // time and expensive page trap spinning, 'SerializePage_lock' is used to block
-  // the mutator thread if such case is encountered. Since this method is always
-  // called by VMThread during safepoint, lock_without_safepoint_check is used
-  // instead. See bug 6546278.
-  SerializePage_lock->lock_without_safepoint_check();
+  // time and expensive page trap spinning, 'SerializePageLock' is used to block
+  // the mutator thread if such case is encountered. See bug 6546278 for details.
+  Thread::muxAcquire(&SerializePageLock, "serialize_thread_states");
   os::protect_memory( (char *)os::get_memory_serialize_page(), os::vm_page_size() );
   os::unguard_memory( (char *)os::get_memory_serialize_page(), os::vm_page_size() );
-  SerializePage_lock->unlock();
+  Thread::muxRelease(&SerializePageLock);
 }
 
 // Returns true if the current stack pointer is above the stack shadow