VirtualBox

Changeset 30613 in vbox


Ignore:
Timestamp:
Jul 5, 2010 12:56:59 PM (15 years ago)
Author:
vboxsync
Message:

Free zero page when loading a saved state with prealloc enabled.

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

Legend:

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

    r30493 r30613  
    33713371VMMDECL(int)    pgmPhysHandlerRedirectToHC(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPHYS GCPhysFault, void *pvUser);
    33723372VMMDECL(int)    pgmPhysRomWriteHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPHYS GCPhysFault, void *pvUser);
     3373int             pgmPhysFreePage(PVM pVM, PGMMFREEPAGESREQ pReq, uint32_t *pcPendingPages, PPGMPAGE pPage, RTGCPHYS GCPhys);
     3374
    33733375#ifdef IN_RING3
    33743376void            pgmR3PhysRelinkRamRanges(PVM pVM);
  • trunk/src/VBox/VMM/PGMPhys.cpp

    r30438 r30613  
    5252*******************************************************************************/
    5353static DECLCALLBACK(int) pgmR3PhysRomWriteHandler(PVM pVM, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType, void *pvUser);
    54 static int pgmPhysFreePage(PVM pVM, PGMMFREEPAGESREQ pReq, uint32_t *pcPendingPages, PPGMPAGE pPage, RTGCPHYS GCPhys);
    5554
    5655
     
    37103709 * @remarks The caller must own the PGM lock.
    37113710 */
    3712 static int pgmPhysFreePage(PVM pVM, PGMMFREEPAGESREQ pReq, uint32_t *pcPendingPages, PPGMPAGE pPage, RTGCPHYS GCPhys)
     3711int pgmPhysFreePage(PVM pVM, PGMMFREEPAGESREQ pReq, uint32_t *pcPendingPages, PPGMPAGE pPage, RTGCPHYS GCPhys)
    37133712{
    37143713    /*
  • trunk/src/VBox/VMM/PGMSavedState.cpp

    r30398 r30613  
    25242524    PPGMROMRANGE    pRom     = NULL;
    25252525    PPGMMMIO2RANGE  pMmio2   = NULL;
     2526
     2527    /*
     2528     * We batch up pages that should be freed instead of calling GMM for
     2529     * each and every one of them.
     2530     */
     2531    uint32_t            cPendingPages = 0;
     2532    PGMMFREEPAGESREQ    pReq;
     2533    int rc = GMMR3FreePagesPrepare(pVM, &pReq, 128 /* batch size */, GMMACCOUNT_BASE);
     2534    AssertLogRelRCReturn(rc, rc);
     2535
    25262536    for (;;)
    25272537    {
     
    25302540         */
    25312541        uint8_t u8;
    2532         int rc = SSMR3GetU8(pSSM, &u8);
     2542        rc = SSMR3GetU8(pSSM, &u8);
    25332543        if (RT_FAILURE(rc))
    25342544            return rc;
    25352545        if (u8 == PGM_STATE_REC_END)
     2546        {
     2547            /*
     2548             * Finish off any pages pending freeing.
     2549             */
     2550            if (cPendingPages)
     2551            {
     2552                rc = GMMR3FreePagesPerform(pVM, pReq, cPendingPages);
     2553                AssertLogRelRCReturn(rc, rc);
     2554            }
     2555            GMMR3FreePagesCleanup(pReq);
    25362556            return VINF_SUCCESS;
     2557        }
    25372558        AssertLogRelMsgReturn((u8 & ~PGM_STATE_REC_FLAG_ADDR) <= PGM_STATE_REC_LAST, ("%#x\n", u8), VERR_SSM_DATA_UNIT_FORMAT_CHANGED);
    25382559        switch (u8 & ~PGM_STATE_REC_FLAG_ADDR)
     
    25712592                            ||  PGM_PAGE_IS_BALLOONED(pPage))
    25722593                            break;
    2573                         /** @todo implement zero page replacing. */
    2574                         AssertLogRelMsgReturn(PGM_PAGE_GET_STATE(pPage) == PGM_PAGE_STATE_ALLOCATED, ("GCPhys=%RGp %R[pgmpage]\n", GCPhys, pPage), VERR_INTERNAL_ERROR_5);
    2575                         void *pvDstPage;
    2576                         rc = pgmPhysGCPhys2CCPtrInternal(pVM, pPage, GCPhys, &pvDstPage);
    2577                         AssertLogRelMsgRCReturn(rc, ("GCPhys=%RGp %R[pgmpage] rc=%Rrc\n", GCPhys, pPage, rc), rc);
    2578                         ASMMemZeroPage(pvDstPage);
     2594                        /* Allocated before (prealloc), so free it now. */
     2595                        rc = pgmPhysFreePage(pVM, pReq, &cPendingPages, pPage, GCPhys);
     2596                        AssertRC(rc);
    25792597                        break;
    25802598                    }
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