Report more statistics. Clean up TryAcquire for Excl and Rec locks.
Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
{
Bool success;
-#if defined(MXUSER_STATS)
- VmTimeType begin;
-#endif
-
ASSERT(lock && (lock->header.signature == MXUSER_EXCL_SIGNATURE));
if (MXUserTryAcquireFail(lock->header.name)) {
return FALSE;
}
-#if defined(MXUSER_STATS)
- begin = Hostinfo_SystemTimerNS();
-#endif
success = MXRecLockTryAcquire(&lock->recursiveLock, GetReturnAddress());
if (success) {
-#if defined(MXUSER_STATS)
- VmTimeType end = Hostinfo_SystemTimerNS();
-#endif
-
MXUserAcquisitionTracking(&lock->header, FALSE);
if (MXRecLockCount(&lock->recursiveLock) > 1) {
}
#if defined(MXUSER_STATS)
- MXUserAcquisitionSample(&lock->acquisitionStats, FALSE, end - begin);
+ MXUserAcquisitionSample(&lock->acquisitionStats, FALSE, 0ULL);
#endif
}
ASSERT(MXUserMX_TryLockRec);
success = (*MXUserMX_TryLockRec)(lock->vmmLock);
} else {
-#if defined(MXUSER_STATS)
- VmTimeType begin;
-#endif
-
if (MXUserTryAcquireFail(lock->header.name)) {
return FALSE;
}
-#if defined(MXUSER_STATS)
- begin = Hostinfo_SystemTimerNS();
-#endif
-
success = MXRecLockTryAcquire(&lock->recursiveLock, GetReturnAddress());
if (success) {
#if defined(MXUSER_STATS)
if (MXRecLockCount(&lock->recursiveLock) == 1) {
- MXUserAcquisitionSample(&lock->acquisitionStats, FALSE,
- Hostinfo_SystemTimerNS() - begin);
+ MXUserAcquisitionSample(&lock->acquisitionStats, FALSE, 0ULL);
}
#endif
MXUserAcquisitionTracking(&sema->header, TRUE); // rank checking
+#if defined(MXUSER_STATS)
+ {
+ Bool tryDownSuccess = FALSE;
+ VmTimeType begin = Hostinfo_SystemTimerNS();
+
+ err = MXUserTryDown(&sema->nativeSemaphore, &tryDownSuccess);
+
+ if (LIKELY(err == 0)) {
+ if (tryDownSuccess) {
+ downOccurred = TRUE;
+ } else {
+ err = MXUserTimedDown(&sema->nativeSemaphore, msecWait,
+ &downOccurred);
+ }
+
+ if (LIKELY(err == 0) && downOccurred) {
+ MXUserHisto *histo;
+ VmTimeType value = Hostinfo_SystemTimerNS() - begin;
+
+ MXUserAcquisitionSample(&sema->acquisitionStats, !tryDownSuccess,
+ value);
+
+ histo = Atomic_ReadPtr(&sema->acquisitionHisto);
+
+ if (UNLIKELY(histo != NULL)) {
+ MXUserHistoSample(histo, value);
+ }
+ }
+ }
+ }
+#else
err = MXUserTimedDown(&sema->nativeSemaphore, msecWait, &downOccurred);
+#endif
if (UNLIKELY(err != 0)) {
MXUserDumpAndPanic(&sema->header, "%s: Internal error (%d)\n",