Changeset 17513 in vbox
- Timestamp:
- Mar 7, 2009 5:44:48 AM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 43946
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/MM.cpp
r17372 r17513 322 322 * value is 'no overcommitment' (default). See GMMPOLICY. 323 323 */ 324 GMMOCPOLICY enm Policy;324 GMMOCPOLICY enmOcPolicy; 325 325 char sz[64]; 326 326 rc = CFGMR3QueryString(CFGMR3GetRoot(pVM), "Policy", sz, sizeof(sz)); … … 329 329 if ( !RTStrICmp(sz, "no_oc") 330 330 || !RTStrICmp(sz, "no overcommitment")) 331 enm Policy = GMMOCPOLICY_NO_OC;331 enmOcPolicy = GMMOCPOLICY_NO_OC; 332 332 else 333 333 return VMSetError(pVM, VERR_INVALID_PARAMETER, RT_SRC_POS, "Unknown \"MM/Policy\" value \"%s\"", sz); 334 334 } 335 335 else if (rc == VERR_CFGM_VALUE_NOT_FOUND) 336 enm Policy = GMMOCPOLICY_NO_OC;336 enmOcPolicy = GMMOCPOLICY_NO_OC; 337 337 else 338 338 AssertMsgRCReturn(rc, ("Configuration error: Failed to query string \"MM/Policy\", rc=%Rrc.\n", rc), rc); … … 364 364 * Make the initial memory reservation with GMM. 365 365 */ 366 rc = GMMR3InitialReservation(pVM, cbRam >> PAGE_SHIFT, 1, 1, enmPolicy, enmPriority); 366 uint64_t cBasePages = (cbRam >> PAGE_SHIFT) + pVM->mm.s.cBasePages; 367 rc = GMMR3InitialReservation(pVM, 368 RT_MAX(cBasePages + pVM->mm.s.cHandyPages, 1), 369 RT_MAX(pVM->mm.s.cShadowPages, 1), 370 RT_MAX(pVM->mm.s.cFixedPages, 1), 371 enmOcPolicy, 372 enmPriority); 367 373 if (RT_FAILURE(rc)) 368 374 { 369 375 if (rc == VERR_GMM_MEMORY_RESERVATION_DECLINED) 370 376 return VMSetError(pVM, rc, RT_SRC_POS, 371 N_("Insufficient free memory to start the VM (cbRam=%#RX64 enm Policy=%d enmPriority=%d)"),372 cbRam, enm Policy, enmPriority);377 N_("Insufficient free memory to start the VM (cbRam=%#RX64 enmOcPolicy=%d enmPriority=%d)"), 378 cbRam, enmOcPolicy, enmPriority); 373 379 return VMSetError(pVM, rc, RT_SRC_POS, "GMMR3InitialReservation(,%#RX64,0,0,%d,%d)", 374 cbRam >> PAGE_SHIFT, enm Policy, enmPriority);380 cbRam >> PAGE_SHIFT, enmOcPolicy, enmPriority); 375 381 } 376 382 … … 409 415 rc = PGM3PhysGrowRange(pVM, &GCPhys); 410 416 } 417 #endif 418 419 #ifdef VBOX_WITH_NEW_PHYS_CODE 420 /* 421 * Enabled mmR3UpdateReservation here since we don't want the 422 * PGMR3PhysRegisterRam calls above mess things up. 423 */ 424 pVM->mm.s.fDoneMMR3InitPaging = true; 425 AssertMsg(pVM->mm.s.cBasePages == cBasePages, ("%RX64 != %RX64\n", pVM->mm.s.cBasePages, cBasePages)); 411 426 #endif 412 427 … … 603 618 if (pVM->mm.s.fDoneMMR3InitPaging) 604 619 return GMMR3UpdateReservation(pVM, 605 RT_MAX(pVM->mm.s.cBasePages , 1),620 RT_MAX(pVM->mm.s.cBasePages + pVM->mm.s.cHandyPages, 1), 606 621 RT_MAX(pVM->mm.s.cShadowPages, 1), 607 622 RT_MAX(pVM->mm.s.cFixedPages, 1)); … … 627 642 if (RT_FAILURE(rc)) 628 643 { 629 VMSetError(pVM, rc, RT_SRC_POS, N_("Failed to reserved physical memory for the RAM (%#RX64 -> %#RX64)"), cOld, pVM->mm.s.cBasePages); 644 VMSetError(pVM, rc, RT_SRC_POS, N_("Failed to reserved physical memory for the RAM (%#RX64 -> %#RX64 + %#RX32)"), 645 cOld, pVM->mm.s.cBasePages, pVM->mm.s.cHandyPages); 630 646 pVM->mm.s.cBasePages = cOld; 647 } 648 return rc; 649 } 650 651 652 /** 653 * Interface for PGM to make reservations for handy pages in addition to the 654 * base memory. 655 * 656 * This can be called before MMR3InitPaging. 657 * 658 * @returns VBox status code. Will set VM error on failure. 659 * @param pVM The shared VM structure. 660 * @param cHandyPages The number of handy pages. 661 */ 662 VMMR3DECL(int) MMR3ReserveHandyPages(PVM pVM, uint32_t cHandyPages) 663 { 664 AssertReturn(!pVM->mm.s.cHandyPages, VERR_WRONG_ORDER); 665 666 pVM->mm.s.cHandyPages = cHandyPages; 667 LogFlow(("MMR3ReserveHandyPages: %RU32 (base %RU64)\n", pVM->mm.s.cHandyPages, pVM->mm.s.cBasePages)); 668 int rc = mmR3UpdateReservation(pVM); 669 if (RT_FAILURE(rc)) 670 { 671 VMSetError(pVM, rc, RT_SRC_POS, N_("Failed to reserved physical memory for the RAM (%#RX64 + %#RX32)"), 672 pVM->mm.s.cBasePages, pVM->mm.s.cHandyPages); 673 pVM->mm.s.cHandyPages = 0; 631 674 } 632 675 return rc; -
trunk/src/VBox/VMM/MMInternal.h
r17251 r17513 762 762 * what the guest sees. */ 763 763 uint64_t cBasePages; 764 /** The number of handy pages that PGM has reserved (GMM). 765 * These are kept out of cBasePages and thus out of the saved state. */ 766 uint32_t cHandyPages; 764 767 /** The number of shadow pages PGM has reserved (GMM). */ 765 768 uint32_t cShadowPages; 766 769 /** The number of fixed pages we've reserved (GMM). */ 767 770 uint32_t cFixedPages; 771 /** Padding. */ 772 uint32_t u32Padding0; 768 773 769 774 #ifndef VBOX_WITH_NEW_PHYS_CODE -
trunk/src/VBox/VMM/PGM.cpp
r17498 r17513 1254 1254 PGMPhysInvalidatePageR0MapTLB(pVM); 1255 1255 PGMPhysInvalidatePageGCMapTLB(pVM); 1256 1257 #ifdef VBOX_WITH_NEW_PHYS_CODE 1258 /* 1259 * For the time being we sport a full set of handy pages in addition to the base 1260 * memory to simplify things. 1261 */ 1262 rc = MMR3ReserveHandyPages(pVM, RT_ELEMENTS(pVM->pgm.s.aHandyPages)); 1263 AssertRCReturn(rc, rc); 1264 #endif 1256 1265 1257 1266 /* … … 1622 1631 STAM_REG(pVM, &pPGM->cSharedPages, STAMTYPE_U32, "/PGM/Page/cSharedPages", STAMUNIT_OCCURENCES, "The number of shared pages."); 1623 1632 STAM_REG(pVM, &pPGM->cZeroPages, STAMTYPE_U32, "/PGM/Page/cZeroPages", STAMUNIT_OCCURENCES, "The number of zero backed pages."); 1633 STAM_REG(pVM, &pPGM->cHandyPages, STAMTYPE_U32, "/PGM/Page/cHandyPages", STAMUNIT_OCCURENCES, "The number of handy pages (not included in cAllPages)."); 1624 1634 STAM_REG(pVM, &pPGM->ChunkR3Map.c, STAMTYPE_U32, "/PGM/ChunkR3Map/c", STAMUNIT_OCCURENCES, "Number of mapped chunks."); 1625 1635 STAM_REG(pVM, &pPGM->ChunkR3Map.cMax, STAMTYPE_U32, "/PGM/ChunkR3Map/cMax", STAMUNIT_OCCURENCES, "Maximum number of mapped chunks."); … … 1646 1656 STAM_REG(pVM, &pPGM->StatR3GuestPDWrite, STAMTYPE_COUNTER, "/PGM/R3/PDWrite", STAMUNIT_OCCURENCES, "The total number of times pgmHCGuestPDWriteHandler() was called."); 1647 1657 STAM_REG(pVM, &pPGM->StatR3GuestPDWriteConflict, STAMTYPE_COUNTER, "/PGM/R3/PDWriteConflict", STAMUNIT_OCCURENCES, "The number of times pgmHCGuestPDWriteHandler() detected a conflict."); 1658 #ifndef VBOX_WITH_NEW_PHYS_CODE 1648 1659 STAM_REG(pVM, &pPGM->StatR3DynRamTotal, STAMTYPE_COUNTER, "/PGM/DynAlloc/TotalAlloc", STAMUNIT_MEGABYTES, "Allocated MBs of guest ram."); 1649 1660 STAM_REG(pVM, &pPGM->StatR3DynRamGrow, STAMTYPE_COUNTER, "/PGM/DynAlloc/Grow", STAMUNIT_OCCURENCES, "Nr of pgmr3PhysGrowRange calls."); 1661 #endif 1650 1662 1651 1663 /* R0 only: */ -
trunk/src/VBox/VMM/PGMInternal.h
r17511 r17513 2785 2785 STAMCOUNTER StatR3GuestPDWrite; /**< R3: The total number of times pgmHCGuestPDWriteHandler() was called. */ 2786 2786 STAMCOUNTER StatR3GuestPDWriteConflict; /**< R3: The number of times GuestPDWriteContlict() detected a conflict. */ 2787 #ifndef VBOX_WITH_NEW_PHYS_CODE 2787 2788 STAMCOUNTER StatR3DynRamTotal; /**< R3: Allocated MBs of guest ram */ 2788 2789 STAMCOUNTER StatR3DynRamGrow; /**< R3: Nr of pgmr3PhysGrowRange calls. */ 2790 #endif 2789 2791 2790 2792 /* R0 only: */ -
trunk/src/VBox/VMM/PGMPhys.cpp
r17510 r17513 519 519 while (iPage-- > 0) 520 520 PGM_PAGE_INIT_ZERO(&pNew->aPages[iPage], pVM, PGMPAGETYPE_RAM); 521 522 /* Update the page count stats. */ 523 pVM->pgm.s.cZeroPages += cPages; 524 pVM->pgm.s.cAllPages += cPages; 521 525 522 526 /* … … 785 789 Assert(PGM_PAGE_GET_TYPE(&pNew->aPages[0]) == PGMPAGETYPE_MMIO); 786 790 791 /* update the page count stats. */ 792 pVM->pgm.s.cZeroPages += cPages; 793 pVM->pgm.s.cAllPages += cPages; 794 787 795 /* link it */ 788 796 pgmR3PhysLinkRamRange(pVM, pNew, pRamPrev); … … 803 811 pNew->cb = pNew->GCPhys = pNew->GCPhysLast = NIL_RTGCPHYS; 804 812 MMHyperFree(pVM, pRam); 813 pVM->pgm.s.cZeroPages -= cb >> PAGE_SHIFT; 814 pVM->pgm.s.cAllPages -= cb >> PAGE_SHIFT; 805 815 } 806 816 … … 854 864 { 855 865 fAllMMIO = false; 866 Assert(PGM_PAGE_GET_TYPE(pPage) != PGMPAGETYPE_MMIO2_ALIAS_MMIO); 856 867 break; 857 868 } 869 Assert(PGM_PAGE_IS_ZERO(pPage)); 858 870 pPage++; 859 871 } … … 870 882 pRam->cb = pRam->GCPhys = pRam->GCPhysLast = NIL_RTGCPHYS; 871 883 MMHyperFree(pVM, pRam); 884 pVM->pgm.s.cAllPages -= pRam->cb >> PAGE_SHIFT; 885 pVM->pgm.s.cZeroPages -= pRam->cb >> PAGE_SHIFT; 872 886 } 873 887 break; … … 1003 1017 } 1004 1018 1019 /* update page count stats */ 1020 pVM->pgm.s.cAllPages += cPages; 1021 pVM->pgm.s.cPrivatePages += cPages; 1022 1005 1023 /* 1006 1024 * Link it into the list. … … 1084 1102 rc = rc2; 1085 1103 1086 rc2 = MMR3AdjustFixedReservation(pVM, -(int32_t)(pCur->RamRange.cb >> PAGE_SHIFT), pCur->RamRange.pszDesc); 1104 uint32_t const cPages = pCur->RamRange.cb >> PAGE_SHIFT; 1105 rc2 = MMR3AdjustFixedReservation(pVM, -(int32_t)cPages, pCur->RamRange.pszDesc); 1087 1106 AssertRC(rc2); 1088 1107 if (RT_FAILURE(rc2) && RT_SUCCESS(rc)) … … 1096 1115 /*rc = MMHyperFree(pVM, pCur); 1097 1116 AssertRCReturn(rc, rc); - not safe, see the alloc call. */ 1117 1118 1119 /* update page count stats */ 1120 pVM->pgm.s.cAllPages -= cPages; 1121 pVM->pgm.s.cPrivatePages -= cPages; 1098 1122 1099 1123 /* next */ … … 1218 1242 PGM_PAGE_SET_STATE(pPageDst, PGM_PAGE_STATE_ALLOCATED); 1219 1243 1244 pVM->pgm.s.cZeroPages--; 1220 1245 GCPhys += PAGE_SIZE; 1221 1246 pPageSrc++; … … 1294 1319 PGM_PAGE_SET_PAGEID(pPageDst, NIL_GMM_PAGEID); 1295 1320 1321 pVM->pgm.s.cZeroPages++; 1296 1322 pPageDst++; 1297 1323 } … … 1610 1636 } 1611 1637 1638 pVM->pgm.s.cAllPages += cPages; 1612 1639 pgmR3PhysLinkRamRange(pVM, pRamNew, pRamPrev); 1613 1640 } … … 1626 1653 1627 1654 pRamNew = pRam; 1655 1656 pVM->pgm.s.cZeroPages -= cPages; 1628 1657 } 1658 pVM->pgm.s.cPrivatePages += cPages; 1659 1629 1660 pgmUnlock(pVM); 1630 1661 … … 1704 1735 } 1705 1736 1737 /* update the page count stats */ 1738 pVM->pgm.s.cZeroPages += cPages; 1739 pVM->pgm.s.cAllPages += cPages; 1740 1706 1741 /* 1707 1742 * Insert the ROM range, tell REM and return successfully. … … 1861 1896 * out all the dirty pages and replace them by the zero page. 1862 1897 */ 1863 if ( 1)///@todo !pVM->pgm.f.fRamPreAlloc)1898 if (!pVM->pgm.s.fRamPreAlloc) 1864 1899 { 1865 1900 /* Count dirty shadow pages. */ … … 1880 1915 if (PGM_PAGE_GET_STATE(&pRom->aPages[iPage].Shadow) != PGM_PAGE_STATE_ZERO) 1881 1916 { 1917 Assert(PGM_PAGE_GET_STATE(&pRom->aPages[iPage].Shadow) == PGM_PAGE_STATE_ALLOCATED); 1882 1918 pReq->aPages[iReqPage].idPage = PGM_PAGE_GET_PAGEID(&pRom->aPages[iPage].Shadow); 1883 1919 iReqPage++; … … 1892 1928 if (PGM_PAGE_GET_STATE(&pRom->aPages[iPage].Shadow) != PGM_PAGE_STATE_ZERO) 1893 1929 PGM_PAGE_INIT_ZERO_REAL(&pRom->aPages[iPage].Shadow, pVM, PGMPAGETYPE_ROM_SHADOW); 1930 1931 /* update the page count stats. */ 1932 pVM->pgm.s.cPrivatePages -= cDirty; 1933 pVM->pgm.s.cZeroPages += cDirty; 1894 1934 } 1895 1935 } … … 1899 1939 for (uint32_t iPage = 0; iPage < cPages; iPage++) 1900 1940 { 1941 Assert(PGM_PAGE_GET_STATE(&pRom->aPages[iPage].Shadow) != PGM_PAGE_STATE_ZERO); 1942 1901 1943 const RTGCPHYS GCPhys = pRom->GCPhys + (iPage << PAGE_SHIFT); 1902 1944 rc = pgmPhysPageMakeWritable(pVM, &pRom->aPages[iPage].Shadow, GCPhys); … … 2820 2862 } 2821 2863 2864 /* update page count stats. */ 2865 if (PGM_PAGE_IS_SHARED(pPage)) 2866 pVM->pgm.s.cSharedPages--; 2867 else 2868 pVM->pgm.s.cPrivatePages--; 2869 pVM->pgm.s.cZeroPages++; 2870 2822 2871 /* 2823 2872 * pPage = ZERO page. -
trunk/src/VBox/VMM/testcase/tstVMStructGC.cpp
r17487 r17513 225 225 GEN_CHECK_OFF(MM, cbRamBase); 226 226 GEN_CHECK_OFF(MM, cBasePages); 227 GEN_CHECK_OFF(MM, cHandyPages); 227 228 GEN_CHECK_OFF(MM, cShadowPages); 228 229 GEN_CHECK_OFF(MM, cFixedPages);
Note:
See TracChangeset
for help on using the changeset viewer.