Changeset 82555 in vbox for trunk/src/VBox/VMM/VMMR3/PGMPool.cpp
- Timestamp:
- Dec 11, 2019 11:56:54 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/PGMPool.cpp
r80334 r82555 170 170 AssertLogRelMsgReturn(cMaxPages <= PGMPOOL_IDX_LAST && cMaxPages >= RT_ALIGN(PGMPOOL_IDX_FIRST, 16), 171 171 ("cMaxPages=%u (%#x)\n", cMaxPages, cMaxPages), VERR_INVALID_PARAMETER); 172 cMaxPages = RT_ALIGN(cMaxPages, 16); 172 AssertCompile(RT_IS_POWER_OF_TWO(PGMPOOL_CFG_MAX_GROW)); 173 if (cMaxPages < PGMPOOL_IDX_LAST) 174 cMaxPages = RT_ALIGN(cMaxPages, PGMPOOL_CFG_MAX_GROW / 2); 173 175 if (cMaxPages > PGMPOOL_IDX_LAST) 174 176 cMaxPages = PGMPOOL_IDX_LAST; … … 314 316 Assert(!pPool->aPages[NIL_PGMPOOL_IDX].fReusedFlushPending); 315 317 316 #ifdef VBOX_WITH_STATISTICS317 318 /* 318 319 * Register statistics. 319 320 */ 321 STAM_REL_REG(pVM, &pPool->StatGrow, STAMTYPE_PROFILE, "/PGM/Pool/Grow", STAMUNIT_TICKS, "Profiling PGMR0PoolGrow"); 322 #ifdef VBOX_WITH_STATISTICS 320 323 STAM_REG(pVM, &pPool->cCurPages, STAMTYPE_U16, "/PGM/Pool/cCurPages", STAMUNIT_PAGES, "Current pool size."); 321 324 STAM_REG(pVM, &pPool->cMaxPages, STAMTYPE_U16, "/PGM/Pool/cMaxPages", STAMUNIT_PAGES, "Max pool size."); … … 473 476 * @returns VBox status code. 474 477 * @param pVM The cross context VM structure. 478 * @param pVCpu The cross context virtual CPU structure of the calling EMT. 475 479 */ 476 VMMR3 DECL(int) PGMR3PoolGrow(PVM pVM)480 VMMR3_INT_DECL(int) PGMR3PoolGrow(PVM pVM, PVMCPU pVCpu) 477 481 { 478 PPGMPOOL pPool = pVM->pgm.s.pPoolR3; 479 AssertReturn(pPool->cCurPages < pPool->cMaxPages, VERR_PGM_POOL_MAXED_OUT_ALREADY); 480 481 /* With 32-bit guests and no EPT, the CR3 limits the root pages to low 482 (below 4 GB) memory. */ 483 /** @todo change the pool to handle ROOT page allocations specially when 484 * required. */ 485 bool fCanUseHighMemory = HMIsNestedPagingActive(pVM); 486 487 pgmLock(pVM); 488 489 /* 490 * How much to grow it by? 491 */ 492 uint32_t cPages = pPool->cMaxPages - pPool->cCurPages; 493 cPages = RT_MIN(PGMPOOL_CFG_MAX_GROW, cPages); 494 LogFlow(("PGMR3PoolGrow: Growing the pool by %d (%#x) pages. fCanUseHighMemory=%RTbool\n", cPages, cPages, fCanUseHighMemory)); 495 496 for (unsigned i = pPool->cCurPages; cPages-- > 0; i++) 497 { 498 PPGMPOOLPAGE pPage = &pPool->aPages[i]; 499 500 if (fCanUseHighMemory) 501 pPage->pvPageR3 = MMR3PageAlloc(pVM); 502 else 503 pPage->pvPageR3 = MMR3PageAllocLow(pVM); 504 if (!pPage->pvPageR3) 505 { 506 Log(("We're out of memory!! i=%d fCanUseHighMemory=%RTbool\n", i, fCanUseHighMemory)); 507 pgmUnlock(pVM); 508 return i ? VINF_SUCCESS : VERR_NO_PAGE_MEMORY; 509 } 510 pPage->Core.Key = MMPage2Phys(pVM, pPage->pvPageR3); 511 AssertFatal(pPage->Core.Key < _4G || fCanUseHighMemory); 512 pPage->GCPhys = NIL_RTGCPHYS; 513 pPage->enmKind = PGMPOOLKIND_FREE; 514 pPage->idx = pPage - &pPool->aPages[0]; 515 LogFlow(("PGMR3PoolGrow: insert page #%#x - %RHp\n", pPage->idx, pPage->Core.Key)); 516 pPage->iNext = pPool->iFreeHead; 517 pPage->iUserHead = NIL_PGMPOOL_USER_INDEX; 518 pPage->iModifiedNext = NIL_PGMPOOL_IDX; 519 pPage->iModifiedPrev = NIL_PGMPOOL_IDX; 520 pPage->iMonitoredNext = NIL_PGMPOOL_IDX; 521 pPage->iMonitoredPrev = NIL_PGMPOOL_IDX; 522 pPage->iAgeNext = NIL_PGMPOOL_IDX; 523 pPage->iAgePrev = NIL_PGMPOOL_IDX; 524 /* commit it */ 525 bool fRc = RTAvloHCPhysInsert(&pPool->HCPhysTree, &pPage->Core); Assert(fRc); NOREF(fRc); 526 pPool->iFreeHead = i; 527 pPool->cCurPages = i + 1; 528 } 529 530 pgmUnlock(pVM); 531 Assert(pPool->cCurPages <= pPool->cMaxPages); 532 return VINF_SUCCESS; 482 /* This used to do a lot of stuff, but it has moved to ring-0 (PGMR0PoolGrow). */ 483 AssertReturn(pVM->pgm.s.pPoolR3->cCurPages < pVM->pgm.s.pPoolR3->cMaxPages, VERR_PGM_POOL_MAXED_OUT_ALREADY); 484 return VMMR3CallR0Emt(pVM, pVCpu, VMMR0_DO_PGM_POOL_GROW, 0, NULL); 533 485 } 534 486
Note:
See TracChangeset
for help on using the changeset viewer.