VirtualBox

Changeset 23513 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Oct 2, 2009 1:21:27 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
53152
Message:

PGMSavedState: MMIO2 optimizations in the works.

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

Legend:

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

    r23488 r23513  
    4141#include <iprt/avl.h>
    4242#include <iprt/critsect.h>
     43#include <iprt/sha.h>
    4344
    4445
     
    12561257
    12571258/**
     1259 * Live save per page data for an MMIO2 page.
     1260 *
     1261 * Not using PGMLIVESAVEPAGE here because we cannot use normal write monitoring
     1262 * of MMIO2 pages.  The current approach is using some optimisitic SHA-1 +
     1263 * CRC-32 for detecting changes as well as special handling of zero pages.  This
     1264 * is a TEMPORARY measure which isn't perfect, but hopefully it is good enough
     1265 * for speeding things up.  (We're using SHA-1 and not SHA-256 or SHA-512
     1266 * because of speed (2.5x and 6x slower).)
     1267 *
     1268 * @todo Implement dirty MMIO2 page reporting that can be enabled during live
     1269 *       save but normally is disabled.  Since we can write monitore guest
     1270 *       accesses on our own, we only need this for host accesses.  Shouldn't be
     1271 *       too difficult for DevVGA, VMMDev might be doable, the planned
     1272 *       networking fun will be fun since it involves ring-0.
     1273 */
     1274typedef struct PGMLIVESAVEMMIO2PAGE
     1275{
     1276    /** Set if the page is considered dirty. */
     1277    bool        fDirty;
     1278    /** The number of scans this page has remained unchanged for.
     1279     * Only updated for dirty pages. */
     1280    uint8_t     cUnchangedScans;
     1281   /** Whether this page was zero at the last scan. */
     1282    bool        fZero;
     1283     /** Alignment padding. */
     1284    uint8_t     u8Padding;
     1285    /** CRC-32 for the first half of the page.
     1286     * This is used together with u32CrcH2 to quickly detect changes in the page
     1287     * during the non-final passes.  */
     1288    uint32_t    u32CrcH1;
     1289    /** CRC-32 for the second half of the page. */
     1290    uint32_t    u32CrcH2;
     1291    /** SHA-1 for the saved page.
     1292     * This is used in the final pass to skip pages without changes. */
     1293    uint8_t     abSha1Saved[RTSHA1_HASH_SIZE];
     1294} PGMLIVESAVEMMIO2PAGE;
     1295/** Pointer to a live save status data for an MMIO2 page. */
     1296typedef PGMLIVESAVEMMIO2PAGE *PPGMLIVESAVEMMIO2PAGE;
     1297
     1298/**
    12581299 * A registered MMIO2 (= Device RAM) range.
    12591300 *
     
    12871328    /** The saved state range ID. */
    12881329    uint8_t                             idSavedState;
    1289 #if HC_ARCH_BITS != 32
    12901330    /** Alignment padding for putting the ram range on a PGMPAGE alignment boundrary. */
    1291     uint8_t                             abAlignemnt[HC_ARCH_BITS == 32 ? 0 : 4];
    1292 #endif
     1331    uint8_t                             abAlignemnt[HC_ARCH_BITS == 32 ? 12 : 12];
     1332    /** Live save per page tracking data. */
     1333    PPGMLIVESAVEMMIO2PAGE               paLSPages;
    12931334    /** The associated RAM range. */
    12941335    PGMRAMRANGE                         RamRange;
  • trunk/src/VBox/VMM/PGMSavedState.cpp

    r23489 r23513  
    9090/** @} */
    9191
     92/** The CRC-32 for a zero half page. */
     93#define PGM_STATE_CRC32_ZERO_HALF_PAGE  UINT32_C(0xf1e8ba9e)
     94
    9295
    9396/*******************************************************************************
     
    207210    /*
    208211     * Initialize the live save tracking in the MMIO2 ranges.
     212     * ASSUME nothing changes here.
    209213     */
    210214    pgmLock(pVM);
    211215    for (PPGMMMIO2RANGE pMmio2 = pVM->pgm.s.pMmio2RangesR3; pMmio2; pMmio2 = pMmio2->pNextR3)
    212216    {
    213         uint32_t const  cPages   = pMmio2->RamRange.cb >> PAGE_SHIFT;
    214 
    215 #if 0 /** @todo MMIO2 dirty page tracking for live save. */
     217        uint32_t const  cPages = pMmio2->RamRange.cb >> PAGE_SHIFT;
     218        pgmUnlock(pVM);
     219
     220        PPGMLIVESAVEMMIO2PAGE paLSPages = (PPGMLIVESAVEMMIO2PAGE)MMR3HeapAllocZ(pVM, MM_TAG_PGM, sizeof(PGMLIVESAVEMMIO2PAGE) * cPages);
     221        if (!paLSPages)
     222            return VERR_NO_MEMORY;
    216223        for (uint32_t iPage = 0; iPage < cPages; iPage++)
    217224        {
    218         }
    219 #endif
     225            paLSPages[iPage].fDirty          = true;
     226            paLSPages[iPage].cUnchangedScans = 0;
     227            paLSPages[iPage].fZero           = false;
     228            paLSPages[iPage].u32CrcH1        = PGM_STATE_CRC32_ZERO_HALF_PAGE;
     229            paLSPages[iPage].u32CrcH2        = PGM_STATE_CRC32_ZERO_HALF_PAGE;
     230        }
     231
     232        pgmLock(pVM);
     233        pMmio2->paLSPages = paLSPages;
    220234        pVM->pgm.s.LiveSave.cMmio2Pages += cPages;
    221235    }
     
    767781 * @param   pSSM                The SSM handle.
    768782 * @param   fLiveSave           Whether it's a live save or not.
    769  * @param   fFinalPass          Whether this is the final pass or not.
    770  */
    771 static int pgmR3SaveMmio2Pages(PVM pVM, PSSMHANDLE pSSM, bool fLiveSave, bool fFinalPass)
     783 * @param   uPass               The pass number.
     784 */
     785static int pgmR3SaveMmio2Pages(PVM pVM, PSSMHANDLE pSSM, bool fLiveSave, uint32_t uPass)
    772786{
    773787    int rc = VINF_SUCCESS;
    774788    /** @todo implement live saving of MMIO2 pages. (Need some way of telling the
    775789     *        device that we wish to know about changes.) */
    776     if (fFinalPass)
    777     {
     790
     791    if (uPass == SSM_PASS_FINAL)
     792    {
     793        /*
     794         * Save all non-zero pages.
     795         */
    778796        pgmLock(pVM);
    779797        for (PPGMMMIO2RANGE pMmio2 = pVM->pgm.s.pMmio2RangesR3;
     
    814832 * @param   pSSM                The SSM handle.
    815833 * @param   fLiveSave           Whether it's a live save or not.
    816  * @param   fFinalPass          Whether this is the final pass or not.
     834 * @param   uPass               The pass number.
    817835 */
    818836static int pgmR3SaveRamPages(PVM pVM, PSSMHANDLE pSSM, bool fLiveSave, uint32_t uPass)
     
    12171235        rc = pgmR3SaveShadowedRomPages(pVM, pSSM, true /*fLiveSave*/, false /*fFinalPass*/);
    12181236    if (RT_SUCCESS(rc))
    1219         rc = pgmR3SaveMmio2Pages(      pVM, pSSM, true /*fLiveSave*/, false /*fFinalPass*/);
     1237        rc = pgmR3SaveMmio2Pages(      pVM, pSSM, true /*fLiveSave*/, uPass);
    12201238    if (RT_SUCCESS(rc))
    12211239        rc = pgmR3SaveRamPages(        pVM, pSSM, true /*fLiveSave*/, uPass);
     
    13691387            rc = pgmR3SaveShadowedRomPages(    pVM, pSSM, true /*fLiveSave*/, true /*fFinalPass*/);
    13701388            if (RT_SUCCESS(rc))
    1371                 rc = pgmR3SaveMmio2Pages(      pVM, pSSM, true /*fLiveSave*/, true /*fFinalPass*/);
     1389                rc = pgmR3SaveMmio2Pages(      pVM, pSSM, true /*fLiveSave*/, SSM_PASS_FINAL);
    13721390            if (RT_SUCCESS(rc))
    13731391                rc = pgmR3SaveRamPages(        pVM, pSSM, true /*fLiveSave*/, SSM_PASS_FINAL);
     
    13831401                rc = pgmR3SaveShadowedRomPages(pVM, pSSM, false /*fLiveSave*/, true /*fFinalPass*/);
    13841402            if (RT_SUCCESS(rc))
    1385                 rc = pgmR3SaveMmio2Pages(      pVM, pSSM, false /*fLiveSave*/, true /*fFinalPass*/);
     1403                rc = pgmR3SaveMmio2Pages(      pVM, pSSM, false /*fLiveSave*/, SSM_PASS_FINAL);
    13861404            if (RT_SUCCESS(rc))
    13871405                rc = pgmR3SaveRamPages(        pVM, pSSM, false /*fLiveSave*/, SSM_PASS_FINAL);
     
    15011519    } while (pCur);
    15021520
     1521    /* Ditto for MMIO2 (ASSUME no runtime MMIO2 changes). */
     1522    for (PPGMMMIO2RANGE pMmio2 = pVM->pgm.s.pMmio2RangesR3; pMmio2; pMmio2 = pMmio2->pNextR3)
     1523    {
     1524        void *pvMmio2ToFree = pMmio2->paLSPages;
     1525        if (pvMmio2ToFree)
     1526        {
     1527            pMmio2->paLSPages = NULL;
     1528            pgmUnlock(pVM);
     1529            MMR3HeapFree(pvMmio2ToFree);
     1530            pgmLock(pVM);
     1531        }
     1532    }
     1533
     1534    /* Update PGM state. */
    15031535    pVM->pgm.s.LiveSave.fActive = false;
    15041536
  • trunk/src/VBox/VMM/testcase/tstCompressionBenchmark.cpp

    r23512 r23513  
    151151    RTPrintf("SHA-512   %'9u KB/s  %'15llu ns - %s\n", uSpeed, NanoTS, szDigest);
    152152}
     153
    153154
    154155/**
     
    631632     */
    632633    RTPrintf("\n"
    633              "tstCompressionBenchmark: Checksum/CRC - All In One\n");
     634             "tstCompressionBenchmark: Hash/CRC - All In One\n");
    634635    tstBenchmarkCRCsAllInOne(g_pabSrc, g_cbPages);
    635636
    636637    RTPrintf("\n"
    637              "tstCompressionBenchmark: Checksum/CRC - Page by Page\n");
     638             "tstCompressionBenchmark: Hash/CRC - Page by Page\n");
    638639    tstBenchmarkCRCsPageByPage(g_pabSrc, g_cbPages);
     640
     641    RTPrintf("\n"
     642             "tstCompressionBenchmark: Hash/CRC - Zero Page Digest\n");
     643    static uint8_t s_abZeroPg[PAGE_SIZE];
     644    RT_ZERO(s_abZeroPg);
     645    tstBenchmarkCRCsAllInOne(s_abZeroPg, PAGE_SIZE);
     646
     647    RTPrintf("\n"
     648             "tstCompressionBenchmark: Hash/CRC - Zero Half Page Digest\n");
     649    tstBenchmarkCRCsAllInOne(s_abZeroPg, PAGE_SIZE / 2);
    639650
    640651    RTPrintf("tstCompressionBenchmark: END RESULTS\n");
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