]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
lib/lock: save some stats memory
authorVMware, Inc <>
Tue, 13 Mar 2012 19:59:30 +0000 (12:59 -0700)
committerDmitry Torokhov <dtor@vmware.com>
Tue, 13 Mar 2012 22:44:50 +0000 (15:44 -0700)
We keep the holder address around. No need, we can grab it when
we need it, saving a bit of memory.

Signed-off-by: Dmitry Torokhov <dtor@vmware.com>
open-vm-tools/lib/lock/ulExcl.c
open-vm-tools/lib/lock/ulRW.c
open-vm-tools/lib/lock/ulRec.c

index c1f47db006da2cc6478a07a976d07cdbf46a93f6..43f0a5a2533405d3f0b20f049dd2889c229e1d7a 100644 (file)
@@ -29,7 +29,6 @@ typedef struct
    MXUserAcquisitionStats  acquisitionStats;
    Atomic_Ptr              acquisitionHisto;
 
-   void                   *holder;
    VmTimeType              holdStart;
    MXUserBasicStats        heldStats;
    Atomic_Ptr              heldHisto;
@@ -242,7 +241,6 @@ static void
 MXUserDumpExclLock(MXUserHeader *header)  // IN:
 {
    MXUserExclLock *lock = (MXUserExclLock *) header;
-   MXUserStats *stats = (MXUserStats *) Atomic_ReadPtr(&lock->statsMem);
 
    Warning("%s: Exclusive lock @ 0x%p\n", __FUNCTION__, lock);
 
@@ -255,10 +253,6 @@ MXUserDumpExclLock(MXUserHeader *header)  // IN:
 
    Warning("\taddress of owner data 0x%p\n",
            &lock->recursiveLock.nativeThreadID);
-
-   if (stats && (stats->holder != NULL)) {
-      Warning("\tholder 0x%p\n", stats->holder);
-   }
 }
 
 
@@ -413,13 +407,13 @@ MXUser_AcquireExclLock(MXUserExclLock *lock)  // IN/OUT:
                               value != 0,  // True if contended
                               value);
 
-      stats->holder = GetReturnAddress();
-
       histo = Atomic_ReadPtr(&stats->acquisitionHisto);
 
       if (UNLIKELY(histo != NULL)) {
-         MXUserHistoSample(histo, value, stats->holder);
+         MXUserHistoSample(histo, value, GetReturnAddress());
       }
+
+      stats->holdStart = Hostinfo_SystemTimerNS();
    } else {
       MXRecLockAcquire(&lock->recursiveLock,
                        NULL);                 // non-stats
@@ -430,10 +424,6 @@ MXUser_AcquireExclLock(MXUserExclLock *lock)  // IN/OUT:
                          "%s: Acquire on an acquired exclusive lock\n",
                          __FUNCTION__);
    }
-
-   if (stats) {
-      stats->holdStart = Hostinfo_SystemTimerNS();
-   }
 }
 
 
@@ -472,8 +462,7 @@ MXUser_ReleaseExclLock(MXUserExclLock *lock)  // IN/OUT:
       histo = Atomic_ReadPtr(&stats->heldHisto);
 
       if (UNLIKELY(histo != NULL)) {
-         MXUserHistoSample(histo, value, stats->holder);
-         stats->holder = NULL;
+         MXUserHistoSample(histo, value, GetReturnAddress());
       }
    }
 
@@ -531,7 +520,7 @@ MXUser_TryAcquireExclLock(MXUserExclLock *lock)  // IN/OUT:
    if (success) {
       MXUserAcquisitionTracking(&lock->header, FALSE);
 
-      if (MXRecLockCount(&lock->recursiveLock) > 1) {
+      if (vmx86_debug && (MXRecLockCount(&lock->recursiveLock) > 1)) {
          MXUserDumpAndPanic(&lock->header,
                             "%s: Acquire on an acquired exclusive lock\n",
                             __FUNCTION__);
index 10b333aa13ed6e5f2f37cecc79d8a6e32f417301..5a10abc42b218404241224a005cfab79afed1952 100644 (file)
@@ -242,7 +242,6 @@ typedef enum {
 
 typedef struct {
    HolderState   state;
-   void         *holder;
    VmTimeType    holdStart;
 } HolderContext;
 
@@ -665,7 +664,6 @@ MXUserGetHolderContext(MXUserRWLock *lock)  // IN:
       HolderContext *newContext = Util_SafeMalloc(sizeof(HolderContext));
 
       newContext->holdStart = 0;
-      newContext->holder = NULL;
       newContext->state = RW_UNLOCKED;
 
       result = HashTable_LookupOrInsert(lock->holderTable, threadID,
@@ -767,6 +765,8 @@ MXUserAcquisition(MXUserRWLock *lock,  // IN/OUT:
       if (forRead && lock->useNative) {
          MXRecLockRelease(&lock->recursiveLock);
       }
+
+      myContext->holdStart = Hostinfo_SystemTimerNS();
    } else {
       if (LIKELY(lock->useNative)) {
          int err = 0;
@@ -789,11 +789,6 @@ MXUserAcquisition(MXUserRWLock *lock,  // IN/OUT:
 
    Atomic_Inc(&lock->holderCount);
    myContext->state = forRead ? RW_LOCKED_FOR_READ : RW_LOCKED_FOR_WRITE;
-
-   if (stats) {
-      myContext->holder = GetReturnAddress();
-      myContext->holdStart = Hostinfo_SystemTimerNS();
-   }
 }
 
 
@@ -938,8 +933,7 @@ MXUser_ReleaseRWLock(MXUserRWLock *lock)  // IN/OUT:
       histo = Atomic_ReadPtr(&stats->heldHisto);
 
       if (UNLIKELY(histo != NULL)) {
-         MXUserHistoSample(histo, duration, myContext->holder);
-         myContext->holder = NULL;
+         MXUserHistoSample(histo, duration, GetReturnAddress());
       }
 
       if ((myContext->state == RW_LOCKED_FOR_READ) && lock->useNative) {
index 2bd81398a947e6d5eba68d8bf41fdfb0f1f7f140..c1c18129f2778a7d2b9b3774020f1cf1fa3c3103 100644 (file)
@@ -29,7 +29,6 @@ typedef struct
    MXUserAcquisitionStats  acquisitionStats;
    Atomic_Ptr              acquisitionHisto;
 
-   void                   *holder;
    uint64                  holdStart;
    MXUserBasicStats        heldStats;
    Atomic_Ptr              heldHisto;
@@ -271,16 +270,10 @@ MXUserDumpRecLock(MXUserHeader *header)  // IN:
    Warning("\treference count %u\n", Atomic_Read(&lock->refCount));
 
    if (lock->vmmLock == NULL) {
-      MXUserStats *stats = (MXUserStats *) Atomic_ReadPtr(&lock->statsMem);
-
       Warning("\tcount %u\n", lock->recursiveLock.referenceCount);
 
       Warning("\taddress of owner data 0x%p\n",
               &lock->recursiveLock.nativeThreadID);
-
-      if (stats && (stats->holder != NULL)) {
-         Warning("\tholder 0x%p\n", stats->holder);
-      }
    } else {
       Warning("\tvmmLock 0x%p\n", lock->vmmLock);
    }
@@ -524,12 +517,10 @@ MXUser_AcquireRecLock(MXUserRecLock *lock)  // IN/OUT:
                                     value != 0,  // True if contended
                                     value);
 
-            stats->holder = GetReturnAddress();
-
             histo = Atomic_ReadPtr(&stats->acquisitionHisto);
 
             if (UNLIKELY(histo != NULL)) {
-               MXUserHistoSample(histo, value, stats->holder);
+               MXUserHistoSample(histo, value, GetReturnAddress());
             }
 
             stats->holdStart = Hostinfo_SystemTimerNS();
@@ -584,8 +575,7 @@ MXUser_ReleaseRecLock(MXUserRecLock *lock)  // IN/OUT:
             MXUserBasicStatsSample(&stats->heldStats, value);
 
             if (UNLIKELY(histo != NULL)) {
-               MXUserHistoSample(histo, value, stats->holder);
-               stats->holder = NULL;
+               MXUserHistoSample(histo, value, GetReturnAddress());
             }
          }
       }