Changeset 21363 in vbox for trunk/src/VBox/VMM
- Timestamp:
- Jul 7, 2009 5:10:52 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 49715
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/PDMDevHlp.cpp
r20927 r21363 1217 1217 /** @copydoc PDMDEVHLPR3::pfnPDMQueueCreate */ 1218 1218 static DECLCALLBACK(int) pdmR3DevHlp_PDMQueueCreate(PPDMDEVINS pDevIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval, 1219 PFNPDMQUEUEDEV pfnCallback, bool fGCEnabled, PPDMQUEUE *ppQueue)1220 { 1221 PDMDEV_ASSERT_DEVINS(pDevIns); 1222 LogFlow(("pdmR3DevHlp_PDMQueueCreate: caller='%s'/%d: cbItem=%#x cItems=%#x cMilliesInterval=%u pfnCallback=%p fGCEnabled=%RTbool p pQueue=%p\n",1223 pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, cbItem, cItems, cMilliesInterval, pfnCallback, fGCEnabled, p pQueue));1219 PFNPDMQUEUEDEV pfnCallback, bool fGCEnabled, const char *pszName, PPDMQUEUE *ppQueue) 1220 { 1221 PDMDEV_ASSERT_DEVINS(pDevIns); 1222 LogFlow(("pdmR3DevHlp_PDMQueueCreate: caller='%s'/%d: cbItem=%#x cItems=%#x cMilliesInterval=%u pfnCallback=%p fGCEnabled=%RTbool pszName=%p:{%s} ppQueue=%p\n", 1223 pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, cbItem, cItems, cMilliesInterval, pfnCallback, fGCEnabled, pszName, pszName, ppQueue)); 1224 1224 1225 1225 PVM pVM = pDevIns->Internal.s.pVMR3; 1226 1226 VM_ASSERT_EMT(pVM); 1227 int rc = PDMR3QueueCreateDevice(pVM, pDevIns, cbItem, cItems, cMilliesInterval, pfnCallback, fGCEnabled, ppQueue); 1227 1228 if (pDevIns->iInstance > 0) 1229 { 1230 pszName = MMR3HeapAPrintf(pVM, MM_TAG_PDM_DEVICE_DESC, "%s-%u", pszName, pDevIns->iInstance); 1231 AssertLogRelReturn(pszName, VERR_NO_MEMORY); 1232 } 1233 1234 int rc = PDMR3QueueCreateDevice(pVM, pDevIns, cbItem, cItems, cMilliesInterval, pfnCallback, fGCEnabled, pszName, ppQueue); 1228 1235 1229 1236 LogFlow(("pdmR3DevHlp_PDMQueueCreate: caller='%s'/%d: returns %Rrc *ppQueue=%p\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc, *ppQueue)); -
trunk/src/VBox/VMM/PDMDevice.cpp
r21188 r21363 137 137 AssertReleaseRCReturn(rc, rc); 138 138 139 rc = PDMR3QueueCreateInternal(pVM, sizeof(PDMDEVHLPTASK), 8, 0, pdmR3DevHlpQueueConsumer, true, &pVM->pdm.s.pDevHlpQueueR3); 139 rc = PDMR3QueueCreateInternal(pVM, sizeof(PDMDEVHLPTASK), 8, 0, pdmR3DevHlpQueueConsumer, true, "DevHlp", 140 &pVM->pdm.s.pDevHlpQueueR3); 140 141 AssertRCReturn(rc, rc); 141 142 pVM->pdm.s.pDevHlpQueueR0 = PDMQueueR0Ptr(pVM->pdm.s.pDevHlpQueueR3); -
trunk/src/VBox/VMM/PDMDriver.cpp
r21188 r21363 815 815 816 816 /** @copydoc PDMDRVHLP::pfnPDMQueueCreate */ 817 static DECLCALLBACK(int) pdmR3DrvHlp_PDMQueueCreate(PPDMDRVINS pDrvIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval, PFNPDMQUEUEDRV pfnCallback, PPDMQUEUE *ppQueue) 818 { 819 PDMDRV_ASSERT_DRVINS(pDrvIns); 820 LogFlow(("pdmR3DrvHlp_PDMQueueCreate: caller='%s'/%d: cbItem=%d cItems=%d cMilliesInterval=%d pfnCallback=%p ppQueue=%p\n", 821 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, cbItem, cItems, cMilliesInterval, pfnCallback, ppQueue, ppQueue)); 822 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM); 823 824 int rc = PDMR3QueueCreateDriver(pDrvIns->Internal.s.pVM, pDrvIns, cbItem, cItems, cMilliesInterval, pfnCallback, ppQueue); 817 static DECLCALLBACK(int) pdmR3DrvHlp_PDMQueueCreate(PPDMDRVINS pDrvIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval, 818 PFNPDMQUEUEDRV pfnCallback, const char *pszName, PPDMQUEUE *ppQueue) 819 { 820 PDMDRV_ASSERT_DRVINS(pDrvIns); 821 LogFlow(("pdmR3DrvHlp_PDMQueueCreate: caller='%s'/%d: cbItem=%d cItems=%d cMilliesInterval=%d pfnCallback=%p pszName=%p:{%s} ppQueue=%p\n", 822 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, cbItem, cItems, cMilliesInterval, pfnCallback, pszName, pszName, ppQueue, ppQueue)); 823 PVM pVM = pDrvIns->Internal.s.pVM; 824 VM_ASSERT_EMT(pVM); 825 826 if (pDrvIns->iInstance > 0) 827 { 828 pszName = MMR3HeapAPrintf(pVM, MM_TAG_PDM_DRIVER_DESC, "%s-%u", pszName, pDrvIns->iInstance); 829 AssertLogRelReturn(pszName, VERR_NO_MEMORY); 830 } 831 832 int rc = PDMR3QueueCreateDriver(pVM, pDrvIns, cbItem, cItems, cMilliesInterval, pfnCallback, pszName, ppQueue); 825 833 826 834 LogFlow(("pdmR3DrvHlp_PDMQueueCreate: caller='%s'/%d: returns %Rrc *ppQueue=%p\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, rc, *ppQueue)); 827 835 return rc; 828 }829 830 831 /** @copydoc PDMDRVHLP::pfnPDMPollerRegister */832 static DECLCALLBACK(int) pdmR3DrvHlp_PDMPollerRegister(PPDMDRVINS pDrvIns, PFNPDMDRVPOLLER pfnPoller)833 {834 PDMDRV_ASSERT_DRVINS(pDrvIns);835 AssertLogRelMsgFailedReturn(("pdmR3DrvHlp_PDMPollerRegister: caller='%s'/%d: pfnPoller=%p -> VERR_NOT_SUPPORTED\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, pfnPoller),836 VERR_NOT_SUPPORTED);837 836 } 838 837 … … 1063 1062 pdmR3DrvHlp_VMSetRuntimeErrorV, 1064 1063 pdmR3DrvHlp_PDMQueueCreate, 1065 pdmR3DrvHlp_PDMPollerRegister,1066 1064 pdmR3DrvHlp_TMGetVirtualFreq, 1067 1065 pdmR3DrvHlp_TMGetVirtualTime, -
trunk/src/VBox/VMM/PDMInternal.h
r21188 r21363 700 700 /** LIFO of pending items - GC. */ 701 701 RCPTRTYPE(PPDMQUEUEITEMCORE) volatile pPendingRC; 702 702 703 /** Item size (bytes). */ 703 RTUINTcbItem;704 uint32_t cbItem; 704 705 /** Number of items in the queue. */ 705 RTUINTcItems;706 uint32_t cItems; 706 707 /** Index to the free head (where we insert). */ 707 708 uint32_t volatile iFreeHead; 708 709 /** Index to the free tail (where we remove). */ 709 710 uint32_t volatile iFreeTail; 711 712 /** Unqiue queue name. */ 713 R3PTRTYPE(const char *) pszName; 714 #if HC_ARCH_BITS == 32 715 RTR3PTR Alignment1; 716 #endif 717 /** Stat: Times PDMQueueAlloc fails. */ 718 STAMCOUNTER StatAllocFailures; 719 /** Stat: PDMQueueInsert calls. */ 720 STAMCOUNTER StatInsert; 721 /** Stat: Queue flushes. */ 722 STAMCOUNTER StatFlush; 723 /** Stat: Queue flushes with pending items left over. */ 724 STAMCOUNTER StatFlushLeftovers; 725 #ifdef VBOX_WITH_STATISTICS 726 /** State: Profiling the flushing. */ 727 STAMPROFILE StatFlushPrf; 728 #endif 710 729 711 730 /** Array of pointers to free items. Variable size. */ -
trunk/src/VBox/VMM/PDMQueue.cpp
r21153 r21363 57 57 * If 0 then the emulation thread will be notified whenever an item arrives. 58 58 * @param fRZEnabled Set if the queue will be used from RC/R0 and need to be allocated from the hyper heap. 59 * @param pszName The queue name. Unique. Not copied. 59 60 * @param ppQueue Where to store the queue handle. 60 61 */ 61 static int pdmR3QueueCreate(PVM pVM, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval, bool fRZEnabled, PPDMQUEUE *ppQueue) 62 static int pdmR3QueueCreate(PVM pVM, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval, bool fRZEnabled, 63 const char *pszName, PPDMQUEUE *ppQueue) 62 64 { 63 65 /* … … 95 97 pQueue->pVMR0 = fRZEnabled ? pVM->pVMR0 : NIL_RTR0PTR; 96 98 pQueue->pVMRC = fRZEnabled ? pVM->pVMRC : NIL_RTRCPTR; 99 pQueue->pszName = pszName; 97 100 pQueue->cMilliesInterval = cMilliesInterval; 98 101 //pQueue->pTimer = NULL; … … 174 177 } 175 178 179 /* 180 * Register the statistics. 181 */ 182 STAMR3RegisterF(pVM, &pQueue->cbItem, STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Item size.", "/PDM/Queue/%s/cbItem", pQueue->pszName); 183 STAMR3RegisterF(pVM, &pQueue->cItems, STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Queue size.", "/PDM/Queue/%s/cItems", pQueue->pszName); 184 STAMR3RegisterF(pVM, &pQueue->StatAllocFailures, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "PDMQueueAlloc failures.", "/PDM/Queue/%s/AllocFailures", pQueue->pszName); 185 STAMR3RegisterF(pVM, &pQueue->StatInsert, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "Calls to PDMQueueInsert.", "/PDM/Queue/%s/Insert", pQueue->pszName); 186 STAMR3RegisterF(pVM, &pQueue->StatFlush, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "Calls to pdmR3QueueFlush.", "/PDM/Queue/%s/Flush", pQueue->pszName); 187 STAMR3RegisterF(pVM, &pQueue->StatFlushLeftovers, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Left over items after flush.", "/PDM/Queue/%s/FlushLeftovers", pQueue->pszName); 188 #ifdef VBOX_WITH_STATISTICS 189 STAMR3RegisterF(pVM, &pQueue->StatFlushPrf, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "Profiling pdmR3QueueFlush.", "/PDM/Queue/%s/FlushPrf", pQueue->pszName); 190 #endif 191 176 192 *ppQueue = pQueue; 177 193 return VINF_SUCCESS; … … 191 207 * @param pfnCallback The consumer function. 192 208 * @param fRZEnabled Set if the queue must be usable from RC/R0. 209 * @param pszName The queue name. Unique. Not copied. 193 210 * @param ppQueue Where to store the queue handle on success. 194 211 * @thread Emulation thread only. 195 212 */ 196 213 VMMR3DECL(int) PDMR3QueueCreateDevice(PVM pVM, PPDMDEVINS pDevIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval, 197 PFNPDMQUEUEDEV pfnCallback, bool fRZEnabled, PPDMQUEUE *ppQueue)198 { 199 LogFlow(("PDMR3QueueCreateDevice: pDevIns=%p cbItem=%d cItems=%d cMilliesInterval=%d pfnCallback=%p fRZEnabled=%RTbool \n",214 PFNPDMQUEUEDEV pfnCallback, bool fRZEnabled, const char *pszName, PPDMQUEUE *ppQueue) 215 { 216 LogFlow(("PDMR3QueueCreateDevice: pDevIns=%p cbItem=%d cItems=%d cMilliesInterval=%d pfnCallback=%p fRZEnabled=%RTbool pszName=%s\n", 200 217 pDevIns, cbItem, cItems, cMilliesInterval, pfnCallback, fRZEnabled)); 201 218 … … 214 231 */ 215 232 PPDMQUEUE pQueue; 216 int rc = pdmR3QueueCreate(pVM, cbItem, cItems, cMilliesInterval, fRZEnabled, &pQueue);233 int rc = pdmR3QueueCreate(pVM, cbItem, cItems, cMilliesInterval, fRZEnabled, pszName, &pQueue); 217 234 if (RT_SUCCESS(rc)) 218 235 { … … 240 257 * If 0 then the emulation thread will be notified whenever an item arrives. 241 258 * @param pfnCallback The consumer function. 259 * @param pszName The queue name. Unique. Not copied. 242 260 * @param ppQueue Where to store the queue handle on success. 243 261 * @thread Emulation thread only. 244 262 */ 245 263 VMMR3DECL(int) PDMR3QueueCreateDriver(PVM pVM, PPDMDRVINS pDrvIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval, 246 PFNPDMQUEUEDRV pfnCallback, PPDMQUEUE *ppQueue)247 { 248 LogFlow(("PDMR3QueueCreateDriver: pDrvIns=%p cbItem=%d cItems=%d cMilliesInterval=%d pfnCallback=%p \n",249 pDrvIns, cbItem, cItems, cMilliesInterval, pfnCallback ));264 PFNPDMQUEUEDRV pfnCallback, const char *pszName, PPDMQUEUE *ppQueue) 265 { 266 LogFlow(("PDMR3QueueCreateDriver: pDrvIns=%p cbItem=%d cItems=%d cMilliesInterval=%d pfnCallback=%p pszName=%s\n", 267 pDrvIns, cbItem, cItems, cMilliesInterval, pfnCallback, pszName)); 250 268 251 269 /* … … 263 281 */ 264 282 PPDMQUEUE pQueue; 265 int rc = pdmR3QueueCreate(pVM, cbItem, cItems, cMilliesInterval, false, &pQueue);283 int rc = pdmR3QueueCreate(pVM, cbItem, cItems, cMilliesInterval, false, pszName, &pQueue); 266 284 if (RT_SUCCESS(rc)) 267 285 { … … 289 307 * @param pfnCallback The consumer function. 290 308 * @param fRZEnabled Set if the queue must be usable from RC/R0. 309 * @param pszName The queue name. Unique. Not copied. 291 310 * @param ppQueue Where to store the queue handle on success. 292 311 * @thread Emulation thread only. 293 312 */ 294 313 VMMR3DECL(int) PDMR3QueueCreateInternal(PVM pVM, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval, 295 PFNPDMQUEUEINT pfnCallback, bool fRZEnabled, PPDMQUEUE *ppQueue)296 { 297 LogFlow(("PDMR3QueueCreateInternal: cbItem=%d cItems=%d cMilliesInterval=%d pfnCallback=%p fRZEnabled=%RTbool \n",298 cbItem, cItems, cMilliesInterval, pfnCallback, fRZEnabled ));314 PFNPDMQUEUEINT pfnCallback, bool fRZEnabled, const char *pszName, PPDMQUEUE *ppQueue) 315 { 316 LogFlow(("PDMR3QueueCreateInternal: cbItem=%d cItems=%d cMilliesInterval=%d pfnCallback=%p fRZEnabled=%RTbool pszName=%s\n", 317 cbItem, cItems, cMilliesInterval, pfnCallback, fRZEnabled, pszName)); 299 318 300 319 /* … … 312 331 */ 313 332 PPDMQUEUE pQueue; 314 int rc = pdmR3QueueCreate(pVM, cbItem, cItems, cMilliesInterval, fRZEnabled, &pQueue);333 int rc = pdmR3QueueCreate(pVM, cbItem, cItems, cMilliesInterval, fRZEnabled, pszName, &pQueue); 315 334 if (RT_SUCCESS(rc)) 316 335 { … … 337 356 * @param pfnCallback The consumer function. 338 357 * @param pvUser The user argument to the consumer function. 358 * @param pszName The queue name. Unique. Not copied. 339 359 * @param ppQueue Where to store the queue handle on success. 340 360 * @thread Emulation thread only. 341 361 */ 342 VMMR3DECL(int) PDMR3QueueCreateExternal(PVM pVM, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval, PFNPDMQUEUEEXT pfnCallback, void *pvUser, PPDMQUEUE *ppQueue)343 { 344 LogFlow(("PDMR3QueueCreateExternal: cbItem=%d cItems=%d cMilliesInterval=%d pfnCallback=%p \n", cbItem, cItems, cMilliesInterval, pfnCallback));362 VMMR3DECL(int) PDMR3QueueCreateExternal(PVM pVM, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval, PFNPDMQUEUEEXT pfnCallback, void *pvUser, const char *pszName, PPDMQUEUE *ppQueue) 363 { 364 LogFlow(("PDMR3QueueCreateExternal: cbItem=%d cItems=%d cMilliesInterval=%d pfnCallback=%p pszName=%s\n", cbItem, cItems, cMilliesInterval, pfnCallback, pszName)); 345 365 346 366 /* … … 358 378 */ 359 379 PPDMQUEUE pQueue; 360 int rc = pdmR3QueueCreate(pVM, cbItem, cItems, cMilliesInterval, false, &pQueue);380 int rc = pdmR3QueueCreate(pVM, cbItem, cItems, cMilliesInterval, false, pszName, &pQueue); 361 381 if (RT_SUCCESS(rc)) 362 382 { … … 438 458 pQueue->pVMR3 = NULL; 439 459 pdmUnlock(pVM); 460 461 /* 462 * Deregister statistics. 463 */ 464 STAMR3Deregister(pVM, &pQueue->cbItem); 465 STAMR3Deregister(pVM, &pQueue->cbItem); 466 STAMR3Deregister(pVM, &pQueue->StatInsert); 467 STAMR3Deregister(pVM, &pQueue->StatFlush); 468 STAMR3Deregister(pVM, &pQueue->StatFlushLeftovers); 469 #ifdef VBOX_WITH_STATISTICS 470 STAMR3Deregister(pVM, &pQueue->StatFlushPrf); 471 #endif 440 472 441 473 /* … … 664 696 static bool pdmR3QueueFlush(PPDMQUEUE pQueue) 665 697 { 698 STAM_PROFILE_START(&pQueue->StatFlushPrf,p); 699 666 700 /* 667 701 * Get the lists. … … 804 838 } 805 839 } 840 841 STAM_REL_COUNTER_INC(&pQueue->StatFlushLeftovers); 842 STAM_PROFILE_STOP(&pQueue->StatFlushPrf,p); 806 843 return false; 807 844 } 808 845 846 STAM_PROFILE_STOP(&pQueue->StatFlushPrf,p); 809 847 return true; 810 848 } -
trunk/src/VBox/VMM/VMMAll/PDMAllQueue.cpp
r21128 r21363 58 58 i = pQueue->iFreeTail; 59 59 if (i == pQueue->iFreeHead) 60 { 61 STAM_REL_COUNTER_INC(&pQueue->StatAllocFailures); 60 62 return NULL; 63 } 61 64 pNew = pQueue->aFreeItems[i].CTX_SUFF(pItem); 62 65 iNext = (i + 1) % (pQueue->cItems + PDMQUEUE_FREE_SLACK); … … 98 101 #endif 99 102 } 103 STAM_REL_COUNTER_INC(&pQueue->StatInsert); 100 104 } 101 105 -
trunk/src/VBox/VMM/testcase/tstVMStructGC.cpp
r20875 r21363 396 396 GEN_CHECK_OFF(PDMQUEUE, iFreeHead); 397 397 GEN_CHECK_OFF(PDMQUEUE, iFreeTail); 398 GEN_CHECK_OFF(PDMQUEUE, pszName); 399 GEN_CHECK_OFF(PDMQUEUE, StatAllocFailures); 400 GEN_CHECK_OFF(PDMQUEUE, StatInsert); 401 GEN_CHECK_OFF(PDMQUEUE, StatFlush); 402 GEN_CHECK_OFF(PDMQUEUE, StatFlushLeftovers); 398 403 GEN_CHECK_OFF(PDMQUEUE, aFreeItems); 399 404 GEN_CHECK_OFF(PDMQUEUE, aFreeItems[1]);
Note:
See TracChangeset
for help on using the changeset viewer.