summaryrefslogtreecommitdiff
path: root/src/VBox/VMM/VMMR3
diff options
context:
space:
mode:
authorvboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2013-06-11 13:34:40 +0000
committervboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2013-06-11 13:34:40 +0000
commit8114e65ceb33d8d9da022e37c376017fc7b592c3 (patch)
tree7d98b67f66426f69e67e9559a42bd4a5c39887ee /src/VBox/VMM/VMMR3
parentc55be6f8931e11f000152db6fd36833b7ad48c79 (diff)
downloadVirtualBox-svn-8114e65ceb33d8d9da022e37c376017fc7b592c3.tar.gz
STAMR3Deregister* optimizations. Relevant for both startup and shutdown times.
git-svn-id: https://www.virtualbox.org/svn/vbox/trunk@46493 cfe28804-0f27-0410-a406-dd0f0b0b656f
Diffstat (limited to 'src/VBox/VMM/VMMR3')
-rw-r--r--src/VBox/VMM/VMMR3/PATM.cpp42
-rw-r--r--src/VBox/VMM/VMMR3/PDMAsyncCompletion.cpp134
-rw-r--r--src/VBox/VMM/VMMR3/PDMAsyncCompletionFile.cpp4
-rw-r--r--src/VBox/VMM/VMMR3/PDMBlkCache.cpp5
-rw-r--r--src/VBox/VMM/VMMR3/PDMCritSect.cpp29
-rw-r--r--src/VBox/VMM/VMMR3/PDMDriver.cpp2
-rw-r--r--src/VBox/VMM/VMMR3/PDMQueue.cpp11
-rw-r--r--src/VBox/VMM/VMMR3/PGMHandler.cpp9
-rw-r--r--src/VBox/VMM/VMMR3/STAM.cpp167
9 files changed, 184 insertions, 219 deletions
diff --git a/src/VBox/VMM/VMMR3/PATM.cpp b/src/VBox/VMM/VMMR3/PATM.cpp
index 8f6482adcff..f82a6836f1f 100644
--- a/src/VBox/VMM/VMMR3/PATM.cpp
+++ b/src/VBox/VMM/VMMR3/PATM.cpp
@@ -5630,23 +5630,8 @@ int patmR3RemovePatch(PVM pVM, PPATMPATCHREC pPatchRec, bool fForceRemove)
#ifdef VBOX_WITH_STATISTICS
if (PATM_STAT_INDEX_IS_VALID(pPatchRec->patch.uPatchIdx))
{
- STAMR3Deregister(pVM, &pPatchRec->patch);
-#ifndef DEBUG_sandervl
- STAMR3Deregister(pVM, &pVM->patm.s.pStatsHC[pPatchRec->patch.uPatchIdx]);
- STAMR3Deregister(pVM, &pPatchRec->patch.cbPatchBlockSize);
- STAMR3Deregister(pVM, &pPatchRec->patch.cbPatchJump);
- STAMR3Deregister(pVM, &pPatchRec->patch.cbPrivInstr);
- STAMR3Deregister(pVM, &pPatchRec->patch.cCodeWrites);
- STAMR3Deregister(pVM, &pPatchRec->patch.cInvalidWrites);
- STAMR3Deregister(pVM, &pPatchRec->patch.cTraps);
- STAMR3Deregister(pVM, &pPatchRec->patch.flags);
- STAMR3Deregister(pVM, &pPatchRec->patch.nrJumpRecs);
- STAMR3Deregister(pVM, &pPatchRec->patch.nrFixups);
- STAMR3Deregister(pVM, &pPatchRec->patch.opcode);
- STAMR3Deregister(pVM, &pPatchRec->patch.uState);
- STAMR3Deregister(pVM, &pPatchRec->patch.uOldState);
- STAMR3Deregister(pVM, &pPatchRec->patch.uOpMode);
-#endif
+ STAMR3DeregisterF(pVM->pUVM, "/PATM/Stats/Patch/0x%RRv", pPatchRec->patch.pPrivInstrGC);
+ STAMR3DeregisterF(pVM->pUVM, "/PATM/Stats/PatchBD/0x%RRv*", pPatchRec->patch.pPrivInstrGC);
}
#endif
@@ -5748,33 +5733,18 @@ int patmR3RefreshPatch(PVM pVM, PPATMPATCHREC pPatchRec)
pTrampolinePatchesHead = pPatch->pTrampolinePatchesHead;
}
- /** Note: quite ugly to enable/disable/remove/insert old and new patches, but there's no easy way around it. */
+ /* Note: quite ugly to enable/disable/remove/insert old and new patches, but there's no easy way around it. */
rc = PATMR3DisablePatch(pVM, pInstrGC);
AssertRC(rc);
- /** Kick it out of the lookup tree to make sure PATMR3InstallPatch doesn't fail (hack alert) */
+ /* Kick it out of the lookup tree to make sure PATMR3InstallPatch doesn't fail (hack alert) */
RTAvloU32Remove(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pPatchRec->Core.Key);
#ifdef VBOX_WITH_STATISTICS
if (PATM_STAT_INDEX_IS_VALID(pPatchRec->patch.uPatchIdx))
{
- STAMR3Deregister(pVM, &pPatchRec->patch);
-#ifndef DEBUG_sandervl
- STAMR3Deregister(pVM, &pVM->patm.s.pStatsHC[pPatchRec->patch.uPatchIdx]);
- STAMR3Deregister(pVM, &pPatchRec->patch.cbPatchBlockSize);
- STAMR3Deregister(pVM, &pPatchRec->patch.cbPatchJump);
- STAMR3Deregister(pVM, &pPatchRec->patch.cbPrivInstr);
- STAMR3Deregister(pVM, &pPatchRec->patch.cCodeWrites);
- STAMR3Deregister(pVM, &pPatchRec->patch.cInvalidWrites);
- STAMR3Deregister(pVM, &pPatchRec->patch.cTraps);
- STAMR3Deregister(pVM, &pPatchRec->patch.flags);
- STAMR3Deregister(pVM, &pPatchRec->patch.nrJumpRecs);
- STAMR3Deregister(pVM, &pPatchRec->patch.nrFixups);
- STAMR3Deregister(pVM, &pPatchRec->patch.opcode);
- STAMR3Deregister(pVM, &pPatchRec->patch.uState);
- STAMR3Deregister(pVM, &pPatchRec->patch.uOldState);
- STAMR3Deregister(pVM, &pPatchRec->patch.uOpMode);
-#endif
+ STAMR3DeregisterF(pVM->pUVM, "/PATM/Stats/Patch/0x%RRv", pPatchRec->patch.pPrivInstrGC);
+ STAMR3DeregisterF(pVM->pUVM, "/PATM/Stats/PatchBD/0x%RRv*", pPatchRec->patch.pPrivInstrGC);
}
#endif
diff --git a/src/VBox/VMM/VMMR3/PDMAsyncCompletion.cpp b/src/VBox/VMM/VMMR3/PDMAsyncCompletion.cpp
index 83c495ab507..6b8e5604ae6 100644
--- a/src/VBox/VMM/VMMR3/PDMAsyncCompletion.cpp
+++ b/src/VBox/VMM/VMMR3/PDMAsyncCompletion.cpp
@@ -1048,229 +1048,166 @@ static int pdmR3AsyncCompletionStatisticsRegister(PPDMASYNCCOMPLETIONENDPOINT pE
pEndpoint->tsIntervalStartMs = RTTimeMilliTS();
- for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimesNs); i++)
- {
+ for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimesNs) && RT_SUCCESS(rc); i++)
rc = STAMR3RegisterF(pVM, &pEndpoint->StatTaskRunTimesNs[i], STAMTYPE_COUNTER,
STAMVISIBILITY_USED, STAMUNIT_OCCURENCES,
"Nanosecond resolution runtime statistics",
"/PDM/AsyncCompletion/File/%s/TaskRun1Ns-%u-%u",
RTPathFilename(pEndpoint->pszUri), i*100, i*100+100-1);
- if (RT_FAILURE(rc))
- break;
- }
- if (RT_SUCCESS(rc))
- {
- for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimesUs); i++)
- {
- rc = STAMR3RegisterF(pVM, &pEndpoint->StatTaskRunTimesUs[i], STAMTYPE_COUNTER,
- STAMVISIBILITY_USED, STAMUNIT_OCCURENCES,
- "Microsecond resolution runtime statistics",
- "/PDM/AsyncCompletion/File/%s/TaskRun2MicroSec-%u-%u",
- RTPathFilename(pEndpoint->pszUri), i*100, i*100+100-1);
- if (RT_FAILURE(rc))
- break;
- }
- }
+ for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimesUs) && RT_SUCCESS(rc); i++)
+ rc = STAMR3RegisterF(pVM, &pEndpoint->StatTaskRunTimesUs[i], STAMTYPE_COUNTER,
+ STAMVISIBILITY_USED, STAMUNIT_OCCURENCES,
+ "Microsecond resolution runtime statistics",
+ "/PDM/AsyncCompletion/File/%s/TaskRun2MicroSec-%u-%u",
+ RTPathFilename(pEndpoint->pszUri), i*100, i*100+100-1);
- if (RT_SUCCESS(rc))
- {
- for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimesMs); i++)
- {
- rc = STAMR3RegisterF(pVM, &pEndpoint->StatTaskRunTimesMs[i], STAMTYPE_COUNTER,
- STAMVISIBILITY_USED, STAMUNIT_OCCURENCES,
- "Milliseconds resolution runtime statistics",
- "/PDM/AsyncCompletion/File/%s/TaskRun3Ms-%u-%u",
- RTPathFilename(pEndpoint->pszUri), i*100, i*100+100-1);
- if (RT_FAILURE(rc))
- break;
- }
- }
+ for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimesMs) && RT_SUCCESS(rc); i++)
+ rc = STAMR3RegisterF(pVM, &pEndpoint->StatTaskRunTimesMs[i], STAMTYPE_COUNTER,
+ STAMVISIBILITY_USED, STAMUNIT_OCCURENCES,
+ "Milliseconds resolution runtime statistics",
+ "/PDM/AsyncCompletion/File/%s/TaskRun3Ms-%u-%u",
+ RTPathFilename(pEndpoint->pszUri), i*100, i*100+100-1);
- if (RT_SUCCESS(rc))
- {
- for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimesMs); i++)
- {
- rc = STAMR3RegisterF(pVM, &pEndpoint->StatTaskRunTimesSec[i], STAMTYPE_COUNTER,
- STAMVISIBILITY_USED, STAMUNIT_OCCURENCES,
- "Second resolution runtime statistics",
- "/PDM/AsyncCompletion/File/%s/TaskRun4Sec-%u-%u",
- RTPathFilename(pEndpoint->pszUri), i*10, i*10+10-1);
- if (RT_FAILURE(rc))
- break;
- }
- }
+ for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimesMs) && RT_SUCCESS(rc); i++)
+ rc = STAMR3RegisterF(pVM, &pEndpoint->StatTaskRunTimesSec[i], STAMTYPE_COUNTER,
+ STAMVISIBILITY_USED, STAMUNIT_OCCURENCES,
+ "Second resolution runtime statistics",
+ "/PDM/AsyncCompletion/File/%s/TaskRun4Sec-%u-%u",
+ RTPathFilename(pEndpoint->pszUri), i*10, i*10+10-1);
if (RT_SUCCESS(rc))
- {
rc = STAMR3RegisterF(pVM, &pEndpoint->StatTaskRunOver100Sec, STAMTYPE_COUNTER,
STAMVISIBILITY_USED, STAMUNIT_OCCURENCES,
"Tasks which ran more than 100sec",
"/PDM/AsyncCompletion/File/%s/TaskRunSecGreater100Sec",
RTPathFilename(pEndpoint->pszUri));
- }
if (RT_SUCCESS(rc))
- {
rc = STAMR3RegisterF(pVM, &pEndpoint->StatIoOpsPerSec, STAMTYPE_COUNTER,
STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,
"Processed I/O operations per second",
"/PDM/AsyncCompletion/File/%s/IoOpsPerSec",
RTPathFilename(pEndpoint->pszUri));
- }
if (RT_SUCCESS(rc))
- {
rc = STAMR3RegisterF(pVM, &pEndpoint->StatIoOpsStarted, STAMTYPE_COUNTER,
STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,
"Started I/O operations for this endpoint",
"/PDM/AsyncCompletion/File/%s/IoOpsStarted",
RTPathFilename(pEndpoint->pszUri));
- }
if (RT_SUCCESS(rc))
- {
rc = STAMR3RegisterF(pVM, &pEndpoint->StatIoOpsCompleted, STAMTYPE_COUNTER,
STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,
"Completed I/O operations for this endpoint",
"/PDM/AsyncCompletion/File/%s/IoOpsCompleted",
RTPathFilename(pEndpoint->pszUri));
- }
if (RT_SUCCESS(rc))
- {
rc = STAMR3RegisterF(pVM, &pEndpoint->StatReqSizeSmaller512, STAMTYPE_COUNTER,
STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,
"Number of requests with a size smaller than 512 bytes",
"/PDM/AsyncCompletion/File/%s/ReqSizeSmaller512",
RTPathFilename(pEndpoint->pszUri));
- }
if (RT_SUCCESS(rc))
- {
rc = STAMR3RegisterF(pVM, &pEndpoint->StatReqSize512To1K, STAMTYPE_COUNTER,
STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,
"Number of requests with a size between 512 bytes and 1KB",
"/PDM/AsyncCompletion/File/%s/ReqSize512To1K",
RTPathFilename(pEndpoint->pszUri));
- }
if (RT_SUCCESS(rc))
- {
rc = STAMR3RegisterF(pVM, &pEndpoint->StatReqSize1KTo2K, STAMTYPE_COUNTER,
STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,
"Number of requests with a size between 1KB and 2KB",
"/PDM/AsyncCompletion/File/%s/ReqSize1KTo2K",
RTPathFilename(pEndpoint->pszUri));
- }
if (RT_SUCCESS(rc))
- {
rc = STAMR3RegisterF(pVM, &pEndpoint->StatReqSize2KTo4K, STAMTYPE_COUNTER,
STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,
"Number of requests with a size between 2KB and 4KB",
"/PDM/AsyncCompletion/File/%s/ReqSize2KTo4K",
RTPathFilename(pEndpoint->pszUri));
- }
if (RT_SUCCESS(rc))
- {
rc = STAMR3RegisterF(pVM, &pEndpoint->StatReqSize4KTo8K, STAMTYPE_COUNTER,
STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,
"Number of requests with a size between 4KB and 8KB",
"/PDM/AsyncCompletion/File/%s/ReqSize4KTo8K",
RTPathFilename(pEndpoint->pszUri));
- }
if (RT_SUCCESS(rc))
- {
rc = STAMR3RegisterF(pVM, &pEndpoint->StatReqSize8KTo16K, STAMTYPE_COUNTER,
STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,
"Number of requests with a size between 8KB and 16KB",
"/PDM/AsyncCompletion/File/%s/ReqSize8KTo16K",
RTPathFilename(pEndpoint->pszUri));
- }
if (RT_SUCCESS(rc))
- {
rc = STAMR3RegisterF(pVM, &pEndpoint->StatReqSize16KTo32K, STAMTYPE_COUNTER,
STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,
"Number of requests with a size between 16KB and 32KB",
"/PDM/AsyncCompletion/File/%s/ReqSize16KTo32K",
RTPathFilename(pEndpoint->pszUri));
- }
if (RT_SUCCESS(rc))
- {
rc = STAMR3RegisterF(pVM, &pEndpoint->StatReqSize32KTo64K, STAMTYPE_COUNTER,
STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,
"Number of requests with a size between 32KB and 64KB",
"/PDM/AsyncCompletion/File/%s/ReqSize32KTo64K",
RTPathFilename(pEndpoint->pszUri));
- }
if (RT_SUCCESS(rc))
- {
rc = STAMR3RegisterF(pVM, &pEndpoint->StatReqSize64KTo128K, STAMTYPE_COUNTER,
STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,
"Number of requests with a size between 64KB and 128KB",
"/PDM/AsyncCompletion/File/%s/ReqSize64KTo128K",
RTPathFilename(pEndpoint->pszUri));
- }
if (RT_SUCCESS(rc))
- {
rc = STAMR3RegisterF(pVM, &pEndpoint->StatReqSize128KTo256K, STAMTYPE_COUNTER,
STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,
"Number of requests with a size between 128KB and 256KB",
"/PDM/AsyncCompletion/File/%s/ReqSize128KTo256K",
RTPathFilename(pEndpoint->pszUri));
- }
if (RT_SUCCESS(rc))
- {
rc = STAMR3RegisterF(pVM, &pEndpoint->StatReqSize256KTo512K, STAMTYPE_COUNTER,
STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,
"Number of requests with a size between 256KB and 512KB",
"/PDM/AsyncCompletion/File/%s/ReqSize256KTo512K",
RTPathFilename(pEndpoint->pszUri));
- }
if (RT_SUCCESS(rc))
- {
rc = STAMR3RegisterF(pVM, &pEndpoint->StatReqSizeOver512K, STAMTYPE_COUNTER,
STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,
"Number of requests with a size over 512KB",
"/PDM/AsyncCompletion/File/%s/ReqSizeOver512K",
RTPathFilename(pEndpoint->pszUri));
- }
if (RT_SUCCESS(rc))
- {
rc = STAMR3RegisterF(pVM, &pEndpoint->StatReqsUnaligned512, STAMTYPE_COUNTER,
STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,
"Number of requests which size is not aligned to 512 bytes",
"/PDM/AsyncCompletion/File/%s/ReqsUnaligned512",
RTPathFilename(pEndpoint->pszUri));
- }
if (RT_SUCCESS(rc))
- {
rc = STAMR3RegisterF(pVM, &pEndpoint->StatReqsUnaligned4K, STAMTYPE_COUNTER,
STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,
"Number of requests which size is not aligned to 4KB",
"/PDM/AsyncCompletion/File/%s/ReqsUnaligned4K",
RTPathFilename(pEndpoint->pszUri));
- }
if (RT_SUCCESS(rc))
- {
rc = STAMR3RegisterF(pVM, &pEndpoint->StatReqsUnaligned8K, STAMTYPE_COUNTER,
STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,
"Number of requests which size is not aligned to 8KB",
"/PDM/AsyncCompletion/File/%s/ReqsUnaligned8K",
RTPathFilename(pEndpoint->pszUri));
- }
return rc;
}
@@ -1284,37 +1221,8 @@ static int pdmR3AsyncCompletionStatisticsRegister(PPDMASYNCCOMPLETIONENDPOINT pE
*/
static void pdmR3AsyncCompletionStatisticsDeregister(PPDMASYNCCOMPLETIONENDPOINT pEndpoint)
{
- PVM pVM = pEndpoint->pEpClass->pVM;
-
- for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimesNs); i++)
- STAMR3Deregister(pVM, &pEndpoint->StatTaskRunTimesNs[i]);
- for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimesUs); i++)
- STAMR3Deregister(pVM, &pEndpoint->StatTaskRunTimesUs[i]);
- for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimesMs); i++)
- STAMR3Deregister(pVM, &pEndpoint->StatTaskRunTimesMs[i]);
- for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimesMs); i++)
- STAMR3Deregister(pVM, &pEndpoint->StatTaskRunTimesSec[i]);
-
- STAMR3Deregister(pVM, &pEndpoint->StatTaskRunOver100Sec);
- STAMR3Deregister(pVM, &pEndpoint->StatIoOpsPerSec);
- STAMR3Deregister(pVM, &pEndpoint->StatIoOpsStarted);
- STAMR3Deregister(pVM, &pEndpoint->StatIoOpsCompleted);
-
- STAMR3Deregister(pVM, &pEndpoint->StatReqSizeSmaller512);
- STAMR3Deregister(pVM, &pEndpoint->StatReqSize512To1K);
- STAMR3Deregister(pVM, &pEndpoint->StatReqSize1KTo2K);
- STAMR3Deregister(pVM, &pEndpoint->StatReqSize2KTo4K);
- STAMR3Deregister(pVM, &pEndpoint->StatReqSize4KTo8K);
- STAMR3Deregister(pVM, &pEndpoint->StatReqSize8KTo16K);
- STAMR3Deregister(pVM, &pEndpoint->StatReqSize16KTo32K);
- STAMR3Deregister(pVM, &pEndpoint->StatReqSize32KTo64K);
- STAMR3Deregister(pVM, &pEndpoint->StatReqSize64KTo128K);
- STAMR3Deregister(pVM, &pEndpoint->StatReqSize128KTo256K);
- STAMR3Deregister(pVM, &pEndpoint->StatReqSize256KTo512K);
- STAMR3Deregister(pVM, &pEndpoint->StatReqSizeOver512K);
- STAMR3Deregister(pVM, &pEndpoint->StatReqsUnaligned512);
- STAMR3Deregister(pVM, &pEndpoint->StatReqsUnaligned4K);
- STAMR3Deregister(pVM, &pEndpoint->StatReqsUnaligned8K);
+ /* I hope this doesn't remove too much... */
+ STAMR3DeregisterF(pEndpoint->pEpClass->pVM->pUVM, "/PDM/AsyncCompletion/File/%s/*", RTPathFilename(pEndpoint->pszUri));
}
diff --git a/src/VBox/VMM/VMMR3/PDMAsyncCompletionFile.cpp b/src/VBox/VMM/VMMR3/PDMAsyncCompletionFile.cpp
index bd20b1ca6a9..afc1213395c 100644
--- a/src/VBox/VMM/VMMR3/PDMAsyncCompletionFile.cpp
+++ b/src/VBox/VMM/VMMR3/PDMAsyncCompletionFile.cpp
@@ -1153,8 +1153,8 @@ static int pdmacFileEpClose(PPDMASYNCCOMPLETIONENDPOINT pEndpoint)
RTFileClose(pEpFile->hFile);
#ifdef VBOX_WITH_STATISTICS
- STAMR3Deregister(pEpClassFile->Core.pVM, &pEpFile->StatRead);
- STAMR3Deregister(pEpClassFile->Core.pVM, &pEpFile->StatWrite);
+ /* Not sure if this might be unnecessary because of similar statement in pdmR3AsyncCompletionStatisticsDeregister? */
+ STAMR3DeregisterF(pEpClassFile->Core.pVM->pUVM, "/PDM/AsyncCompletion/File/%s/*", RTPathFilename(pEpFile->Core.pszUri));
#endif
return VINF_SUCCESS;
diff --git a/src/VBox/VMM/VMMR3/PDMBlkCache.cpp b/src/VBox/VMM/VMMR3/PDMBlkCache.cpp
index 80f574551a2..9551c6d4856 100644
--- a/src/VBox/VMM/VMMR3/PDMBlkCache.cpp
+++ b/src/VBox/VMM/VMMR3/PDMBlkCache.cpp
@@ -1241,9 +1241,8 @@ static int pdmR3BlkCacheRetain(PVM pVM, PPPDMBLKCACHE ppBlkCache, const char *pc
LogFlowFunc(("returns success\n"));
return VINF_SUCCESS;
}
- else
- rc = VERR_NO_MEMORY;
+ rc = VERR_NO_MEMORY;
RTSemRWDestroy(pBlkCache->SemRWEntries);
}
@@ -1445,7 +1444,7 @@ VMMR3DECL(void) PDMR3BlkCacheRelease(PPDMBLKCACHE pBlkCache)
RTSemRWDestroy(pBlkCache->SemRWEntries);
#ifdef VBOX_WITH_STATISTICS
- STAMR3Deregister(pCache->pVM, &pBlkCache->StatWriteDeferred);
+ STAMR3DeregisterF(pCache->pVM->pUVM, "/PDM/BlkCache/%s/Cache/DeferredWrites", pBlkCache->pszId);
#endif
RTStrFree(pBlkCache->pszId);
diff --git a/src/VBox/VMM/VMMR3/PDMCritSect.cpp b/src/VBox/VMM/VMMR3/PDMCritSect.cpp
index 21786512107..58e926d7450 100644
--- a/src/VBox/VMM/VMMR3/PDMCritSect.cpp
+++ b/src/VBox/VMM/VMMR3/PDMCritSect.cpp
@@ -524,17 +524,10 @@ static int pdmR3CritSectDeleteOne(PVM pVM, PUVM pUVM, PPDMCRITSECTINT pCritSect,
pCritSect->pVMR3 = NULL;
pCritSect->pVMR0 = NIL_RTR0PTR;
pCritSect->pVMRC = NIL_RTRCPTR;
+ if (!fFinal)
+ STAMR3DeregisterF(pVM->pUVM, "/PDM/CritSects/%s/*", pCritSect->pszName);
RTStrFree((char *)pCritSect->pszName);
pCritSect->pszName = NULL;
- if (!fFinal)
- {
- STAMR3Deregister(pVM, &pCritSect->StatContentionRZLock);
- STAMR3Deregister(pVM, &pCritSect->StatContentionRZUnlock);
- STAMR3Deregister(pVM, &pCritSect->StatContentionR3);
-#ifdef VBOX_WITH_STATISTICS
- STAMR3Deregister(pVM, &pCritSect->StatLocked);
-#endif
- }
return rc;
}
@@ -601,24 +594,10 @@ static int pdmR3CritSectRwDeleteOne(PVM pVM, PUVM pUVM, PPDMCRITSECTRWINT pCritS
pCritSect->pVMR3 = NULL;
pCritSect->pVMR0 = NIL_RTR0PTR;
pCritSect->pVMRC = NIL_RTRCPTR;
+ if (!fFinal)
+ STAMR3DeregisterF(pVM->pUVM, "/PDM/CritSectsRw/%s/*", pCritSect->pszName);
RTStrFree((char *)pCritSect->pszName);
pCritSect->pszName = NULL;
- if (!fFinal)
- {
- STAMR3Deregister(pVM, &pCritSect->StatContentionRZEnterExcl);
- STAMR3Deregister(pVM, &pCritSect->StatContentionRZLeaveExcl);
- STAMR3Deregister(pVM, &pCritSect->StatContentionRZEnterShared);
- STAMR3Deregister(pVM, &pCritSect->StatContentionRZLeaveShared);
- STAMR3Deregister(pVM, &pCritSect->StatRZEnterExcl);
- STAMR3Deregister(pVM, &pCritSect->StatRZEnterShared);
- STAMR3Deregister(pVM, &pCritSect->StatContentionR3EnterExcl);
- STAMR3Deregister(pVM, &pCritSect->StatContentionR3EnterShared);
- STAMR3Deregister(pVM, &pCritSect->StatR3EnterExcl);
- STAMR3Deregister(pVM, &pCritSect->StatR3EnterShared);
-#ifdef VBOX_WITH_STATISTICS
- STAMR3Deregister(pVM, &pCritSect->StatWriteLocked);
-#endif
- }
return RT_SUCCESS(rc1) ? rc2 : rc1;
}
diff --git a/src/VBox/VMM/VMMR3/PDMDriver.cpp b/src/VBox/VMM/VMMR3/PDMDriver.cpp
index b424bf349e2..7d29fdea471 100644
--- a/src/VBox/VMM/VMMR3/PDMDriver.cpp
+++ b/src/VBox/VMM/VMMR3/PDMDriver.cpp
@@ -1426,7 +1426,7 @@ static DECLCALLBACK(int) pdmR3DrvHlp_STAMDeregister(PPDMDRVINS pDrvIns, void *pv
PDMDRV_ASSERT_DRVINS(pDrvIns);
VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
- int rc = STAMR3DeregisterU(pDrvIns->Internal.s.pVMR3->pUVM, pvSample);
+ int rc = STAMR3DeregisterByAddr(pDrvIns->Internal.s.pVMR3->pUVM, pvSample);
AssertRC(rc);
return rc;
}
diff --git a/src/VBox/VMM/VMMR3/PDMQueue.cpp b/src/VBox/VMM/VMMR3/PDMQueue.cpp
index 67f51839204..d1fac474b4c 100644
--- a/src/VBox/VMM/VMMR3/PDMQueue.cpp
+++ b/src/VBox/VMM/VMMR3/PDMQueue.cpp
@@ -445,16 +445,7 @@ VMMR3_INT_DECL(int) PDMR3QueueDestroy(PPDMQUEUE pQueue)
/*
* Deregister statistics.
*/
- STAMR3Deregister(pVM, &pQueue->cbItem);
- STAMR3Deregister(pVM, &pQueue->cbItem);
- STAMR3Deregister(pVM, &pQueue->StatAllocFailures);
- STAMR3Deregister(pVM, &pQueue->StatInsert);
- STAMR3Deregister(pVM, &pQueue->StatFlush);
- STAMR3Deregister(pVM, &pQueue->StatFlushLeftovers);
-#ifdef VBOX_WITH_STATISTICS
- STAMR3Deregister(pVM, &pQueue->StatFlushPrf);
- STAMR3Deregister(pVM, (void *)&pQueue->cStatPending);
-#endif
+ STAMR3DeregisterF(pVM->pUVM, "/PDM/Queue/%s/cbItem", pQueue->pszName);
/*
* Destroy the timer and free it.
diff --git a/src/VBox/VMM/VMMR3/PGMHandler.cpp b/src/VBox/VMM/VMMR3/PGMHandler.cpp
index 7df19c67027..d2493a140f5 100644
--- a/src/VBox/VMM/VMMR3/PGMHandler.cpp
+++ b/src/VBox/VMM/VMMR3/PGMHandler.cpp
@@ -410,9 +410,8 @@ VMMDECL(int) PGMR3HandlerVirtualRegisterEx(PVM pVM, PGMVIRTHANDLERTYPE enmType,
pgmUnlock(pVM);
#ifdef VBOX_WITH_STATISTICS
- char szPath[256];
- RTStrPrintf(szPath, sizeof(szPath), "/PGM/VirtHandler/Calls/%RGv-%RGv", pNew->Core.Key, pNew->Core.KeyLast);
- rc = STAMR3Register(pVM, &pNew->Stat, STAMTYPE_PROFILE, STAMVISIBILITY_USED, szPath, STAMUNIT_TICKS_PER_CALL, pszDesc);
+ rc = STAMR3RegisterF(pVM, &pNew->Stat, STAMTYPE_PROFILE, STAMVISIBILITY_USED, STAMUNIT_TICKS_PER_CALL, pszDesc,
+ "/PGM/VirtHandler/Calls/%RGv-%RGv", pNew->Core.Key, pNew->Core.KeyLast);
AssertRC(rc);
#endif
return VINF_SUCCESS;
@@ -508,7 +507,9 @@ VMMDECL(int) PGMHandlerVirtualDeregister(PVM pVM, RTGCPTR GCPtr)
pgmUnlock(pVM);
- STAM_DEREG(pVM, &pCur->Stat);
+#ifdef VBOX_WITH_STATISTICS
+ STAMR3DeregisterF(pVM->pUVM, "/PGM/VirtHandler/Calls/%RGv-%RGv", pCur->Core.Key, pCur->Core.KeyLast);
+#endif
MMHyperFree(pVM, pCur);
return VINF_SUCCESS;
diff --git a/src/VBox/VMM/VMMR3/STAM.cpp b/src/VBox/VMM/VMMR3/STAM.cpp
index 9d8a2aa1f73..8bfe0e3af09 100644
--- a/src/VBox/VMM/VMMR3/STAM.cpp
+++ b/src/VBox/VMM/VMMR3/STAM.cpp
@@ -64,6 +64,13 @@
/*******************************************************************************
+* Defined Constants And Macros *
+*******************************************************************************/
+/** The maximum name length excluding the terminator. */
+#define STAM_MAX_NAME_LEN 239
+
+
+/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
/**
@@ -486,14 +493,11 @@ VMMR3DECL(int) STAMR3RegisterVU(PUVM pUVM, void *pvSample, STAMTYPE enmType, ST
{
AssertReturn(enmType != STAMTYPE_CALLBACK, VERR_INVALID_PARAMETER);
- char *pszFormattedName;
- RTStrAPrintfV(&pszFormattedName, pszName, args);
- if (!pszFormattedName)
- return VERR_NO_MEMORY;
+ char szFormattedName[STAM_MAX_NAME_LEN + 8];
+ size_t cch = RTStrPrintfV(szFormattedName, sizeof(szFormattedName), pszName, args);
+ AssertReturn(cch <= STAM_MAX_NAME_LEN, VERR_OUT_OF_RANGE);
- int rc = STAMR3RegisterU(pUVM, pvSample, enmType, enmVisibility, pszFormattedName, enmUnit, pszDesc);
- RTStrFree(pszFormattedName);
- return rc;
+ return STAMR3RegisterU(pUVM, pvSample, enmType, enmVisibility, szFormattedName, enmUnit, pszDesc);
}
@@ -1253,7 +1257,7 @@ static int stamR3RegisterU(PUVM pUVM, void *pvSample, PFNSTAMR3CALLBACKRESET pfn
AssertReturn(pszName[0] == '/', VERR_INVALID_NAME);
AssertReturn(pszName[1] != '/' && pszName[1], VERR_INVALID_NAME);
uint32_t const cchName = (uint32_t)strlen(pszName);
- AssertReturn(cchName < 256, VERR_OUT_OF_RANGE);
+ AssertReturn(cchName <= STAM_MAX_NAME_LEN, VERR_OUT_OF_RANGE);
AssertReturn(pszName[cchName - 1] != '/', VERR_INVALID_NAME);
AssertReturn(memchr(pszName, '\\', cchName) == NULL, VERR_INVALID_NAME);
@@ -1436,7 +1440,29 @@ static int stamR3RegisterU(PUVM pUVM, void *pvSample, PFNSTAMR3CALLBACKRESET pfn
/**
- * Deregisters a sample previously registered by STAR3Register().
+ * Destroys the statistics descriptor, unlinking it and freeing all resources.
+ *
+ * @returns VINF_SUCCESS
+ * @param pUVM Pointer to the user mode VM structure.
+ * @param pCur The descriptor to destroy.
+ */
+static int stamR3DestroyDesc(PUVM pUVM, PSTAMDESC pCur)
+{
+ RTListNodeRemove(&pCur->ListEntry);
+#ifdef STAM_WITH_LOOKUP_TREE
+ pCur->pLookup->pDesc = NULL; /** @todo free lookup nodes once it's working. */
+ stamR3LookupDecUsage(pCur->pLookup);
+ stamR3LookupMaybeFree(pCur->pLookup);
+#endif
+ RTMemFree(pCur);
+
+ return VINF_SUCCESS;
+}
+
+
+/**
+ * Deregisters a sample previously registered by STAR3Register() given its
+ * address.
*
* This is intended used for devices which can be unplugged and for
* temporary samples.
@@ -1445,10 +1471,15 @@ static int stamR3RegisterU(PUVM pUVM, void *pvSample, PFNSTAMR3CALLBACKRESET pfn
* @param pUVM Pointer to the user mode VM structure.
* @param pvSample Pointer to the sample registered with STAMR3Register().
*/
-VMMR3DECL(int) STAMR3DeregisterU(PUVM pUVM, void *pvSample)
+VMMR3DECL(int) STAMR3DeregisterByAddr(PUVM pUVM, void *pvSample)
{
UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
+ /* This is a complete waste of time when shutting down. */
+ VMSTATE enmState = VMR3GetStateU(pUVM);
+ if (enmState >= VMSTATE_DESTROYING)
+ return VINF_SUCCESS;
+
STAM_LOCK_WR(pUVM);
/*
@@ -1459,17 +1490,50 @@ VMMR3DECL(int) STAMR3DeregisterU(PUVM pUVM, void *pvSample)
RTListForEachSafe(&pUVM->stam.s.List, pCur, pNext, STAMDESC, ListEntry)
{
if (pCur->u.pv == pvSample)
+ rc = stamR3DestroyDesc(pUVM, pCur);
+ }
+
+ STAM_UNLOCK_WR(pUVM);
+ return rc;
+}
+
+
+/**
+ * Worker for STAMR3Deregister, STAMR3DeregisterV and STAMR3DeregisterF.
+ *
+ * @returns VBox status code.
+ * @retval VWRN_NOT_FOUND if no matching names found.
+ *
+ * @param pUVM Pointer to the user mode VM structure.
+ * @param pszPat The name pattern.
+ */
+static int stamR3DeregisterByPattern(PUVM pUVM, const char *pszPat)
+{
+ Assert(!strchr(pszPat, '|')); /* single pattern! */
+
+ int rc = VWRN_NOT_FOUND;
+ STAM_LOCK_WR(pUVM);
+
+ PSTAMDESC pLast;
+ PSTAMDESC pCur = stamR3LookupFindPatternDescRange(pUVM->stam.s.pRoot, &pUVM->stam.s.List, pszPat, &pLast);
+ if (pCur)
+ {
+ for (;;)
{
- RTListNodeRemove(&pCur->ListEntry);
-#ifdef STAM_WITH_LOOKUP_TREE
- pCur->pLookup->pDesc = NULL; /** @todo free lookup nodes once it's working. */
- stamR3LookupDecUsage(pCur->pLookup);
- stamR3LookupMaybeFree(pCur->pLookup);
-#endif
- RTMemFree(pCur);
- rc = VINF_SUCCESS;
+ PSTAMDESC pNext = RTListNodeGetNext(&pCur->ListEntry, STAMDESC, ListEntry);
+
+ if (RTStrSimplePatternMatch(pszPat, pCur->pszName))
+ rc = stamR3DestroyDesc(pUVM, pCur);
+
+ /* advance. */
+ if (pCur == pLast)
+ break;
+ pCur = pNext;
}
+ Assert(pLast);
}
+ else
+ Assert(!pLast);
STAM_UNLOCK_WR(pUVM);
return rc;
@@ -1477,18 +1541,71 @@ VMMR3DECL(int) STAMR3DeregisterU(PUVM pUVM, void *pvSample)
/**
- * Deregisters a sample previously registered by STAR3Register().
+ * Deregister zero or more samples given a (single) pattern matching their
+ * names.
*
- * This is intended used for devices which can be unplugged and for
- * temporary samples.
+ * @returns VBox status.
+ * @param pUVM Pointer to the user mode VM structure.
+ * @param pszPat The name pattern.
+ * @sa STAMR3DeregisterF, STAMR3DeregisterV
+ */
+VMMR3DECL(int) STAMR3Deregister(PUVM pUVM, const char *pszPat)
+{
+ UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
+
+ /* This is a complete waste of time when shutting down. */
+ VMSTATE enmState = VMR3GetStateU(pUVM);
+ if (enmState >= VMSTATE_DESTROYING)
+ return VINF_SUCCESS;
+
+ return stamR3DeregisterByPattern(pUVM, pszPat);
+}
+
+
+/**
+ * Deregister zero or more samples given a (single) pattern matching their
+ * names.
*
* @returns VBox status.
- * @param pVM Pointer to the VM.
- * @param pvSample Pointer to the sample registered with STAMR3Register().
+ * @param pUVM Pointer to the user mode VM structure.
+ * @param pszPatFmt The name pattern format string.
+ * @param ... Format string arguments.
+ * @sa STAMR3Deregister, STAMR3DeregisterV
*/
-VMMR3DECL(int) STAMR3Deregister(PVM pVM, void *pvSample)
+VMMR3DECL(int) STAMR3DeregisterF(PUVM pUVM, const char *pszPatFmt, ...)
{
- return STAMR3DeregisterU(pVM->pUVM, pvSample);
+ va_list va;
+ va_start(va, pszPatFmt);
+ int rc = STAMR3DeregisterV(pUVM, pszPatFmt, va);
+ va_end(va);
+ return rc;
+}
+
+
+/**
+ * Deregister zero or more samples given a (single) pattern matching their
+ * names.
+ *
+ * @returns VBox status.
+ * @param pUVM Pointer to the user mode VM structure.
+ * @param pszPatFmt The name pattern format string.
+ * @param va Format string arguments.
+ * @sa STAMR3Deregister, STAMR3DeregisterF
+ */
+VMMR3DECL(int) STAMR3DeregisterV(PUVM pUVM, const char *pszPatFmt, va_list va)
+{
+ UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
+
+ /* This is a complete waste of time when shutting down. */
+ VMSTATE enmState = VMR3GetStateU(pUVM);
+ if (enmState >= VMSTATE_DESTROYING)
+ return VINF_SUCCESS;
+
+ char szPat[STAM_MAX_NAME_LEN + 8];
+ size_t cchPat = RTStrPrintfV(szPat, sizeof(szPat), pszPatFmt, va);
+ AssertReturn(cchPat <= STAM_MAX_NAME_LEN, VERR_OUT_OF_RANGE);
+
+ return stamR3DeregisterByPattern(pUVM, szPat);
}