VirtualBox

Changeset 45189 in vbox


Ignore:
Timestamp:
Mar 26, 2013 9:31:59 AM (12 years ago)
Author:
vboxsync
Message:

STAM,VM: ring-3 only testing of pdmcritsectrw.h (disabled).

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/uvm.h

    r45152 r45189  
    134134        struct STAMUSERPERVM    s;
    135135#endif
    136         uint8_t                 padding[6624];
     136        uint8_t                 padding[6880];
    137137    } stam;
    138138
  • trunk/src/VBox/VMM/VMMAll/PDMAllCritSectRw.cpp

    r45178 r45189  
    110110    AssertPtrReturn(pThis, RTLOCKVAL_SUB_CLASS_INVALID);
    111111    AssertReturn(pThis->s.Core.u32Magic == RTCRITSECTRW_MAGIC, RTLOCKVAL_SUB_CLASS_INVALID);
    112 # ifdef PDMCRITSECTRW_STRICT
     112#if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3)
    113113    AssertReturn(!(pThis->s.Core.fFlags & RTCRITSECT_FLAGS_NOP), RTLOCKVAL_SUB_CLASS_INVALID);
    114114
     
    131131    AssertReturn(pThis->s.Core.u32Magic == RTCRITSECTRW_MAGIC, VERR_SEM_DESTROYED);
    132132
    133 #ifdef PDMCRITSECTRW_STRICT
     133#if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3)
    134134    RTTHREAD hThreadSelf = RTThreadSelfAutoAdopt();
    135135    if (!fTryOnly)
     
    165165            if (ASMAtomicCmpXchgU64(&pThis->s.Core.u64State, u64State, u64OldState))
    166166            {
    167 #ifdef PDMCRITSECTRW_STRICT
     167#if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3)
    168168                RTLockValidatorRecSharedAddOwner(pThis->s.Core.pValidatorRead, hThreadSelf, pSrcPos);
    169169#endif
     
    179179            {
    180180                Assert(!pThis->s.Core.fNeedReset);
    181 #ifdef PDMCRITSECTRW_STRICT
     181#if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3)
    182182                RTLockValidatorRecSharedAddOwner(pThis->s.Core.pValidatorRead, hThreadSelf, pSrcPos);
    183183#endif
     
    193193            if (hNativeSelf == hNativeWriter)
    194194            {
    195 #ifdef PDMCRITSECTRW_STRICT
     195#if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3)
    196196                int rc9 = RTLockValidatorRecExclRecursionMixed(pThis->s.Core.pValidatorWrite, &pThis->s.Core.pValidatorRead->Core, pSrcPos);
    197197                if (RT_FAILURE(rc9))
     
    225225                {
    226226                    int rc;
    227 #ifdef PDMCRITSECTRW_STRICT
     227#if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3)
    228228                    rc = RTLockValidatorRecSharedCheckBlocking(pThis->s.Core.pValidatorRead, hThreadSelf, pSrcPos, true,
    229229                                                               RT_INDEFINITE_WAIT, RTTHREADSTATE_RW_READ, false);
     
    295295                }
    296296
    297 #ifdef PDMCRITSECTRW_STRICT
     297#if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3)
    298298                RTLockValidatorRecSharedAddOwner(pThis->s.Core.pValidatorRead, hThreadSelf, pSrcPos);
    299299#endif
     
    342342VMMDECL(int) PDMCritSectRwEnterShared(PPDMCRITSECTRW pThis, int rcBusy)
    343343{
    344 #ifndef PDMCRITSECTRW_STRICT
     344#if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3)
    345345    return pdmCritSectRwEnterShared(pThis, rcBusy, NULL, false /*fTryOnly*/);
    346346#else
     
    401401VMMDECL(int) PDMCritSectRwTryEnterShared(PPDMCRITSECTRW pThis)
    402402{
    403 #ifndef PDMCRITSECTRW_STRICT
     403#if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3)
    404404    return pdmCritSectRwEnterShared(pThis, VERR_SEM_BUSY, NULL, true /*fTryOnly*/);
    405405#else
     
    462462    if ((u64State & RTCSRW_DIR_MASK) == (RTCSRW_DIR_READ << RTCSRW_DIR_SHIFT))
    463463    {
    464 #ifdef PDMCRITSECTRW_STRICT
     464#if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3)
    465465        int rc9 = RTLockValidatorRecSharedCheckAndRelease(pThis->s.Core.pValidatorRead, NIL_RTTHREAD);
    466466        if (RT_FAILURE(rc9))
     
    507507        AssertReturn(hNativeSelf == hNativeWriter, VERR_NOT_OWNER);
    508508        AssertReturn(pThis->s.Core.cWriterReads > 0, VERR_NOT_OWNER);
    509 #ifdef PDMCRITSECTRW_STRICT
     509#if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3)
    510510        int rc = RTLockValidatorRecExclUnwindMixed(pThis->s.Core.pValidatorWrite, &pThis->s.Core.pValidatorRead->Core);
    511511        if (RT_FAILURE(rc))
     
    527527    AssertReturn(pThis->s.Core.u32Magic == RTCRITSECTRW_MAGIC, VERR_SEM_DESTROYED);
    528528
    529 #ifdef PDMCRITSECTRW_STRICT
     529#if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3)
    530530    RTTHREAD hThreadSelf = NIL_RTTHREAD;
    531531    if (!fTryOnly)
     
    547547    {
    548548        Assert((ASMAtomicReadU64(&pThis->s.Core.u64State) & RTCSRW_DIR_MASK) == (RTCSRW_DIR_WRITE << RTCSRW_DIR_SHIFT));
    549 #ifdef PDMCRITSECTRW_STRICT
     549#if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3)
    550550        int rc9 = RTLockValidatorRecExclRecursion(pThis->s.Core.pValidatorWrite, pSrcPos);
    551551        if (RT_FAILURE(rc9))
     
    626626        {
    627627            int rc;
    628 #ifdef PDMCRITSECTRW_STRICT
     628#if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3)
    629629            if (!fTryOnly)
    630630            {
     
    684684    ASMAtomicWriteU32(&pThis->s.Core.cWriteRecursions, 1);
    685685    Assert(pThis->s.Core.cWriterReads == 0);
    686 #ifdef PDMCRITSECTRW_STRICT
     686#if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3)
    687687    RTLockValidatorRecExclSetOwner(pThis->s.Core.pValidatorWrite, hThreadSelf, pSrcPos, true);
    688688#endif
     
    715715VMMDECL(int) PDMCritSectRwEnterExcl(PPDMCRITSECTRW pThis, int rcBusy)
    716716{
    717 #ifndef PDMCRITSECTRW_STRICT
     717#if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3)
    718718    return pdmCritSectRwEnterExcl(pThis, rcBusy, NULL, false /*fTryAgain*/);
    719719#else
     
    771771VMMDECL(int) PDMCritSectRwTryEnterExcl(PPDMCRITSECTRW pThis)
    772772{
    773 #ifndef PDMCRITSECTRW_STRICT
     773#if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3)
    774774    return pdmCritSectRwEnterExcl(pThis, VERR_SEM_BUSY, NULL, true /*fTryAgain*/);
    775775#else
     
    829829
    830830    /*
    831      * Unwind a recursion.
     831     * Unwind one recursion. Is it the final one?
    832832     */
    833833    if (pThis->s.Core.cWriteRecursions == 1)
    834834    {
    835835        AssertReturn(pThis->s.Core.cWriterReads == 0, VERR_WRONG_ORDER); /* (must release all read recursions before the final write.) */
    836 #ifdef PDMCRITSECTRW_STRICT
     836#if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3)
    837837        int rc9 = RTLockValidatorRecExclReleaseOwner(pThis->s.Core.pValidatorWrite, true);
    838838        if (RT_FAILURE(rc9))
     
    858858                || (u64State & RTCSRW_CNT_RD_MASK) == 0)
    859859            {
    860                 /* Don't change the direction, wait up the next writer if any. */
     860                /* Don't change the direction, wake up the next writer if any. */
    861861                u64State &= ~RTCSRW_CNT_WR_MASK;
    862862                u64State |= c << RTCSRW_CNT_WR_SHIFT;
     
    893893    else
    894894    {
     895        /*
     896         * Not the final recursion.
     897         */
    895898        Assert(pThis->s.Core.cWriteRecursions != 0);
    896 #ifdef PDMCRITSECTRW_STRICT
     899#if defined(PDMCRITSECTRW_STRICT) && defined(IN_RING3)
    897900        int rc9 = RTLockValidatorRecExclUnwind(pThis->s.Core.pValidatorWrite);
    898901        if (RT_FAILURE(rc9))
  • trunk/src/VBox/VMM/VMMR3/CFGM.cpp

    r44528 r45189  
    3434 * is implemented via the CFGMR3SetRestrictedRoot() API.
    3535 *
    36  * Data validation out over the basic primitives is left to the caller. The
    37  * caller is in a better position to know the proper validation rules of the
    38  * individual properties.
     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.
    3939 *
    4040 * @see grp_cfgm
  • trunk/src/VBox/VMM/VMMR3/STAM.cpp

    r44399 r45189  
    4848*   Header Files                                                               *
    4949*******************************************************************************/
     50/*#define USE_PDMCRITSECTRW - testing, not for production. */
    5051#define LOG_GROUP LOG_GROUP_STAM
    5152#include <VBox/vmm/stam.h>
     
    263264VMMR3DECL(int) STAMR3InitUVM(PUVM pUVM)
    264265{
     266    int rc;
    265267    LogFlow(("STAMR3Init\n"));
    266268
     
    272274
    273275    /*
    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);
    277280    AssertRCReturn(rc, rc);
     281#endif
    278282
    279283    /*
     
    318322    pUVM->stam.s.pHead = NULL;
    319323
     324#ifndef USE_PDMCRITSECTRW
    320325    Assert(pUVM->stam.s.RWSem != NIL_RTSEMRW);
    321326    RTSemRWDestroy(pUVM->stam.s.RWSem);
    322327    pUVM->stam.s.RWSem = NIL_RTSEMRW;
     328#endif
    323329}
    324330
     
    598604                           STAMTYPE enmType, STAMVISIBILITY enmVisibility, const char *pszName, STAMUNIT enmUnit, const char *pszDesc)
    599605{
     606    STAM_LAZY_INIT(pUVM);
    600607    STAM_LOCK_WR(pUVM);
    601608
  • trunk/src/VBox/VMM/VMMR3/VM.cpp

    r45152 r45189  
    514514                     * Init fundamental (sub-)components - STAM, MMR3Heap and PDMLdr.
    515515                     */
    516                     rc = STAMR3InitUVM(pUVM);
     516                    rc = PDMR3InitUVM(pUVM);
    517517                    if (RT_SUCCESS(rc))
    518518                    {
    519                         rc = MMR3InitUVM(pUVM);
     519                        rc = STAMR3InitUVM(pUVM);
    520520                        if (RT_SUCCESS(rc))
    521521                        {
    522                             rc = PDMR3InitUVM(pUVM);
     522                            rc = MMR3InitUVM(pUVM);
    523523                            if (RT_SUCCESS(rc))
    524524                            {
     
    528528                                for (i = 0; i < cCpus; i++)
    529529                                {
    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,
    532532                                                         cCpus > 1 ? "EMT-%u" : "EMT", i);
    533533                                    if (RT_FAILURE(rc))
     
    548548                                    /** @todo rainy day: terminate the EMTs. */
    549549                                }
    550                                 PDMR3TermUVM(pUVM);
     550                                MMR3TermUVM(pUVM);
    551551                            }
    552                             MMR3TermUVM(pUVM);
     552                            STAMR3TermUVM(pUVM);
    553553                        }
    554                         STAMR3TermUVM(pUVM);
     554                        PDMR3TermUVM(pUVM);
    555555                    }
    556556                    RTCritSectDelete(&pUVM->vm.s.AtErrorCritSect);
  • trunk/src/VBox/VMM/include/STAMInternal.h

    r44528 r45189  
    2424#include <VBox/vmm/gvmm.h>
    2525#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
    2731
    2832
     
    102106    R3PTRTYPE(PSTAMDESC)    pHead;
    103107    /** RW Lock for the list. */
     108#ifndef USE_PDMCRITSECTRW
    104109    RTSEMRW                 RWSem;
     110#else
     111    PDMCRITSECTRW           CritSectRw;
     112#endif
    105113
    106114    /** The copy of the GVMM statistics. */
     
    120128
    121129
     130#ifndef USE_PDMCRITSECTRW
    122131/** 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)
    124133/** 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)
    126135/** 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)
    128137/** 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
    130171
    131172/** @} */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette