Changeset 45189 in vbox
- Timestamp:
- Mar 26, 2013 9:31:59 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/uvm.h
r45152 r45189 134 134 struct STAMUSERPERVM s; 135 135 #endif 136 uint8_t padding[6 624];136 uint8_t padding[6880]; 137 137 } stam; 138 138 -
trunk/src/VBox/VMM/VMMAll/PDMAllCritSectRw.cpp
r45178 r45189 110 110 AssertPtrReturn(pThis, RTLOCKVAL_SUB_CLASS_INVALID); 111 111 AssertReturn(pThis->s.Core.u32Magic == RTCRITSECTRW_MAGIC, RTLOCKVAL_SUB_CLASS_INVALID); 112 # ifdef PDMCRITSECTRW_STRICT112 #if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3) 113 113 AssertReturn(!(pThis->s.Core.fFlags & RTCRITSECT_FLAGS_NOP), RTLOCKVAL_SUB_CLASS_INVALID); 114 114 … … 131 131 AssertReturn(pThis->s.Core.u32Magic == RTCRITSECTRW_MAGIC, VERR_SEM_DESTROYED); 132 132 133 #if def PDMCRITSECTRW_STRICT133 #if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3) 134 134 RTTHREAD hThreadSelf = RTThreadSelfAutoAdopt(); 135 135 if (!fTryOnly) … … 165 165 if (ASMAtomicCmpXchgU64(&pThis->s.Core.u64State, u64State, u64OldState)) 166 166 { 167 #if def PDMCRITSECTRW_STRICT167 #if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3) 168 168 RTLockValidatorRecSharedAddOwner(pThis->s.Core.pValidatorRead, hThreadSelf, pSrcPos); 169 169 #endif … … 179 179 { 180 180 Assert(!pThis->s.Core.fNeedReset); 181 #if def PDMCRITSECTRW_STRICT181 #if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3) 182 182 RTLockValidatorRecSharedAddOwner(pThis->s.Core.pValidatorRead, hThreadSelf, pSrcPos); 183 183 #endif … … 193 193 if (hNativeSelf == hNativeWriter) 194 194 { 195 #if def PDMCRITSECTRW_STRICT195 #if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3) 196 196 int rc9 = RTLockValidatorRecExclRecursionMixed(pThis->s.Core.pValidatorWrite, &pThis->s.Core.pValidatorRead->Core, pSrcPos); 197 197 if (RT_FAILURE(rc9)) … … 225 225 { 226 226 int rc; 227 #if def PDMCRITSECTRW_STRICT227 #if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3) 228 228 rc = RTLockValidatorRecSharedCheckBlocking(pThis->s.Core.pValidatorRead, hThreadSelf, pSrcPos, true, 229 229 RT_INDEFINITE_WAIT, RTTHREADSTATE_RW_READ, false); … … 295 295 } 296 296 297 #if def PDMCRITSECTRW_STRICT297 #if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3) 298 298 RTLockValidatorRecSharedAddOwner(pThis->s.Core.pValidatorRead, hThreadSelf, pSrcPos); 299 299 #endif … … 342 342 VMMDECL(int) PDMCritSectRwEnterShared(PPDMCRITSECTRW pThis, int rcBusy) 343 343 { 344 #if ndef PDMCRITSECTRW_STRICT344 #if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3) 345 345 return pdmCritSectRwEnterShared(pThis, rcBusy, NULL, false /*fTryOnly*/); 346 346 #else … … 401 401 VMMDECL(int) PDMCritSectRwTryEnterShared(PPDMCRITSECTRW pThis) 402 402 { 403 #if ndef PDMCRITSECTRW_STRICT403 #if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3) 404 404 return pdmCritSectRwEnterShared(pThis, VERR_SEM_BUSY, NULL, true /*fTryOnly*/); 405 405 #else … … 462 462 if ((u64State & RTCSRW_DIR_MASK) == (RTCSRW_DIR_READ << RTCSRW_DIR_SHIFT)) 463 463 { 464 #if def PDMCRITSECTRW_STRICT464 #if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3) 465 465 int rc9 = RTLockValidatorRecSharedCheckAndRelease(pThis->s.Core.pValidatorRead, NIL_RTTHREAD); 466 466 if (RT_FAILURE(rc9)) … … 507 507 AssertReturn(hNativeSelf == hNativeWriter, VERR_NOT_OWNER); 508 508 AssertReturn(pThis->s.Core.cWriterReads > 0, VERR_NOT_OWNER); 509 #if def PDMCRITSECTRW_STRICT509 #if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3) 510 510 int rc = RTLockValidatorRecExclUnwindMixed(pThis->s.Core.pValidatorWrite, &pThis->s.Core.pValidatorRead->Core); 511 511 if (RT_FAILURE(rc)) … … 527 527 AssertReturn(pThis->s.Core.u32Magic == RTCRITSECTRW_MAGIC, VERR_SEM_DESTROYED); 528 528 529 #if def PDMCRITSECTRW_STRICT529 #if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3) 530 530 RTTHREAD hThreadSelf = NIL_RTTHREAD; 531 531 if (!fTryOnly) … … 547 547 { 548 548 Assert((ASMAtomicReadU64(&pThis->s.Core.u64State) & RTCSRW_DIR_MASK) == (RTCSRW_DIR_WRITE << RTCSRW_DIR_SHIFT)); 549 #if def PDMCRITSECTRW_STRICT549 #if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3) 550 550 int rc9 = RTLockValidatorRecExclRecursion(pThis->s.Core.pValidatorWrite, pSrcPos); 551 551 if (RT_FAILURE(rc9)) … … 626 626 { 627 627 int rc; 628 #if def PDMCRITSECTRW_STRICT628 #if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3) 629 629 if (!fTryOnly) 630 630 { … … 684 684 ASMAtomicWriteU32(&pThis->s.Core.cWriteRecursions, 1); 685 685 Assert(pThis->s.Core.cWriterReads == 0); 686 #if def PDMCRITSECTRW_STRICT686 #if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3) 687 687 RTLockValidatorRecExclSetOwner(pThis->s.Core.pValidatorWrite, hThreadSelf, pSrcPos, true); 688 688 #endif … … 715 715 VMMDECL(int) PDMCritSectRwEnterExcl(PPDMCRITSECTRW pThis, int rcBusy) 716 716 { 717 #if ndef PDMCRITSECTRW_STRICT717 #if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3) 718 718 return pdmCritSectRwEnterExcl(pThis, rcBusy, NULL, false /*fTryAgain*/); 719 719 #else … … 771 771 VMMDECL(int) PDMCritSectRwTryEnterExcl(PPDMCRITSECTRW pThis) 772 772 { 773 #if ndef PDMCRITSECTRW_STRICT773 #if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3) 774 774 return pdmCritSectRwEnterExcl(pThis, VERR_SEM_BUSY, NULL, true /*fTryAgain*/); 775 775 #else … … 829 829 830 830 /* 831 * Unwind a recursion.831 * Unwind one recursion. Is it the final one? 832 832 */ 833 833 if (pThis->s.Core.cWriteRecursions == 1) 834 834 { 835 835 AssertReturn(pThis->s.Core.cWriterReads == 0, VERR_WRONG_ORDER); /* (must release all read recursions before the final write.) */ 836 #if def PDMCRITSECTRW_STRICT836 #if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3) 837 837 int rc9 = RTLockValidatorRecExclReleaseOwner(pThis->s.Core.pValidatorWrite, true); 838 838 if (RT_FAILURE(rc9)) … … 858 858 || (u64State & RTCSRW_CNT_RD_MASK) == 0) 859 859 { 860 /* Don't change the direction, wa itup the next writer if any. */860 /* Don't change the direction, wake up the next writer if any. */ 861 861 u64State &= ~RTCSRW_CNT_WR_MASK; 862 862 u64State |= c << RTCSRW_CNT_WR_SHIFT; … … 893 893 else 894 894 { 895 /* 896 * Not the final recursion. 897 */ 895 898 Assert(pThis->s.Core.cWriteRecursions != 0); 896 #if def PDMCRITSECTRW_STRICT899 #if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3) 897 900 int rc9 = RTLockValidatorRecExclUnwind(pThis->s.Core.pValidatorWrite); 898 901 if (RT_FAILURE(rc9)) -
trunk/src/VBox/VMM/VMMR3/CFGM.cpp
r44528 r45189 34 34 * is implemented via the CFGMR3SetRestrictedRoot() API. 35 35 * 36 * Data validation out over the basic primitives is left to the caller. The37 * caller is in a better position to know the proper validation rules of the38 * individualproperties.36 * Data validation beyond the basic primitives is left to the caller. The caller 37 * is in a better position to know the proper validation rules of the individual 38 * properties. 39 39 * 40 40 * @see grp_cfgm -
trunk/src/VBox/VMM/VMMR3/STAM.cpp
r44399 r45189 48 48 * Header Files * 49 49 *******************************************************************************/ 50 /*#define USE_PDMCRITSECTRW - testing, not for production. */ 50 51 #define LOG_GROUP LOG_GROUP_STAM 51 52 #include <VBox/vmm/stam.h> … … 263 264 VMMR3DECL(int) STAMR3InitUVM(PUVM pUVM) 264 265 { 266 int rc; 265 267 LogFlow(("STAMR3Init\n")); 266 268 … … 272 274 273 275 /* 274 * Setup any fixed pointers and offsets. 275 */ 276 int rc = RTSemRWCreate(&pUVM->stam.s.RWSem); 276 * Initialize the read/write lock. 277 */ 278 #ifndef USE_PDMCRITSECTRW 279 rc = RTSemRWCreate(&pUVM->stam.s.RWSem); 277 280 AssertRCReturn(rc, rc); 281 #endif 278 282 279 283 /* … … 318 322 pUVM->stam.s.pHead = NULL; 319 323 324 #ifndef USE_PDMCRITSECTRW 320 325 Assert(pUVM->stam.s.RWSem != NIL_RTSEMRW); 321 326 RTSemRWDestroy(pUVM->stam.s.RWSem); 322 327 pUVM->stam.s.RWSem = NIL_RTSEMRW; 328 #endif 323 329 } 324 330 … … 598 604 STAMTYPE enmType, STAMVISIBILITY enmVisibility, const char *pszName, STAMUNIT enmUnit, const char *pszDesc) 599 605 { 606 STAM_LAZY_INIT(pUVM); 600 607 STAM_LOCK_WR(pUVM); 601 608 -
trunk/src/VBox/VMM/VMMR3/VM.cpp
r45152 r45189 514 514 * Init fundamental (sub-)components - STAM, MMR3Heap and PDMLdr. 515 515 */ 516 rc = STAMR3InitUVM(pUVM);516 rc = PDMR3InitUVM(pUVM); 517 517 if (RT_SUCCESS(rc)) 518 518 { 519 rc = MMR3InitUVM(pUVM);519 rc = STAMR3InitUVM(pUVM); 520 520 if (RT_SUCCESS(rc)) 521 521 { 522 rc = PDMR3InitUVM(pUVM);522 rc = MMR3InitUVM(pUVM); 523 523 if (RT_SUCCESS(rc)) 524 524 { … … 528 528 for (i = 0; i < cCpus; i++) 529 529 { 530 rc = RTThreadCreateF(&pUVM->aCpus[i].vm.s.ThreadEMT, vmR3EmulationThread, &pUVM->aCpus[i], _1M,531 RTTHREADTYPE_EMULATION, RTTHREADFLAGS_WAITABLE,530 rc = RTThreadCreateF(&pUVM->aCpus[i].vm.s.ThreadEMT, vmR3EmulationThread, &pUVM->aCpus[i], 531 _1M, RTTHREADTYPE_EMULATION, RTTHREADFLAGS_WAITABLE, 532 532 cCpus > 1 ? "EMT-%u" : "EMT", i); 533 533 if (RT_FAILURE(rc)) … … 548 548 /** @todo rainy day: terminate the EMTs. */ 549 549 } 550 PDMR3TermUVM(pUVM);550 MMR3TermUVM(pUVM); 551 551 } 552 MMR3TermUVM(pUVM);552 STAMR3TermUVM(pUVM); 553 553 } 554 STAMR3TermUVM(pUVM);554 PDMR3TermUVM(pUVM); 555 555 } 556 556 RTCritSectDelete(&pUVM->vm.s.AtErrorCritSect); -
trunk/src/VBox/VMM/include/STAMInternal.h
r44528 r45189 24 24 #include <VBox/vmm/gvmm.h> 25 25 #include <VBox/vmm/gmm.h> 26 #include <iprt/semaphore.h> 26 #ifndef USE_PDMCRITSECTRW 27 # include <iprt/semaphore.h> 28 #else 29 # include <VBox/vmm/pdmcritsectrw.h> 30 #endif 27 31 28 32 … … 102 106 R3PTRTYPE(PSTAMDESC) pHead; 103 107 /** RW Lock for the list. */ 108 #ifndef USE_PDMCRITSECTRW 104 109 RTSEMRW RWSem; 110 #else 111 PDMCRITSECTRW CritSectRw; 112 #endif 105 113 106 114 /** The copy of the GVMM statistics. */ … … 120 128 121 129 130 #ifndef USE_PDMCRITSECTRW 122 131 /** Locks the sample descriptors for reading. */ 123 # define STAM_LOCK_RD(pUVM)do { int rcSem = RTSemRWRequestRead(pUVM->stam.s.RWSem, RT_INDEFINITE_WAIT); AssertRC(rcSem); } while (0)132 # define STAM_LOCK_RD(pUVM) do { int rcSem = RTSemRWRequestRead(pUVM->stam.s.RWSem, RT_INDEFINITE_WAIT); AssertRC(rcSem); } while (0) 124 133 /** Locks the sample descriptors for writing. */ 125 # define STAM_LOCK_WR(pUVM)do { int rcSem = RTSemRWRequestWrite(pUVM->stam.s.RWSem, RT_INDEFINITE_WAIT); AssertRC(rcSem); } while (0)134 # define STAM_LOCK_WR(pUVM) do { int rcSem = RTSemRWRequestWrite(pUVM->stam.s.RWSem, RT_INDEFINITE_WAIT); AssertRC(rcSem); } while (0) 126 135 /** UnLocks the sample descriptors after reading. */ 127 # define STAM_UNLOCK_RD(pUVM)do { int rcSem = RTSemRWReleaseRead(pUVM->stam.s.RWSem); AssertRC(rcSem); } while (0)136 # define STAM_UNLOCK_RD(pUVM) do { int rcSem = RTSemRWReleaseRead(pUVM->stam.s.RWSem); AssertRC(rcSem); } while (0) 128 137 /** UnLocks the sample descriptors after writing. */ 129 #define STAM_UNLOCK_WR(pUVM) do { int rcSem = RTSemRWReleaseWrite(pUVM->stam.s.RWSem); AssertRC(rcSem); } while (0) 138 # define STAM_UNLOCK_WR(pUVM) do { int rcSem = RTSemRWReleaseWrite(pUVM->stam.s.RWSem); AssertRC(rcSem); } while (0) 139 /** Lazy initialization */ 140 # define STAM_LAZY_INIT(pUVM) do { } while (0) 141 #else 142 /** Locks the sample descriptors for reading. */ 143 # define STAM_LOCK_RD(pUVM) \ 144 if (PDMCritSectRwIsInitialized(&pUVM->stam.s.CritSectRw)) \ 145 { int rcSem = PDMCritSectRwEnterShared(&pUVM->stam.s.CritSectRw, VINF_SUCCESS); AssertRC(rcSem); } else do { } while (0) 146 /** Locks the sample descriptors for writing. */ 147 # define STAM_LOCK_WR(pUVM) \ 148 if (PDMCritSectRwIsInitialized(&pUVM->stam.s.CritSectRw)) \ 149 { int rcSem = PDMCritSectRwEnterExcl(&pUVM->stam.s.CritSectRw, VINF_SUCCESS); AssertRC(rcSem); } else do { } while (0) 150 /** UnLocks the sample descriptors after reading. */ 151 # define STAM_UNLOCK_RD(pUVM) \ 152 if (PDMCritSectRwIsInitialized(&pUVM->stam.s.CritSectRw)) \ 153 { int rcSem = PDMCritSectRwLeaveShared(&pUVM->stam.s.CritSectRw); AssertRC(rcSem); } else do { } while (0) 154 /** UnLocks the sample descriptors after writing. */ 155 # define STAM_UNLOCK_WR(pUVM) \ 156 if (PDMCritSectRwIsInitialized(&pUVM->stam.s.CritSectRw)) \ 157 { int rcSem = PDMCritSectRwLeaveExcl(&pUVM->stam.s.CritSectRw); AssertRC(rcSem); } else do { } while (0) 158 /** Lazy initialization. */ 159 # define STAM_LAZY_INIT(pUVM) \ 160 if (!PDMCritSectRwIsInitialized(&pUVM->stam.s.CritSectRw) && (pUVM)->pVM) \ 161 { \ 162 static bool volatile s_fInProgress = false; \ 163 if (!s_fInProgress) \ 164 { \ 165 s_fInProgress = true; \ 166 int rcSem = PDMR3CritSectRwInit(pUVM->pVM, &pUVM->stam.s.CritSectRw, RT_SRC_POS, "stam-rw"); \ 167 AssertRC(rcSem); Assert(PDMCritSectRwIsInitialized(&pUVM->stam.s.CritSectRw) || RT_FAILURE(rcSem)); \ 168 } \ 169 } else do { } while (0) 170 #endif 130 171 131 172 /** @} */
Note:
See TracChangeset
for help on using the changeset viewer.