static void MXUserStatsActionRW(MXUserHeader *header) // IN: { MXUserRWLock *lock = (MXUserRWLock *) header; MXUserHeldStats *heldStats = Atomic_ReadPtr(&lock->heldStatsMem); MXUserAcquireStats *acquireStats = Atomic_ReadPtr(&lock->acquireStatsMem); if (heldStats) { MXUserDumpBasicStats(&heldStats->data, header); if (Atomic_ReadPtr(&heldStats->histo) != NULL) { MXUserHistoDump(Atomic_ReadPtr(&heldStats->histo), header); } } if (acquireStats) { Bool isHot; Bool doLog; double contentionRatio; /* * Dump the statistics for the specified lock. */ MXUserDumpAcquisitionStats(&acquireStats->data, header); if (Atomic_ReadPtr(&acquireStats->histo) != NULL) { MXUserHistoDump(Atomic_ReadPtr(&acquireStats->histo), header); } /* * Has the lock gone "hot"? If so, implement the hot actions. */ MXUserKitchen(&acquireStats->data, &contentionRatio, &isHot, &doLog); if (isHot) { MXUserForceHisto(&acquireStats->histo, MXUSER_STAT_CLASS_ACQUISITION, MXUSER_DEFAULT_HISTO_MIN_VALUE_NS, MXUSER_DEFAULT_HISTO_DECADES); if (heldStats) { MXUserForceHisto(&heldStats->histo, MXUSER_STAT_CLASS_HELD, MXUSER_DEFAULT_HISTO_MIN_VALUE_NS, MXUSER_DEFAULT_HISTO_DECADES); } if (doLog) { Log("HOT LOCK (%s); contention ratio %f\n", lock->header.name, contentionRatio); } } } }
void MXUserDumpAcquisitionStats(MXUserAcquisitionStats *stats, // IN: MXUserHeader *header) // IN: { if (stats->numAttempts > 0) { if (stats->numSuccesses > 0) { MXUserDumpBasicStats(&stats->basicStats, header); } MXUserStatsLog("MXUser: ce l=%u a=%"FMT64"u s=%"FMT64"u sc=%"FMT64"u " "sct=%"FMT64"u t=%"FMT64"u\n", header->bits.serialNumber, stats->numAttempts, stats->numSuccesses, stats->numSuccessesContended, stats->successContentionTime, stats->totalContentionTime); } }