Changeset 23513 in vbox for trunk/src/VBox
- Timestamp:
- Oct 2, 2009 1:21:27 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 53152
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/PGMInternal.h
r23488 r23513 41 41 #include <iprt/avl.h> 42 42 #include <iprt/critsect.h> 43 #include <iprt/sha.h> 43 44 44 45 … … 1256 1257 1257 1258 /** 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 */ 1274 typedef 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. */ 1296 typedef PGMLIVESAVEMMIO2PAGE *PPGMLIVESAVEMMIO2PAGE; 1297 1298 /** 1258 1299 * A registered MMIO2 (= Device RAM) range. 1259 1300 * … … 1287 1328 /** The saved state range ID. */ 1288 1329 uint8_t idSavedState; 1289 #if HC_ARCH_BITS != 321290 1330 /** 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; 1293 1334 /** The associated RAM range. */ 1294 1335 PGMRAMRANGE RamRange; -
trunk/src/VBox/VMM/PGMSavedState.cpp
r23489 r23513 90 90 /** @} */ 91 91 92 /** The CRC-32 for a zero half page. */ 93 #define PGM_STATE_CRC32_ZERO_HALF_PAGE UINT32_C(0xf1e8ba9e) 94 92 95 93 96 /******************************************************************************* … … 207 210 /* 208 211 * Initialize the live save tracking in the MMIO2 ranges. 212 * ASSUME nothing changes here. 209 213 */ 210 214 pgmLock(pVM); 211 215 for (PPGMMMIO2RANGE pMmio2 = pVM->pgm.s.pMmio2RangesR3; pMmio2; pMmio2 = pMmio2->pNextR3) 212 216 { 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; 216 223 for (uint32_t iPage = 0; iPage < cPages; iPage++) 217 224 { 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; 220 234 pVM->pgm.s.LiveSave.cMmio2Pages += cPages; 221 235 } … … 767 781 * @param pSSM The SSM handle. 768 782 * @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 */ 785 static int pgmR3SaveMmio2Pages(PVM pVM, PSSMHANDLE pSSM, bool fLiveSave, uint32_t uPass) 772 786 { 773 787 int rc = VINF_SUCCESS; 774 788 /** @todo implement live saving of MMIO2 pages. (Need some way of telling the 775 789 * 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 */ 778 796 pgmLock(pVM); 779 797 for (PPGMMMIO2RANGE pMmio2 = pVM->pgm.s.pMmio2RangesR3; … … 814 832 * @param pSSM The SSM handle. 815 833 * @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. 817 835 */ 818 836 static int pgmR3SaveRamPages(PVM pVM, PSSMHANDLE pSSM, bool fLiveSave, uint32_t uPass) … … 1217 1235 rc = pgmR3SaveShadowedRomPages(pVM, pSSM, true /*fLiveSave*/, false /*fFinalPass*/); 1218 1236 if (RT_SUCCESS(rc)) 1219 rc = pgmR3SaveMmio2Pages( pVM, pSSM, true /*fLiveSave*/, false /*fFinalPass*/);1237 rc = pgmR3SaveMmio2Pages( pVM, pSSM, true /*fLiveSave*/, uPass); 1220 1238 if (RT_SUCCESS(rc)) 1221 1239 rc = pgmR3SaveRamPages( pVM, pSSM, true /*fLiveSave*/, uPass); … … 1369 1387 rc = pgmR3SaveShadowedRomPages( pVM, pSSM, true /*fLiveSave*/, true /*fFinalPass*/); 1370 1388 if (RT_SUCCESS(rc)) 1371 rc = pgmR3SaveMmio2Pages( pVM, pSSM, true /*fLiveSave*/, true /*fFinalPass*/);1389 rc = pgmR3SaveMmio2Pages( pVM, pSSM, true /*fLiveSave*/, SSM_PASS_FINAL); 1372 1390 if (RT_SUCCESS(rc)) 1373 1391 rc = pgmR3SaveRamPages( pVM, pSSM, true /*fLiveSave*/, SSM_PASS_FINAL); … … 1383 1401 rc = pgmR3SaveShadowedRomPages(pVM, pSSM, false /*fLiveSave*/, true /*fFinalPass*/); 1384 1402 if (RT_SUCCESS(rc)) 1385 rc = pgmR3SaveMmio2Pages( pVM, pSSM, false /*fLiveSave*/, true /*fFinalPass*/);1403 rc = pgmR3SaveMmio2Pages( pVM, pSSM, false /*fLiveSave*/, SSM_PASS_FINAL); 1386 1404 if (RT_SUCCESS(rc)) 1387 1405 rc = pgmR3SaveRamPages( pVM, pSSM, false /*fLiveSave*/, SSM_PASS_FINAL); … … 1501 1519 } while (pCur); 1502 1520 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. */ 1503 1535 pVM->pgm.s.LiveSave.fActive = false; 1504 1536 -
trunk/src/VBox/VMM/testcase/tstCompressionBenchmark.cpp
r23512 r23513 151 151 RTPrintf("SHA-512 %'9u KB/s %'15llu ns - %s\n", uSpeed, NanoTS, szDigest); 152 152 } 153 153 154 154 155 /** … … 631 632 */ 632 633 RTPrintf("\n" 633 "tstCompressionBenchmark: Checksum/CRC - All In One\n");634 "tstCompressionBenchmark: Hash/CRC - All In One\n"); 634 635 tstBenchmarkCRCsAllInOne(g_pabSrc, g_cbPages); 635 636 636 637 RTPrintf("\n" 637 "tstCompressionBenchmark: Checksum/CRC - Page by Page\n");638 "tstCompressionBenchmark: Hash/CRC - Page by Page\n"); 638 639 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); 639 650 640 651 RTPrintf("tstCompressionBenchmark: END RESULTS\n");
Note:
See TracChangeset
for help on using the changeset viewer.