VirtualBox

Changeset 19785 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
May 18, 2009 1:23:45 PM (16 years ago)
Author:
vboxsync
Message:

Locking should not be required after all

Location:
trunk/src/VBox/VMM
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/PDMInternal.h

    r19784 r19785  
    613613typedef enum PDMQUEUETYPE
    614614{
    615     /** Uninitialized. */
    616     PDMQUEUETYPE_UNINIT = 0,
    617615    /** Device consumer. */
    618     PDMQUEUETYPE_DEV,
     616    PDMQUEUETYPE_DEV = 1,
    619617    /** Driver consumer. */
    620618    PDMQUEUETYPE_DRV,
     
    10221020int         pdmLockEx(PVM pVM, int rc);
    10231021void        pdmUnlock(PVM pVM);
    1024 bool        pdmIsLockOwner(PVM pVM);
     1022
    10251023/** @} */
    10261024
  • trunk/src/VBox/VMM/PDMQueue.cpp

    r19784 r19785  
    9292     * Initialize the data fields.
    9393     */
    94     pQueue->pVMR3   = pVM;
    95     pQueue->pVMR0   = fRZEnabled ? pVM->pVMR0 : NIL_RTR0PTR;
    96     pQueue->pVMRC   = fRZEnabled ? pVM->pVMRC : NIL_RTRCPTR;
    97     pQueue->enmType = PDMQUEUETYPE_UNINIT;
     94    pQueue->pVMR3 = pVM;
     95    pQueue->pVMR0 = fRZEnabled ? pVM->pVMR0 : NIL_RTR0PTR;
     96    pQueue->pVMRC = fRZEnabled ? pVM->pVMRC : NIL_RTRCPTR;
    9897    pQueue->cMilliesInterval = cMilliesInterval;
    9998    //pQueue->pTimer = NULL;
    100     pQueue->cbItem  = cbItem;
    101     pQueue->cItems  = cItems;
     99    pQueue->cbItem = cbItem;
     100    pQueue->cItems = cItems;
    102101    //pQueue->pPendingR3 = NULL;
    103102    //pQueue->pPendingR0 = NULL;
     
    145144         * Insert into the queue list for timer driven queues.
    146145         */
    147         pdmLock(pVM);
    148146        pQueue->pNext = pVM->pdm.s.pQueuesTimer;
    149147        pVM->pdm.s.pQueuesTimer = pQueue;
    150         pdmUnlock(pVM);
    151148    }
    152149    else
     
    162159         *   problem any longer. The priority might be a nice feature for later though.
    163160         */
    164         pdmLock(pVM);
    165161        if (!pVM->pdm.s.pQueuesForced)
    166162            pVM->pdm.s.pQueuesForced = pQueue;
     
    172168            pPrev->pNext = pQueue;
    173169        }
    174         pdmUnlock(pVM);
    175170    }
    176171
     
    397392     * Unlink it.
    398393     */
    399     pdmLock(pVM);
    400394    if (pQueue->pTimer)
    401395    {
     
    438432    pQueue->pNext = NULL;
    439433    pQueue->pVMR3 = NULL;
    440     pdmUnlock(pVM);
    441434
    442435    /*
     
    483476     * Unlink it.
    484477     */
    485     pdmLock(pVM);
    486478    PPDMQUEUE pQueueNext = pVM->pdm.s.pQueuesTimer;
    487479    PPDMQUEUE pQueue = pVM->pdm.s.pQueuesForced;
     
    507499    } while (pQueue);
    508500
    509     pdmUnlock(pVM);
    510 
    511501    return VINF_SUCCESS;
    512502}
     
    535525     * Unlink it.
    536526     */
    537     pdmLock(pVM);
    538527    PPDMQUEUE pQueueNext = pVM->pdm.s.pQueuesTimer;
    539528    PPDMQUEUE pQueue = pVM->pdm.s.pQueuesForced;
     
    558547        pQueueNext = NULL;
    559548    } while (pQueue);
    560     pdmUnlock(pVM);
    561549
    562550    return VINF_SUCCESS;
     
    575563     * Process the queues.
    576564     */
    577     pdmLock(pVM);
    578565    PPDMQUEUE pQueueNext = pVM->pdm.s.pQueuesTimer;
    579566    PPDMQUEUE pQueue = pVM->pdm.s.pQueuesForced;
     
    615602        pQueueNext = NULL;
    616603    } while (pQueue);
    617     pdmUnlock(pVM);
    618604}
    619605
     
    631617    LogFlow(("PDMR3QueuesFlush:\n"));
    632618
    633     Assert(!pdmIsLockOwner(pVM));
    634619    /* Use atomic test and clear to prevent useless checks; pdmR3QueueFlush is SMP safe. */
    635620    if (VM_FF_TESTANDCLEAR(pVM, VM_FF_PDM_QUEUES_BIT))
    636621    {
    637         pdmLock(pVM);
    638622        for (PPDMQUEUE pCur = pVM->pdm.s.pQueuesForced; pCur; pCur = pCur->pNext)
    639623        {
     
    648632            }
    649633        }
    650         pdmUnlock(pVM);
    651634    }
    652635}
     
    670653
    671654    AssertMsg(pItems || pItemsRC || pItemsR0, ("ERROR: can't all be NULL now!\n"));
    672     Assert(pdmIsLockOwner(pQueue->pVMR3));
     655
    673656
    674657    /*
     
    818801    VM_ASSERT_EMT(pVM);
    819802
    820     pdmLock(pVM);
    821803    /*
    822804     * Flush the queue.
     
    850832            }
    851833    }
    852     pdmUnlock(pVM);
    853834}
    854835
     
    859840 * @param   pQueue  The queue.
    860841 * @param   pItem   The item.
    861  *
    862  * Note: SMP safe
    863842 */
    864843DECLINLINE(void) pdmR3QueueFree(PPDMQUEUE pQueue, PPDMQUEUEITEMCORE pItem)
     
    893872    PPDMQUEUE pQueue = (PPDMQUEUE)pvUser;
    894873    Assert(pTimer == pQueue->pTimer); NOREF(pTimer);
    895     Assert(!pdmIsLockOwner(pVM));
    896874
    897875    if (    pQueue->pPendingR3
    898876        ||  pQueue->pPendingR0
    899877        ||  pQueue->pPendingRC)
    900     {
    901         pdmLock(pVM);
    902878        pdmR3QueueFlush(pQueue);
    903         pdmUnlock(pVM);
    904     }
    905879    int rc = TMTimerSetMillies(pQueue->pTimer, pQueue->cMilliesInterval);
    906880    AssertRC(rc);
  • trunk/src/VBox/VMM/VMMAll/PDMAll.cpp

    r19784 r19785  
    349349}
    350350
    351 /**
    352  * Check if this VCPU currently owns the PDM lock.
    353  *
    354  * @returns bool owner/not owner
    355  * @param   pVM         The VM to operate on.
    356  */
    357 bool pdmIsLockOwner(PVM pVM)
    358 {
    359     return PDMCritSectIsOwner(&pVM->pdm.s.CritSect);
    360 }
    361 
    362351
    363352/**
  • trunk/src/VBox/VMM/VMMAll/PDMAllQueue.cpp

    r19784 r19785  
    4747 * @param   pQueue      The queue handle.
    4848 * @thread  Any thread.
    49  *
    50  * Note: SMP safe
    5149 */
    5250VMMDECL(PPDMQUEUEITEMCORE) PDMQueueAlloc(PPDMQUEUE pQueue)
     
    7674 * @param   pItem       The item to insert.
    7775 * @thread  Any thread.
    78  *
    79  * Note: SMP safe
    8076 */
    8177VMMDECL(void) PDMQueueInsert(PPDMQUEUE pQueue, PPDMQUEUEITEMCORE pItem)
     
    196192#else /* IN_RING3: */
    197193    PVMREQ pReq;
    198     Assert(!pdmIsLockOwner(pVM));
    199194    VMR3ReqCall(pVM, VMCPUID_ANY, &pReq, RT_INDEFINITE_WAIT, (PFNRT)PDMR3QueueFlushWorker, 2, pVM, pQueue);
    200195    VMR3ReqFree(pReq);
  • trunk/src/VBox/VMM/VMMAll/PGMAllBth.h

    r19784 r19785  
    421421                                && !(uErr & X86_TRAP_PF_P))
    422422                            {
    423                                 pgmLock(pVM);
    424423                                rc = PGM_BTH_NAME(SyncPage)(pVCpu, PdeSrc, pvFault, PGM_SYNC_NR_PAGES, uErr);
    425                                 pgmUnlock(pVM);
    426424                                if (    RT_FAILURE(rc)
    427425                                    || !(uErr & X86_TRAP_PF_RW)
     
    469467                            && !(uErr & X86_TRAP_PF_P))
    470468                        {
    471                             pgmLock(pVM);
    472469                            rc = PGM_BTH_NAME(SyncPage)(pVCpu, PdeSrc, pvFault, PGM_SYNC_NR_PAGES, uErr);
    473                             pgmUnlock(pVM);
    474470                            if (    RT_FAILURE(rc)
    475471                                ||  rc == VINF_PGM_SYNCPAGE_MODIFIED_PDE
     
    565561                        &&  !(uErr & X86_TRAP_PF_P))
    566562                    {
    567                         pgmLock(pVM);
    568563                        rc = PGM_BTH_NAME(SyncPage)(pVCpu, PdeSrc, pvFault, PGM_SYNC_NR_PAGES, uErr);
    569                         pgmUnlock(pVM);
    570564                        if (    RT_FAILURE(rc)
    571565                            ||  rc == VINF_PGM_SYNCPAGE_MODIFIED_PDE
     
    701695                                 */
    702696                                LogFlow(("CSAM ring 3 job\n"));
    703                                 pgmLock(pVM);
    704697                                int rc2 = PGM_BTH_NAME(SyncPage)(pVCpu, PdeSrc, pvFault, 1, uErr);
    705                                 pgmUnlock(pVM);
    706698                                AssertRC(rc2);
    707699
     
    751743                }
    752744#   endif /* PGM_WITH_PAGING(PGM_GST_TYPE, PGM_SHW_TYPE) && !defined(IN_RING0) */
    753                 pgmLock(pVM);
    754745                rc = PGM_BTH_NAME(SyncPage)(pVCpu, PdeSrc, pvFault, PGM_SYNC_NR_PAGES, uErr);
    755                 pgmUnlock(pVM);
    756746                if (RT_SUCCESS(rc))
    757747                {
     
    798788                     *       page is not present, which is not true in this case.
    799789                     */
    800                     pgmLock(pVM);
    801790                    rc = PGM_BTH_NAME(SyncPage)(pVCpu, PdeSrc, pvFault, 1, uErr);
    802                     pgmUnlock(pVM);
    803791                    if (RT_SUCCESS(rc))
    804792                    {
     
    12331221                    PGM_BTH_NAME(SyncPageWorkerTrackDeref)(pShwPage, pPT->a[iPTEDst].u & SHW_PTE_PG_MASK);
    12341222#  endif
    1235                     ASMAtomicWriteSize(&pPT->a[iPTEDst], 0);
     1223                    pPT->a[iPTEDst].u = 0;
    12361224                }
    12371225# else /* Syncing it here isn't 100% safe and it's probably not worth spending time syncing it. */
    1238                 pgmLock(pVM);
    12391226                rc = PGM_BTH_NAME(SyncPage)(pVCpu, PdeSrc, GCPtrPage, 1, 0);
    1240                 pgmUnlock(pVM);
    12411227                if (RT_SUCCESS(rc))
    12421228                    rc = VINF_SUCCESS;
     
    16241610    LogFlow(("SyncPage: GCPtrPage=%RGv cPages=%u uErr=%#x\n", GCPtrPage, cPages, uErr));
    16251611
    1626     Assert(PGMIsLockOwner(pVM));
    16271612#if    (   PGM_GST_TYPE == PGM_TYPE_32BIT  \
    16281613        || PGM_GST_TYPE == PGM_TYPE_PAE    \
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