6988439: Parallel Class Loading test deadlock involving MethodData_lock and Pending List Lock

Fri, 10 Dec 2010 12:13:03 -0500

author
coleenp
date
Fri, 10 Dec 2010 12:13:03 -0500
changeset 2363
7cf1a74771e8
parent 2362
a5610f0862fe
child 2365
54f5dd2aa1d9

6988439: Parallel Class Loading test deadlock involving MethodData_lock and Pending List Lock
Summary: Don't acquire methodData_lock while holding pending list lock
Reviewed-by: kvn, never, ysr

src/share/vm/oops/instanceRefKlass.cpp file | annotate | diff | comparison | revisions
src/share/vm/oops/instanceRefKlass.hpp file | annotate | diff | comparison | revisions
src/share/vm/oops/methodOop.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/oops/instanceRefKlass.cpp	Thu Dec 09 20:12:06 2010 -0500
     1.2 +++ b/src/share/vm/oops/instanceRefKlass.cpp	Fri Dec 10 12:13:03 2010 -0500
     1.3 @@ -457,6 +457,11 @@
     1.4    }
     1.5  }
     1.6  
     1.7 +bool instanceRefKlass::owns_pending_list_lock(JavaThread* thread) {
     1.8 +  Handle h_lock(thread, java_lang_ref_Reference::pending_list_lock());
     1.9 +  return ObjectSynchronizer::current_thread_holds_lock(thread, h_lock);
    1.10 +}
    1.11 +
    1.12  void instanceRefKlass::acquire_pending_list_lock(BasicLock *pending_list_basic_lock) {
    1.13    // we may enter this with pending exception set
    1.14    PRESERVE_EXCEPTION_MARK;  // exceptions are never thrown, needed for TRAPS argument
     2.1 --- a/src/share/vm/oops/instanceRefKlass.hpp	Thu Dec 09 20:12:06 2010 -0500
     2.2 +++ b/src/share/vm/oops/instanceRefKlass.hpp	Fri Dec 10 12:13:03 2010 -0500
     2.3 @@ -89,6 +89,7 @@
     2.4  
     2.5    static void release_and_notify_pending_list_lock(BasicLock *pending_list_basic_lock);
     2.6    static void acquire_pending_list_lock(BasicLock *pending_list_basic_lock);
     2.7 +  static bool owns_pending_list_lock(JavaThread* thread);
     2.8  
     2.9    // Update non-static oop maps so 'referent', 'nextPending' and
    2.10    // 'discovered' will look like non-oops
     3.1 --- a/src/share/vm/oops/methodOop.cpp	Thu Dec 09 20:12:06 2010 -0500
     3.2 +++ b/src/share/vm/oops/methodOop.cpp	Fri Dec 10 12:13:03 2010 -0500
     3.3 @@ -309,6 +309,12 @@
     3.4  // Build a methodDataOop object to hold information about this method
     3.5  // collected in the interpreter.
     3.6  void methodOopDesc::build_interpreter_method_data(methodHandle method, TRAPS) {
     3.7 +  // Do not profile method if current thread holds the pending list lock,
     3.8 +  // which avoids deadlock for acquiring the MethodData_lock.
     3.9 +  if (instanceRefKlass::owns_pending_list_lock((JavaThread*)THREAD)) {
    3.10 +    return;
    3.11 +  }
    3.12 +
    3.13    // Grab a lock here to prevent multiple
    3.14    // methodDataOops from being created.
    3.15    MutexLocker ml(MethodData_lock, THREAD);

mercurial