Mercurial > hg > release > heapstats-2.0
changeset 82:3324d817a225
Bug 2376: Deadlock finder needs to return a original _thread_state to HotSpot VM.
reviewed-by: yasuenag
author | KUBOTA Yuji <kubota.yuji@lab.ntt.co.jp> |
---|---|
date | Fri, 22 May 2015 11:57:03 +0900 |
parents | b99a74102ae0 |
children | 8c44485d3603 |
files | agent/ChangeLog agent/src/heapstats-engines/deadlockFinder.cpp |
diffstat | 2 files changed, 26 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/agent/ChangeLog Fri May 22 11:40:27 2015 +0900 +++ b/agent/ChangeLog Fri May 22 11:57:03 2015 +0900 @@ -1,3 +1,7 @@ +2015-05-22 KUBOTA Yuji <kubota.yuji@lab.ntt.co.jp> + + * Bug 2376: Deadlock finder needs to return a original _thread_state to HotSpot VM. + 2015-05-22 KUBOTA Yuji <kubota.yuji@lab.ntt.co.jp> * Bug 2366: Change the calculation of g1StartAddr to create the bitmap for G1GC
--- a/agent/src/heapstats-engines/deadlockFinder.cpp Fri May 22 11:40:27 2015 +0900 +++ b/agent/src/heapstats-engines/deadlockFinder.cpp Fri May 22 11:57:03 2015 +0900 @@ -195,14 +195,6 @@ * \brief Get safepoint state. * \return Is synchronizing or working at safepoint now. */ -inline bool isInWorkSafepoint(void){ - return (TVMVariables::getInstance()->getSafePointState() != 0); -} - -/*! - * \brief Get safepoint state. - * \return Is working at safepoint now. - */ inline bool isAtSafepoint(void){ return (TVMVariables::getInstance()->getSafePointState() == 2); } @@ -535,24 +527,9 @@ /* Get self thread id. */ pid_t threadId = syscall(SYS_gettid); - /* Check deadlock. */ - bool foundDeadlock = findDeadLock(threadId, monitor); - - if (unlikely(foundDeadlock)) { - - /* Get threads. */ - getLockedThreads(threadId, monitor, list); - - /* Count list item. */ - for (TDeadlockList *item = (*list); item != NULL; - item = item->next) { - - deadlockCount++; - } - } - int *status = (int *)incAddress(thisThreadPtr, ofsJavaThreadThreadState); + int original_status = *status; /* * Normally thread status is "_thread_in_native" @@ -575,6 +552,24 @@ * * So thread status reset here by force. */ + *status = THREAD_IN_VM; + + /* Check deadlock. */ + bool foundDeadlock = findDeadLock(threadId, monitor); + + if (unlikely(foundDeadlock)) { + + /* Get threads. */ + getLockedThreads(threadId, monitor, list); + + /* Count list item. */ + for (TDeadlockList *item = (*list); item != NULL; + item = item->next) { + + deadlockCount++; + } + } + if (*status == THREAD_IN_VM) { bool needLock = !monitor_owned_by_self(thread_lock); @@ -592,7 +587,7 @@ } /* Reset "_thread_state". */ - *status = THREAD_IN_NATIVE; + *status = original_status; /* Reset "_safepoint_state". */ threadSafepointStateDestroy(thisThreadPtr); threadSafepointStateCreate(thisThreadPtr); @@ -718,7 +713,7 @@ jobject monitorOop = NULL; /* Get owner thread of this monitor. */ - threadPtr = get_lock_owner(monitor, !isInWorkSafepoint()); + threadPtr = get_lock_owner(monitor, !isAtSafepoint()); /* No deadlock (no owner thread of this monitor). */ if (unlikely(threadPtr == NULL)) { @@ -799,7 +794,7 @@ TDeadlockList *threadRec = NULL; /* Get owner thread of this monitor. */ - threadPtr = get_lock_owner(monitor, !isInWorkSafepoint()); + threadPtr = get_lock_owner(monitor, !isAtSafepoint()); if (unlikely(threadPtr == NULL)) { /* Shouldn't reach to here. */