VirtualBox

Ignore:
Timestamp:
Dec 12, 2008 1:23:23 AM (16 years ago)
Author:
vboxsync
Message:

Avoid a few calls to RTMpCpuId() and RTMCpuIdToSetIndex().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/PGMR0DynMap.cpp

    r15344 r15346  
    367367        }
    368368        pSet->cEntries = PGMMAPSET_CLOSED;
     369        pSet->iCpu = -1;
    369370        memset(&pSet->aiHashTable[0], 0xff, sizeof(pSet->aiHashTable));
    370371    }
     
    465466                }
    466467                pSet->cEntries = PGMMAPSET_CLOSED;
     468                pSet->iCpu = -1;
    467469            }
    468470            else
     
    12721274 * @param   pThis       The dynamic mapping cache instance.
    12731275 * @param   HCPhys      The address of the page to be mapped.
     1276 * @param   iRealCpu    The real cpu set index. (optimization)
    12741277 * @param   pVM         The shared VM structure, for statistics only.
    12751278 * @param   ppvPage     Where to the page address.
    12761279 */
    1277 DECLINLINE(uint32_t) pgmR0DynMapPage(PPGMR0DYNMAP pThis, RTHCPHYS HCPhys, PVM pVM, void **ppvPage)
     1280DECLINLINE(uint32_t) pgmR0DynMapPage(PPGMR0DYNMAP pThis, RTHCPHYS HCPhys, int32_t iRealCpu, PVM pVM, void **ppvPage)
    12781281{
    12791282    RTSPINLOCKTMP   Tmp       = RTSPINLOCKTMP_INITIALIZER;
     
    13451348     * Invalidate the entry?
    13461349     */
    1347     RTCPUID idRealCpu = RTMpCpuId();
    1348     bool fInvalidateIt = RTCpuSetIsMember(&paPages[iPage].PendingSet, idRealCpu);
     1350    bool fInvalidateIt = RTCpuSetIsMemberByIndex(&paPages[iPage].PendingSet, iRealCpu);
    13491351    if (RT_UNLIKELY(fInvalidateIt))
    1350         RTCpuSetDel(&paPages[iPage].PendingSet, idRealCpu);
     1352        RTCpuSetDelByIndex(&paPages[iPage].PendingSet, iRealCpu);
    13511353
    13521354    RTSpinlockRelease(pThis->hSpinlock, &Tmp);
     
    14971499    Assert(pVCpu->pgm.s.AutoSet.cEntries == PGMMAPSET_CLOSED);
    14981500    pVCpu->pgm.s.AutoSet.cEntries = 0;
     1501    pVCpu->pgm.s.AutoSet.iCpu = RTMpCpuIdToSetIndex(RTMpCpuId());
    14991502}
    15001503
     
    15541557    AssertMsg(cEntries <= RT_ELEMENTS(pSet->aEntries), ("%#x (%u)\n", cEntries, cEntries));
    15551558    pSet->cEntries = PGMMAPSET_CLOSED;
     1559    pSet->iCpu = -1;
    15561560
    15571561    pgmDynMapFlushAutoSetWorker(pSet, cEntries);
     
    15801584        pgmDynMapFlushAutoSetWorker(pSet, cEntries);
    15811585    }
     1586    Assert(pSet->iCpu == RTMpCpuIdToSetIndex(RTMpCpuId()));
    15821587}
    15831588
     
    16071612        {
    16081613            PPGMR0DYNMAP    pThis = g_pPGMR0DynMap;
    1609             RTCPUID         idRealCpu = RTMpCpuId();
    1610 
    1611             while (i-- > 0)
    1612             {
    1613                 Assert(pSet->aEntries[i].cRefs > 0);
    1614                 uint32_t iPage = pSet->aEntries[i].iPage;
    1615                 Assert(iPage < pThis->cPages);
    1616                 if (RTCpuSetIsMember(&pThis->paPages[iPage].PendingSet, idRealCpu))
     1614            int32_t         iRealCpu = RTMpCpuIdToSetIndex(RTMpCpuId());
     1615            if (pSet->iCpu != iRealCpu)
     1616            {
     1617                while (i-- > 0)
    16171618                {
    1618                     RTCpuSetDel(&pThis->paPages[iPage].PendingSet, idRealCpu);
    1619                     ASMInvalidatePage(pThis->paPages[iPage].pvPage);
    1620                     STAM_COUNTER_INC(&pVCpu->pVMR0->pgm.s.StatR0DynMapMigrateInvlPg);
     1619                    Assert(pSet->aEntries[i].cRefs > 0);
     1620                    uint32_t iPage = pSet->aEntries[i].iPage;
     1621                    Assert(iPage < pThis->cPages);
     1622                    if (RTCpuSetIsMemberByIndex(&pThis->paPages[iPage].PendingSet, iRealCpu))
     1623                    {
     1624                        RTCpuSetDelByIndex(&pThis->paPages[iPage].PendingSet, iRealCpu);
     1625                        ASMInvalidatePage(pThis->paPages[iPage].pvPage);
     1626                        STAM_COUNTER_INC(&pVCpu->pVMR0->pgm.s.StatR0DynMapMigrateInvlPg);
     1627                    }
    16211628                }
     1629
     1630                pSet->iCpu = iRealCpu;
    16221631            }
    16231632        }
     
    16841693int pgmR0DynMapHCPageCommon(PVM pVM, PPGMMAPSET pSet, RTHCPHYS HCPhys, void **ppv)
    16851694{
     1695    Assert(pSet->iCpu == RTMpCpuIdToSetIndex(RTMpCpuId()));
     1696
    16861697    /*
    16871698     * Map it.
    16881699     */
    16891700    void *pvPage;
    1690     uint32_t const  iPage = pgmR0DynMapPage(g_pPGMR0DynMap, HCPhys, pVM, &pvPage);
     1701    uint32_t const  iPage = pgmR0DynMapPage(g_pPGMR0DynMap, HCPhys, pSet->iCpu, pVM, &pvPage);
    16911702    if (RT_UNLIKELY(iPage == UINT32_MAX))
    16921703    {
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