VirtualBox

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


Ignore:
Timestamp:
Oct 3, 2009 9:54:08 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
53177
Message:

PGMSavedState: Mmio2 bugfixes and more statistics.

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

Legend:

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

    r23518 r23534  
    27122712    struct
    27132713    {
    2714         /** The number of ready pages.  */
    2715         uint32_t                    cReadyPages;
    2716         /** The number of dirty pages. */
    2717         uint32_t                    cDirtyPages;
     2714        /** Per type statistics. */
     2715        struct
     2716        {
     2717            /** The number of ready pages.  */
     2718            uint32_t                cReadyPages;
     2719            /** The number of dirty pages. */
     2720            uint32_t                cDirtyPages;
     2721        }                           Rom,
     2722                                    Mmio2,
     2723                                    Ram;
    27182724        /** The number of monitored pages. */
    27192725        uint32_t                    cMonitoredPages;
    27202726        /** The number of ignored pages.  */
    27212727        uint32_t                    cIgnoredPages;
    2722         /** The number of dirty MMIO2 pages. */
    2723         uint32_t                    cDirtyMmio2Pages;
    27242728        /** Indicates that a live save operation is active.  */
    27252729        bool                        fActive;
    27262730        /** Padding. */
    2727         bool                        afReserved[3];
     2731        bool                        afReserved[4+3];
    27282732    } LiveSave;
    27292733
  • trunk/src/VBox/VMM/PGMSavedState.cpp

    r23532 r23534  
    215215        }
    216216
    217         pVM->pgm.s.LiveSave.cDirtyPages += cPages;
     217        pVM->pgm.s.LiveSave.Rom.cDirtyPages += cPages;
    218218        if (pRom->fFlags & PGMPHYS_ROM_FLAGS_SHADOWED)
    219             pVM->pgm.s.LiveSave.cDirtyPages += cPages;
     219            pVM->pgm.s.LiveSave.Rom.cDirtyPages += cPages;
    220220    }
    221221    pgmUnlock(pVM);
     
    356356                    {
    357357                        pRomPage->LiveSave.fDirty = true;
    358                         pVM->pgm.s.LiveSave.cReadyPages--;
    359                         pVM->pgm.s.LiveSave.cDirtyPages++;
     358                        pVM->pgm.s.LiveSave.Rom.cReadyPages--;
     359                        pVM->pgm.s.LiveSave.Rom.cDirtyPages++;
    360360                    }
    361361                    pRomPage->LiveSave.fDirtiedRecently = true;
     
    433433            if (fLiveSave)
    434434            {
    435                 pVM->pgm.s.LiveSave.cDirtyPages--;
    436                 pVM->pgm.s.LiveSave.cReadyPages++;
     435                pVM->pgm.s.LiveSave.Rom.cDirtyPages--;
     436                pVM->pgm.s.LiveSave.Rom.cReadyPages++;
    437437            }
    438438        }
     
    498498                        pRomPage->LiveSave.u8Prot = (uint8_t)enmProt;
    499499                        pRomPage->LiveSave.fDirty = false;
    500                         pVM->pgm.s.LiveSave.cReadyPages++;
    501                         pVM->pgm.s.LiveSave.cDirtyPages--;
     500                        pVM->pgm.s.LiveSave.Rom.cReadyPages++;
     501                        pVM->pgm.s.LiveSave.Rom.cDirtyPages--;
    502502                    }
    503503                    pgmUnlock(pVM);
     
    598598        pgmLock(pVM);
    599599        pMmio2->paLSPages = paLSPages;
    600         pVM->pgm.s.LiveSave.cDirtyMmio2Pages += cPages;
     600        pVM->pgm.s.LiveSave.Mmio2.cDirtyPages += cPages;
    601601    }
    602602    pgmUnlock(pVM);
     
    767767    {
    768768        pLSPage->fDirty = true;
    769         pVM->pgm.s.LiveSave.cReadyPages--;
    770         pVM->pgm.s.LiveSave.cDirtyMmio2Pages++;
     769        pVM->pgm.s.LiveSave.Mmio2.cReadyPages--;
     770        pVM->pgm.s.LiveSave.Mmio2.cDirtyPages++;
    771771    }
    772772    return true;
     
    783783{
    784784    /*
    785      * Only do this every 4th time as it's a little bit expensive.
    786      */
    787     if (    (uPass & 3) != 0
     785     * Since this is a bit expensive we lower the scan rate after a little while.
     786     */
     787    if (    (    (uPass & 3) != 0
     788             &&  uPass > 10)
    788789        ||  uPass == SSM_PASS_FINAL)
    789790        return;
     
    879880    }
    880881    /*
    881      * Only do this every 4rd time since it's kind of expense.
     882     * Reduce the rate after a little while since the current MMIO2 approach is
     883     * a bit expensive.
    882884     * We position it two passes after the scan pass to avoid saving busy pages.
    883885     */
    884     else if ((uPass & 3) == 2)
     886    else if (   uPass <= 10
     887             || (uPass & 3) == 2)
    885888    {
    886889        pgmLock(pVM);
     
    906909
    907910                /* Save it. */
    908                 if (!paLSPages[iPage].fZero)
    909                     RTSha1(pbPage, PAGE_SIZE, paLSPages[iPage].abSha1Saved);
     911                bool const fZero = paLSPages[iPage].fZero;
     912                uint8_t abPage[PAGE_SIZE];
     913                if (!fZero)
     914                {
     915                    memcpy(abPage, pbPage, PAGE_SIZE);
     916                    RTSha1(abPage, PAGE_SIZE, paLSPages[iPage].abSha1Saved);
     917                }
     918
    910919                uint8_t u8Type = paLSPages[iPage].fZero ? PGM_STATE_REC_MMIO2_ZERO : PGM_STATE_REC_MMIO2_RAW;
    911920                if (iPage != 0 && iPage == iPageLast + 1)
     
    918927                }
    919928                if (u8Type == PGM_STATE_REC_MMIO2_RAW)
    920                     rc = SSMR3PutMem(pSSM, pbPage, PAGE_SIZE);
     929                    rc = SSMR3PutMem(pSSM, abPage, PAGE_SIZE);
    921930                if (RT_FAILURE(rc))
    922931                    break;
     932
     933                /* Housekeeping. */
     934                paLSPages[iPage].fDirty = false;
     935                pVM->pgm.s.LiveSave.Mmio2.cDirtyPages--;
     936                pVM->pgm.s.LiveSave.Mmio2.cReadyPages++;
    923937                iPageLast = iPage;
    924938            }
     
    10371051                            }
    10381052                            paLSPages[iPage].fIgnore     = 0;
    1039                             pVM->pgm.s.LiveSave.cDirtyPages++;
     1053                            pVM->pgm.s.LiveSave.Ram.cDirtyPages++;
    10401054                            break;
    10411055
     
    11471161                                if (!paLSPages[iPage].fDirty)
    11481162                                {
    1149                                     pVM->pgm.s.LiveSave.cReadyPages--;
    1150                                     pVM->pgm.s.LiveSave.cDirtyPages++;
     1163                                    pVM->pgm.s.LiveSave.Ram.cReadyPages--;
     1164                                    pVM->pgm.s.LiveSave.Ram.cDirtyPages++;
    11511165                                    if (++paLSPages[iPage].cDirtied > PGMLIVSAVEPAGE_MAX_DIRTIED)
    11521166                                        paLSPages[iPage].cDirtied = PGMLIVSAVEPAGE_MAX_DIRTIED;
     
    11711185                                    if (!paLSPages[iPage].fDirty)
    11721186                                    {
    1173                                         pVM->pgm.s.LiveSave.cReadyPages--;
    1174                                         pVM->pgm.s.LiveSave.cDirtyPages++;
     1187                                        pVM->pgm.s.LiveSave.Ram.cReadyPages--;
     1188                                        pVM->pgm.s.LiveSave.Ram.cDirtyPages++;
    11751189                                        if (++paLSPages[iPage].cDirtied > PGMLIVSAVEPAGE_MAX_DIRTIED)
    11761190                                            paLSPages[iPage].cDirtied = PGMLIVSAVEPAGE_MAX_DIRTIED;
     
    11871201                                    {
    11881202                                        paLSPages[iPage].fDirty = 1;
    1189                                         pVM->pgm.s.LiveSave.cReadyPages--;
    1190                                         pVM->pgm.s.LiveSave.cDirtyPages++;
     1203                                        pVM->pgm.s.LiveSave.Ram.cReadyPages--;
     1204                                        pVM->pgm.s.LiveSave.Ram.cDirtyPages++;
    11911205                                    }
    11921206                                }
     
    12011215                                    {
    12021216                                        paLSPages[iPage].fDirty = 1;
    1203                                         pVM->pgm.s.LiveSave.cReadyPages--;
    1204                                         pVM->pgm.s.LiveSave.cDirtyPages++;
     1217                                        pVM->pgm.s.LiveSave.Ram.cReadyPages--;
     1218                                        pVM->pgm.s.LiveSave.Ram.cDirtyPages++;
    12051219                                    }
    12061220                                }
     
    12371251                        /** @todo the counting doesn't quite work out here. fix later? */
    12381252                        if (paLSPages[iPage].fDirty)
    1239                             pVM->pgm.s.LiveSave.cDirtyPages--;
     1253                            pVM->pgm.s.LiveSave.Ram.cDirtyPages--;
    12401254                        else
    1241                             pVM->pgm.s.LiveSave.cReadyPages--;
     1255                            pVM->pgm.s.LiveSave.Ram.cReadyPages--;
    12421256                        pVM->pgm.s.LiveSave.cIgnoredPages++;
    12431257                    }
     
    13831397                        paLSPages[iPage].fDirty = 0;
    13841398                        paLSPages[iPage].uPassSaved = uPass;
    1385                         pVM->pgm.s.LiveSave.cReadyPages++;
    1386                         pVM->pgm.s.LiveSave.cDirtyPages--;
     1399                        pVM->pgm.s.LiveSave.Ram.cReadyPages++;
     1400                        pVM->pgm.s.LiveSave.Ram.cDirtyPages--;
    13871401                    }
    13881402                    if (idRamRangesGen != pVM->pgm.s.idRamRangesGen)
     
    15361550static DECLCALLBACK(int)  pgmR3LiveVote(PVM pVM, PSSMHANDLE pSSM)
    15371551{
    1538 //    RTPrintf("# Ready=%08x Dirty=%#08x Ignored=%#08x Monitored=%#08x MMIO2=%#08x\n",
    1539 //             pVM->pgm.s.LiveSave.cReadyPages,
    1540 //             pVM->pgm.s.LiveSave.cDirtyPages,
    1541 //             pVM->pgm.s.LiveSave.cIgnoredPages,
    1542 //             pVM->pgm.s.LiveSave.cMonitoredPages,
    1543 //             pVM->pgm.s.LiveSave.cMmio2Pages
    1544 //             );
    1545 //    static int s_iHack = 0;
    1546 //    if ((++s_iHack % 25) == 0)
    1547 //        return VINF_SUCCESS;
    1548 
    1549     if (pVM->pgm.s.LiveSave.cDirtyPages < 256) /* semi random number. */
     1552#if 0
     1553    RTPrintf("# Ram R/D=%08x/%08x Ignored=%#08x Monitored=%#08x  Rom R/D=%08x/%08x  Mmio2 R/D=%08x/%08x\n",
     1554             pVM->pgm.s.LiveSave.Ram.cReadyPages,
     1555             pVM->pgm.s.LiveSave.Ram.cDirtyPages,
     1556             pVM->pgm.s.LiveSave.cIgnoredPages,
     1557             pVM->pgm.s.LiveSave.cMonitoredPages,
     1558             pVM->pgm.s.LiveSave.Rom.cReadyPages,
     1559             pVM->pgm.s.LiveSave.Rom.cDirtyPages,
     1560             pVM->pgm.s.LiveSave.Mmio2.cReadyPages,
     1561             pVM->pgm.s.LiveSave.Mmio2.cDirtyPages
     1562             );
     1563    static int s_iHack = 0;
     1564    if ((++s_iHack % 42) == 0)
    15501565        return VINF_SUCCESS;
     1566#else
     1567    if (      pVM->pgm.s.LiveSave.Rom.cDirtyPages
     1568           +  pVM->pgm.s.LiveSave.Mmio2.cDirtyPages
     1569           +  pVM->pgm.s.LiveSave.Ram.cDirtyPages
     1570        <  256)                         /* semi random numbers. */
     1571        return VINF_SUCCESS;
     1572#endif
    15511573    return VINF_SSM_VOTE_FOR_ANOTHER_PASS;
    15521574}
     
    16451667     * Initialize the statistics.
    16461668     */
    1647     pVM->pgm.s.LiveSave.cReadyPages      = 0;
    1648     pVM->pgm.s.LiveSave.cDirtyPages      = 0;
    1649     pVM->pgm.s.LiveSave.cIgnoredPages    = 0;
    1650     pVM->pgm.s.LiveSave.cDirtyMmio2Pages = 0;
    1651     pVM->pgm.s.LiveSave.fActive          = true;
     1669    pVM->pgm.s.LiveSave.Rom.cReadyPages   = 0;
     1670    pVM->pgm.s.LiveSave.Rom.cDirtyPages   = 0;
     1671    pVM->pgm.s.LiveSave.Mmio2.cReadyPages = 0;
     1672    pVM->pgm.s.LiveSave.Mmio2.cDirtyPages = 0;
     1673    pVM->pgm.s.LiveSave.Ram.cReadyPages   = 0;
     1674    pVM->pgm.s.LiveSave.Ram.cDirtyPages   = 0;
     1675    pVM->pgm.s.LiveSave.cIgnoredPages     = 0;
     1676    pVM->pgm.s.LiveSave.fActive           = true;
    16521677
    16531678    /*
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