Changeset 14877 in vbox
- Timestamp:
- Dec 1, 2008 4:37:38 PM (16 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/PGM.cpp
r14868 r14877 1606 1606 STAM_REG(pVM, &pPGM->StatR0DynMapPageHit1, STAMTYPE_COUNTER, "/PGM/R0/DynMapPage/Hit1", STAMUNIT_OCCURENCES, "Hit at iPage+1"); 1607 1607 STAM_REG(pVM, &pPGM->StatR0DynMapPageHit2, STAMTYPE_COUNTER, "/PGM/R0/DynMapPage/Hit2", STAMUNIT_OCCURENCES, "Hit at iPage+2"); 1608 STAM_REG(pVM, &pPGM->StatR0DynMapPageHit3, STAMTYPE_COUNTER, "/PGM/R0/DynMapPage/Hit3", STAMUNIT_OCCURENCES, "Hit at iPage+3");1609 1608 STAM_REG(pVM, &pPGM->StatR0DynMapPageInvlPg, STAMTYPE_COUNTER, "/PGM/R0/DynMapPage/InvlPg", STAMUNIT_OCCURENCES, "invlpg count in pgmR0DynMapPageSlow."); 1610 1609 STAM_REG(pVM, &pPGM->StatR0DynMapPageSlow, STAMTYPE_COUNTER, "/PGM/R0/DynMapPage/Slow", STAMUNIT_OCCURENCES, "Calls to pgmR0DynMapPageSlow - subtract this from pgmR0DynMapPage to get 1st level hits."); -
trunk/src/VBox/VMM/PGMInternal.h
r14868 r14877 2570 2570 STAMCOUNTER StatR0DynMapPageHit1; /**< R0: Hit at iPage+1. */ 2571 2571 STAMCOUNTER StatR0DynMapPageHit2; /**< R0: Hit at iPage+2. */ 2572 STAMCOUNTER StatR0DynMapPageHit3; /**< R0: Hit at iPage+3. */2573 2572 STAMCOUNTER StatR0DynMapPageInvlPg; /**< R0: invlpg. */ 2574 2573 STAMCOUNTER StatR0DynMapPageSlow; /**< R0: Calls to pgmR0DynMapPageSlow. */ -
trunk/src/VBox/VMM/VMMR0/PGMR0DynMap.cpp
r14868 r14877 44 44 *******************************************************************************/ 45 45 /** The max size of the mapping cache (in pages). */ 46 #define PGMR0DYNMAP_MAX_PAGES (( 8*_1M) >> PAGE_SHIFT)46 #define PGMR0DYNMAP_MAX_PAGES ((16*_1M) >> PAGE_SHIFT) 47 47 /** The small segment size that is adopted on out-of-memory conditions with a 48 48 * single big segment. */ 49 49 #define PGMR0DYNMAP_SMALL_SEG_PAGES 128 50 50 /** The number of pages we reserve per CPU. */ 51 #define PGMR0DYNMAP_PAGES_PER_CPU 64 51 #define PGMR0DYNMAP_PAGES_PER_CPU 256 52 /** The minimum number of pages we reserve per CPU. 53 * This must be equal or larger than the autoset size. */ 54 #define PGMR0DYNMAP_PAGES_PER_CPU_MIN 32 52 55 /** The number of guard pages. 53 56 * @remarks Never do tuning of the hashing or whatnot with a strict build! */ … … 534 537 Assert(pThis->cPages <= PGMR0DYNMAP_MAX_PAGES); 535 538 536 /* cCpus * PGMR0DYNMAP_PAGES_PER_CPU (/2). */539 /* cCpus * PGMR0DYNMAP_PAGES_PER_CPU(_MIN). */ 537 540 RTCPUID cCpus = RTMpGetCount(); 538 541 AssertReturn(cCpus > 0 && cCpus <= RTCPUSET_MAX_CPUS, 0); 539 uint32_t cPages = cCpus * 540 uint32_t cMinPages = cCpus * (PGMR0DYNMAP_PAGES_PER_CPU / 2);542 uint32_t cPages = cCpus * PGMR0DYNMAP_PAGES_PER_CPU; 543 uint32_t cMinPages = cCpus * PGMR0DYNMAP_PAGES_PER_CPU_MIN; 541 544 542 545 /* adjust against cMaxLoad. */ … … 1174 1177 1175 1178 /* 1176 * Check if any of the first 4pages are unreferenced since the caller1179 * Check if any of the first 3 pages are unreferenced since the caller 1177 1180 * already has made sure they aren't matching. 1178 1181 */ … … 1189 1192 else if (!paPages[(iPage + 2) % cPages].cRefs) 1190 1193 iFreePage = (iPage + 2) % cPages; 1191 else if (!paPages[(iPage + 3) % cPages].cRefs)1192 iFreePage = (iPage + 3) % cPages;1193 1194 else 1194 1195 { … … 1196 1197 * Search for an unused or matching entry. 1197 1198 */ 1198 iFreePage = (iPage + 4) % cPages;1199 iFreePage = (iPage + 3) % cPages; 1199 1200 for (;;) 1200 1201 { … … 1222 1223 /* Check for lost hits. */ 1223 1224 if (!fLooped) 1224 for (uint32_t iPage2 = (iPage + 4) % cPages; iPage2 != iPage; iPage2 = (iPage2 + 1) % cPages)1225 for (uint32_t iPage2 = (iPage + 3) % cPages; iPage2 != iPage; iPage2 = (iPage2 + 1) % cPages) 1225 1226 if (paPages[iPage2].HCPhys == HCPhys) 1226 1227 STAM_COUNTER_INC(&pVM->pgm.s.StatR0DynMapPageSlowLostHits); … … 1278 1279 /* 1279 1280 * Find an entry, if possible a matching one. The HCPhys address is hashed 1280 * down to a page index, collisions are handled by linear searching. Optimize1281 * for a hit in the first 4pages.1281 * down to a page index, collisions are handled by linear searching. 1282 * Optimized for a hit in the first 3 pages. 1282 1283 * 1283 1284 * To the cheap hits here and defer the tedious searching and inserting … … 1307 1308 else 1308 1309 { 1309 iPage 2 = (iPage + 3) % cPages;1310 if ( paPages[iPage2].HCPhys == HCPhys)1310 iPage = pgmR0DynMapPageSlow(pThis, HCPhys, iPage, pVM); 1311 if (RT_UNLIKELY(iPage == UINT32_MAX)) 1311 1312 { 1312 iPage = iPage2; 1313 STAM_COUNTER_INC(&pVM->pgm.s.StatR0DynMapPageHit3); 1314 } 1315 else 1316 { 1317 iPage = pgmR0DynMapPageSlow(pThis, HCPhys, iPage, pVM); 1318 if (RT_UNLIKELY(iPage == UINT32_MAX)) 1319 { 1320 RTSpinlockRelease(pThis->hSpinlock, &Tmp); 1321 return iPage; 1322 } 1313 RTSpinlockRelease(pThis->hSpinlock, &Tmp); 1314 return iPage; 1323 1315 } 1324 1316 }
Note:
See TracChangeset
for help on using the changeset viewer.