VirtualBox

Changeset 23460 in vbox for trunk/src/VBox/VMM/VMMAll


Ignore:
Timestamp:
Oct 1, 2009 2:02:51 AM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
53057
Message:

PGM: Page lock counters. (disabled)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp

    r23453 r23460  
    10691069            if (pMap)
    10701070                pMap->cRefs++;
    1071 # if 0 /** @todo implement locking properly */
    1072             if (RT_LIKELY(pPage->cLocks != PGM_PAGE_MAX_LOCKS))
    1073                 if (RT_UNLIKELY(++pPage->cLocks == PGM_PAGE_MAX_LOCKS))
    1074                 {
    1075                     AssertMsgFailed(("%RGp is entering permanent locked state!\n", GCPhys));
    1076                     if (pMap)
    1077                         pMap->cRefs++; /* Extra ref to prevent it from going away. */
    1078                 }
     1071
     1072# ifdef PGM_PAGE_WITH_LOCKS
     1073            unsigned cLocks = PGM_PAGE_GET_WRITE_LOCKS(pPage);
     1074            if (RT_LIKELY(cLocks < PGM_PAGE_MAX_LOCKS - 1))
     1075                PGM_PAGE_INC_WRITE_LOCKS(pPage);
     1076            else if (cLocks != PGM_PAGE_GET_WRITE_LOCKS(pPage))
     1077            {
     1078                PGM_PAGE_INC_WRITE_LOCKS(pPage);
     1079                AssertMsgFailed(("%RGp / %R[pgmpage] is entering permanent write locked state!\n", GCPhys, pPage));
     1080                if (pMap)
     1081                    pMap->cRefs++; /* Extra ref to prevent it from going away. */
     1082            }
    10791083# endif
     1084
    10801085            *ppv = (void *)((uintptr_t)pTlbe->pv | (GCPhys & PAGE_OFFSET_MASK));
    1081             pLock->pvPage = pPage;
     1086            pLock->uPageAndType = (uintptr_t)pPage | PGMPAGEMAPLOCK_TYPE_WRITE;
    10821087            pLock->pvMap = pMap;
    10831088        }
     
    11641169            if (pMap)
    11651170                pMap->cRefs++;
    1166 # if 0 /** @todo implement locking properly */
    1167             if (RT_LIKELY(pPage->cLocks != PGM_PAGE_MAX_LOCKS))
    1168                 if (RT_UNLIKELY(++pPage->cLocks == PGM_PAGE_MAX_LOCKS))
    1169                 {
    1170                     AssertMsgFailed(("%RGp is entering permanent locked state!\n", GCPhys));
    1171                     if (pMap)
    1172                         pMap->cRefs++; /* Extra ref to prevent it from going away. */
    1173                 }
     1171
     1172# ifdef PGM_PAGE_WITH_LOCKS
     1173            unsigned cLocks = PGM_PAGE_GET_READ_LOCKS(pPage);
     1174            if (RT_LIKELY(cLocks < PGM_PAGE_MAX_LOCKS - 1))
     1175                PGM_PAGE_INC_READ_LOCKS(pPage);
     1176            else if (cLocks != PGM_PAGE_GET_READ_LOCKS(pPage))
     1177            {
     1178                PGM_PAGE_INC_READ_LOCKS(pPage);
     1179                AssertMsgFailed(("%RGp / %R[pgmpage] is entering permanent readonly locked state!\n", GCPhys, pPage));
     1180                if (pMap)
     1181                    pMap->cRefs++; /* Extra ref to prevent it from going away. */
     1182            }
    11741183# endif
     1184
    11751185            *ppv = (void *)((uintptr_t)pTlbe->pv | (GCPhys & PAGE_OFFSET_MASK));
    1176             pLock->pvPage = pPage;
     1186            pLock->uPageAndType = (uintptr_t)pPage | PGMPAGEMAPLOCK_TYPE_READ;
    11771187            pLock->pvMap = pMap;
    11781188        }
     
    12741284
    12751285#else   /* IN_RING3 */
    1276     PPGMPAGEMAP pMap = (PPGMPAGEMAP)pLock->pvMap;
    1277     if (!pMap)
    1278     {
    1279         /* The ZERO page and MMIO2 ends up here. */
    1280         Assert(pLock->pvPage);
    1281         pLock->pvPage = NULL;
     1286    PPGMPAGEMAP pMap       = (PPGMPAGEMAP)pLock->pvMap;
     1287    PPGMPAGE    pPage      = (PPGMPAGE)(pLock->uPageAndType & ~PGMPAGEMAPLOCK_TYPE_MASK);
     1288    bool        fWriteLock = (pLock->uPageAndType & PGMPAGEMAPLOCK_TYPE_MASK) == PGMPAGEMAPLOCK_TYPE_WRITE;
     1289
     1290    pLock->uPageAndType = 0;
     1291    pLock->pvMap = NULL;
     1292
     1293    pgmLock(pVM);
     1294# ifdef PGM_PAGE_WITH_LOCKS
     1295    if (fWriteLock)
     1296    {
     1297        unsigned cLocks = PGM_PAGE_GET_WRITE_LOCKS(pPage);
     1298        Assert(cLocks > 0);
     1299        if (RT_LIKELY(cLocks > 0 && cLocks < PGM_PAGE_MAX_LOCKS))
     1300            PGM_PAGE_DEC_WRITE_LOCKS(pPage);
     1301
     1302        if (PGM_PAGE_GET_STATE(pPage) == PGM_PAGE_STATE_WRITE_MONITORED)
     1303        {
     1304            PGM_PAGE_SET_WRITTEN_TO(pPage);
     1305            PGM_PAGE_SET_STATE(pPage, PGM_PAGE_STATE_ALLOCATED);
     1306            Assert(pVM->pgm.s.cMonitoredPages > 0);
     1307            pVM->pgm.s.cMonitoredPages--;
     1308            pVM->pgm.s.cWrittenToPages++;
     1309        }
    12821310    }
    12831311    else
    12841312    {
    1285         pgmLock(pVM);
    1286 
    1287 # if 0 /** @todo implement page locking */
    1288         PPGMPAGE pPage = (PPGMPAGE)pLock->pvPage;
    1289         Assert(pPage->cLocks >= 1);
    1290         if (pPage->cLocks != PGM_PAGE_MAX_LOCKS)
    1291             pPage->cLocks--;
    1292 # endif
    1293 
     1313        unsigned cLocks = PGM_PAGE_GET_READ_LOCKS(pPage);
     1314        Assert(cLocks > 0);
     1315        if (RT_LIKELY(cLocks > 0 && cLocks < PGM_PAGE_MAX_LOCKS))
     1316            PGM_PAGE_DEC_READ_LOCKS(pPage);
     1317    }
     1318#endif
     1319
     1320    if (pMap)
     1321    {
    12941322        Assert(pMap->cRefs >= 1);
    12951323        pMap->cRefs--;
    12961324        pMap->iAge = 0;
    1297 
    1298         pgmUnlock(pVM);
    1299     }
     1325    }
     1326    pgmUnlock(pVM);
    13001327#endif /* IN_RING3 */
    13011328}
Note: See TracChangeset for help on using the changeset viewer.

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